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-detail-modal",
42 templateUrl: "./topic-detail-modal.component.html",
43 styleUrls: ["./topic-detail-modal.component.css"]
45 export class TopicDetailModalComponent implements OnInit {
46 @Input() topic: Topic;
47 @Output() passEntry: EventEmitter<any> = new EventEmitter();
51 dataFormats: Array<string> = ["JSON", "XML"];
52 tempSeletedDbs: any = [];
56 idExFields: Array<any> = [];
57 idExNewField: any = {};
58 @ViewChild("t_login") t_login: ElementRef;
59 @ViewChild("t_password") t_password: ElementRef;
60 @ViewChild("t_dataFormat") t_dataFormat: ElementRef;
61 @ViewChild("t_ttl") t_ttl: ElementRef;
64 public activeModal: NgbActiveModal,
65 private restApiService: RestApiService
71 this.topic.sinkdbs.forEach(item => {
72 this.tempSeletedDbs.push(item);
74 this.tempEnabled = this.topic.enabled;
75 this.tempSaveRaw = this.topic.saveRaw;
76 this.tempMsg = this.topic.correlateClearedMessage;
79 if (this.topic.messageIdPath != null) {
80 var feed = this.topic.messageIdPath.split(",");
81 for (var i = 0; i < feed.length; i++) {
82 var data = { item: feed[i] };
83 this.idExFields.push(data);
86 this.idExFields.push([]);
92 this.restApiService.getDbList().subscribe((data: {}) => {
98 updateSelectedDB(event: any, name: string) {
99 if (event.target.checked) {
100 console.log("checked");
101 if (!this.tempSeletedDbs.find(db => db === name)) {
102 this.tempSeletedDbs.push(name);
105 console.log("unchecked");
106 const index = this.tempSeletedDbs.indexOf(name, 0);
108 this.tempSeletedDbs.splice(index, 1);
114 this.idExFields.push(this.idExNewField);
115 this.idExNewField = {};
118 deleteIdField(index: number) {
119 if (this.idExFields.length > 1) {
120 this.idExFields.splice(index, 1);
125 this.topic.enabled = this.tempEnabled;
126 this.topic.login = this.t_login.nativeElement.value;
127 this.topic.password = this.t_password.nativeElement.value;
129 this.topic.sinkdbs = this.tempSeletedDbs;
131 this.topic.dataFormat = this.t_dataFormat.nativeElement.value;
132 this.topic.ttl = this.t_ttl.nativeElement.value;
133 this.topic.saveRaw = this.tempSaveRaw;
134 this.topic.correlateClearedMessage = this.tempMsg;
135 this.topic.messageIdPath = "";
136 for (var i = 0; i < this.idExFields.length; i++) {
138 this.topic.messageIdPath = this.idExFields[i].item;
140 this.topic.messageIdPath =
141 this.topic.messageIdPath + "," + this.idExFields[i].item;
145 console.log("==================================");
146 console.log("Update topic name: " + this.topic.name);
147 console.log("Update topic login: " + this.topic.login);
148 console.log("Update topic password: " + this.topic.password);
149 console.log("Update topic sinkdbs: " + this.topic.sinkdbs);
150 console.log("Update topic enabled: " + this.topic.enabled);
151 console.log("Update topic saveRaw: " + this.topic.saveRaw);
152 console.log("Update topic dataFormat: " + this.topic.dataFormat);
153 console.log("Update topic ttl: " + this.topic.ttl);
155 "Update topic correlateClearedMessage: " +
156 this.topic.correlateClearedMessage
158 console.log("Update topic messageIdPath: " + this.topic.messageIdPath);
161 if (this.topic.sinkdbs.length == 0) {
162 this.topic.type = false;
164 this.topic.type = true;
166 console.log("Update topic type: " + this.topic.type);
167 console.log("==================================");
168 this.passEntry.emit(this.topic);