open-vault/ui/app/routes/vault/cluster/clients.js
Angel Garbarino eba46e0d4d
Some folder restructuring to help with route loading states (#14022)
* initial reshuffle to use outlet and remove dashboard and index replace with higher level parent clients

* loading

* clean up

* test clean up

* clean up
2022-02-11 15:15:12 -07:00

47 lines
1.3 KiB
JavaScript

import Route from '@ember/routing/route';
import RSVP from 'rsvp';
import { action } from '@ember/object';
export default class ClientsRoute extends Route {
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) {
console.debug(e);
return [];
}
}
async model() {
let config = await this.store.queryRecord('clients/config', {}).catch((e) => {
console.debug(e);
// swallowing error so activity can show if no config permissions
return {};
});
return RSVP.hash({
config,
versionHistory: this.getVersionHistory(),
});
}
@action
async loading(transition) {
// eslint-disable-next-line ember/no-controller-access-in-routes
let controller = this.controllerFor(this.routeName);
controller.set('currentlyLoading', true);
transition.promise.finally(function () {
controller.set('currentlyLoading', false);
});
}
}