--- /dev/null
+/*
+ Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
+
+ 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.
+*/
+
+export class kafka {
+ id: number;
+ name: string;
+ enabled: boolean;
+ brokerList: string;
+ zooKeeper: string;
+ group: string;
+ secure: boolean;
+ login: string;
+ pass: string;
+ securityProtocol: string;
+ includedTopic: string;
+ excludedTopic: string;
+ consumerCount: number;
+ timeout: number
+}
catchError(this.handleError)
);
}
+
+ /*
+ Kafka
+*/
+ getAllKafkaList(){
+ return this.http.get(prefix + "kafkas").pipe( //onlin
+ retry(1),
+ map(this.extractData),
+ catchError(this.handleError)
+ );
+ }
+ DeleteKafka(id): Observable<any> {
+ return this.http.delete(prefix + "kafkas/" + id).pipe( //online
+ retry(1),
+ map(this.extractData2),
+ catchError(this.handleError)
+ );
+ }
}
+/*
+ Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
+
+ 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.
+*/
+.kafka-li{
+ float: left;
+ list-style: none;
+ margin:15px 0;
+}
+.add-kafka{
+ cursor: pointer;
+}
+<!--
+ Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
+
+ 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.
+-->
<div class="row">
<div class="col-md-12 pb-2 path">
Home > Kafka
</div>
<div class="col-md-12">
-
+ <ul class="kafka-list clearfix">
+ <li *ngFor="let kafka of this.kafkas;let thisIndex=index" class="col-md-3 kafka-li">
+ <app-card [iconPath]="this.cardIconPath" [iconSize]="'sm'" [subcontent]="kafka.name"
+ [modifiable]="this.cardModifiable">
+ </app-card>
+ </li>
+ <li class="col-md-3 kafka-li add-kafka">
+ <app-card [iconPath]="this.cardAddicon" [iconSize]="'sm'">
+ </app-card>
+ </li>
+ </ul>
</div>
</div>
+/*
+ Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
+
+ 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.
+*/
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { KafkaComponent } from './kafka.component';
-import { Component, OnInit } from '@angular/core';
+/*
+ Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
+
+ 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.
+*/
+import { Component,EventEmitter, OnInit, Output } from '@angular/core';
+import { kafka } from "../../core/models/kafka.model";
import { AdminService } from "../../core/services/admin.service";
+import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
+
+import { RestApiService } from "src/app/core/services/rest-api.service";
+
+// Loading spinner
+import { NgxSpinnerService } from "ngx-spinner";
+import {ToastrNotificationService} from "../../shared/components/toastr-notification/toastr-notification.service";
@Component({
selector: 'app-kafka',
templateUrl: './kafka.component.html',
styleUrls: ['./kafka.component.css']
})
export class KafkaComponent implements OnInit {
- constructor(private adminService: AdminService) {
+ kafkaList: any = [];
+ kafkas: kafka[] = [];
+
+ cardIconPath: string;
+ cardModifiable: boolean;
+ cardAddicon: string;
+
+ constructor(
+ private adminService: AdminService,
+ private kafkaApiService: RestApiService,
+ private notificationService: ToastrNotificationService,
+ private modalService: NgbModal,
+ private spinner: NgxSpinnerService
+ ) {
// Set page title
this.adminService.setTitle("SIDEBAR.KAFKA");
+ this.initList();
+ }
+
+ ngOnInit() {
+ this.spinner.show();
+ this.cardIconPath = "assets/icons/couchbase_able.svg";
+ this.cardModifiable = true;
+ this.cardAddicon = "assets/icons/add.svg";
+ }
+ initList() {
+ this.initData().then(data => {
+ this.initDbsList(this.kafkaList).then(data => {
+ this.kafkas = data;
+ console.log(this.kafkas, "kafkas[]")
+ });
+ });
+ }
+
+ async initData() {
+ this.kafkaList = [];
+ this.kafkaList = await this.getKafkaList();
+ setTimeout(() => {
+ this.spinner.hide();
+ }, 500);
+ }
+
+ getKafkaList() {
+ var data: any;
+ data = this.kafkaApiService.getAllKafkaList().toPromise();
+ return data;
+ }
+
+ async initDbsList(kafkaList: []) {
+ var k: kafka[] = [];
+
+ if (kafkaList.length > 0) {
+ for (var i = 0; i < kafkaList.length; i++) {
+ let data = kafkaList[i];
+ let feed = {
+ id: data["id"],
+ name: data["name"],
+ enabled: data["enabled"],
+ brokerList: data["brokerList"],
+ zooKeeper: data["zooKeeper"],
+ group: data["group"],
+ secure: data["secure"],
+ login: data["login"],
+ pass: data["pass"],
+ securityProtocol: data["securityProtocol"],
+ includedTopic: data["includedTopic"],
+ excludedTopic: data["excludedTopic"],
+ consumerCount: data["consumerCount"],
+ timeout: data["timeout"]
+ };
+ k.push(feed);
+ }
+ }
+ return k;
}
- ngOnInit() { }
}