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-detail-modal",
43 templateUrl: "./topic-detail-modal.component.html",
44 styleUrls: ["./topic-detail-modal.component.css"]
46 export class TopicDetailModalComponent implements OnInit {
47 @Input() topic: Topic;
48 @Output() passEntry: EventEmitter<any> = new EventEmitter();
52 dataFormats: Array<string> = ["JSON", "XML"];
53 tempSeletedDbs: any = [];
57 idExFields: Array<any> = [];
58 idExNewField: any = {};
59 @ViewChild("t_login") t_login: ElementRef;
60 @ViewChild("t_password") t_password: ElementRef;
61 @ViewChild("t_dataFormat") t_dataFormat: ElementRef;
62 @ViewChild("t_ttl") t_ttl: ElementRef;
65 public activeModal: NgbActiveModal,
66 public adminService: AdminService,
67 private restApiService: RestApiService
73 this.topic.sinkdbs.forEach(item => {
74 this.tempSeletedDbs.push(item);
76 this.tempEnabled = this.topic.enabled;
77 this.tempSaveRaw = this.topic.saveRaw;
78 this.tempMsg = this.topic.correlateClearedMessage;
81 if (this.topic.messageIdPath != null) {
82 var feed = this.topic.messageIdPath.split(",");
83 for (var i = 0; i < feed.length; i++) {
84 var data = { item: feed[i] };
85 this.idExFields.push(data);
88 this.idExFields.push([]);
94 this.restApiService.getDbList().subscribe((data: {}) => {
99 updateSelectedDB(event: any, name: string) {
100 if (event.target.checked) {
101 if (!this.tempSeletedDbs.find(db => db === name)) {
102 this.tempSeletedDbs.push(name);
105 const index = this.tempSeletedDbs.indexOf(name, 0);
107 this.tempSeletedDbs.splice(index, 1);
113 this.idExFields.push(this.idExNewField);
114 this.idExNewField = {};
117 deleteIdField(index: number) {
118 if (this.idExFields.length > 1) {
119 this.idExFields.splice(index, 1);
124 this.topic.enabled = this.tempEnabled;
125 this.topic.login = this.t_login.nativeElement.value;
126 this.topic.password = this.t_password.nativeElement.value;
128 this.topic.sinkdbs = this.tempSeletedDbs;
130 this.topic.dataFormat = this.t_dataFormat.nativeElement.value;
131 this.topic.ttl = this.t_ttl.nativeElement.value;
132 this.topic.saveRaw = this.tempSaveRaw;
133 this.topic.correlateClearedMessage = this.tempMsg;
134 this.topic.messageIdPath = "";
135 for (var i = 0; i < this.idExFields.length; i++) {
137 this.topic.messageIdPath = this.idExFields[i].item;
139 this.topic.messageIdPath =
140 this.topic.messageIdPath + "," + this.idExFields[i].item;
145 if (this.topic.sinkdbs.length == 0) {
146 this.topic.config = false;
148 this.topic.config = true;
150 this.passEntry.emit(this.topic);