Fixed kafka's ui and add getKafkaDetail()
Change-Id: I4f5b3c06feb19c39a7d67b678704f726c305e7c8
Issue-ID: DCAEGEN2-1877
Signed-off-by: ZhangZihao <zhangzihao@chinamobile.com>
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 0c52089..dc1a023 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
@@ -160,7 +160,7 @@
*/
getDbEncryptList(flag): Observable<any> {
return this.http
- .get(prefix + "dbs/list?tool=" + flag)
+ .get(prefix + "dbs/list?isDb=" + flag)
.pipe(retry(1), map(this.extractData), catchError(this.handleError));
}
diff --git a/components/datalake-handler/admin/src/src/app/views/kafka/kafka-list/kafka-list.component.ts b/components/datalake-handler/admin/src/src/app/views/kafka/kafka-list/kafka-list.component.ts
index 1acd617..b8dbb0e 100644
--- a/components/datalake-handler/admin/src/src/app/views/kafka/kafka-list/kafka-list.component.ts
+++ b/components/datalake-handler/admin/src/src/app/views/kafka/kafka-list/kafka-list.component.ts
@@ -30,11 +30,7 @@
import { ToastrNotificationService } from "src/app/shared/components/toastr-notification/toastr-notification.service";
import {AlertComponent} from "../../../shared/components/alert/alert.component";
import {NewKafkaModalComponent} from "./new-kafka-modal/new-kafka-modal.component";
-import {ModalContentData} from "../../../shared/modules/modal/modal.data";
-import {ModalDemoComponent} from "../../test/modal-demo/modal-demo.component";
-import {ModalComponent} from "../../../shared/modules/modal/modal.component";
import {EditKafkaModalComponent} from "./edit-kafka-modal/edit-kafka-modal.component";
-import {el} from "@angular/platform-browser/testing/src/browser_util";
@Component({
selector: 'app-kafka-list',
@@ -51,6 +47,7 @@
Kafka_New: Kafka;
Kafka_Newbody: Kafka;
cardIconPathList: any = [];
+ kafkaData: any = [];
constructor(
private kafkaApiService: RestApiService,
@@ -74,6 +71,7 @@
if (this.kafkas.length > 0) {
let a = "assets/icons/kafka_able.svg";
let b = "assets/icons/kafka_disable.svg";
+ this.cardIconPathList.splice(0,this.cardIconPathList.length);
for (let i = 0; i < this.kafkas.length; i++) {
this.cardIconPath = (this.kafkas[i].enabled == true) ? a : b;
this.cardIconPathList.push(this.cardIconPath);
@@ -98,6 +96,16 @@
return data;
}
+ async getKafkaDetailModal(id: number) {
+ this.kafkaData = [];
+ this.kafkaData = await this.getKafkaModal(id);
+ return this.kafkaData;
+ }
+
+ getKafkaModal(id: number) {
+ return this.kafkaApiService.getKafka(id).toPromise();
+ }
+
async initKafkasList(kafkaList: []) {
let k: Kafka[] = [];
if (kafkaList.length > 0) {
@@ -208,33 +216,38 @@
}
editKafkaModal(id: number) {
- console.log("id", id)
- const index = this.kafkaList.findIndex(t => t.id === id);
- const modalRef = this.modalService.open(EditKafkaModalComponent, {
- windowClass: "dl-md-modal kafkas",
- centered: true
- });
- modalRef.componentInstance.editKafka = this.kafkaList[index];
- modalRef.componentInstance.passEntry.subscribe(receivedEntry => {
- this.Kafka_New = receivedEntry;
- this.kafkaApiService
- .updateKafka(this.Kafka_New)
- .subscribe(
- res => {
- if (res.statusCode == 200) {
- this.kafkaList[index] = this.Kafka_New;
- this.kafkaList = [...this.kafkaList];
- this.notificationService.success("SUCCESSFULLY_UPDATED");
- } else {
- this.notificationService.error("FAILED_UPDATED");
+ this.getKafkaDetailModal(id).then(data => {
+ console.log("id", id);
+ const index = this.kafkaList.findIndex(t => t.id === id);
+ const modalRef = this.modalService.open(EditKafkaModalComponent, {
+ windowClass: "dl-md-modal kafkas",
+ centered: true
+ });
+ modalRef.componentInstance.editKafka = data;
+ modalRef.componentInstance.passEntry.subscribe(receivedEntry => {
+ this.Kafka_New = receivedEntry;
+ this.kafkaApiService
+ .updateKafka(this.Kafka_New)
+ .subscribe(
+ res => {
+ this.spinner.hide();
+ if (res.statusCode == 200) {
+ this.kafkaList[index] = this.Kafka_New;
+ this.kafkaList = [...this.kafkaList];
+ this.notificationService.success("SUCCESSFULLY_UPDATED");
+ this.initList();
+ } else {
+ this.notificationService.error("FAILED_UPDATED");
+ }
+ modalRef.close();
+ },
+ err => {
+ this.notificationService.error(err);
+ modalRef.close();
}
- modalRef.close();
- },
- err => {
- this.notificationService.error(err);
- modalRef.close();
- }
- );
- })
+ );
+ });
+ });
+
}
}
diff --git a/components/datalake-handler/admin/src/src/app/views/tools/tools.component.ts b/components/datalake-handler/admin/src/src/app/views/tools/tools.component.ts
index be0d253..65de6ad 100644
--- a/components/datalake-handler/admin/src/src/app/views/tools/tools.component.ts
+++ b/components/datalake-handler/admin/src/src/app/views/tools/tools.component.ts
@@ -50,7 +50,7 @@
private adminService: AdminService,
private notificationService: ToastrNotificationService,
private modalService: NgbModal,
- private dbApiService: RestApiService,
+ private dbApiService: RestApiService
) {
this.adminService.setTitle("SIDEBAR.DASHBOARDLIST");
this.initData().then(data => { });
diff --git a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/KafkaController.java b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/KafkaController.java
index 41995e0..9865e0a 100644
--- a/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/KafkaController.java
+++ b/components/datalake-handler/feeder/src/main/java/org/onap/datalake/feeder/controller/KafkaController.java
@@ -121,14 +121,14 @@
Kafka oldKafka = kafkaService.getKafkaById(id);
if (oldKafka == null) {
- sendError(response, 400, "kafka not found "+id);
+ sendError(response, 400, "kafka not found, ID: "+id);
} else {
kafkaRepository.delete(oldKafka);
response.setStatus(204);
}
}
- @GetMapping("")
+ /*@GetMapping("")
@ResponseBody
@ApiOperation(value="List all Kafka id")
public List<Integer> list() {
@@ -139,12 +139,30 @@
retString.add(k.getId());
}
return retString;
- }
+ }*/
+ @GetMapping("")
+ @ResponseBody
+ @ApiOperation(value="List all Kafkas")
public List<KafkaConfig> queryAllKafka(){
return kafkaService.getAllKafka();
}
+ @GetMapping("/{id}")
+ @ResponseBody
+ @ApiOperation(value="Get detail of kafka by id")
+ public KafkaConfig getKafkaDetail(@PathVariable int id, HttpServletResponse response) throws IOException {
+ log.info("Get detail of kafka, ID: " + id);
+ Kafka oldKafka = kafkaService.getKafkaById(id);
+ if (oldKafka == null) {
+ sendError(response, 400, "kafka not found, ID: "+id);
+ return null;
+ } else {
+ log.info("ResponseBody......" + oldKafka.getKafkaConfig());
+ return oldKafka.getKafkaConfig();
+ }
+ }
+
private PostReturnBody<KafkaConfig> mkPostReturnBody(int statusCode, Kafka kafka) {
PostReturnBody<KafkaConfig> retBody = new PostReturnBody<>();
retBody.setStatusCode(statusCode);