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 { Topic } from "src/app/core/models/topic.model";
41 selector: "app-topic-config-modal",
42 templateUrl: "./topic-config-modal.component.html",
43 styleUrls: ["./topic-config-modal.component.css"]
45 export class TopicConfigModalComponent implements OnInit {
46 @Input() topic: Topic;
47 @Input() title: string;
48 @Output() passEntry: EventEmitter<any> = new EventEmitter();
52 dataFormats: Array<string> = ["JSON", "XML"];
53 tempSeletedDbs: any = [];
56 @ViewChild("t_login") t_login: ElementRef;
57 @ViewChild("t_password") t_password: ElementRef;
58 @ViewChild("t_dataFormat") t_dataFormat: ElementRef;
59 @ViewChild("t_ttl") t_ttl: ElementRef;
62 public activeModal: NgbActiveModal,
63 private restApiService: RestApiService
70 this.topic.sinkdbs.forEach(item => {
71 this.tempSeletedDbs.push(item);
73 this.tempEnabled = this.topic.enabled;
74 this.tempSaveRaw = this.topic.saveRaw;
79 this.restApiService.getDbList().subscribe((data: {}) => {
85 updateSelectedDB(event: any, name: string) {
86 if (event.target.checked) {
87 console.log("checked");
88 if (!this.tempSeletedDbs.find(db => db === name)) {
89 this.tempSeletedDbs.push(name);
92 console.log("unchecked");
93 const index = this.tempSeletedDbs.indexOf(name, 0);
95 this.tempSeletedDbs.splice(index, 1);
101 this.topic.enabled = this.tempEnabled;
102 this.topic.login = this.t_login.nativeElement.value;
103 this.topic.password = this.t_password.nativeElement.value;
104 this.topic.sinkdbs = this.tempSeletedDbs;
105 this.topic.dataFormat = this.t_dataFormat.nativeElement.value;
106 this.topic.ttl = this.t_ttl.nativeElement.value;
107 this.topic.saveRaw = this.tempSaveRaw;
109 console.log("==================================");
110 console.log("Update topic name: " + this.topic.name);
111 console.log("Update topic login: " + this.topic.login);
112 console.log("Update topic password: " + this.topic.password);
113 console.log("Update topic sinkdbs: " + this.topic.sinkdbs);
114 console.log("Update topic enabled: " + this.topic.enabled);
115 console.log("Update topic saveRaw: " + this.topic.saveRaw);
116 console.log("Update topic dataFormat: " + this.topic.dataFormat);
117 console.log("Update topic ttl: " + this.topic.ttl);
118 console.log("==================================");
120 this.passEntry.emit(this.topic);