Skip to content

Commit d2b79a0

Browse files
Entity Stat aggregate view simplified.
#345
1 parent d32ee27 commit d2b79a0

5 files changed

Lines changed: 52 additions & 56 deletions

File tree

waltz-ng/client/applications/directives/apps-by-investment-pie.html renamed to waltz-ng/client/applications/components/apps-by-investment-pie.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div>
2-
<waltz-pie-table data="ctrl.data"
3-
config="ctrl.config"
2+
<waltz-pie-table data="$ctrl.data"
3+
config="$ctrl.config"
44
class="clickable"
55
waltz-jump-to="apps-section"
66
icon="money"

waltz-ng/client/applications/directives/apps-by-investment-pie.js renamed to waltz-ng/client/applications/components/apps-by-investment-pie.js

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ import {ragColorScale} from "../../common/colors";
2121
import {toKeyCounts} from "../../common";
2222

2323

24-
const BINDINGS = {
25-
applications: '=',
26-
size: '='
24+
const bindings = {
25+
applications: '<',
26+
size: '<'
2727
};
2828

2929

30+
const template = require('./apps-by-investment-pie.html');
31+
32+
3033
const DEFAULT_SIZE = 80;
3134

35+
3236
const investmentLabels = {
3337
'R' : 'Disinvest',
3438
'A' : 'Maintain',
@@ -39,7 +43,7 @@ const investmentLabels = {
3943
const config = {
4044
colorProvider: (d) => ragColorScale(d.data.key),
4145
size: DEFAULT_SIZE,
42-
labelProvider: (k) => investmentLabels[k] || 'Unknown'
46+
labelProvider: (d) => investmentLabels[d.key] || 'Unknown'
4347
};
4448

4549

@@ -48,32 +52,25 @@ function calcAppInvestmentPieStats(apps) {
4852
}
4953

5054

51-
function controller($scope) {
55+
function controller() {
5256
const vm = this;
5357

5458
vm.config = config;
5559
vm.data = [];
5660

57-
$scope.$watch('ctrl.size', sz => vm.config.size = sz ? sz : DEFAULT_SIZE);
58-
59-
$scope.$watch('ctrl.applications', apps => {
60-
if (!apps) return;
61-
vm.data = calcAppInvestmentPieStats(apps);
62-
});
63-
61+
vm.$onChanges = () => {
62+
vm.config.size = vm.size
63+
? vm.size
64+
: DEFAULT_SIZE;
65+
vm.data = calcAppInvestmentPieStats(vm.applications);
66+
};
6467
}
6568

66-
controller.$inject = ['$scope'];
67-
6869

69-
export default () => {
70-
return {
71-
restrict: 'E',
72-
replace: true,
73-
template: require('./apps-by-investment-pie.html'),
74-
scope: {},
75-
bindToController: BINDINGS,
76-
controllerAs: 'ctrl',
77-
controller
78-
};
70+
const component = {
71+
template,
72+
bindings,
73+
controller
7974
};
75+
76+
export default component;

waltz-ng/client/applications/directives/apps-by-lifecycle-phase-pie.html renamed to waltz-ng/client/applications/components/apps-by-lifecycle-phase-pie.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div>
2-
<waltz-pie-table data="ctrl.data"
3-
config="ctrl.config"
2+
<waltz-pie-table data="$ctrl.data"
3+
config="$ctrl.config"
44
class="clickable"
55
waltz-jump-to="apps-section"
66
icon="desktop"

waltz-ng/client/applications/directives/apps-by-lifecycle-phase-pie.js renamed to waltz-ng/client/applications/components/apps-by-lifecycle-phase-pie.js

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,55 +18,54 @@
1818
*/
1919

2020
import {lifecyclePhaseColorScale} from "../../common/colors";
21+
import {lifecyclePhaseDisplayNames} from '../../common/services/display_names';
2122
import {toKeyCounts} from "../../common";
2223

2324

24-
const BINDINGS = {
25-
applications: '=',
26-
size: '='
25+
const bindings = {
26+
applications: '<',
27+
size: '<'
2728
};
2829

2930

31+
const template = require('./apps-by-lifecycle-phase-pie.html');
32+
33+
3034
const DEFAULT_SIZE = 80;
3135

36+
3237
const config = {
3338
colorProvider: (d) => lifecyclePhaseColorScale(d.data.key),
34-
size: DEFAULT_SIZE
39+
size: DEFAULT_SIZE,
40+
labelProvider: d => lifecyclePhaseDisplayNames[d.key] || 'Unknown'
3541
};
3642

3743

38-
39-
function calcAppPhasePieStats(apps) {
44+
function calcAppPhasePieStats(apps = []) {
4045
return toKeyCounts(apps, a => a.lifecyclePhase);
4146
}
4247

4348

44-
function controller($scope) {
49+
function controller() {
4550
const vm = this;
4651

4752
vm.config = config;
4853
vm.data = [];
4954

50-
$scope.$watch('ctrl.size', sz => vm.config.size = sz ? sz : DEFAULT_SIZE);
51-
52-
$scope.$watch('ctrl.applications', apps => {
53-
if (!apps) return;
54-
vm.data = calcAppPhasePieStats(apps);
55-
});
56-
55+
vm.$onChanges = () => {
56+
vm.config.size = vm.size
57+
? vm.size
58+
: DEFAULT_SIZE;
59+
vm.data = calcAppPhasePieStats(vm.applications);
60+
};
5761
}
5862

59-
controller.$inject = ['$scope'];
60-
6163

62-
export default () => {
63-
return {
64-
restrict: 'E',
65-
replace: true,
66-
template: require('./apps-by-lifecycle-phase-pie.html'),
67-
scope: {},
68-
bindToController: BINDINGS,
69-
controllerAs: 'ctrl',
70-
controller
71-
};
64+
const component = {
65+
template,
66+
bindings,
67+
controller
7268
};
69+
70+
71+
export default component;

waltz-ng/client/applications/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ export default (module) => {
2323
.directive('waltzAppOverviewSection', require('./directives/app-overview-section'))
2424
.directive('waltzAppSelector', require('./directives/app-selector'))
2525
.directive('waltzAppTable', require('./directives/app-table'))
26-
.directive('waltzAppsByInvestmentPie', require('./directives/apps-by-investment-pie'))
27-
.directive('waltzAppsByLifecyclePhasePie', require('./directives/apps-by-lifecycle-phase-pie'))
2826
.directive('waltzAssetCodeExplorer', require('./directives/asset-code-explorer'))
2927
.directive('waltzBasicAppSelector', require('./directives/basic-app-selector'));
3028

3129
module
30+
.component('waltzAppsByInvestmentPie', require('./components/apps-by-investment-pie'))
31+
.component('waltzAppsByLifecyclePhasePie', require('./components/apps-by-lifecycle-phase-pie'))
3232
.component('waltzAppSummary', require('./components/app-summary'));
3333
};

0 commit comments

Comments
 (0)