User statistics updates

This commit is contained in:
2018-07-30 11:50:10 +02:00
parent 833c10ea7f
commit d304bbeb5e
15 changed files with 103 additions and 38 deletions
@@ -29,3 +29,9 @@ export default Ember.Component.extend
'filters.workflow_action_definition_organization_id': '' 'filters.workflow_action_definition_organization_id': ''
@$('.select-organization .dropdown.button').removeClass('orange') @$('.select-organization .dropdown.button').removeClass('orange')
@send 'apply_filters' @send 'apply_filters'
didRender: ->
if organization_id = @get('filters.workflow_action_definition_organization_id')
if organization = @get('relevant_organizations').findBy('id', organization_id)
@set 'scope_organization', organization
@$('.select-organization .dropdown.button').addClass('orange')
@@ -46,5 +46,14 @@ export default Ember.Component.extend({
return this.send('apply_filters'); return this.send('apply_filters');
} }
} }
},
didRender: function() {
var organization, organization_id;
if (organization_id = this.get('filters.workflow_action_definition_organization_id')) {
if (organization = this.get('relevant_organizations').findBy('id', organization_id)) {
this.set('scope_organization', organization);
return this.$('.select-organization .dropdown.button').addClass('orange');
}
}
} }
}); });
@@ -5,6 +5,7 @@ export default Ember.Component.extend
record: null # parameter record: null # parameter
project_specific: false # parameter project_specific: false # parameter
session: Ember.inject.service('session') session: Ember.inject.service('session')
classNames: ['project-aggregate-statistics', 'project-aggregate-organization-statistics']
statistics: Ember.computed 'statistics_data.isFulfilled', 'project_specific', -> statistics: Ember.computed 'statistics_data.isFulfilled', 'project_specific', ->
d = @get('statistics_data') d = @get('statistics_data')
return {} unless d.isFulfilled return {} unless d.isFulfilled
@@ -21,7 +22,7 @@ export default Ember.Component.extend
project_name = project.get('name') project_name = project.get('name')
target[project_name] = [] target[project_name] = []
states.forEach (state) -> states.forEach (state) ->
target[project_name].push(state: state, count: stats[state] || 0) target[project_name].push(state: state, count: stats[state] || 0, project_id: project_id)
else else
for state, count of stats for state, count of stats
target[state] += count target[state] += count
+3 -1
View File
@@ -7,6 +7,7 @@ export default Ember.Component.extend({
record: null, record: null,
project_specific: false, project_specific: false,
session: Ember.inject.service('session'), session: Ember.inject.service('session'),
classNames: ['project-aggregate-statistics', 'project-aggregate-organization-statistics'],
statistics: Ember.computed('statistics_data.isFulfilled', 'project_specific', function() { statistics: Ember.computed('statistics_data.isFulfilled', 'project_specific', function() {
var count, d, global_name, project, project_id, project_name, project_specific, ref, state, states, stats, target; var count, d, global_name, project, project_id, project_name, project_specific, ref, state, states, stats, target;
d = this.get('statistics_data'); d = this.get('statistics_data');
@@ -32,7 +33,8 @@ export default Ember.Component.extend({
states.forEach(function(state) { states.forEach(function(state) {
return target[project_name].push({ return target[project_name].push({
state: state, state: state,
count: stats[state] || 0 count: stats[state] || 0,
project_id: project_id
}); });
}); });
} else { } else {
@@ -5,11 +5,13 @@ export default Ember.Component.extend
user: null # parameter user: null # parameter
project_specific: false # parameter project_specific: false # parameter
session: Ember.inject.service('session') session: Ember.inject.service('session')
classNames: ['project-aggregate-statistics', 'project-aggregate-user-statistics']
statistics: Ember.computed 'statistics_data.isFulfilled', 'project_specific', -> statistics: Ember.computed 'statistics_data.isFulfilled', 'project_specific', ->
d = @get('statistics_data') d = @get('statistics_data')
return {} unless d.isFulfilled return {} unless d.isFulfilled
target = {} target = {}
states = ['pending', 'planned', 'active', 'overdue', 'inquiry', 'rejected', 'completed'] #states = ['pending', 'planned', 'active', 'overdue', 'inquiry', 'rejected', 'completed']
states = @get('globals.project_instance_action.states')
project_specific = @get('project_specific') project_specific = @get('project_specific')
unless project_specific unless project_specific
global_name = t('user.statistics1.global.title') global_name = t('user.statistics1.global.title')
@@ -21,7 +23,7 @@ export default Ember.Component.extend
project_name = project.get('name') project_name = project.get('name')
target[project_name] = [] target[project_name] = []
states.forEach (state) -> states.forEach (state) ->
target[project_name].push(state: state, count: stats[state] || 0) target[project_name].push(state: state, count: stats[state] || 0, project_id: project_id)
else else
for state, count of stats for state, count of stats
target[state] += count target[state] += count
+4 -2
View File
@@ -7,6 +7,7 @@ export default Ember.Component.extend({
user: null, user: null,
project_specific: false, project_specific: false,
session: Ember.inject.service('session'), session: Ember.inject.service('session'),
classNames: ['project-aggregate-statistics', 'project-aggregate-user-statistics'],
statistics: Ember.computed('statistics_data.isFulfilled', 'project_specific', function() { statistics: Ember.computed('statistics_data.isFulfilled', 'project_specific', function() {
var count, d, global_name, project, project_id, project_name, project_specific, ref, state, states, stats, target; var count, d, global_name, project, project_id, project_name, project_specific, ref, state, states, stats, target;
d = this.get('statistics_data'); d = this.get('statistics_data');
@@ -14,7 +15,7 @@ export default Ember.Component.extend({
return {}; return {};
} }
target = {}; target = {};
states = ['pending', 'planned', 'active', 'overdue', 'inquiry', 'rejected', 'completed']; states = this.get('globals.project_instance_action.states');
project_specific = this.get('project_specific'); project_specific = this.get('project_specific');
if (!project_specific) { if (!project_specific) {
global_name = t('user.statistics1.global.title'); global_name = t('user.statistics1.global.title');
@@ -32,7 +33,8 @@ export default Ember.Component.extend({
states.forEach(function(state) { states.forEach(function(state) {
return target[project_name].push({ return target[project_name].push({
state: state, state: state,
count: stats[state] || 0 count: stats[state] || 0,
project_id: project_id
}); });
}); });
} else { } else {
+9 -8
View File
@@ -19,11 +19,12 @@ export filters = Ember.Object.create
export default Ember.Route.extend export default Ember.Route.extend
queryParams: queryParams:
state: {refreshModel: true} state: {refreshModel: true}
project: {refreshModel: true} project: {refreshModel: true}
action: {refreshModel: true} action: {refreshModel: true}
page: {refreshModel: true} page: {refreshModel: true}
perPage: {refreshModel: true} perPage: {refreshModel: true}
organization_id: {refreshModel: true}
modelName: 'panda/project-instance-action' modelName: 'panda/project-instance-action'
setupController: (controller) -> setupController: (controller) ->
controller.set 'filters', filters controller.set 'filters', filters
@@ -53,8 +54,9 @@ export default Ember.Route.extend
# 'pointing_project_instance_action_connections.project_instance_action.workflow_action_definition.~organization' # 'pointing_project_instance_action_connections.project_instance_action.workflow_action_definition.~organization'
# 'pointing_project_instance_action_connections.project_instance_action.workflow_action_definition.~workflow_action_offsets' # 'pointing_project_instance_action_connections.project_instance_action.workflow_action_definition.~workflow_action_offsets'
#] #]
filters.state_in = [params.state] if params.state filters.set('state_in', params.state.split(',')) if params.state
filters.workflow_action_definition_identifier_in = [params.action] if params.action filters.set('workflow_action_definition_identifier_in', params.action.split(',')) if params.action
filters.set('workflow_action_definition_organization_id', params.organization_id) if params.organization_id
Ember.RSVP.hash Ember.RSVP.hash
projects: @store.findAll('panda/project') projects: @store.findAll('panda/project')
organizations: @store.findAll('panda/organization') organizations: @store.findAll('panda/organization')
@@ -66,5 +68,4 @@ export default Ember.Route.extend
page: params.page || 1 page: params.page || 1
perPage: params.perPage || 30 perPage: params.perPage || 30
otherParams: otherParams:
#include: includes.join(',')
include: 'action-list' include: 'action-list'
+8 -2
View File
@@ -35,6 +35,9 @@ export default Ember.Route.extend({
}, },
perPage: { perPage: {
refreshModel: true refreshModel: true
},
organization_id: {
refreshModel: true
} }
}, },
modelName: 'panda/project-instance-action', modelName: 'panda/project-instance-action',
@@ -44,10 +47,13 @@ export default Ember.Route.extend({
}, },
model: function(params) { model: function(params) {
if (params.state) { if (params.state) {
filters.state_in = [params.state]; filters.set('state_in', params.state.split(','));
} }
if (params.action) { if (params.action) {
filters.workflow_action_definition_identifier_in = [params.action]; filters.set('workflow_action_definition_identifier_in', params.action.split(','));
}
if (params.organization_id) {
filters.set('workflow_action_definition_organization_id', params.organization_id);
} }
return Ember.RSVP.hash({ return Ember.RSVP.hash({
projects: this.store.findAll('panda/project'), projects: this.store.findAll('panda/project'),
@@ -1,3 +1,6 @@
.state-badge .state-badge
&.with-action &.with-action
cursor: pointer cursor: pointer
.project-aggregate-statistics
.ui.label.state-badge
margin-right: 4px
@@ -2,7 +2,8 @@ import Ember from 'ember'
import {create_date_sort} from 'ember-cli-dunlop/utils/date-sort' import {create_date_sort} from 'ember-cli-dunlop/utils/date-sort'
date_sort = create_date_sort('date') date_sort = create_date_sort('date')
export default Ember.Controller.extend export default Ember.Controller.extend
queryParams: ['state'] organizations: ( -> @store.peekAll('panda/organization')).property()
queryParams: ['state', 'organization_id']
#filter: Ember.Object.create #filter: Ember.Object.create
# workflow_action_definition_id_in: [] # workflow_action_definition_id_in: []
# project_instance_group_workflow_group_id_in: [] # project_instance_group_workflow_group_id_in: []
@@ -2,6 +2,7 @@ import Ember from 'ember'
import PagedRemoteArray from 'ember-cli-dunlop/utils/paged-remote-array' import PagedRemoteArray from 'ember-cli-dunlop/utils/paged-remote-array'
export filters = Ember.Object.create export filters = Ember.Object.create
workflow_action_definition_id_in: [] workflow_action_definition_id_in: []
workflow_action_definition_organization_id_eq: ''
project_instance_group_workflow_group_id: '' project_instance_group_workflow_group_id: ''
state_in: [] state_in: []
target_date_gteq: null target_date_gteq: null
@@ -11,9 +12,10 @@ export filters = Ember.Object.create
export default Ember.Route.extend export default Ember.Route.extend
modelName: 'panda/project-instance-action' modelName: 'panda/project-instance-action'
queryParams: queryParams:
state: {refreshModel: true} state: {refreshModel: true}
page: {refreshModel: true} organization_id: {refreshModel: true}
perPage: {refreshModel: true} page: {refreshModel: true}
perPage: {refreshModel: true}
setupController: (controller, model) -> setupController: (controller, model) ->
controller.set 'filters', filters controller.set 'filters', filters
controller.set 'project', @modelFor('project.show') controller.set 'project', @modelFor('project.show')
@@ -21,13 +23,14 @@ export default Ember.Route.extend
model: (params) -> model: (params) ->
project = @modelFor 'project.show' project = @modelFor 'project.show'
filters.project_id = project.id filters.set('project_id', project.id)
includes = 'action-list' filters.set('state_in', params.state.split(',')) if params.state
filters.state_in = [params.state] if params.state filters.set('workflow_action_definition_organization_id_eq', params.organization_id) if params.organization_id
PagedRemoteArray.create PagedRemoteArray.create
modelName: @modelName modelName: @modelName
store: @store store: @store
filters: filters filters: filters
page: params.page || 1 page: params.page || 1
perPage: params.perPage || 30 perPage: params.perPage || 30
otherParams: {includes: includes} otherParams:
include: 'action-list'
@@ -18,8 +18,8 @@ export default Ember.Route.extend
model: (params) -> model: (params) ->
project = @modelFor 'project.show' project = @modelFor 'project.show'
filters.project_id = project.id filters.set('project_id', project.id)
filters.state_in = [params.state] if params.state filters.set('state_in', params.state.split(',')) if params.state
PagedRemoteArray.create PagedRemoteArray.create
modelName: @modelName modelName: @modelName
store: @store store: @store
@@ -1,18 +1,31 @@
if statistics if statistics
ui-checkbox class='toggle' label=(t 'user.statistics1.project_specific.label') checked=project_specific onChange=(action (mut project_specific)) ui-checkbox class='toggle' label=(t 'user.statistics1.project_specific.label') checked=project_specific onChange=(action (mut project_specific))
'
if project_specific if project_specific
each-in statistics as |project_name stats| each-in statistics as |project_name stats|
.ui.header= project_name .ui.header= project_name
= each stats as |stat| = each stats as |stat|
= state-badge stat.state if (can 'read' 'model' 'panda/project-instance')
' = link-to 'project.show.project-instance-action' stat.project_id (query-params state=stat.state organization_id=record.id)
span.between-brackets= stat.count = state-badge stat.state
'
span.between-brackets= stat.count
else
= state-badge stat.state
'
span.between-brackets= stat.count
else else
/.ui.header= t 'user.statistics1.global.title' /.ui.header= t 'user.statistics1.global.title'
each-in statistics as |state count| each-in statistics as |state count|
= state-badge state if (can 'read' 'model' 'panda/project-instance')
' = link-to 'action-list' (query-params state=state organization_id=record.id)
span.between-brackets= count = state-badge state
'
span.between-brackets= count
else
= state-badge state
'
span.between-brackets= count
= yield = yield
else else
.ui.active.inline.centered.loader .ui.active.inline.centered.loader
@@ -3,19 +3,32 @@ if user.email
span.ui.segment.pull-right= user.nickname span.ui.segment.pull-right= user.nickname
if statistics if statistics
ui-checkbox class='toggle' label=(t 'user.statistics1.project_specific.label') checked=project_specific onChange=(action (mut project_specific)) ui-checkbox class='toggle' label=(t 'user.statistics1.project_specific.label') checked=project_specific onChange=(action (mut project_specific))
'
if project_specific if project_specific
each-in statistics as |project_name stats| each-in statistics as |project_name stats|
.ui.header= project_name .ui.header= project_name
= each stats as |stat| = each stats as |stat|
= state-badge stat.state if (can 'read' 'model' 'panda/project-instance')
' = link-to 'project.show.project-instance-action' stat.project_id (query-params state=stat.state)
span.between-brackets= stat.count = state-badge stat.state
'
span.between-brackets= stat.count
else
= state-badge stat.state
'
span.between-brackets= stat.count
else else
/.ui.header= t 'user.statistics1.global.title' /.ui.header= t 'user.statistics1.global.title'
each-in statistics as |state count| each-in statistics as |state count|
= state-badge state if (can 'read' 'model' 'panda/project-instance')
' = link-to 'action-list' (query-params state=state)
span.between-brackets= count = state-badge state
'
span.between-brackets= count
else
= state-badge state
'
span.between-brackets= count
= yield = yield
else else
.ui.active.inline.centered.loader .ui.active.inline.centered.loader
@@ -21,6 +21,7 @@ d-breadcrumbs as |breadcrumb|
table.ui.bottom.attached.stiped.table table.ui.bottom.attached.stiped.table
thead thead
tr tr
th= t 'models.organization'
th= t 'models.project_instance_group' th= t 'models.project_instance_group'
th= t 'models.workflow_action_definition' th= t 'models.workflow_action_definition'
th= t 'models.project_instance' th= t 'models.project_instance'
@@ -35,6 +36,7 @@ table.ui.bottom.attached.stiped.table
th= t 'attributes.project_instance_action.target_date' th= t 'attributes.project_instance_action.target_date'
th= t 'attributes.project_instance_action.value' th= t 'attributes.project_instance_action.value'
table-filters content=model filters=filters as |filter| table-filters content=model filters=filters as |filter|
= filter.dropdown-select key='workflow_action_definition_organization_id_eq' options=organizations labelPath='name'
= filter.dropdown-select key='project_instance_group_workflow_group_id' options=project.sorted_workflow_groups labelPath='name' = filter.dropdown-select key='project_instance_group_workflow_group_id' options=project.sorted_workflow_groups labelPath='name'
/ ui-dropdown class='right basic labeled icon' action='nothing' / ui-dropdown class='right basic labeled icon' action='nothing'
i.dropdown.icon i.dropdown.icon
@@ -84,6 +86,7 @@ table.ui.bottom.attached.stiped.table
tbody tbody
each filtered_project_instance_actions as |project_instance_action| each filtered_project_instance_actions as |project_instance_action|
tr tr
td= project_instance_action.workflow_action_definition.organization.name
td td
if project_instance_action.project_instance_group.id if project_instance_action.project_instance_group.id
= link-to 'project.show.project-instance-group.show' project_instance_action.project_instance.project.id project_instance_action.project_instance_group.id = link-to 'project.show.project-instance-group.show' project_instance_action.project_instance.project.id project_instance_action.project_instance_group.id