Sha256: 3744812e27d46c1179d99663d8ccf09b84dbaf042c4cab309ed3073cc8a27f9f

Contents?: true

Size: 789 Bytes

Versions: 9

Compression:

Stored size: 789 Bytes

Contents

import { Controller } from "stimulus"
import axios from "axios"
import { axiosPostable } from "../lib/utils"

export default class extends Controller {
  initialize() {
    this.axios = axiosPostable(axios)
  }
  
  connect() {
    this.checkingInterval = setInterval(this.checkBuildingStatus.bind(this), 5000)
  }

  async checkBuildingStatus() {
    try {
      let response = await this.axios.get(this.data.get('path'))
      if (response.data.updated) {
        this.element.classList.remove('is-warning')
        this.element.classList.add('is-success')
        this.element.innerHTML = 'Public Website Updated!'
        clearInterval(this.checkingInterval)
        setTimeout(() => { this.element.remove() }, 8000)
      }
    } catch (error) {
      console.error(error)
    }
  }
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
yarii-editor-0.4.8 app/javascript/controllers/building_controller.js
yarii-editor-0.4.7 app/javascript/controllers/building_controller.js
yarii-editor-0.4.6 app/javascript/controllers/building_controller.js
yarii-editor-0.4.5 app/javascript/controllers/building_controller.js
yarii-editor-0.4.4 app/javascript/controllers/building_controller.js
yarii-editor-0.4.3 app/javascript/controllers/building_controller.js
yarii-editor-0.4.2 app/javascript/controllers/building_controller.js
yarii-editor-0.4.1 app/javascript/controllers/building_controller.js
yarii-editor-0.4.0 app/javascript/controllers/building_controller.js