2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 AT&T Intellectual Property and Nokia
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================LICENSE_END===================================
21 import { Component, OnInit, Inject } from '@angular/core';
22 import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
23 import { AppMgrService } from '../services/app-mgr/app-mgr.service';
24 import { ErrorDialogService } from '../services/ui/error-dialog.service';
25 import { BehaviorSubject } from 'rxjs/BehaviorSubject';
26 import { finalize } from 'rxjs/operators';
30 selector: 'rd-app-configuration',
31 templateUrl: './app-configuration.component.html',
32 styleUrls: ['./app-configuration.component.scss']
34 export class AppConfigurationComponent implements OnInit {
36 private loadingSubject = new BehaviorSubject<boolean>(false);
37 public loading$ = this.loadingSubject.asObservable();
40 private dialogRef: MatDialogRef<AppConfigurationComponent>,
41 private appMgrService: AppMgrService,
42 private errorDiaglogService: ErrorDialogService,
43 @Inject(MAT_DIALOG_DATA) private data
47 xappConfigSchema: any;
51 this.loadingSubject.next(true);
52 this.appMgrService.getConfig()
54 finalize(() => this.loadingSubject.next(false))
58 this.loadConfigForm(this.data.name, allConfig)
65 metadata: this.xappMetadata,
66 descriptor: this.xappConfigSchema,
68 layout: this.xappLayout
70 this.appMgrService.putConfig(config)
71 this.dialogRef.close();
74 loadConfigForm(name: string, allConfig: any) {
75 var xappConfig = allConfig.find(xapp => xapp.metadata.name == name)
76 if (xappConfig != null) {
77 this.xappMetadata = xappConfig.metadata
78 this.xappConfigSchema = xappConfig.descriptor;
79 this.xappConfigData = xappConfig.config;
80 this.xappLayout= xappConfig.layout;
82 this.errorDiaglogService.displayError("Cannot find configration data for " + name);
83 this.dialogRef.close();