2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   6  *=================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *     http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  25  * @contributor Chunmeng Guo
 
  29 import {Component, Output, EventEmitter, ViewChild, ElementRef} from "@angular/core";
 
  30 import {NgbActiveModal, NgbModal} from "@ng-bootstrap/ng-bootstrap";
 
  31 import {CouchbaseComponent} from "src/app/views/database/database-list/dbs-modal/couchbase/couchbase.component";
 
  32 import {DruidComponent} from "src/app/views/database/database-list/dbs-modal/druid/druid.component";
 
  33 import {ElasticsearchComponent} from "src/app/views/database/database-list/dbs-modal/elasticsearch/elasticsearch.component";
 
  34 import {MongodbComponent} from "src/app/views/database/database-list/dbs-modal/mongodb/mongodb.component";
 
  35 import {HdfsComponent} from "src/app/views/database/database-list/dbs-modal/hdfs/hdfs.component";
 
  36 import {Db} from "src/app/core/models/db.model";
 
  37 import {RestApiService} from "src/app/core/services/rest-api.service";
 
  38 import {ToastrNotificationService} from "src/app/shared/components/toastr-notification/toastr-notification.service";
 
  39 import {NgxSpinnerService} from "ngx-spinner";
 
  42   selector: "app-database-add-modal",
 
  43   templateUrl: "./database-add-modal.component.html",
 
  44   styleUrls: ["./database-add-modal.component.css"]
 
  46 export class DatabaseAddModalComponent {
 
  47   @Output() passEntry: EventEmitter<any> = new EventEmitter();
 
  48   seletedItem: string = "";
 
  51   loading: Boolean = true;
 
  55     public activeModal: NgbActiveModal,
 
  56     private spinner: NgxSpinnerService,
 
  57     private notificationService: ToastrNotificationService,
 
  58     private modalService: NgbModal,
 
  59     private dbApiService: RestApiService
 
  64   clickItem(name: string) {
 
  65     this.seletedItem = name;
 
  69     console.log(this.seletedItem, "next");
 
  70     this.openNewModal(this.seletedItem);
 
  74     this.dbNew = new Db();
 
  75     this.db_NewBody = new Db();
 
  76     modalRef.componentInstance.db = this.db_NewBody;
 
  77     modalRef.componentInstance.dbList_length = this.dbList.length;
 
  78     modalRef.componentInstance.passEntry.subscribe(receivedEntry => {
 
  79       this.db_NewBody = receivedEntry;
 
  81         .createDb(this.db_NewBody)
 
  85             if (res.statusCode == 200) {
 
  86               this.dbNew = res.returnBody;
 
  87               this.dbList.push(this.dbNew);
 
  88               this.dbList = [...this.dbList];
 
  89               this.notificationService.success("SUCCESSFULLY_CREARED");
 
  91               this.notificationService.error("FAILED_CREARED");
 
  97             this.notificationService.error(err);
 
 104   openNewModal(name: string) {
 
 109         modalRef = this.modalService.open(CouchbaseComponent, {
 
 113         this.newDb(modalRef);
 
 117         modalRef = this.modalService.open(DruidComponent, {
 
 121         this.newDb(modalRef);
 
 124       case "Elasticsearch": {
 
 125         modalRef = this.modalService.open(ElasticsearchComponent, {
 
 129         this.newDb(modalRef);
 
 133         modalRef = this.modalService.open(MongodbComponent, {
 
 137         this.newDb(modalRef);
 
 141         modalRef = this.modalService.open(HdfsComponent, {
 
 145         this.newDb(modalRef);