This commit is contained in:
Andras Bacsai
2022-12-01 10:23:43 +01:00
parent 12c0760cb3
commit a129be0dbd
9 changed files with 122 additions and 112 deletions

View File

@@ -179,24 +179,40 @@
if ($status.application.statuses.length === 0) {
$status.application.overallStatus = 'stopped';
} else {
if ($status.application.statuses.length !== numberOfApplications) {
$status.application.overallStatus = 'degraded';
} else {
for (const oneStatus of $status.application.statuses) {
if (oneStatus.status.isExited || oneStatus.status.isRestarting) {
$status.application.overallStatus = 'degraded';
break;
}
if (oneStatus.status.isRunning) {
$status.application.overallStatus = 'healthy';
}
if (
!oneStatus.status.isExited &&
!oneStatus.status.isRestarting &&
!oneStatus.status.isRunning
) {
$status.application.overallStatus = 'stopped';
}
// if ($status.application.statuses.length !== numberOfApplications) {
// $status.application.overallStatus = 'degraded';
// } else {
// for (const oneStatus of $status.application.statuses) {
// if (oneStatus.status.isExited || oneStatus.status.isRestarting) {
// $status.application.overallStatus = 'degraded';
// break;
// }
// if (oneStatus.status.isRunning) {
// $status.application.overallStatus = 'healthy';
// }
// if (
// !oneStatus.status.isExited &&
// !oneStatus.status.isRestarting &&
// !oneStatus.status.isRunning
// ) {
// $status.application.overallStatus = 'stopped';
// }
// }
// }
for (const oneStatus of $status.application.statuses) {
if (oneStatus.status.isExited || oneStatus.status.isRestarting) {
$status.application.overallStatus = 'degraded';
break;
}
if (oneStatus.status.isRunning) {
$status.application.overallStatus = 'healthy';
}
if (
!oneStatus.status.isExited &&
!oneStatus.status.isRestarting &&
!oneStatus.status.isRunning
) {
$status.application.overallStatus = 'stopped';
}
}
}

View File

@@ -312,30 +312,6 @@
await getGitlabToken();
}
scanRepository(isPublicRepository);
// let htmlUrl = application.gitSource.htmlUrl;
// const left = screen.width / 2 - 1020 / 2;
// const top = screen.height / 2 - 618 / 2;
// const newWindow = open(
// `${htmlUrl}/oauth/authorize?client_id=${
// application.gitSource.gitlabApp.appId
// }&redirect_uri=${getAPIUrl()}/webhooks/gitlab&response_type=code&scope=api+email+read_repository&state=${
// $page.params.id
// }`,
// 'GitLab',
// 'resizable=1, scrollbars=1, fullscreen=0, height=618, width=1020,top=' +
// top +
// ', left=' +
// left +
// ', toolbar=0, menubar=0, status=0'
// );
// const timer = setInterval(() => {
// if (newWindow?.closed) {
// clearInterval(timer);
// $appSession.tokens.gitlab = localStorage.getItem('gitLabToken');
// // localStorage.removeItem('gitLabToken' );
// }
// }, 100);
}
} else if (error.message === 'Bad credentials') {
const { token } = await get(`/applications/${id}/configuration/githubToken`);

View File

@@ -54,7 +54,7 @@
<div class="w-full">
<div class="mx-auto w-full">
<div class="flex flex-row border-b border-coolgray-500 mb-6 space-x-2">
<div class="title font-bold pb-3">Revert Application</div>
<div class="title font-bold pb-3">Revert</div>
</div>
<div>
You can revert application to a previously built image. Currently only locally stored images
@@ -67,53 +67,60 @@
>
feature <a href={`/applications/${id}/features`}>here</a>.
</div>
<div
class="px-4 lg:pb-10 pb-6 flex flex-wrap items-center justify-center lg:justify-start gap-8"
>
{#each imagesAvailables as image}
<div class="gap-2 py-4 m-2">
<div class="flex flex-col justify-center items-center">
<div class="text-xl font-bold">
{image.tag}
</div>
<div>
<a
class="flex no-underline text-xs my-4"
href="{application.gitSource.htmlUrl}/{application.repository}/commit/{image.tag}"
target="_blank noreferrer"
>
<button class="btn btn-sm">
Check Commit
<svg
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor"
class="w-3 h-3 text-white ml-2"
{#if imagesAvailables.length > 0}
<div
class="px-4 lg:pb-10 pb-6 flex flex-wrap items-center justify-center lg:justify-start gap-8"
>
{#each imagesAvailables as image}
<div class="gap-2 py-4 m-2">
<div class="flex flex-col justify-center items-center">
<div class="text-xl font-bold">
{image.tag}
</div>
<div>
<a
class="flex no-underline text-xs my-4"
href="{application.gitSource.htmlUrl}/{application.repository}/commit/{image.tag}"
target="_blank noreferrer"
>
<button class="btn btn-sm">
Check Commit
<svg
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor"
class="w-3 h-3 text-white ml-2"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M4.5 19.5l15-15m0 0H8.25m11.25 0v11.25"
/>
</svg>
</button></a
>
{#if image.repository + ':' + image.tag !== runningImage}
<button
class="btn btn-sm btn-primary w-full"
on:click={() => revertApplication(image)}>Revert Now</button
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M4.5 19.5l15-15m0 0H8.25m11.25 0v11.25"
/>
</svg>
</button></a
>
{#if image.repository + ':' + image.tag !== runningImage}
<button
class="btn btn-sm btn-primary w-full"
on:click={() => revertApplication(image)}>Revert Now</button
>
{:else}
<button class="btn btn-sm btn-primary w-full btn-disabled bg-transparent underline"
>Currently Used</button
>
{/if}
{:else}
<button
class="btn btn-sm btn-primary w-full btn-disabled bg-transparent underline"
>Currently Used</button
>
{/if}
</div>
</div>
</div>
</div>
{/each}
</div>
{/each}
</div>
{:else}
<div class="flex flex-col justify-center items-center">
<div class="text-xl font-bold">No images available</div>
</div>
{/if}
</div>
</div>

View File

@@ -35,6 +35,9 @@
if (service?.volumes) {
for (const [_, volumeName] of Object.entries(service.volumes)) {
let [volume, target] = volumeName.split(':');
if (volume === '.') {
volume = target;
}
if (!target) {
target = volume;
volume = `${application.id}${volume.replace(/\//gi, '-').replace(/\./gi, '')}`;