mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-02 17:35:17 +02:00
automatically create new category when category in integrations is not found (#11)
automatically create new category when category in docker or kubernetes labels is not found
This commit is contained in:
parent
4280511372
commit
349d63c3e3
4 changed files with 52 additions and 31 deletions
|
@ -217,6 +217,12 @@ async function retrieveDockerApps(apps, orderType, unpinStoppedApps) {
|
|||
|
||||
for (let i = 0; i < names.length; i++) {
|
||||
const category = categoriesLabels[i] ? categories.find(category => category.name.toUpperCase() === categoriesLabels[i].toUpperCase()) : dockerDefaultCategory;
|
||||
if (!category) {
|
||||
category = await createNewCategory(categoriesLabels[i]);
|
||||
if (category) {
|
||||
categories.push(category);
|
||||
}
|
||||
}
|
||||
|
||||
dockerApps.push({
|
||||
name: names[i] || names[0],
|
||||
|
@ -250,6 +256,15 @@ async function retrieveDockerApps(apps, orderType, unpinStoppedApps) {
|
|||
return apps;
|
||||
}
|
||||
|
||||
async function createNewCategory(newCategoryName) {
|
||||
return await Category.create({
|
||||
name: newCategoryName,
|
||||
type: 'apps',
|
||||
isPinned: true,
|
||||
orderId: Number.MAX_SAFE_INTEGER //New category will always be last and can then be re-ordered manually by user
|
||||
});
|
||||
}
|
||||
|
||||
async function retrieveKubernetesApps(apps, orderType, unpinStoppedApps) {
|
||||
let ingresses = null;
|
||||
|
||||
|
@ -295,6 +310,12 @@ async function retrieveKubernetesApps(apps, orderType, unpinStoppedApps) {
|
|||
|
||||
for (let i = 0; i < names.length; i++) {
|
||||
const category = categoriesLabels[i] ? categories.find(category => category.name.toUpperCase() === categoriesLabels[i].toUpperCase()) : kubernetesDefaultCategory;
|
||||
if (!category) {
|
||||
category = await createNewCategory(categoriesLabels[i]);
|
||||
if (category) {
|
||||
categories.push(category);
|
||||
}
|
||||
}
|
||||
|
||||
kubernetesApps.push({
|
||||
name: names[i] || names[0],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue