4a865f21e03b0db0aefcef8d09ea5220ac80b38f
[dcaegen2/services.git] /
1 /*
2     Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
3
4     Licensed under the Apache License, Version 2.0 (the "License");
5     you may not use this file except in compliance with the License.
6     You may obtain a copy of the License at
7
8             http://www.apache.org/licenses/LICENSE-2.0
9
10     Unless required by applicable law or agreed to in writing, software
11     distributed under the License is distributed on an "AS IS" BASIS,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15 */
16 import {Component, OnInit, Input, Output, ViewChild, EventEmitter, ElementRef} from '@angular/core';
17 import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
18 import { Dashboard } from "src/app/core/models/dashboard.model";
19 import { AdminService } from "src/app/core/services/admin.service";
20 import { RestApiService } from "src/app/core/services/rest-api.service";
21 @Component({
22   selector: 'app-create-dashboard',
23   templateUrl: './create-dashboard.component.html',
24   styleUrls: ['./create-dashboard.component.css']
25 })
26 export class CreateDashboardComponent implements OnInit {
27
28   constructor(
29     public activeModal: NgbActiveModal,
30     public adminService: AdminService,
31     public restApiService: RestApiService,
32   ) {}
33
34   @Output() passEntry: EventEmitter<any> = new EventEmitter();
35   @Input() dashboard: Dashboard;
36   @Input() nameArr;
37   tempDb: Dashboard;
38
39   selectshow = false;
40   tempDbNameTitle = null;
41
42   @ViewChild("t_dataDashboardName") t_dataDashboardName: ElementRef;
43
44   ngOnInit() {
45     // cache for display
46
47     console.log(this.dashboard);
48     this.tempDb = new Dashboard();
49     if(this.dashboard.enabled==undefined){
50       this.dashboard.enabled = true;
51     }
52     const feeds = {
53       name: this.dashboard.name,
54       host: this.dashboard.host,
55       port: this.dashboard.port,
56       login: this.dashboard.login,
57       pass: this.dashboard.pass,
58       enabled: this.dashboard.enabled,
59     };
60     console.log(feeds);
61     this.tempDb = feeds;
62     this.tempDbNameTitle = this.dashboard.host
63   }
64
65
66
67   passBack() {
68     if(this.tempDb.host == '' || this.tempDb.host == undefined){
69       return false;
70     }
71     this.dashboard = this.tempDb;
72     this.dashboard.name = this.t_dataDashboardName.nativeElement.value;
73     console.log(this.dashboard,"this.dashboard output");
74     this.passEntry.emit(this.dashboard);
75   }
76
77 }