diff options
author | cyuamber <xuranyjy@chinamobile.com> | 2019-08-01 16:43:30 +0800 |
---|---|---|
committer | cyuamber <xuranyjy@chinamobile.com> | 2019-08-01 16:43:37 +0800 |
commit | fbfee66b0da114f4e5bc34e54d31e10feaa7dd58 (patch) | |
tree | e4e5b7e992c9794ba5eb1a660a63c1722835f318 /components/datalake-handler/admin/src | |
parent | f093423fccc6c2059f1c94f3fe226202b8fcec12 (diff) |
Kafka interface Function modification
Change-Id: I2857df735992e4f48bc492650865aa124ec30baf
Issue-ID: DCAEGEN2-1693
Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
Diffstat (limited to 'components/datalake-handler/admin/src')
6 files changed, 210 insertions, 4 deletions
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 index 00000000..9901de46 --- /dev/null +++ b/components/datalake-handler/admin/src/src/app/core/models/kafka.model.ts @@ -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 +} diff --git a/components/datalake-handler/admin/src/src/app/core/services/rest-api.service.ts b/components/datalake-handler/admin/src/src/app/core/services/rest-api.service.ts index fe634983..defae797 100644 --- a/components/datalake-handler/admin/src/src/app/core/services/rest-api.service.ts +++ b/components/datalake-handler/admin/src/src/app/core/services/rest-api.service.ts @@ -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) + ); + } } diff --git a/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.css b/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.css index e69de29b..ed7832ae 100644 --- a/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.css +++ b/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.css @@ -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; +} diff --git a/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.html b/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.html index 6b8a6df1..63a2c1fe 100644 --- a/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.html +++ b/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.html @@ -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> diff --git a/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.spec.ts b/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.spec.ts index e786c0cc..0831fc2b 100644 --- a/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.spec.ts +++ b/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.spec.ts @@ -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'; diff --git a/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.ts b/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.ts index 2ebd36e4..4579f53f 100644 --- a/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.ts +++ b/components/datalake-handler/admin/src/src/app/views/kafka/kafka.component.ts @@ -1,16 +1,109 @@ -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() { } } |