settings and project operations progress

This commit is contained in:
2018-07-18 20:40:02 -05:00
parent 5d59910424
commit 9a51c2b731
16 changed files with 195 additions and 1 deletions
@@ -0,0 +1,12 @@
import Ember from 'ember'
export default Ember.Controller.extend
operation_running_time: Ember.computed 'globals.operation_running', ->
return '' unless start_time = @get('globals.operation_running')
duration = moment.duration(moment().diff(start_time))
if duration.days()
"#{duration.days()} days and #{duration.hours()} hours"
else
hours = ('0' + duration.hours()).slice(-2)
minutes = ('0' + duration.minutes()).slice(-2)
seconds = ('0' + duration.seconds()).slice(-2)
"#{hours}:#{minutes}:#{seconds}"
+20
View File
@@ -0,0 +1,20 @@
// Generated by CoffeeScript 1.12.5
import Ember from 'ember';
export default Ember.Controller.extend({
operation_running_time: Ember.computed('globals.operation_running', function() {
var duration, hours, minutes, seconds, start_time;
if (!(start_time = this.get('globals.operation_running'))) {
return '';
}
duration = moment.duration(moment().diff(start_time));
if (duration.days()) {
return (duration.days()) + " days and " + (duration.hours()) + " hours";
} else {
hours = ('0' + duration.hours()).slice(-2);
minutes = ('0' + duration.minutes()).slice(-2);
seconds = ('0' + duration.seconds()).slice(-2);
return hours + ":" + minutes + ":" + seconds;
}
})
});
+4
View File
@@ -0,0 +1,4 @@
import DS from 'ember-data'
export default DS.Model.extend
value: DS.attr()
+6
View File
@@ -0,0 +1,6 @@
// Generated by CoffeeScript 1.12.5
import DS from 'ember-data';
export default DS.Model.extend({
value: DS.attr()
});
+44
View File
@@ -0,0 +1,44 @@
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')
+64
View File
@@ -0,0 +1,64 @@
// 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');
}
}
});
+2
View File
@@ -9,6 +9,7 @@ pandaRouteSetup = (context) ->
# @route 'show'
@route 'dunlop-generator'
@route 'analysis'
@route 'operate'
@route 'project-instance', ->
@route 'show', path: ':project_instance_id', ->
@route 'groups'
@@ -19,6 +20,7 @@ pandaRouteSetup = (context) ->
@route 'show', path: ':project_instance_group_id'
@route 'project-instance-action', ->
@route 'show', path: ':project_instance_action_id'
#@route 'project/views', path: 'views'
context.route 'login'
#@route 'organization', path: 'organizations/:organization_id'
+1
View File
@@ -14,6 +14,7 @@ pandaRouteSetup = function(context) {
this.route('add-progress');
this.route('dunlop-generator');
this.route('analysis');
this.route('operate');
this.route('project-instance', function() {
return this.route('show', {
path: ':project_instance_id'