2 Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
19 * @author Chunmeng Guo
23 import {Component, EventEmitter, OnInit, Output} from '@angular/core';
24 import {Db} from "src/app/core/models/db.model";
25 import {NgbActiveModal, NgbModal} from "@ng-bootstrap/ng-bootstrap";
26 import {NgxSpinnerService} from "ngx-spinner";
27 import {ToastrNotificationService} from "src/app/shared/components/toastr-notification/toastr-notification.service";
28 import {RestApiService} from "src/app/core/services/rest-api.service";
29 import {ModalToolsComponent} from "src/app/views/tools/modal-tools/modal-tools.component";
32 selector: 'app-tool-add-modal',
33 templateUrl: './tool-add-modal.component.html',
34 styleUrls: ['./tool-add-modal.component.css']
36 export class ToolAddModalComponent implements OnInit {
38 @Output() passEntry: EventEmitter<any> = new EventEmitter();
39 seletedItem: string = "";
41 loading: Boolean = true;
45 public activeModal: NgbActiveModal,
46 private spinner: NgxSpinnerService,
47 private notificationService: ToastrNotificationService,
48 private modalService: NgbModal,
49 private dbApiService: RestApiService
55 clickItem(name: string) {
56 this.seletedItem = name;
60 console.log(this.seletedItem, "next");
61 this.openNewModal(this.seletedItem);
65 this.toolNew = new Db();
66 this.tool_NewBody = new Db();
67 modalRef.componentInstance.tool = this.tool_NewBody;
68 modalRef.componentInstance.toolList_length = this.toolList.length;
69 modalRef.componentInstance.passEntry.subscribe(receivedEntry => {
70 this.tool_NewBody = receivedEntry;
72 .createDb(this.tool_NewBody)
76 if (res.statusCode == 200) {
77 this.toolNew = res.returnBody;
78 this.toolList.push(this.toolNew);
79 this.toolList = [...this.toolList];
80 this.notificationService.success("SUCCESSFULLY_CREARED");
82 this.notificationService.error("FAILED_CREARED");
88 this.notificationService.error(err);
95 openNewModal(name: string) {
100 modalRef = this.modalService.open(ModalToolsComponent, {
104 modalRef.componentInstance.data = name;
105 this.newTool(modalRef);
109 modalRef = this.modalService.open(ModalToolsComponent, {
113 modalRef.componentInstance.data = name;
114 this.newTool(modalRef);