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.
24 } from "@angular/core";
25 import { NgbActiveModal } from "@ng-bootstrap/ng-bootstrap";
26 import { DashboardApiService } from "src/app/core/services/dashboard-api.service";
27 import { AdminService } from "src/app/core/services/admin.service";
28 import {NgbModal} from "@ng-bootstrap/ng-bootstrap";
29 import { Template,newTemplate} from "src/app/core/models/template.model";
30 import {AlertComponent} from "../../../../core/alert/alert.component";
33 selector: 'app-new-template-modal',
34 templateUrl: './new-template-modal.component.html',
35 styleUrls: ['./new-template-modal.component.css']
37 export class NewTemplateModalComponent implements OnInit {
38 @Input() template: newTemplate;
39 @Input() templatelist_length;
40 @Input() selectedLangs;
41 templateInput: newTemplate
42 templatetypedata: Array<any> = [];
43 topicname: Array<any> = [];
44 @Output() passEntry: EventEmitter<any> = new EventEmitter();
45 // @ViewChild("inputtemplateName") inputtemplateName: ElementRef;
46 // @ViewChild("templatebody") templatebody: ElementRef;
47 @ViewChild("templatetype") templatetype: ElementRef;
48 @ViewChild("topic") topic: ElementRef;
51 public activeModal: NgbActiveModal,
52 public dashboardApiService: DashboardApiService,
53 private modalService: NgbModal,
56 inputtemplateName = null;
61 this.getTemplateTypeName();
63 this.templateInput = new Template();
65 name: this.template.name,
66 submitted: this.template.submitted,
67 body: this.template.body,
68 note: this.template.note,
69 topic: this.template.topic,
70 designType: this.template.designType
72 this.templateInput = feed;
75 this.dashboardApiService.getTopicName().subscribe(data => {
76 this.topicname = data;
77 console.log(this.topicname,"this.topicname")
81 getTemplateTypeName(){
82 this.dashboardApiService.getTemplateTypeName().subscribe(data => {
83 this.templatetypedata = data;
84 console.log(this.templatetypedata,"this.templatetypedata")
89 if(this.templateInput.name == '' || this.templateInput.name == undefined){
91 if (this.selectedLangs == "en-us") {
92 tips = "Name input is required."
93 } else if (this.selectedLangs == "zh-hans") {
95 } else if (this.selectedLangs == "zh-hant") {
100 this.template = this.templateInput;
101 console.log(this.templateInput);
102 this.template.designType = this.templatetype.nativeElement.value;
103 this.template.topic = this.topic.nativeElement.value;
104 // this.template.id = this.templatelist_length+1;
105 this.template.submitted = true;
106 this.template.note = "";
107 console.log(this.template);
108 this.passEntry.emit(this.template);