36ccfaa3aa
* adds development workflow to mirage config * adds mirage handler and factory for mfa workflow * adds mfa handling to auth service and cluster adapter * moves auth success logic from form to controller * adds mfa form component * shows delayed auth message for all methods * adds new code delay to mfa form * adds error views * fixes merge conflict * adds integration tests for mfa-form component * fixes auth tests * updates mfa response handling to align with backend * updates mfa-form to handle multiple methods and constraints * adds noDefault arg to Select component * updates mirage mfa handler to align with backend and adds generator for various mfa scenarios * adds tests * flaky test fix attempt * reverts test fix attempt * adds changelog entry * updates comments for todo items * removes faker from mfa mirage factory and handler * adds number to word helper * fixes tests * Revert "Merge branch 'main' into ui/mfa" This reverts commit 8ee6a6aaa1b6c9ec16b985c10d91c3806819ec40, reversing changes made to 2428dd6cca07bb41cda3f453619646ca3a88bfd0. * format-ttl helper fix from main
75 lines
2.5 KiB
JavaScript
75 lines
2.5 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import { tracked } from '@glimmer/tracking';
|
|
import { isAfter, startOfMonth } from 'date-fns';
|
|
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 firstUpgradeVersion = this.args.model.versionHistory[0].id || null; // return 1.9.0 or earliest upgrade post 1.9.0
|
|
@tracked upgradeDate = this.args.model.versionHistory[0].timestampInstalled || null; // returns RFC3339 timestamp
|
|
|
|
@tracked selectedNamespace = null;
|
|
@tracked namespaceArray = this.byNamespaceCurrent.map((namespace) => {
|
|
return { name: namespace['label'], id: namespace['label'] };
|
|
});
|
|
|
|
// Response client count data by namespace for current/partial month
|
|
get byNamespaceCurrent() {
|
|
return this.args.model.monthly?.byNamespace || [];
|
|
}
|
|
|
|
get isGatheringData() {
|
|
// return true if tracking IS enabled but no data collected yet
|
|
return this.args.model.config?.enabled === 'On' && this.byNamespaceCurrent.length === 0;
|
|
}
|
|
|
|
get hasAttributionData() {
|
|
return this.totalUsageCounts.clients !== 0 && this.totalClientsData.length !== 0;
|
|
}
|
|
|
|
get countsIncludeOlderData() {
|
|
let firstUpgrade = this.args.model.versionHistory[0];
|
|
if (!firstUpgrade) {
|
|
return false;
|
|
}
|
|
let versionDate = new Date(firstUpgrade.timestampInstalled);
|
|
// compare against this month and this year to show message or not.
|
|
return isAfter(versionDate, startOfMonth(new Date())) ? versionDate : false;
|
|
}
|
|
|
|
// 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;
|
|
}
|
|
}
|