From d68b879ec204c3f33605a1f043129afa8b6c1a50 Mon Sep 17 00:00:00 2001 From: Denys Butenko Date: Fri, 27 Sep 2024 16:39:18 +0700 Subject: [PATCH 1/5] NAS-131403: Use `app.redeploy` endpoint for restart apps --- .../api/api-job-directory.interface.ts | 1 + .../apps/services/applications.service.ts | 20 ++----------------- .../app-controls/app-controls.component.ts | 2 +- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/app/interfaces/api/api-job-directory.interface.ts b/src/app/interfaces/api/api-job-directory.interface.ts index 32a97683772..e3ceca5a649 100644 --- a/src/app/interfaces/api/api-job-directory.interface.ts +++ b/src/app/interfaces/api/api-job-directory.interface.ts @@ -78,6 +78,7 @@ export interface ApiJobDirectory { 'app.update': { params: [string, AppUpdate]; response: App }; 'app.start': { params: AppStartQueryParams; response: void }; 'app.stop': { params: AppStartQueryParams; response: void }; + 'app.redeploy': { params: AppStartQueryParams; response: void }; 'app.delete': { params: AppDeleteParams; response: boolean }; 'app.upgrade': { params: AppUpgradeParams; response: App }; 'app.rollback': { params: AppRollbackParams; response: App }; diff --git a/src/app/pages/apps/services/applications.service.ts b/src/app/pages/apps/services/applications.service.ts index 80c18682370..0568084dffb 100644 --- a/src/app/pages/apps/services/applications.service.ts +++ b/src/app/pages/apps/services/applications.service.ts @@ -1,15 +1,11 @@ import { Injectable } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { - EMPTY, Observable, OperatorFunction, filter, map, pipe, shareReplay, - switchMap, } from 'rxjs'; import { customApp } from 'app/constants/catalog.constants'; import { AppExtraCategory } from 'app/enums/app-extra-category.enum'; -import { AppState } from 'app/enums/app-state.enum'; -import { JobState } from 'app/enums/job-state.enum'; import { ApiEvent } from 'app/interfaces/api-message.interface'; import { App, AppStartQueryParams, AppUpgradeParams, @@ -107,20 +103,8 @@ export class ApplicationsService { return this.ws.job('app.stop', [name]); } - restartApplication(app: App): Observable> { - switch (app.state) { - case AppState.Running: - return this.stopApplication(app.name).pipe( - filter((job) => job.state === JobState.Success), - switchMap(() => this.startApplication(app.name)), - ); - case AppState.Crashed: - case AppState.Stopped: - return this.startApplication(app.name); - case AppState.Deploying: - default: - return EMPTY; - } + restartApplication(name: string): Observable> { + return this.ws.job('app.redeploy', [name]); } convertDateToRelativeDate(date: Date): string { diff --git a/src/app/pages/dashboard/widgets/apps/common/app-controls/app-controls.component.ts b/src/app/pages/dashboard/widgets/apps/common/app-controls/app-controls.component.ts index c141c7f72c7..6b2e18185ad 100644 --- a/src/app/pages/dashboard/widgets/apps/common/app-controls/app-controls.component.ts +++ b/src/app/pages/dashboard/widgets/apps/common/app-controls/app-controls.component.ts @@ -34,7 +34,7 @@ export class AppControlsComponent { onRestartApp(app: App): void { this.isRestarting.set(true); this.snackbar.success(this.translate.instant('App is restarting')); - this.appService.restartApplication(app) + this.appService.restartApplication(app.name) .pipe(untilDestroyed(this)) .subscribe({ complete: () => { From 40362a6e4151b73a92995eb94d5f1a92348042cd Mon Sep 17 00:00:00 2001 From: Denys Butenko Date: Mon, 30 Sep 2024 17:10:39 +0700 Subject: [PATCH 2/5] NAS-131403: Add restart action to installed apps --- .../app-row/app-row.component.html | 12 +++++++++++ .../app-row/app-row.component.spec.ts | 4 ++++ .../app-row/app-row.component.ts | 5 +++++ .../installed-apps.component.html | 1 + .../installed-apps.component.spec.ts | 6 ++++++ .../installed-apps.component.ts | 20 +++++++++++++++++- .../app-controls/app-controls.component.ts | 21 +++++++++++-------- src/assets/i18n/af.json | 2 ++ src/assets/i18n/ar.json | 2 ++ src/assets/i18n/ast.json | 2 ++ src/assets/i18n/az.json | 2 ++ src/assets/i18n/be.json | 2 ++ src/assets/i18n/bg.json | 2 ++ src/assets/i18n/bn.json | 2 ++ src/assets/i18n/br.json | 2 ++ src/assets/i18n/bs.json | 2 ++ src/assets/i18n/ca.json | 2 ++ src/assets/i18n/cs.json | 2 ++ src/assets/i18n/cy.json | 2 ++ src/assets/i18n/da.json | 2 ++ src/assets/i18n/de.json | 2 ++ src/assets/i18n/dsb.json | 2 ++ src/assets/i18n/el.json | 2 ++ src/assets/i18n/en-au.json | 2 ++ src/assets/i18n/en-gb.json | 2 ++ src/assets/i18n/en.json | 2 ++ src/assets/i18n/eo.json | 2 ++ src/assets/i18n/es-ar.json | 2 ++ src/assets/i18n/es-co.json | 2 ++ src/assets/i18n/es-mx.json | 2 ++ src/assets/i18n/es-ni.json | 2 ++ src/assets/i18n/es-ve.json | 2 ++ src/assets/i18n/es.json | 2 ++ src/assets/i18n/et.json | 2 ++ src/assets/i18n/eu.json | 2 ++ src/assets/i18n/fa.json | 2 ++ src/assets/i18n/fi.json | 2 ++ src/assets/i18n/fr.json | 2 ++ src/assets/i18n/fy.json | 2 ++ src/assets/i18n/ga.json | 2 ++ src/assets/i18n/gd.json | 2 ++ src/assets/i18n/gl.json | 2 ++ src/assets/i18n/he.json | 2 ++ src/assets/i18n/hi.json | 2 ++ src/assets/i18n/hr.json | 2 ++ src/assets/i18n/hsb.json | 2 ++ src/assets/i18n/hu.json | 2 ++ src/assets/i18n/ia.json | 2 ++ src/assets/i18n/id.json | 2 ++ src/assets/i18n/io.json | 2 ++ src/assets/i18n/is.json | 2 ++ src/assets/i18n/it.json | 2 ++ src/assets/i18n/ja.json | 2 ++ src/assets/i18n/ka.json | 2 ++ src/assets/i18n/kk.json | 2 ++ src/assets/i18n/km.json | 2 ++ src/assets/i18n/kn.json | 2 ++ src/assets/i18n/ko.json | 2 ++ src/assets/i18n/lb.json | 2 ++ src/assets/i18n/lt.json | 2 ++ src/assets/i18n/lv.json | 2 ++ src/assets/i18n/mk.json | 2 ++ src/assets/i18n/ml.json | 2 ++ src/assets/i18n/mn.json | 2 ++ src/assets/i18n/mr.json | 2 ++ src/assets/i18n/my.json | 2 ++ src/assets/i18n/nb.json | 2 ++ src/assets/i18n/ne.json | 2 ++ src/assets/i18n/nl.json | 2 ++ src/assets/i18n/nn.json | 2 ++ src/assets/i18n/os.json | 2 ++ src/assets/i18n/pa.json | 2 ++ src/assets/i18n/pl.json | 2 ++ src/assets/i18n/pt-br.json | 2 ++ src/assets/i18n/pt.json | 2 ++ src/assets/i18n/ro.json | 2 ++ src/assets/i18n/ru.json | 2 ++ src/assets/i18n/sk.json | 2 ++ src/assets/i18n/sl.json | 2 ++ src/assets/i18n/sq.json | 2 ++ src/assets/i18n/sr-latn.json | 2 ++ src/assets/i18n/sr.json | 2 ++ src/assets/i18n/strings.json | 2 ++ src/assets/i18n/sv.json | 2 ++ src/assets/i18n/sw.json | 2 ++ src/assets/i18n/ta.json | 2 ++ src/assets/i18n/te.json | 2 ++ src/assets/i18n/th.json | 2 ++ src/assets/i18n/tr.json | 2 ++ src/assets/i18n/tt.json | 2 ++ src/assets/i18n/udm.json | 2 ++ src/assets/i18n/uk.json | 2 ++ src/assets/i18n/vi.json | 2 ++ src/assets/i18n/zh-hans.json | 2 ++ src/assets/i18n/zh-hant.json | 2 ++ 95 files changed, 235 insertions(+), 10 deletions(-) diff --git a/src/app/pages/apps/components/installed-apps/app-row/app-row.component.html b/src/app/pages/apps/components/installed-apps/app-row/app-row.component.html index e2478dacce0..4913d5cf7d8 100644 --- a/src/app/pages/apps/components/installed-apps/app-row/app-row.component.html +++ b/src/app/pages/apps/components/installed-apps/app-row/app-row.component.html @@ -73,6 +73,18 @@ } @else { + +