mirror of
https://github.com/ershisan99/coolify.git
synced 2026-01-24 20:52:10 +00:00
fix: ui
This commit is contained in:
@@ -11,7 +11,7 @@ export let containerStatus = writable({});
|
||||
let PERMITED_STATUS = ['loading', 'running', 'healthy', 'building', 'degraded', 'stopped', 'error'];
|
||||
|
||||
// refreshStatus([{id}])
|
||||
export async function refreshStatus(list:Array<any>) {
|
||||
export async function refreshStatus(list: Array<any>) {
|
||||
for (const item of list) {
|
||||
setStatus(item.id, 'loading');
|
||||
getStatus(item, true);
|
||||
@@ -32,7 +32,7 @@ export async function getStatus(resource: any, force: boolean = false) {
|
||||
} else if (typeof dualCerts !== 'undefined') { // Service
|
||||
const response = await get(`/services/${id}/status`);
|
||||
newStatus = parseServiceResponse(response);
|
||||
} else if (typeof engine !== 'undefined'){ // Destination/Server
|
||||
} else if (typeof engine !== 'undefined') { // Destination/Server
|
||||
const response = await get(`/destinations/${id}/status`);
|
||||
newStatus = response.isRunning ? 'running' : 'stopped';
|
||||
} else { // Database
|
||||
@@ -49,25 +49,25 @@ export async function getStatus(resource: any, force: boolean = false) {
|
||||
}
|
||||
|
||||
const setStatus = (thingId, newStatus) => {
|
||||
if(!PERMITED_STATUS.includes(newStatus))
|
||||
throw(`Change to ${newStatus} is not permitted. Try: ${PERMITED_STATUS.join(', ')}`);
|
||||
containerStatus.update(n => Object.assign(n, {thingId: newStatus}));
|
||||
if (!PERMITED_STATUS.includes(newStatus))
|
||||
throw (`Change to ${newStatus} is not permitted. Try: ${PERMITED_STATUS.join(', ')}`);
|
||||
containerStatus.update(n => Object.assign(n, { thingId: newStatus }));
|
||||
};
|
||||
|
||||
// -- Response Parsing
|
||||
|
||||
function parseApplicationsResponse(list:Array<any>){
|
||||
function parseApplicationsResponse(list: Array<any>) {
|
||||
if (list.length === 0) return 'stopped';
|
||||
if (list.length === 1) return list[0].status.isRunning ? 'running' : 'stopped';
|
||||
return allWorking(list.map( (el:any) => el.status.isRunning ))
|
||||
return allWorking(list.map((el: any) => el.status.isRunning))
|
||||
}
|
||||
|
||||
function parseServiceResponse(response:any){
|
||||
function parseServiceResponse(response: any) {
|
||||
if (Object.keys(response).length === 0) return 'stopped';
|
||||
let list = Object.keys(response).map((el) => el.status.isRunning)
|
||||
return allWorking(list) ? 'running' : 'degraded'
|
||||
}
|
||||
|
||||
function allWorking(list:Array<any>){
|
||||
return list.reduce((acum:boolean,res:boolean) => acum && res) ? 'running' : 'degraded';
|
||||
function allWorking(list: Array<any>) {
|
||||
return list.reduce((acum: boolean, res: boolean) => acum && res) ? 'running' : 'degraded';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user