1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*
* ============LICENSE_START=======================================================
* ONAP : DataLake
* ================================================================================
* Copyright 2019 QCT
*=================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
*/
/**
*
* @author Ekko Chang
*
* @contributor Chunmeng Guo
*
*/
import {Component, Input, Output, EventEmitter, ViewChild, ElementRef} from "@angular/core";
import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
import { Db } from "src/app/core/models/db.model";
import { AdminService } from "src/app/core/services/admin.service";
import {NgxSpinnerService} from "ngx-spinner";
@Component({
selector: "app-hdfs",
templateUrl: "./hdfs.component.html",
styleUrls: ["./hdfs.component.css"]
})
export class HdfsComponent {
@Output() passEntry: EventEmitter<any> = new EventEmitter();
@Input() editDb: Db;
@Input() db: Db;
@Input() dbList_length;
dbInput: Db;
dbTypeIdList: Array<string> = ["HDFS"];
@ViewChild("d_dbTypeId") d_dbTypeId: ElementRef;
defaultDbType: string;
dbInputTitle = "";
constructor(
public activeModal: NgbActiveModal,
public adminService: AdminService,
private spinner: NgxSpinnerService
) { }
ngOnInit() {
if (this.editDb == null) {
this.dbInput = new Db();
const feed = {
id: null,
name: this.db.name,
enabled: this.db.enabled,
host: this.db.host,
port: this.db.port,
database: this.db.database,
encrypt: this.db.encrypt,
login: this.db.login,
pass: this.db.pass,
dbTypeId: this.db.dbTypeId
}
this.dbInput = feed;
this.dbInputTitle = "New Hdfs";
console.log("create db");
} else {
this.dbInput = this.editDb;
this.dbInputTitle = "Edit" + "-" + this.editDb.dbTypeId + "-" + this.editDb.name;
this.defaultDbType = this.dbInput.dbTypeId;
console.log("edit db");
}
}
passBack() {
this.spinner.show();
if (this.dbInput.name == '' || this.dbInput.name == undefined) {
return false;
}
this.editDb = this.dbInput;
this.editDb.dbTypeId = this.d_dbTypeId.nativeElement.value;
console.log(this.editDb, "db");
this.passEntry.emit(this.editDb);
setTimeout(() => {
this.spinner.hide();
}, 500);
}
}
|