mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-24 13:39:35 +02:00
fix integrations
This commit is contained in:
parent
e5154576b4
commit
e7cd4d7705
21 changed files with 125 additions and 63 deletions
|
@ -115,7 +115,7 @@ const useDocker = async (apps) => {
|
|||
const icons = labels['flame.icon'] ? labels['flame.icon'].split(';') : [];
|
||||
|
||||
for (let i = 0; i < names.length; i++) {
|
||||
const category = categoriesLabels[i] ? categories.find(category => category.name.toUpperCase() === categoriesLabels[i].toUpperCase()) : dockerDefaultCategory;
|
||||
let category = categoriesLabels[i] ? categories.find(category => category.name.toUpperCase() === categoriesLabels[i].toUpperCase()) : dockerDefaultCategory;
|
||||
if (!category) {
|
||||
category = await createNewCategory(categoriesLabels[i]);
|
||||
if (category) {
|
||||
|
@ -129,7 +129,7 @@ const useDocker = async (apps) => {
|
|||
name: names[i] || names[0],
|
||||
url: urls[i] || urls[0],
|
||||
icon: icons[i] || 'docker',
|
||||
category: category.id,
|
||||
categoryId: category.id,
|
||||
orderId: orders[i] || 500,
|
||||
});
|
||||
}
|
||||
|
@ -141,7 +141,6 @@ const useDocker = async (apps) => {
|
|||
await app.update({ isPinned: false });
|
||||
}
|
||||
}
|
||||
|
||||
for (const item of dockerApps) {
|
||||
// If app already exists, update it
|
||||
if (apps.some((app) => app.name === item.name)) {
|
||||
|
|
|
@ -67,7 +67,7 @@ const useKubernetes = async (apps) => {
|
|||
const icons = annotations['flame.pawelmalak/icon'] ? annotations['flame.pawelmalak/icon'].split(';') : [];
|
||||
|
||||
for (let i = 0; i < names.length; i++) {
|
||||
const category = categoriesLabels[i] ? categories.find(category => category.name.toUpperCase() === categoriesLabels[i].toUpperCase()) : kubernetesDefaultCategory;
|
||||
let category = categoriesLabels[i] ? categories.find(category => category.name.toUpperCase() === categoriesLabels[i].toUpperCase()) : kubernetesDefaultCategory;
|
||||
if (!category) {
|
||||
category = await createNewCategory(categoriesLabels[i]);
|
||||
if (category) {
|
||||
|
@ -81,7 +81,7 @@ const useKubernetes = async (apps) => {
|
|||
name: names[i] || names[0],
|
||||
url: urls[i] || urls[0],
|
||||
icon: icons[i] || 'kubernetes',
|
||||
category: category.id,
|
||||
categoryId: category.id,
|
||||
orderId: orders[i] || 500,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,12 +10,11 @@ const { useKubernetes, useDocker } = require('./docker');
|
|||
// @access Public
|
||||
const getAllApps = asyncWrapper(async (req, res, next) => {
|
||||
const {
|
||||
useOrdering: orderType,
|
||||
dockerApps: useDockerAPI,
|
||||
kubernetesApps: useKubernetesAPI,
|
||||
useOrdering: orderType
|
||||
} = await loadConfig();
|
||||
|
||||
let apps = await loadIntegrationsApps();
|
||||
// Load apps to create/update apps from integrations (Docker, Kubernetes, etc.)
|
||||
await initIntegrationsApps();
|
||||
|
||||
// apps visibility
|
||||
const where = req.isAuthenticated ? {} : { isPublic: true };
|
||||
|
@ -44,26 +43,4 @@ const getAllApps = asyncWrapper(async (req, res, next) => {
|
|||
});
|
||||
});
|
||||
|
||||
const loadIntegrationsApps = asyncWrapper(async () => {
|
||||
const {
|
||||
dockerApps: useDockerAPI,
|
||||
kubernetesApps: useKubernetesAPI,
|
||||
} = await loadConfig();
|
||||
|
||||
let apps;
|
||||
|
||||
if (useDockerAPI) {
|
||||
await useDocker(apps);
|
||||
}
|
||||
|
||||
if (useKubernetesAPI) {
|
||||
await useKubernetes(apps);
|
||||
}
|
||||
|
||||
return apps;
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
getAllApps,
|
||||
loadIntegrationsApps
|
||||
}
|
||||
module.exports = getAllApps;
|
||||
|
|
42
controllers/apps/getIntegrationsApps.js
Normal file
42
controllers/apps/getIntegrationsApps.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
const asyncWrapper = require('../../middleware/asyncWrapper');
|
||||
const App = require('../../models/App');
|
||||
const { Sequelize } = require('sequelize');
|
||||
const loadConfig = require('../../utils/loadConfig');
|
||||
|
||||
const { useKubernetes, useDocker } = require('./docker');
|
||||
|
||||
// @desc Get all apps
|
||||
// @route GET /api/integrationsApps
|
||||
// @access Public
|
||||
const getIntegrationsApps = asyncWrapper(async (req, res, next) => {
|
||||
const {
|
||||
useOrdering: orderType,
|
||||
dockerApps: useDockerAPI,
|
||||
kubernetesApps: useKubernetesAPI,
|
||||
} = await loadConfig();
|
||||
|
||||
let apps;
|
||||
|
||||
if (useDockerAPI) {
|
||||
await useDocker(apps);
|
||||
}
|
||||
|
||||
if (useKubernetesAPI) {
|
||||
await useKubernetes(apps);
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
// Set header to fetch containers info every time
|
||||
return res.status(200).setHeader('Cache-Control', 'no-store').json({
|
||||
success: true,
|
||||
data: apps,
|
||||
});
|
||||
}
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
data: apps,
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = getIntegrationsApps;
|
|
@ -4,5 +4,5 @@ module.exports = {
|
|||
deleteApp: require('./deleteApp'),
|
||||
updateApp: require('./updateApp'),
|
||||
reorderApps: require('./reorderApps'),
|
||||
getAllApps: require('./getAllApps').getAllApps,
|
||||
getAllApps: require('./getAllApps'),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue