change: change template model and dashboard-list service structure 32/91432/2
authorcyuamber <xuranyjy@chinamobile.com>
Mon, 15 Jul 2019 07:47:51 +0000 (15:47 +0800)
committerxu ran <xuranyjy@chinamobile.com>
Mon, 15 Jul 2019 07:51:24 +0000 (07:51 +0000)
Change-Id: I262440d8e915cb325cca4f101b1225d151827334
Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
Issue-ID: DCAEGEN2-1663

components/datalake-handler/admin/src/proxy.conf.json
components/datalake-handler/admin/src/src/app/core/alert/alert.component.ts
components/datalake-handler/admin/src/src/app/core/models/template.model.ts
components/datalake-handler/admin/src/src/app/core/services/dashboard-api.service.spec.ts [deleted file]
components/datalake-handler/admin/src/src/app/core/services/dashboard-api.service.ts [deleted file]
components/datalake-handler/admin/src/src/app/core/services/rest-api.service.ts
components/datalake-handler/admin/src/src/app/dashboard-setting/dashboard-list/dashboard-list.component.ts
components/datalake-handler/admin/src/src/app/dashboard-setting/template/template-list/edit-template-modal/edit-template-modal.component.ts
components/datalake-handler/admin/src/src/app/dashboard-setting/template/template-list/new-template-modal/new-template-modal.component.ts
components/datalake-handler/admin/src/src/app/dashboard-setting/template/template-list/template-list.component.ts
components/datalake-handler/admin/src/src/index.html

index a9924e8..1dde4e8 100644 (file)
@@ -1,8 +1,8 @@
 {
   "/datalake/v1": {
-    "target": "http://192.168.1.97:1680",
+    "target": "http://10.73.242.196:1680",
     "secure": false,
     "logLevel": "debug",
     "changeOrigin": true
   }
-}
+}
\ No newline at end of file
index 6514ae8..3774ec3 100644 (file)
@@ -38,10 +38,9 @@ export class AlertComponent {
   @Input() dashboardDeteleModelShow;
   @Output() passEntry: EventEmitter<any> = new EventEmitter();
 
-  constructor(public activeModal: NgbActiveModal) {}
+  constructor(public activeModal: NgbActiveModal) { }
 
   passBack() {
-    console.log(this.dashboardDeteleModelShow,"dashboardDeteleModelShow");
     this.passEntry.emit(true);
   }
 }
index af9ef3d..3df882f 100644 (file)
@@ -25,12 +25,12 @@ export class Template {
   designTypeName: string;
 }
 
-export class newTemplate {
-  name: string;
-  submitted: boolean;
-  body: string;
-  note: string;
-  topicName: string;
-  designType: string;
-  designTypeName: string;
-}
+// export class newTemplate {
+//   name: string;
+//   submitted: boolean;
+//   body: string;
+//   note: string;
+//   topicName: string;
+//   designType: string;
+//   designTypeName: string;
+// }
diff --git a/components/datalake-handler/admin/src/src/app/core/services/dashboard-api.service.spec.ts b/components/datalake-handler/admin/src/src/app/core/services/dashboard-api.service.spec.ts
deleted file mode 100644 (file)
index ee5bd91..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-    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 { TestBed } from '@angular/core/testing';
-
-import { DashboardApiService } from './dashboard-api.service';
-
-describe('DashboardApiService', () => {
-  beforeEach(() => TestBed.configureTestingModule({}));
-
-  it('should be created', () => {
-    const service: DashboardApiService = TestBed.get(DashboardApiService);
-    expect(service).toBeTruthy();
-  });
-});
diff --git a/components/datalake-handler/admin/src/src/app/core/services/dashboard-api.service.ts b/components/datalake-handler/admin/src/src/app/core/services/dashboard-api.service.ts
deleted file mode 100644 (file)
index 67bfb75..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-    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 { Injectable } from "@angular/core";
-import { HttpClient, HttpHeaders } from "@angular/common/http";
-import { Observable, of } from "rxjs";
-import { map, catchError, tap, retry } from "rxjs/operators";
-import { throwError } from "rxjs";
-
-import { Template, newTemplate } from "src/app/core/models/template.model";
-import { Dashboard } from "src/app/core/models/dashboard.model";
-
-const prefix = "/datalake/v1/";
-
-@Injectable({
-  providedIn: 'root'
-})
-export class DashboardApiService {
-
-  constructor(private http: HttpClient) {
-  }
-
-  private extractData(res: Response) {
-    if (res.status < 200 || res.status >= 300) {
-      throw new Error("Bad response status: " + res.status);
-    }
-    let body = res;
-    return body || {};
-  }
-
-  private handleError(error) {
-    let errorMessage = "";
-    if (error.error instanceof ErrorEvent) {
-      // Get client-side error
-      errorMessage = error.error.message;
-    } else {
-      // Get server-side error
-      errorMessage = `Error Code: ${error.status}\nMessage: ${error.message}`;
-      console.log(errorMessage);
-    }
-    return throwError(errorMessage);
-  }
-
-  private extractData2(res: Response) {
-    // console.log(res, "detele/deploy template");
-    let body = res;
-    return body || {};
-  }
-
-
-  /*
-  Dashboard
-*/
-  getDashboardList(): Observable<any> {
-    let url = prefix + "portals"; //onilne
-    return this.http.get(url).pipe(
-      retry(1),
-      map(this.extractData),
-      catchError(this.handleError)
-    );
-  }
-
-  createUpadteDashboard(d: Dashboard): Observable<any> {
-    // let url = prefix +"/dashboard-list/successCreteOrEditDemo.json"; //local
-    let url = prefix + "portals";//onilne
-    return this.http
-      .put(url, d)
-      .pipe(
-        retry(1),
-        tap(_ => this.extractData),
-        catchError(this.handleError)
-      );
-  }
-
-  deleteDashboard(d: Dashboard): Observable<any> {
-    let url = prefix + "portals"; //onilne
-    return this.http
-      .put(url, d)
-      .pipe(
-        retry(1),
-        tap(_ => console.log(`deleted db name=${d.name}`)),
-        catchError(this.handleError)
-      );
-  }
-
-  // getDashboardName(): Observable<any> {
-  //   // let url = prefix +"/dashboard-list/getDashboardName.json"; //local
-  //   let url = prefix + "portals/getNames?enabled=false"; //onilne
-  //   return this.http.get(url).pipe(
-  //     retry(1),
-  //     map(this.extractData),
-  //     catchError(this.handleError)
-  //   );
-  // }
-
-  /*
-    Template
-  */
-  getTemplateAll(): Observable<any> {
-    return this.http.get(prefix + "designs/").pipe( //onlin
-      retry(1),
-      map(this.extractData),
-      catchError(this.handleError)
-    );
-  }
-
-  createNewTemplate(t: newTemplate): Observable<any> {
-    return this.http
-      .post(prefix + "designs", t)
-      .pipe(
-        retry(1),
-        tap(_ => this.extractData),
-        catchError(this.handleError)
-      );
-  }
-
-  updateNewTemplate(t: Template): Observable<any> {
-    let id = t.id;
-    return this.http
-      .put(prefix + "designs/" + id, t)
-      .pipe(
-        retry(1),
-        tap(_ => this.extractData),
-        catchError(this.handleError)
-      );
-  }
-
-  getTopicName(): Observable<any> {
-    return this.http.get(prefix + "topics").pipe( //onlin
-      retry(1),
-      map(this.extractData),
-      catchError(this.handleError)
-    );
-  }
-
-  getTemplateTypeName(): Observable<any> {
-    return this.http.get(prefix + "designTypes").pipe( //onlin
-      retry(1),
-      map(this.extractData),
-      catchError(this.handleError)
-    );
-  }
-
-  DeleteTemplate(id): Observable<any> {
-    return this.http.delete(prefix + "designs/" + id).pipe( //online
-      retry(1),
-      map(this.extractData2),
-      catchError(this.handleError)
-    );
-  }
-  deployTemplateKibana(id, body): Observable<any> {
-    body.submitted = true;
-    return this.http.post(prefix + "designs/deploy/" + id, body).pipe(   //online
-      retry(1),
-      map(this.extractData2),
-      catchError(this.handleError)
-    );
-  }
-}
index 05bfdd1..a2e44e9 100644 (file)
@@ -33,6 +33,8 @@ import { throwError } from "rxjs";
 
 import { Topic } from "src/app/core/models/topic.model";
 import { Db } from "src/app/core/models/db.model";
+import { Template } from "src/app/core/models/template.model";
+import { Dashboard } from "src/app/core/models/dashboard.model";
 
 const prefix = "/datalake/v1/";
 const httpOptions = {
@@ -45,7 +47,7 @@ const httpOptions = {
   providedIn: "root"
 })
 export class RestApiService {
-  constructor(private http: HttpClient) {}
+  constructor(private http: HttpClient) { }
 
   private extractData(res: Response) {
     if (res.status < 200 || res.status >= 300) {
@@ -68,6 +70,11 @@ export class RestApiService {
     return throwError(errorMessage);
   }
 
+  private extractData2(res: Response) {
+    let body = res;
+    return body || {};
+  }
+
   /*
     Topic default config
   */
@@ -172,7 +179,7 @@ export class RestApiService {
       catchError(this.handleError)
     );
   }
-  
+
   upadteDb(d: Db): Observable<any> {
     return this.http
       .put(prefix + "dbs", d)
@@ -209,4 +216,107 @@ export class RestApiService {
       catchError(this.handleError)
     );
   }
+
+
+  /*
+Dashboard
+*/
+  getDashboardList(): Observable<any> {
+    let url = prefix + "portals"; //onilne
+    return this.http.get(url).pipe(
+      retry(1),
+      map(this.extractData),
+      catchError(this.handleError)
+    );
+  }
+
+  createUpadteDashboard(d: Dashboard): Observable<any> {
+    // let url = prefix +"/dashboard-list/successCreteOrEditDemo.json"; //local
+    let url = prefix + "portals";//onilne
+    return this.http
+      .put(url, d)
+      .pipe(
+        retry(1),
+        tap(_ => this.extractData),
+        catchError(this.handleError)
+      );
+  }
+
+  deleteDashboard(d: Dashboard): Observable<any> {
+    let url = prefix + "portals"; //onilne
+    return this.http
+      .put(url, d)
+      .pipe(
+        retry(1),
+        tap(_ => console.log(`deleted db name=${d.name}`)),
+        catchError(this.handleError)
+      );
+  }
+
+
+  /*
+  Template
+*/
+  getTemplateAll(): Observable<any> {
+    return this.http.get(prefix + "designs/").pipe( //onlin
+      retry(1),
+      map(this.extractData),
+      catchError(this.handleError)
+    );
+  }
+
+  createNewTemplate(t: Template): Observable<any> {
+    return this.http
+      .post(prefix + "designs", t)
+      .pipe(
+        retry(1),
+        tap(_ => this.extractData),
+        catchError(this.handleError)
+      );
+  }
+
+  updateNewTemplate(t: Template): Observable<any> {
+    let id = t.id;
+    return this.http
+      .put(prefix + "designs/" + id, t)
+      .pipe(
+        retry(1),
+        tap(_ => this.extractData),
+        catchError(this.handleError)
+      );
+  }
+
+  // getTopicName(): Observable<any> {
+  //   return this.http.get(prefix + "topics").pipe( //onlin
+  //     retry(1),
+  //     map(this.extractData),
+  //     catchError(this.handleError)
+  //   );
+  // }
+
+  getTemplateTypeName(): Observable<any> {
+    return this.http.get(prefix + "designTypes").pipe( //onlin
+      retry(1),
+      map(this.extractData),
+      catchError(this.handleError)
+    );
+  }
+
+  DeleteTemplate(id): Observable<any> {
+    return this.http.delete(prefix + "designs/" + id).pipe( //online
+      retry(1),
+      map(this.extractData2),
+      catchError(this.handleError)
+    );
+  }
+  deployTemplateKibana(id, body): Observable<any> {
+    body.submitted = true;
+    return this.http.post(prefix + "designs/deploy/" + id, body).pipe(   //online
+      retry(1),
+      map(this.extractData2),
+      catchError(this.handleError)
+    );
+  }
 }
+
+
index 8bb4126..17a6b2e 100644 (file)
     See the License for the specific language governing permissions and
     limitations under the License.
 */
-import {Component, EventEmitter, OnInit, Output} from '@angular/core';
-import {Dashboard} from "../../core/models/dashboard.model";
-import {NgbModal} from "@ng-bootstrap/ng-bootstrap";
-import {CreateDashboardComponent} from "./create-dashboard/create-dashboard.component";
+import { Component, EventEmitter, OnInit, Output } from '@angular/core';
+import { Dashboard } from "../../core/models/dashboard.model";
+import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
+import { CreateDashboardComponent } from "./create-dashboard/create-dashboard.component";
 
-import {AdminService} from "../../core/services/admin.service";
+import { AdminService } from "../../core/services/admin.service";
 
 // DB modal components
-import {DashboardApiService} from "src/app/core/services/dashboard-api.service";
-
-import {AlertComponent} from "src/app/core/alert/alert.component";
+import { RestApiService } from "src/app/core/services/rest-api.service";
 
 // Notify
-import {ToastrNotificationService} from "src/app/core/services/toastr-notification.service";
+import { ToastrNotificationService } from "src/app/core/services/toastr-notification.service";
 // Loading spinner
-import {NgxSpinnerService} from "ngx-spinner";
+import { NgxSpinnerService } from "ngx-spinner";
 
 @Component({
   selector: 'app-dashboard-list',
@@ -49,7 +47,7 @@ export class DashboardListComponent implements OnInit {
 
   constructor(
     private adminService: AdminService,
-    private dashboardApiService: DashboardApiService,
+    private dashboardApiService: RestApiService,
     private notificationService: ToastrNotificationService,
     private modalService: NgbModal,
     private spinner: NgxSpinnerService
@@ -63,7 +61,7 @@ export class DashboardListComponent implements OnInit {
   ngOnInit() {
     this.spinner.show();
   }
-  initList(){
+  initList() {
     this.initData().then(data => {
       this.initDbsList(this.dbList).then(data => {
         this.dbs = data;
index c77bd56..f42e737 100644 (file)
@@ -23,9 +23,8 @@ import {
   ElementRef
 } from "@angular/core";
 import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
-import { DashboardApiService } from "src/app/core/services/dashboard-api.service";
+import { RestApiService } from "src/app/core/services/rest-api.service";
 import { Template } from "src/app/core/models/template.model";
-import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
 
 // Loading spinner
 import { NgxSpinnerService } from "ngx-spinner";
@@ -49,9 +48,8 @@ export class EditTemplateModalComponent implements OnInit {
 
   constructor(
     public activeModal: NgbActiveModal,
-    public dashboardApiService: DashboardApiService,
+    public dashboardApiService: RestApiService,
     private spinner: NgxSpinnerService,
-    private modalService: NgbModal,
   ) { }
 
   inputtemplateName = null;
@@ -77,7 +75,7 @@ export class EditTemplateModalComponent implements OnInit {
     this.getTemplateTypeName();
   }
   getTopicName() {
-    this.dashboardApiService.getTopicName().subscribe(data => {
+    this.dashboardApiService.getTopicsFromFeeder().subscribe(data => {
       this.topicname = data;
     });
   }
@@ -123,7 +121,7 @@ export class EditTemplateModalComponent implements OnInit {
     this.edittemplate.designType = this.templatetypedata.filter(item => {
       return item.name === this.templatetype.nativeElement.value;
     })[0].id || "";
-    
+
     this.edittemplate.designTypeName = this.templatetype.nativeElement.value;
     this.edittemplate.topicName = this.topic.nativeElement.value;
     this.passEntry.emit(this.edittemplate);
index d842a11..5e46bf9 100644 (file)
@@ -23,12 +23,11 @@ import {
   ElementRef
 } from "@angular/core";
 import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
-import { DashboardApiService } from "src/app/core/services/dashboard-api.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 { Template, newTemplate } from "src/app/core/models/template.model";
+import { Template } from "src/app/core/models/template.model";
 
 @Component({
   selector: 'app-new-template-modal',
@@ -36,9 +35,9 @@ import { Template, newTemplate } from "src/app/core/models/template.model";
   styleUrls: ['./new-template-modal.component.css']
 })
 export class NewTemplateModalComponent implements OnInit {
-  @Input() template: newTemplate;
+  @Input() template: Template;
   @Input() templatelist_length;
-  templateInput: newTemplate
+  templateInput: Template
   templatetypedata: Array<any> = [];
   topicname: Array<any> = [];
   @Output() passEntry: EventEmitter<any> = new EventEmitter();
@@ -47,10 +46,8 @@ export class NewTemplateModalComponent implements OnInit {
 
   constructor(
     public activeModal: NgbActiveModal,
-    public dashboardApiService: DashboardApiService,
+    public dashboardApiService: RestApiService,
     private spinner: NgxSpinnerService,
-    private modalService: NgbModal,
-
   ) { }
   inputtemplateName = null;
   templatebody = null;
@@ -62,6 +59,7 @@ export class NewTemplateModalComponent implements OnInit {
     // cache for display
     this.templateInput = new Template();
     const feed = {
+      id: null,
       name: this.template.name,
       submitted: this.template.submitted,
       body: this.template.body,
@@ -73,7 +71,7 @@ export class NewTemplateModalComponent implements OnInit {
     this.templateInput = feed;
   }
   getTopicName() {
-    this.dashboardApiService.getTopicName().subscribe(data => {
+    this.dashboardApiService.getTopicsFromFeeder().subscribe(data => {
       this.topicname = data;
     });
   }
index 440f221..6bc9c9d 100644 (file)
@@ -14,9 +14,9 @@
     limitations under the License.
 */
 import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
-import { DashboardApiService } from "src/app/core/services/dashboard-api.service";
+import { RestApiService } from "src/app/core/services/rest-api.service";
 import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
-import { Template, newTemplate } from "src/app/core/models/template.model";
+import { Template } from "src/app/core/models/template.model";
 // Loading spinner
 import { NgxSpinnerService } from "ngx-spinner";
 
@@ -37,7 +37,7 @@ export class TemplateListComponent {
   templates: Template[] = [];
   temps: Template[] = [];
   Template_New: Template;
-  Template_Newbody: newTemplate;
+  Template_Newbody: Template;
   dashboardDeteleModelShow = true;
   loadingIndicator: boolean = true;
   mesgNoData = {
@@ -52,7 +52,7 @@ export class TemplateListComponent {
   @ViewChild("searchText") searchText: ElementRef;
   constructor(
     private modalService: NgbModal,
-    private dashboardApiService: DashboardApiService,
+    private dashboardApiService: RestApiService,
     private spinner: NgxSpinnerService,
     private notificationService: ToastrNotificationService,
   ) {
@@ -82,7 +82,7 @@ export class TemplateListComponent {
     this.template_list = [];
     this.template_list = await this.getTemplateList();
     this.Template_New = new Template();
-    this.Template_Newbody = new newTemplate();
+    this.Template_Newbody = new Template();
     return true;
   }
 
@@ -116,7 +116,7 @@ export class TemplateListComponent {
       centered: true
     });
     this.Template_New = new Template();
-    this.Template_Newbody = new newTemplate();
+    this.Template_Newbody = new Template();
     modalRef.componentInstance.template = this.Template_Newbody;
     modalRef.componentInstance.templatelist_length = this.template_list.length;
     modalRef.componentInstance.passEntry.subscribe(receivedEntry => {
index 4b2611c..2549c4a 100644 (file)
@@ -31,7 +31,7 @@ limitations under the License.
 
   <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
     integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
-  <link href="https://fonts.googleapis.com/css?family=Noto+Sans+TC|Open+Sans:300,400,600|Roboto:100" rel="stylesheet">
+<link href="https://fonts.googleapis.com/css?family=Noto+Sans+TC|Open+Sans:300,400,600|Roboto:100" rel="stylesheet">
 
 </head>