2020-02-13 19:44:57 +00:00
|
|
|
import Route from '@ember/routing/route';
|
2022-02-08 21:07:04 +00:00
|
|
|
import RSVP from 'rsvp';
|
|
|
|
import { action } from '@ember/object';
|
2022-02-14 18:27:09 +00:00
|
|
|
import getStorage from 'vault/lib/token-storage';
|
2022-01-18 20:17:24 +00:00
|
|
|
|
2022-02-14 18:27:09 +00:00
|
|
|
const INPUTTED_START_DATE = 'vault:ui-inputted-start-date';
|
2022-02-08 21:07:04 +00:00
|
|
|
export default class ClientsRoute extends Route {
|
2022-02-08 18:12:23 +00:00
|
|
|
async getVersionHistory() {
|
|
|
|
try {
|
|
|
|
let arrayOfModels = [];
|
|
|
|
let response = await this.store.findAll('clients/version-history'); // returns a class with nested models
|
|
|
|
response.forEach((model) => {
|
|
|
|
arrayOfModels.push({
|
|
|
|
id: model.id,
|
|
|
|
perviousVersion: model.previousVersion,
|
|
|
|
timestampInstalled: model.timestampInstalled,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return arrayOfModels;
|
|
|
|
} catch (e) {
|
2022-02-08 21:07:04 +00:00
|
|
|
console.debug(e);
|
|
|
|
return [];
|
2022-01-18 20:17:24 +00:00
|
|
|
}
|
2022-02-08 21:07:04 +00:00
|
|
|
}
|
2022-02-01 20:45:01 +00:00
|
|
|
|
2022-01-25 22:06:56 +00:00
|
|
|
async model() {
|
2022-02-08 21:07:04 +00:00
|
|
|
let config = await this.store.queryRecord('clients/config', {}).catch((e) => {
|
2020-10-05 21:34:52 +00:00
|
|
|
console.debug(e);
|
|
|
|
// swallowing error so activity can show if no config permissions
|
|
|
|
return {};
|
|
|
|
});
|
2022-01-18 20:17:24 +00:00
|
|
|
|
2022-02-08 21:07:04 +00:00
|
|
|
return RSVP.hash({
|
2020-10-01 19:37:33 +00:00
|
|
|
config,
|
2022-02-08 21:07:04 +00:00
|
|
|
versionHistory: this.getVersionHistory(),
|
2020-10-01 19:37:33 +00:00
|
|
|
});
|
2022-02-08 21:07:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
async loading(transition) {
|
|
|
|
// eslint-disable-next-line ember/no-controller-access-in-routes
|
2022-02-11 22:15:12 +00:00
|
|
|
let controller = this.controllerFor(this.routeName);
|
|
|
|
controller.set('currentlyLoading', true);
|
|
|
|
transition.promise.finally(function () {
|
|
|
|
controller.set('currentlyLoading', false);
|
|
|
|
});
|
2022-02-08 21:07:04 +00:00
|
|
|
}
|
2022-02-14 18:27:09 +00:00
|
|
|
|
|
|
|
@action
|
|
|
|
deactivate() {
|
|
|
|
// when navigating away from parent route, delete manually inputted license start date
|
|
|
|
getStorage().removeItem(INPUTTED_START_DATE);
|
|
|
|
}
|
2022-02-08 21:07:04 +00:00
|
|
|
}
|