mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-07 22:28:48 +00: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:
parent
5ecb9466ae
commit
8d016629d3
2 changed files with 34 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue