24695ddedc
* setup * add forward slash * fix icon issue * add to current view * fixes * change * final cleanup * remove todo
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import { tracked } from '@glimmer/tracking';
|
|
import { action } from '@ember/object';
|
|
export default class Current extends Component {
|
|
chartLegend = [
|
|
{ key: 'entity_clients', label: 'entity clients' },
|
|
{ key: 'non_entity_clients', label: 'non-entity clients' },
|
|
];
|
|
@tracked namespaceArray = this.args.model.monthly?.byNamespace.map((namespace) => {
|
|
return { name: namespace['label'], id: namespace['label'] };
|
|
});
|
|
@tracked selectedNamespace = null;
|
|
|
|
// TODO CMB get from model
|
|
get upgradeDate() {
|
|
return this.args.upgradeDate || null;
|
|
}
|
|
|
|
get licenseStartDate() {
|
|
return this.args.licenseStartDate || null;
|
|
}
|
|
|
|
// API client count data by namespace for current/partial month
|
|
get byNamespaceCurrent() {
|
|
return this.args.model.monthly?.byNamespace || null;
|
|
}
|
|
|
|
// top level TOTAL client counts for current/partial month
|
|
get totalUsageCounts() {
|
|
return this.selectedNamespace
|
|
? this.filterByNamespace(this.selectedNamespace)
|
|
: this.args.model.monthly?.total;
|
|
}
|
|
|
|
// total client data for horizontal bar chart in attribution component
|
|
get totalClientsData() {
|
|
if (this.selectedNamespace) {
|
|
let filteredNamespace = this.filterByNamespace(this.selectedNamespace);
|
|
return filteredNamespace.mounts ? this.filterByNamespace(this.selectedNamespace).mounts : null;
|
|
} else {
|
|
return this.byNamespaceCurrent;
|
|
}
|
|
}
|
|
|
|
get responseTimestamp() {
|
|
return this.args.model.monthly?.responseTimestamp;
|
|
}
|
|
|
|
// HELPERS
|
|
filterByNamespace(namespace) {
|
|
return this.byNamespaceCurrent.find((ns) => ns.label === namespace);
|
|
}
|
|
|
|
// ACTIONS
|
|
@action
|
|
selectNamespace([value]) {
|
|
// value comes in as [namespace0]
|
|
this.selectedNamespace = value;
|
|
}
|
|
}
|