Make group order customizable

This commit is contained in:
Oliver Traber 2022-01-15 23:51:16 +01:00
parent a7547fca94
commit f4a8cdfeb5
Signed by: Bluemedia
GPG key ID: C7BA47275B086E2C

View file

@ -44,11 +44,30 @@ export default {
}, },
computed: { computed: {
// Group endpoints by their group name // Group endpoints by their group name
// and sort the groups according to the config if specified
groups() { groups() {
return this.apiData.reduce(function(rv, x) { // Group
let groups = this.apiData.reduce(function(rv, x) {
(rv[x["group"]] = rv[x["group"]] || []).push(x); (rv[x["group"]] = rv[x["group"]] || []).push(x);
return rv; return rv;
}, {}); }, {});
console.log(groups);
// Sort
if (this.config.groupOrder) {
let order = [...this.config.groupOrder];
let tmp = {};
Object.assign(tmp, groups);
groups = {};
order.forEach(key => {
if (key in tmp) {
groups[key] = tmp[key];
delete tmp[key];
}
});
Object.assign(groups, tmp);
console.log(groups);
}
return groups;
}, },
// Get an array of all failed endpoints // Get an array of all failed endpoints
failedEndpoints() { failedEndpoints() {