Skip to content

Commit

Permalink
NAS-131403: Use app.redeploy endpoint for restart apps
Browse files Browse the repository at this point in the history
  • Loading branch information
denysbutenko committed Sep 27, 2024
1 parent 9c40ce8 commit d68b879
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/app/interfaces/api/api-job-directory.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
20 changes: 2 additions & 18 deletions src/app/pages/apps/services/applications.service.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -107,20 +103,8 @@ export class ApplicationsService {
return this.ws.job('app.stop', [name]);
}

restartApplication(app: App): Observable<Job<void>> {
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<Job<void>> {
return this.ws.job('app.redeploy', [name]);
}

convertDateToRelativeDate(date: Date): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {
Expand Down

0 comments on commit d68b879

Please sign in to comment.