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
+1 -1
View File
@@ -5,5 +5,5 @@
Setting `disableAnalytics` to true will prevent any data from being sent. Setting `disableAnalytics` to true will prevent any data from being sent.
*/ */
"disableAnalytics": false "disableAnalytics": true
} }
@@ -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 'show'
@route 'dunlop-generator' @route 'dunlop-generator'
@route 'analysis' @route 'analysis'
@route 'operate'
@route 'project-instance', -> @route 'project-instance', ->
@route 'show', path: ':project_instance_id', -> @route 'show', path: ':project_instance_id', ->
@route 'groups' @route 'groups'
@@ -19,6 +20,7 @@ pandaRouteSetup = (context) ->
@route 'show', path: ':project_instance_group_id' @route 'show', path: ':project_instance_group_id'
@route 'project-instance-action', -> @route 'project-instance-action', ->
@route 'show', path: ':project_instance_action_id' @route 'show', path: ':project_instance_action_id'
#@route 'project/views', path: 'views' #@route 'project/views', path: 'views'
context.route 'login' context.route 'login'
#@route 'organization', path: 'organizations/:organization_id' #@route 'organization', path: 'organizations/:organization_id'
+1
View File
@@ -14,6 +14,7 @@ pandaRouteSetup = function(context) {
this.route('add-progress'); this.route('add-progress');
this.route('dunlop-generator'); this.route('dunlop-generator');
this.route('analysis'); this.route('analysis');
this.route('operate');
this.route('project-instance', function() { this.route('project-instance', function() {
return this.route('show', { return this.route('show', {
path: ':project_instance_id' path: ':project_instance_id'
+1
View File
@@ -0,0 +1 @@
export { default } from 'ember-panda/controllers/project/show/operate';
+1
View File
@@ -0,0 +1 @@
export { default } from 'ember-panda/routes/project/show/operate';
+9
View File
@@ -23,6 +23,15 @@ d-breadcrumbs as |breadcrumb|
h2.ui.header h2.ui.header
i.bar.chart.icon i.bar.chart.icon
.content= link-to 'project.show.analysis' model: span= t 'project.analysis.title' .content= link-to 'project.show.analysis' model: span= t 'project.analysis.title'
if (can 'operate' 'model' 'panda/project')
h2.ui.header
/i.icons
i.database.icon
i.cogs.icon
/i.paint.brush.icon
i.wrench.icon
/i.schlix.icon
.content= link-to 'project.show.operate' model: span= t 'project.operate.title'
/ul.ui.list /ul.ui.list
li= link-to 'project.show.dunlop' model li= link-to 'project.show.dunlop' model
span= t 'project.dunlop.title' span= t 'project.dunlop.title'
+22
View File
@@ -0,0 +1,22 @@
d-breadcrumbs as |breadcrumb|
breadcrumb.item
= link-to 'project.index': span= t 'models.plural.project'
breadcrumb.item
span= t 'models.project'
span :
= link-to 'project.show' model: span= model.name
breadcrumb.item active=true
span= t 'project.operate.title'
if globals.operation_running
.ui.segment
p  
.ui.active.inverted.dimmer: .ui.medium.text.loader
= t 'project.operate.operation_running_text'
'
span.between-brackets= operation_running_time
p  
p  
else
.ui.horizontal.divider= t 'project.operate.set_value_on_non_final_with_closed_group.title'
.ui.segment
+1
View File
@@ -59,6 +59,7 @@
"ember-load-initializers": "^1.0.0", "ember-load-initializers": "^1.0.0",
"ember-math-helpers": "^2.2.3", "ember-math-helpers": "^2.2.3",
"ember-one-way-controls": "^2.0.1", "ember-one-way-controls": "^2.0.1",
"ember-poll": "^1.4.0",
"ember-resolver": "^4.0.0", "ember-resolver": "^4.0.0",
"ember-route-action-helper": "^2.0.6", "ember-route-action-helper": "^2.0.6",
"ember-semantic-ui-calendar": "^1.0.1", "ember-semantic-ui-calendar": "^1.0.1",
@@ -33,4 +33,9 @@ translations = project:
show: show:
dunlop_project_info: dunlop_project_info:
title: "${models.project} %{name} info" title: "${models.project} %{name} info"
operate:
title: '${models.project} operations'
operation_running_text: 'There already is an operation running'
set_value_on_non_final_with_closed_group:
title: 'Set value on actions where group is closed'
export default translations export default translations
@@ -28,6 +28,8 @@ default_globals =
workflow_group: workflow_group:
batch_element_threshold_unit_options: ['businessday', 'day', 'week'] batch_element_threshold_unit_options: ['businessday', 'day', 'week']
operation_running: '' # should be set to false through api call
project_instance: project_instance:
states: ['uncategorized', 'unplanned', 'planned', 'active', 'overdue', 'any_rejected', 'all_completed'] states: ['uncategorized', 'unplanned', 'planned', 'active', 'overdue', 'any_rejected', 'all_completed']