From: Tiago Melo Date: Tue, 5 Jun 2018 15:43:55 +0000 (+0100) Subject: mgr/dashboard: Update services to use the new 'provideIn' configuration X-Git-Tag: v14.0.1~1128^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=ca8e7e82df1ee7377140624bf6f9aa40bc9247d9;p=ceph.git mgr/dashboard: Update services to use the new 'provideIn' configuration Angular 6 introduced a new way to define where a service should be provided, which helps during the build of the project. Signed-off-by: Tiago Melo --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/api.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/api.module.ts index 8a8fd64da5caa..4066a30420b54 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/api.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/api.module.ts @@ -1,43 +1,7 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { AuthService } from './auth.service'; -import { CephfsService } from './cephfs.service'; -import { ConfigurationService } from './configuration.service'; -import { DashboardService } from './dashboard.service'; -import { HostService } from './host.service'; -import { LoggingService } from './logging.service'; -import { MonitorService } from './monitor.service'; -import { OsdService } from './osd.service'; -import { PerformanceCounterService } from './performance-counter.service'; -import { PoolService } from './pool.service'; -import { RbdMirroringService } from './rbd-mirroring.service'; -import { RbdService } from './rbd.service'; -import { RgwBucketService } from './rgw-bucket.service'; -import { RgwDaemonService } from './rgw-daemon.service'; -import { RgwUserService } from './rgw-user.service'; -import { TcmuIscsiService } from './tcmu-iscsi.service'; - @NgModule({ - imports: [CommonModule], - declarations: [], - providers: [ - AuthService, - CephfsService, - ConfigurationService, - DashboardService, - HostService, - MonitorService, - OsdService, - PoolService, - RbdService, - RbdMirroringService, - RgwBucketService, - RgwDaemonService, - RgwUserService, - PerformanceCounterService, - LoggingService, - TcmuIscsiService - ] + imports: [CommonModule] }) export class ApiModule {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.ts index c915884a03451..74edcedf4ae23 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.ts @@ -3,23 +3,29 @@ import { Injectable } from '@angular/core'; import { Credentials } from '../models/credentials'; import { AuthStorageService } from '../services/auth-storage.service'; +import { ApiModule } from './api.module'; -@Injectable() +@Injectable({ + providedIn: ApiModule +}) export class AuthService { - - constructor(private authStorageService: AuthStorageService, - private http: HttpClient) { - } + constructor(private authStorageService: AuthStorageService, private http: HttpClient) {} login(credentials: Credentials) { - return this.http.post('api/auth', credentials).toPromise().then((resp: Credentials) => { - this.authStorageService.set(resp.username); - }); + return this.http + .post('api/auth', credentials) + .toPromise() + .then((resp: Credentials) => { + this.authStorageService.set(resp.username); + }); } logout() { - return this.http.delete('api/auth').toPromise().then(() => { - this.authStorageService.remove(); - }); + return this.http + .delete('api/auth') + .toPromise() + .then(() => { + this.authStorageService.remove(); + }); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.ts index 81d2521779a85..745f2589243db 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.ts @@ -1,7 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class CephfsService { baseURL = 'api/cephfs'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/configuration.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/configuration.service.ts index 41ac7bb5196ad..5dd305cdc865d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/configuration.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/configuration.service.ts @@ -1,7 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class ConfigurationService { constructor(private http: HttpClient) {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/dashboard.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/dashboard.service.ts index cb51cb4d71b0c..04bdece8cf6a4 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/dashboard.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/dashboard.service.ts @@ -1,7 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class DashboardService { constructor(private http: HttpClient) {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.ts index 3d28cd78926a3..f68231bf173b9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.ts @@ -1,7 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class HostService { constructor(private http: HttpClient) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/logging.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/logging.service.ts index 746df5438746b..097f86edfe822 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/logging.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/logging.service.ts @@ -1,7 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class LoggingService { constructor(private http: HttpClient) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/monitor.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/monitor.service.ts index 32057f3b6ea11..115d1ca378835 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/monitor.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/monitor.service.ts @@ -1,7 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class MonitorService { constructor(private http: HttpClient) {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts index a59bcbcf34249..29ffa721cb72a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.ts @@ -1,7 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class OsdService { private path = 'api/osd'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.ts index 05317bc28a6ee..6cd54dfdad1b2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.ts @@ -4,7 +4,11 @@ import { Injectable } from '@angular/core'; import { of as observableOf } from 'rxjs'; import { mergeMap } from 'rxjs/operators'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class PerformanceCounterService { private url = 'api/perf_counters'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.ts index 4a6da48a98770..8ecdc669e9f38 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.ts @@ -1,7 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class PoolService { constructor(private http: HttpClient) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts index b840b3053a05e..1dbe79bfcd485 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd-mirroring.service.ts @@ -1,7 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class RbdMirroringService { constructor(private http: HttpClient) {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts index 30099c4a0f1f5..134928551d99d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts @@ -1,7 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class RbdService { constructor(private http: HttpClient) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts index acf03f664192f..e6b4062a5a19c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts @@ -5,7 +5,11 @@ import * as _ from 'lodash'; import { forkJoin as observableForkJoin, of as observableOf } from 'rxjs'; import { mergeMap } from 'rxjs/operators'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class RgwBucketService { private url = '/api/rgw/proxy/bucket'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-daemon.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-daemon.service.ts index 48e24c98ad449..59b83dc588f82 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-daemon.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-daemon.service.ts @@ -1,7 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class RgwDaemonService { private url = 'api/rgw/daemon'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts index d031dde446f83..f1b78f12baf49 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts @@ -5,7 +5,11 @@ import * as _ from 'lodash'; import {forkJoin as observableForkJoin, of as observableOf } from 'rxjs'; import { mergeMap } from 'rxjs/operators'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class RgwUserService { private url = '/api/rgw/proxy/user'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/tcmu-iscsi.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/tcmu-iscsi.service.ts index 2f36bb81813b9..7514b942f46e2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/tcmu-iscsi.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/tcmu-iscsi.service.ts @@ -1,7 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -@Injectable() +import { ApiModule } from './api.module'; + +@Injectable({ + providedIn: ApiModule +}) export class TcmuIscsiService { constructor(private http: HttpClient) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts index b706cd55d4f8f..283978358870e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts @@ -16,8 +16,11 @@ import { NotificationType } from '../enum/notification-type.enum'; import { FinishedTask } from '../models/finished-task'; import { AuthStorageService } from './auth-storage.service'; import { NotificationService } from './notification.service'; +import { ServicesModule } from './services.module'; -@Injectable() +@Injectable({ + providedIn: ServicesModule +}) export class ApiInterceptorService implements HttpInterceptor { constructor( private router: Router, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-guard.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-guard.service.ts index a3ec803870325..b3028c2c0b7ee 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-guard.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-guard.service.ts @@ -2,8 +2,11 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router'; import { AuthStorageService } from './auth-storage.service'; +import { ServicesModule } from './services.module'; -@Injectable() +@Injectable({ + providedIn: ServicesModule +}) export class AuthGuardService implements CanActivate { constructor(private router: Router, private authStorageService: AuthStorageService) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-storage.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-storage.service.ts index cd6dbbe7a0b22..889220f93ba76 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-storage.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-storage.service.ts @@ -1,6 +1,10 @@ import { Injectable } from '@angular/core'; -@Injectable() +import { ServicesModule } from './services.module'; + +@Injectable({ + providedIn: ServicesModule +}) export class AuthStorageService { constructor() { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/formatter.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/formatter.service.ts index 6f1cfe4ec47ab..5d777e886b82e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/formatter.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/formatter.service.ts @@ -2,7 +2,11 @@ import { Injectable } from '@angular/core'; import * as _ from 'lodash'; -@Injectable() +import { ServicesModule } from './services.module'; + +@Injectable({ + providedIn: ServicesModule +}) export class FormatterService { constructor() {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts index a70e75d6fcde0..5f47c2dc20cfc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts @@ -11,6 +11,8 @@ import { import { of as observableOf } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; +import { ServicesModule } from './services.module'; + /** * This service checks if a route can be activated by executing a * REST API call to '/api//status'. If the returned response @@ -36,7 +38,9 @@ import { catchError, map } from 'rxjs/operators'; * }, * ... */ -@Injectable() +@Injectable({ + providedIn: ServicesModule +}) export class ModuleStatusGuardService implements CanActivate, CanActivateChild { constructor(private http: HttpClient, private router: Router) {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts index d698ee4a73911..13a9f4350a4c9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts @@ -7,9 +7,12 @@ import { BehaviorSubject } from 'rxjs'; import { NotificationType } from '../enum/notification-type.enum'; import { CdNotification } from '../models/cd-notification'; import { FinishedTask } from '../models/finished-task'; +import { ServicesModule } from './services.module'; import { TaskManagerMessageService } from './task-manager-message.service'; -@Injectable() +@Injectable({ + providedIn: ServicesModule +}) export class NotificationService { // Observable sources private dataSource = new BehaviorSubject([]); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/services.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/services.module.ts index 6bdce286beb9b..0278df0618dee 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/services.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/services.module.ts @@ -1,27 +1,7 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { AuthGuardService } from './auth-guard.service'; -import { AuthStorageService } from './auth-storage.service'; -import { FormatterService } from './formatter.service'; -import { ModuleStatusGuardService } from './module-status-guard.service'; -import { NotificationService } from './notification.service'; -import { SummaryService } from './summary.service'; -import { TaskManagerMessageService } from './task-manager-message.service'; -import { TaskManagerService } from './task-manager.service'; - @NgModule({ - imports: [CommonModule], - declarations: [], - providers: [ - AuthGuardService, - AuthStorageService, - FormatterService, - SummaryService, - ModuleStatusGuardService, - NotificationService, - TaskManagerService, - TaskManagerMessageService - ] + imports: [CommonModule] }) export class ServicesModule {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts index b597fb96c1adb..c2fafa201184a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts @@ -4,8 +4,11 @@ import { Injectable, NgZone } from '@angular/core'; import { Subject } from 'rxjs'; import { AuthStorageService } from './auth-storage.service'; +import { ServicesModule } from './services.module'; -@Injectable() +@Injectable({ + providedIn: ServicesModule +}) export class SummaryService { // Observable sources private summaryDataSource = new Subject(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager-message.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager-message.service.ts index f3ce7da23b179..e7d034bc90407 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager-message.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager-message.service.ts @@ -3,24 +3,28 @@ import { Injectable } from '@angular/core'; import { Components } from '../enum/components.enum'; import { FinishedTask } from '../models/finished-task'; import { Task } from '../models/task'; +import { ServicesModule } from './services.module'; class TaskManagerMessage { descr: (metadata) => string; success: (metadata) => string; error: (metadata) => object; - constructor(descr: (metadata) => string, - success: (metadata) => string, - error: (metadata) => object) { + constructor( + descr: (metadata) => string, + success: (metadata) => string, + error: (metadata) => object + ) { this.descr = descr; this.success = success; this.error = error; } } -@Injectable() +@Injectable({ + providedIn: ServicesModule +}) export class TaskManagerMessageService { - messages = { 'rbd/create': new TaskManagerMessage( (metadata) => `Create RBD '${metadata.pool_name}/${metadata.image_name}'`, @@ -82,16 +86,17 @@ export class TaskManagerMessageService { (metadata) => `RBD '${metadata.pool_name}/${metadata.image_name}' has been flattened successfully`, () => { - return { - }; + return {}; } ), 'rbd/snap/create': new TaskManagerMessage( - (metadata) => `Create snapshot ` + - `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}'`, - (metadata) => `Snapshot ` + - `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}' ` + - `has been created successfully`, + (metadata) => + `Create snapshot ` + + `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}'`, + (metadata) => + `Snapshot ` + + `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}' ` + + `has been created successfully`, (metadata) => { return { '17': `Name '${metadata.snapshot_name}' is already in use.` @@ -99,11 +104,13 @@ export class TaskManagerMessageService { } ), 'rbd/snap/edit': new TaskManagerMessage( - (metadata) => `Update snapshot ` + - `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}'`, - (metadata) => `Snapshot ` + - `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}' ` + - `has been updated successfully`, + (metadata) => + `Update snapshot ` + + `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}'`, + (metadata) => + `Snapshot ` + + `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}' ` + + `has been updated successfully`, () => { return { '16': `Cannot unprotect snapshot because it contains child images.` @@ -111,11 +118,13 @@ export class TaskManagerMessageService { } ), 'rbd/snap/delete': new TaskManagerMessage( - (metadata) => `Delete snapshot ` + - `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}'`, - (metadata) => `Snapshot ` + - `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}' ` + - `has been deleted successfully`, + (metadata) => + `Delete snapshot ` + + `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}'`, + (metadata) => + `Snapshot ` + + `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}' ` + + `has been deleted successfully`, () => { return { '16': `Snapshot is protected.` @@ -123,14 +132,15 @@ export class TaskManagerMessageService { } ), 'rbd/snap/rollback': new TaskManagerMessage( - (metadata) => `Rollback snapshot ` + - `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}'`, - (metadata) => `Snapshot ` + - `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}' ` + - `has been rolled back successfully`, + (metadata) => + `Rollback snapshot ` + + `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}'`, + (metadata) => + `Snapshot ` + + `'${metadata.pool_name}/${metadata.image_name}@${metadata.snapshot_name}' ` + + `has been rolled back successfully`, () => { - return { - }; + return {}; } ) }; @@ -141,12 +151,11 @@ export class TaskManagerMessageService { }, (metadata) => 'Task executed successfully', () => { - return { - }; + return {}; } ); - constructor() { } + constructor() {} getSuccessMessage(finishedTask: FinishedTask) { const taskManagerMessage = this.messages[finishedTask.name] || this.defaultMessage; @@ -155,8 +164,10 @@ export class TaskManagerMessageService { getErrorMessage(finishedTask: FinishedTask) { const taskManagerMessage = this.messages[finishedTask.name] || this.defaultMessage; - return taskManagerMessage.error(finishedTask.metadata)[finishedTask.exception.code] || - finishedTask.exception.detail; + return ( + taskManagerMessage.error(finishedTask.metadata)[finishedTask.exception.code] || + finishedTask.exception.detail + ); } getDescription(task: Task) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.ts index b7435e50b7c90..9eedf43e2ff8d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.ts @@ -5,6 +5,7 @@ import * as _ from 'lodash'; import { ExecutingTask } from '../models/executing-task'; import { FinishedTask } from '../models/finished-task'; import { Task } from '../models/task'; +import { ServicesModule } from './services.module'; import { SummaryService } from './summary.service'; class TaskSubscription { @@ -19,7 +20,9 @@ class TaskSubscription { } } -@Injectable() +@Injectable({ + providedIn: ServicesModule +}) export class TaskManagerService { subscriptions: Array = [];