45 lines
1.5 KiB
CoffeeScript
45 lines
1.5 KiB
CoffeeScript
import Ember from 'ember'
|
|
import config from 'ember-get-config'
|
|
#import Route from '@ember/route'
|
|
#import { inject as service } from '@ember/service'
|
|
export default Ember.Route.extend
|
|
poll: Ember.inject.service()
|
|
session: Ember.inject.service()
|
|
|
|
model: -> @modelFor('project.show')
|
|
|
|
afterModel: (model, transition) ->
|
|
model.reload() unless @controllerFor('application').get('currentRouteName') in ['loading', 'project.show.operate']
|
|
|
|
actions:
|
|
didTransition: ->
|
|
model_name = 'panda/setting'
|
|
base_url = @store.adapterFor(model_name).buildURL(model_name)
|
|
endpoint = "#{base_url}/operation_running/get_value"
|
|
|
|
request =
|
|
url: endpoint
|
|
success: (operation_running) =>
|
|
if operation_running
|
|
@set 'router.globals.operation_running', moment(operation_running)
|
|
else
|
|
@set 'router.globals.operation_running', ''
|
|
session = @get('session')
|
|
if Ember.get(session, 'isAuthenticated')
|
|
session.authorize 'authorizer:devise', (key, authorization) ->
|
|
request.crossDomain = true
|
|
request.headers = {"#{key}": authorization}
|
|
|
|
pollFunction = =>
|
|
Ember.$.ajax request
|
|
pollFunction()
|
|
pollId = @get('poll').addPoll
|
|
interval: 30 * 1000
|
|
callback: pollFunction
|
|
label: 'project-running'
|
|
#@get('poll').startPoll(pollId)
|
|
#@get('poll').startPollByLabel('project-running')
|
|
|
|
willTransition: ->
|
|
@get('poll').stopPollByLabel('project-running')
|