65 lines
2.0 KiB
JavaScript
65 lines
2.0 KiB
JavaScript
// Generated by CoffeeScript 1.12.5
|
|
import Ember from 'ember';
|
|
|
|
import config from 'ember-get-config';
|
|
|
|
export default Ember.Route.extend({
|
|
poll: Ember.inject.service(),
|
|
session: Ember.inject.service(),
|
|
model: function() {
|
|
return this.modelFor('project.show');
|
|
},
|
|
afterModel: function(model, transition) {
|
|
var ref;
|
|
if ((ref = this.controllerFor('application').get('currentRouteName')) !== 'loading' && ref !== 'project.show.operate') {
|
|
return model.reload();
|
|
}
|
|
},
|
|
actions: {
|
|
didTransition: function() {
|
|
var base_url, endpoint, model_name, pollFunction, pollId, request, session;
|
|
model_name = 'panda/setting';
|
|
base_url = this.store.adapterFor(model_name).buildURL(model_name);
|
|
endpoint = base_url + "/operation_running/get_value";
|
|
request = {
|
|
url: endpoint,
|
|
success: (function(_this) {
|
|
return function(operation_running) {
|
|
if (operation_running) {
|
|
return _this.set('router.globals.operation_running', moment(operation_running));
|
|
} else {
|
|
return _this.set('router.globals.operation_running', '');
|
|
}
|
|
};
|
|
})(this)
|
|
};
|
|
session = this.get('session');
|
|
if (Ember.get(session, 'isAuthenticated')) {
|
|
session.authorize('authorizer:devise', function(key, authorization) {
|
|
var obj;
|
|
request.crossDomain = true;
|
|
return request.headers = (
|
|
obj = {},
|
|
obj["" + key] = authorization,
|
|
obj
|
|
);
|
|
});
|
|
}
|
|
pollFunction = (function(_this) {
|
|
return function() {
|
|
return Ember.$.ajax(request);
|
|
};
|
|
})(this);
|
|
pollFunction();
|
|
return pollId = this.get('poll').addPoll({
|
|
interval: 30 * 1000,
|
|
callback: pollFunction,
|
|
label: 'project-running'
|
|
});
|
|
},
|
|
willTransition: function() {
|
|
return this.get('poll').stopPollByLabel('project-running');
|
|
}
|
|
}
|
|
});
|