mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user