mirror of
https://github.com/ceph/ceph
synced 2025-02-22 18:47:18 +00:00
Merge pull request #22082 from tspmelo/wip-angular-6
mgr/dashboard: Update Angular to version 6 Reviewed-by: Ricardo Marques <rimarques@suse.com> Reviewed-by: Stephan Müller <smueller@suse.com> Reviewed-by: Volker Theile <vtheile@suse.com>
This commit is contained in:
commit
7acd015a06
@ -1,66 +0,0 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"project": {
|
||||
"name": "ceph-dashboard"
|
||||
},
|
||||
"apps": [
|
||||
{
|
||||
"root": "src",
|
||||
"outDir": "dist",
|
||||
"assets": [
|
||||
"assets",
|
||||
"favicon.ico"
|
||||
],
|
||||
"index": "index.html",
|
||||
"main": "main.ts",
|
||||
"polyfills": "polyfills.ts",
|
||||
"test": "test.ts",
|
||||
"tsconfig": "tsconfig.app.json",
|
||||
"testTsconfig": "tsconfig.spec.json",
|
||||
"prefix": "cd",
|
||||
"styles": [
|
||||
"../node_modules/bootstrap/dist/css/bootstrap.css",
|
||||
"../node_modules/ng2-toastr/bundles/ng2-toastr.min.css",
|
||||
"../node_modules/fork-awesome/css/fork-awesome.css",
|
||||
"../node_modules/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css",
|
||||
"styles.scss"
|
||||
],
|
||||
"scripts": [
|
||||
"../node_modules/chart.js/dist/Chart.bundle.js"
|
||||
],
|
||||
"environmentSource": "environments/environment.ts",
|
||||
"environments": {
|
||||
"dev": "environments/environment.ts",
|
||||
"prod": "environments/environment.prod.ts"
|
||||
}
|
||||
}
|
||||
],
|
||||
"e2e": {
|
||||
"protractor": {
|
||||
"config": "./protractor.conf.js"
|
||||
}
|
||||
},
|
||||
"lint": [
|
||||
{
|
||||
"project": "src/tsconfig.app.json",
|
||||
"exclude": "**/node_modules/**"
|
||||
},
|
||||
{
|
||||
"project": "src/tsconfig.spec.json",
|
||||
"exclude": "**/node_modules/**"
|
||||
},
|
||||
{
|
||||
"project": "e2e/tsconfig.e2e.json",
|
||||
"exclude": "**/node_modules/**"
|
||||
}
|
||||
],
|
||||
"test": {
|
||||
"karma": {
|
||||
"config": "./karma.conf.js"
|
||||
}
|
||||
},
|
||||
"defaults": {
|
||||
"styleExt": "scss",
|
||||
"component": {}
|
||||
}
|
||||
}
|
144
src/pybind/mgr/dashboard/frontend/angular.json
Normal file
144
src/pybind/mgr/dashboard/frontend/angular.json
Normal file
@ -0,0 +1,144 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"ceph-dashboard": {
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"projectType": "application",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"outputPath": "dist",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
"tsConfig": "src/tsconfig.app.json",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"assets": [
|
||||
"src/assets",
|
||||
"src/favicon.ico"
|
||||
],
|
||||
"styles": [
|
||||
"node_modules/bootstrap/dist/css/bootstrap.css",
|
||||
"node_modules/ng2-toastr/bundles/ng2-toastr.min.css",
|
||||
"node_modules/fork-awesome/css/fork-awesome.css",
|
||||
"node_modules/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css",
|
||||
"src/styles.scss"
|
||||
],
|
||||
"scripts": [
|
||||
"node_modules/chart.js/dist/Chart.bundle.js"
|
||||
]
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
"extractCss": true,
|
||||
"namedChunks": false,
|
||||
"aot": true,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true,
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.prod.ts"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"options": {
|
||||
"browserTarget": "ceph-dashboard:build"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"browserTarget": "ceph-dashboard:build:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "ceph-dashboard:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "src/test.ts",
|
||||
"karmaConfig": "./karma.conf.js",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "src/tsconfig.spec.json",
|
||||
"scripts": [
|
||||
"node_modules/chart.js/dist/Chart.bundle.js"
|
||||
],
|
||||
"styles": [
|
||||
"node_modules/bootstrap/dist/css/bootstrap.css",
|
||||
"node_modules/ng2-toastr/bundles/ng2-toastr.min.css",
|
||||
"node_modules/fork-awesome/css/fork-awesome.css",
|
||||
"node_modules/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css",
|
||||
"src/styles.scss"
|
||||
],
|
||||
"assets": [
|
||||
"src/assets",
|
||||
"src/favicon.ico"
|
||||
]
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"src/tsconfig.app.json",
|
||||
"src/tsconfig.spec.json"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ceph-dashboard-e2e": {
|
||||
"root": "",
|
||||
"sourceRoot": "",
|
||||
"projectType": "application",
|
||||
"architect": {
|
||||
"e2e": {
|
||||
"builder": "@angular-devkit/build-angular:protractor",
|
||||
"options": {
|
||||
"protractorConfig": "./protractor.conf.js",
|
||||
"devServerTarget": "ceph-dashboard:serve"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"e2e/tsconfig.e2e.json"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultProject": "ceph-dashboard",
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"prefix": "cd",
|
||||
"styleext": "scss"
|
||||
},
|
||||
"@schematics/angular:directive": {
|
||||
"prefix": "cd"
|
||||
}
|
||||
}
|
||||
}
|
@ -4,13 +4,13 @@
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
basePath: '',
|
||||
frameworks: ['jasmine', '@angular/cli'],
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
plugins: [
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage-istanbul-reporter'),
|
||||
require('@angular/cli/plugins/karma'),
|
||||
require('@angular-devkit/build-angular/plugins/karma'),
|
||||
require('karma-phantomjs-launcher'),
|
||||
require('karma-junit-reporter')
|
||||
],
|
||||
@ -18,7 +18,8 @@ module.exports = function (config) {
|
||||
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||
},
|
||||
coverageIstanbulReporter: {
|
||||
reports: [ 'html', 'lcovonly', 'cobertura' ],
|
||||
dir: require('path').join(__dirname, 'coverage'),
|
||||
reports: ['html', 'lcovonly', 'cobertura'],
|
||||
fixWebpackSourcePaths: true
|
||||
},
|
||||
angularCli: {
|
||||
|
@ -4,7 +4,7 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve --delete-output-path false --proxy-config proxy.conf.json --host 0.0.0.0",
|
||||
"start": "ng serve --proxy-config proxy.conf.json --host 0.0.0.0",
|
||||
"build": "ng build",
|
||||
"test": "jest --watch",
|
||||
"test:ci": "jest --coverage",
|
||||
@ -35,61 +35,61 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@angular/animations": "^5.0.0",
|
||||
"@angular/common": "^5.0.0",
|
||||
"@angular/compiler": "^5.0.0",
|
||||
"@angular/core": "^5.0.0",
|
||||
"@angular/forms": "^5.0.0",
|
||||
"@angular/http": "^5.0.0",
|
||||
"@angular/platform-browser": "^5.0.0",
|
||||
"@angular/platform-browser-dynamic": "^5.0.0",
|
||||
"@angular/router": "^5.0.0",
|
||||
"@angular/animations": "^6.0.4",
|
||||
"@angular/common": "^6.0.4",
|
||||
"@angular/compiler": "^6.0.4",
|
||||
"@angular/core": "^6.0.4",
|
||||
"@angular/forms": "^6.0.4",
|
||||
"@angular/http": "^6.0.4",
|
||||
"@angular/platform-browser": "^6.0.4",
|
||||
"@angular/platform-browser-dynamic": "^6.0.4",
|
||||
"@angular/router": "^6.0.4",
|
||||
"@swimlane/ngx-datatable": "^13.0.1",
|
||||
"@types/lodash": "^4.14.95",
|
||||
"@types/lodash": "^4.14.109",
|
||||
"awesome-bootstrap-checkbox": "0.3.7",
|
||||
"bootstrap": "^3.3.7",
|
||||
"chart.js": "^2.7.1",
|
||||
"core-js": "^2.4.1",
|
||||
"fork-awesome": "1.0.11",
|
||||
"lodash": "^4.17.4",
|
||||
"moment": "2.20.1",
|
||||
"chart.js": "^2.7.2",
|
||||
"core-js": "^2.5.7",
|
||||
"fork-awesome": "^1.1.0",
|
||||
"lodash": "^4.17.10",
|
||||
"moment": "^2.22.2",
|
||||
"ng2-charts": "^1.6.0",
|
||||
"ng2-toastr": "4.1.2",
|
||||
"ngx-bootstrap": "^2.0.1",
|
||||
"ng2-toastr": "github:zzakir/ng2-toastr#master",
|
||||
"ngx-bootstrap": "^2.0.5",
|
||||
"rxjs": "^6.2.0",
|
||||
"rxjs-compat": "^6.2.0",
|
||||
"zone.js": "^0.8.14"
|
||||
"zone.js": "^0.8.26"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular/cli": "^1.6.5",
|
||||
"@angular/compiler-cli": "^5.0.0",
|
||||
"@angular/language-service": "^5.0.0",
|
||||
"@types/jasmine": "~2.5.53",
|
||||
"@types/jasminewd2": "~2.0.2",
|
||||
"@types/jest": "^22.2.3",
|
||||
"@types/node": "~6.0.60",
|
||||
"@angular-devkit/build-angular": "~0.6.8",
|
||||
"@angular/cli": "^6.0.8",
|
||||
"@angular/compiler-cli": "^6.0.4",
|
||||
"@angular/language-service": "^6.0.4",
|
||||
"@types/jasmine": "~2.8.8",
|
||||
"@types/jasminewd2": "~2.0.3",
|
||||
"@types/jest": "^23.0.0",
|
||||
"@types/node": "^8.10.19",
|
||||
"babel-preset-env": "^1.7.0",
|
||||
"codelyzer": "^4.0.1",
|
||||
"copy-webpack-plugin": "4.3.0",
|
||||
"jasmine-core": "~2.6.2",
|
||||
"jasmine-spec-reporter": "~4.1.0",
|
||||
"jest": "^22.4.3",
|
||||
"codelyzer": "^4.3.0",
|
||||
"jasmine-core": "~3.1.0",
|
||||
"jasmine-spec-reporter": "~4.2.1",
|
||||
"jest": "^23.1.0",
|
||||
"jest-canvas-mock": "^1.0.2",
|
||||
"jest-preset-angular": "^5.2.2",
|
||||
"karma": "~1.7.0",
|
||||
"karma-chrome-launcher": "~2.1.1",
|
||||
"karma": "~2.0.2",
|
||||
"karma-chrome-launcher": "~2.2.0",
|
||||
"karma-cli": "~1.0.1",
|
||||
"karma-coverage-istanbul-reporter": "^1.2.1",
|
||||
"karma-jasmine": "~1.1.0",
|
||||
"karma-jasmine-html-reporter": "^0.2.2",
|
||||
"karma-coverage-istanbul-reporter": "^2.0.1",
|
||||
"karma-jasmine": "~1.1.2",
|
||||
"karma-jasmine-html-reporter": "^1.1.0",
|
||||
"karma-junit-reporter": "^1.2.0",
|
||||
"karma-phantomjs-launcher": "^1.0.4",
|
||||
"prettier": "1.12.1",
|
||||
"pretty-quick": "^1.4.1",
|
||||
"protractor": "~5.3.0",
|
||||
"ts-node": "~3.2.0",
|
||||
"tslint": "~5.9.1",
|
||||
"tslint-eslint-rules": "^4.1.1",
|
||||
"typescript": "~2.4.2"
|
||||
"prettier": "^1.13.5",
|
||||
"pretty-quick": "^1.6.0",
|
||||
"protractor": "~5.3.2",
|
||||
"ts-node": "~5.0.1",
|
||||
"tslint": "~5.10.0",
|
||||
"tslint-eslint-rules": "^5.3.1",
|
||||
"typescript": "2.7.2"
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ export class OsdPerformanceHistogramComponent implements OnChanges {
|
||||
if (!this.histogram) {
|
||||
return;
|
||||
}
|
||||
let sum = 0;
|
||||
let max = 0;
|
||||
|
||||
_.each(this.histogram.values, (row, i) => {
|
||||
@ -42,7 +41,6 @@ export class OsdPerformanceHistogramComponent implements OnChanges {
|
||||
} else {
|
||||
val = col;
|
||||
}
|
||||
sum += val;
|
||||
max = Math.max(max, val);
|
||||
});
|
||||
});
|
||||
|
@ -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 {}
|
||||
|
@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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) {}
|
||||
|
||||
|
@ -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) {}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {}
|
||||
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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) {}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
@ -1,6 +1,10 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
import { ServicesModule } from './services.module';
|
||||
|
||||
@Injectable({
|
||||
providedIn: ServicesModule
|
||||
})
|
||||
export class AuthStorageService {
|
||||
|
||||
constructor() {
|
||||
|
@ -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() {}
|
||||
|
||||
|
@ -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/<apiPath>/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) {}
|
||||
|
||||
|
@ -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<CdNotification[]>([]);
|
||||
|
@ -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 {}
|
||||
|
@ -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();
|
||||
|
@ -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) {
|
||||
|
@ -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<TaskSubscription> = [];
|
||||
|
||||
|
@ -11,7 +11,8 @@
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"test.ts"
|
||||
"test.ts",
|
||||
"polyfills.ts"
|
||||
],
|
||||
"include": [
|
||||
"**/*.spec.ts",
|
||||
|
Loading…
Reference in New Issue
Block a user