2 * ============LICENSE_START=======================================================
4 * ================================================================================
6 *=================================================================================
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=========================================================
35 } from "@angular/core";
36 import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
37 import { RestApiService } from "src/app/core/services/rest-api.service";
38 import { AdminService } from "src/app/core/services/admin.service";
39 import { Topic } from "src/app/core/models/topic.model";
42 selector: "app-topic-config-modal",
43 templateUrl: "./topic-config-modal.component.html",
44 styleUrls: ["./topic-config-modal.component.css"]
46 export class TopicConfigModalComponent implements OnInit {
47 @Input() topic: Topic;
48 @Input() title: string;
49 @Output() passEntry: EventEmitter<any> = new EventEmitter();
53 dataFormats: Array<string> = ["JSON", "XML"];
54 tempSeletedDbs: any = [];
57 @ViewChild("t_login") t_login: ElementRef;
58 @ViewChild("t_password") t_password: ElementRef;
59 @ViewChild("t_dataFormat") t_dataFormat: ElementRef;
60 @ViewChild("t_ttl") t_ttl: ElementRef;
63 public activeModal: NgbActiveModal,
64 public adminService: AdminService,
65 private restApiService: RestApiService
72 this.topic.sinkdbs.forEach(item => {
73 this.tempSeletedDbs.push(item);
75 this.tempEnabled = this.topic.enabled;
76 this.tempSaveRaw = this.topic.saveRaw;
81 this.restApiService.getDbList().subscribe((data: {}) => {
86 updateSelectedDB(event: any, name: string) {
87 if (event.target.checked) {
88 if (!this.tempSeletedDbs.find(db => db === name)) {
89 this.tempSeletedDbs.push(name);
92 const index = this.tempSeletedDbs.indexOf(name, 0);
94 this.tempSeletedDbs.splice(index, 1);
100 this.topic.enabled = this.tempEnabled;
101 this.topic.login = this.t_login.nativeElement.value;
102 this.topic.password = this.t_password.nativeElement.value;
103 this.topic.sinkdbs = this.tempSeletedDbs;
104 this.topic.dataFormat = this.t_dataFormat.nativeElement.value;
105 this.topic.ttl = this.t_ttl.nativeElement.value;
106 this.topic.saveRaw = this.tempSaveRaw;
108 this.passEntry.emit(this.topic);