Services are now sorted by the 'weight' field.

* Default for discovered services is 0
* Default weight for configured services is their index within their
  group scaled by 100, i.e. (index + 1) * 100
* Should be backwards compatible with current loose ordering
This commit is contained in:
James Wynn 2023-01-24 12:48:49 -06:00
parent 5ecb9466ae
commit 8d016629d3
2 changed files with 34 additions and 1 deletions

View file

@ -13,6 +13,17 @@ import {
} from "utils/config/service-helpers";
import { cleanWidgetGroups, widgetsFromConfig } from "utils/config/widget-helpers";
/**
* Compares services by weight then by name.
*/
function compareServices(service1, service2) {
const comp = service1.weight - service2.weight;
if (comp !== 0) {
return comp;
}
return service1.name.localeCompare(service2.name);
}
export async function bookmarksResponse() {
checkAndCopyConfig("bookmarks.yaml");
@ -112,7 +123,8 @@ export async function servicesResponse() {
...discoveredDockerGroup.services,
...discoveredKubernetesGroup.services,
...configuredGroup.services
].filter((service) => service),
].filter((service) => service)
.sort(compareServices),
};
if (definedLayouts) {