Kafka interface Function modification 43/92443/1
authorcyuamber <xuranyjy@chinamobile.com>
Thu, 1 Aug 2019 08:43:30 +0000 (16:43 +0800)
committercyuamber <xuranyjy@chinamobile.com>
Thu, 1 Aug 2019 08:43:37 +0000 (16:43 +0800)
Change-Id: I2857df735992e4f48bc492650865aa124ec30baf
Issue-ID: DCAEGEN2-1693
Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
components/datalake-handler/admin/src/src/app/core/models/kafka.model.ts [new file with mode: 0644]
components/datalake-handler/admin/src/src/app/core/services/rest-api.service.ts
components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.css
components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.html
components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.spec.ts
components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.ts

diff --git a/components/datalake-handler/admin/src/src/app/core/models/kafka.model.ts b/components/datalake-handler/admin/src/src/app/core/models/kafka.model.ts
new file mode 100644 (file)
index 0000000..9901de4
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+    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
+}
index fe63498..defae79 100644 (file)
@@ -325,6 +325,24 @@ Dashboard
       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)
+    );
+  }
 }
 
 
index e69de29..ed7832a 100644 (file)
@@ -0,0 +1,23 @@
+/*
+    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;
+}
index 6b8a6df..63a2c1f 100644 (file)
@@ -1,9 +1,34 @@
+<!--
+    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>
index e786c0c..0831fc2 100644 (file)
@@ -1,3 +1,18 @@
+/*
+    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';
index 2ebd36e..4579f53 100644 (file)
-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() { }
 
 }