1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-19 19:49:37 +02:00

Enhance K8s and Docker features:

* Implement `description` and `visible` labels/annotations
* Find app by `name` or `url` instead of just `name` for update
This commit is contained in:
PortableProgrammer 2023-04-18 19:20:01 -06:00
parent 446b4095f6
commit 5282679f09
2 changed files with 25 additions and 4 deletions

View file

@ -92,15 +92,28 @@ const useDocker = async (apps) => {
const names = labels['flame.name'].split(';'); const names = labels['flame.name'].split(';');
const urls = labels['flame.url'].split(';'); const urls = labels['flame.url'].split(';');
let icons = ''; let icons = '';
let descriptions = '';
let visibility = '';
if ('flame.icon' in labels) { if ('flame.icon' in labels) {
icons = labels['flame.icon'].split(';'); icons = labels['flame.icon'].split(';');
} }
if ('flame.description' in labels) {
descriptions = labels['flame.description'].split(';');
}
if ('flame.visible' in labels) {
visibility = labels['flame.visible'].split(';');
}
dockerApps.push({ dockerApps.push({
name: names[i] || names[0], name: names[i] || names[0],
url: urls[i] || urls[0], url: urls[i] || urls[0],
icon: icons[i] || 'docker', icon: icons[i] || 'docker',
// Add description and visbility
description: descriptions[i] || '',
isPublic: (visibility[i] && /^true$/.test(visibility[i]) ? visibility[i] : visibility[0]) || null,
}); });
} }
} }
@ -114,8 +127,9 @@ const useDocker = async (apps) => {
for (const item of dockerApps) { for (const item of dockerApps) {
// If app already exists, update it // If app already exists, update it
if (apps.some((app) => app.name === item.name)) { // Find by name or url
const app = apps.find((a) => a.name === item.name); if (apps.some((app) => app.name === item.name || app.url === item.url)) {
const app = apps.find((a) => a.name === item.name || app.url === item.url);
if ( if (
item.icon === 'custom' || item.icon === 'custom' ||
@ -125,6 +139,9 @@ const useDocker = async (apps) => {
await app.update({ await app.update({
name: item.name, name: item.name,
url: item.url, url: item.url,
// Add description and visbility
description: item.description,
isPublic: item.isPublic,
isPinned: true, isPinned: true,
}); });
} else { } else {

View file

@ -43,6 +43,9 @@ const useKubernetes = async (apps) => {
name: annotations['flame.pawelmalak/name'], name: annotations['flame.pawelmalak/name'],
url: annotations['flame.pawelmalak/url'], url: annotations['flame.pawelmalak/url'],
icon: annotations['flame.pawelmalak/icon'] || 'kubernetes', icon: annotations['flame.pawelmalak/icon'] || 'kubernetes',
// Add description and visibility
description: annotations['flame.pawelmalak/description'] || '',
isPublic: (annotations['flame.pawelmalak/visible'] && /^true$/.test(annotations['flame.pawelmalak/visible']) ? 1 : 0),
}); });
} }
} }
@ -54,8 +57,9 @@ const useKubernetes = async (apps) => {
} }
for (const item of kubernetesApps) { for (const item of kubernetesApps) {
if (apps.some((app) => app.name === item.name)) { // Find by name or url
const app = apps.find((a) => a.name === item.name); if (apps.some((app) => app.name === item.name || app.url === item.url)) {
const app = apps.find((a) => a.name === item.name || app.url === item.url);
await app.update({ ...item, isPinned: true }); await app.update({ ...item, isPinned: true });
} else { } else {
await App.create({ await App.create({