mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-09 04:25:18 +02:00
Revert "chore(): removed docker & kubernetes from database + stoppedApp pin option"
This reverts commit 5111c7ad79
.
This commit is contained in:
parent
5111c7ad79
commit
e69d16284a
3 changed files with 69 additions and 28 deletions
|
@ -52,7 +52,8 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
|
||||||
bookmarksSameTab: 0,
|
bookmarksSameTab: 0,
|
||||||
searchSameTab: 0,
|
searchSameTab: 0,
|
||||||
dockerApps: 1,
|
dockerApps: 1,
|
||||||
kubernetesApps: 1
|
kubernetesApps: 1,
|
||||||
|
unpinStoppedApps: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get config
|
// Get config
|
||||||
|
@ -71,7 +72,8 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
|
||||||
bookmarksSameTab: searchConfig('bookmarksSameTab', 0),
|
bookmarksSameTab: searchConfig('bookmarksSameTab', 0),
|
||||||
searchSameTab: searchConfig('searchSameTab', 0),
|
searchSameTab: searchConfig('searchSameTab', 0),
|
||||||
dockerApps: searchConfig('dockerApps', 0),
|
dockerApps: searchConfig('dockerApps', 0),
|
||||||
kubernetesApps: searchConfig('kubernetesApps', 0)
|
kubernetesApps: searchConfig('kubernetesApps', 0),
|
||||||
|
unpinStoppedApps: searchConfig('unpinStoppedApps', 0)
|
||||||
});
|
});
|
||||||
}, [props.loading]);
|
}, [props.loading]);
|
||||||
|
|
||||||
|
@ -283,6 +285,20 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
|
||||||
<option value={0}>False</option>
|
<option value={0}>False</option>
|
||||||
</select>
|
</select>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor='unpinStoppedApps'>
|
||||||
|
Unpin stopped containers / other apps
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
id='unpinStoppedApps'
|
||||||
|
name='unpinStoppedApps'
|
||||||
|
value={formData.unpinStoppedApps}
|
||||||
|
onChange={e => inputChangeHandler(e, true)}
|
||||||
|
>
|
||||||
|
<option value={1}>True</option>
|
||||||
|
<option value={0}>False</option>
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
{/* KUBERNETES SETTINGS */}
|
{/* KUBERNETES SETTINGS */}
|
||||||
<h2 className={classes.SettingsSection}>Kubernetes</h2>
|
<h2 className={classes.SettingsSection}>Kubernetes</h2>
|
||||||
|
|
|
@ -20,4 +20,5 @@ export interface SettingsForm {
|
||||||
searchSameTab: number;
|
searchSameTab: number;
|
||||||
dockerApps: number;
|
dockerApps: number;
|
||||||
kubernetesApps: number;
|
kubernetesApps: number;
|
||||||
|
unpinStoppedApps: number;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,6 @@ exports.getApps = asyncWrapper(async (req, res, next) => {
|
||||||
const orderType = useOrdering ? useOrdering.value : 'createdAt';
|
const orderType = useOrdering ? useOrdering.value : 'createdAt';
|
||||||
let apps;
|
let apps;
|
||||||
|
|
||||||
let dockerApps = [];
|
|
||||||
if (useDockerApi && useDockerApi.value == 1) {
|
if (useDockerApi && useDockerApi.value == 1) {
|
||||||
let containers = null;
|
let containers = null;
|
||||||
|
|
||||||
|
@ -79,7 +78,12 @@ exports.getApps = asyncWrapper(async (req, res, next) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (containers) {
|
if (containers) {
|
||||||
|
apps = await App.findAll({
|
||||||
|
order: [[orderType, 'ASC']]
|
||||||
|
});
|
||||||
|
|
||||||
containers = containers.filter(e => Object.keys(e.Labels).length !== 0);
|
containers = containers.filter(e => Object.keys(e.Labels).length !== 0);
|
||||||
|
const dockerApps = [];
|
||||||
for (const container of containers) {
|
for (const container of containers) {
|
||||||
const labels = container.Labels;
|
const labels = container.Labels;
|
||||||
|
|
||||||
|
@ -91,7 +95,24 @@ exports.getApps = asyncWrapper(async (req, res, next) => {
|
||||||
dockerApps.push({
|
dockerApps.push({
|
||||||
name: labels['flame.name'],
|
name: labels['flame.name'],
|
||||||
url: labels['flame.url'],
|
url: labels['flame.url'],
|
||||||
icon: labels['flame.icon'] || 'docker',
|
icon: labels['flame.icon'] || 'docker'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unpinStoppedApps && unpinStoppedApps.value == 1) {
|
||||||
|
for (const app of apps) {
|
||||||
|
await app.update({ isPinned: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const item of dockerApps) {
|
||||||
|
if (apps.some(app => app.name === item.name)) {
|
||||||
|
const app = apps.filter(e => e.name === item.name)[0];
|
||||||
|
await app.update({ ...item, isPinned: true });
|
||||||
|
} else {
|
||||||
|
await App.create({
|
||||||
|
...item,
|
||||||
isPinned: true
|
isPinned: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -99,7 +120,6 @@ exports.getApps = asyncWrapper(async (req, res, next) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let kubernetesApps = [];
|
|
||||||
if (useKubernetesApi && useKubernetesApi.value == 1) {
|
if (useKubernetesApi && useKubernetesApi.value == 1) {
|
||||||
let ingresses = null;
|
let ingresses = null;
|
||||||
|
|
||||||
|
@ -116,10 +136,14 @@ exports.getApps = asyncWrapper(async (req, res, next) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ingresses) {
|
if (ingresses) {
|
||||||
|
apps = await App.findAll({
|
||||||
|
order: [[orderType, 'ASC']]
|
||||||
|
});
|
||||||
|
|
||||||
ingresses = ingresses.filter(e => Object.keys(e.metadata.annotations).length !== 0);
|
ingresses = ingresses.filter(e => Object.keys(e.metadata.annotations).length !== 0);
|
||||||
|
const kubernetesApps = [];
|
||||||
for (const ingress of ingresses) {
|
for (const ingress of ingresses) {
|
||||||
const annotations = ingress.metadata.annotations;
|
const annotations = ingress.metadata.annotations;
|
||||||
const creationTimestamp = ingress.metadata.creationTimestamp;
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
'flame.pawelmalak/name' in annotations &&
|
'flame.pawelmalak/name' in annotations &&
|
||||||
|
@ -129,8 +153,24 @@ exports.getApps = asyncWrapper(async (req, res, next) => {
|
||||||
kubernetesApps.push({
|
kubernetesApps.push({
|
||||||
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'
|
||||||
createdAt: creationTimestamp,
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unpinStoppedApps && unpinStoppedApps.value == 1) {
|
||||||
|
for (const app of apps) {
|
||||||
|
await app.update({ isPinned: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const item of kubernetesApps) {
|
||||||
|
if (apps.some(app => app.name === item.name)) {
|
||||||
|
const app = apps.filter(e => e.name === item.name)[0];
|
||||||
|
await app.update({ ...item, isPinned: true });
|
||||||
|
} else {
|
||||||
|
await App.create({
|
||||||
|
...item,
|
||||||
isPinned: true
|
isPinned: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -139,28 +179,12 @@ exports.getApps = asyncWrapper(async (req, res, next) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderType == 'name') {
|
if (orderType == 'name') {
|
||||||
apps = await App.findAll();
|
apps = await App.findAll({
|
||||||
apps = apps.concat(dockerApps);
|
order: [[Sequelize.fn('lower', Sequelize.col('name')), 'ASC']]
|
||||||
apps = apps.concat(kubernetesApps);
|
|
||||||
apps.sort((a, b) => {
|
|
||||||
if (a.name < b.name)
|
|
||||||
return -1;
|
|
||||||
if (a.name > b.name)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
apps = await App.findAll();
|
apps = await App.findAll({
|
||||||
apps = apps.concat(dockerApps);
|
order: [[orderType, 'ASC']]
|
||||||
apps = apps.concat(kubernetesApps);
|
|
||||||
apps.sort((a, b) => {
|
|
||||||
if (!a[orderType] || !b[orderType])
|
|
||||||
return -1;
|
|
||||||
if (a[orderType] < b[orderType])
|
|
||||||
return -1;
|
|
||||||
if (a[orderType] > b[orderType])
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue