1 import {Component, OnInit} from '@angular/core';
2 import {PackageCreationService} from '../package-creation.service';
3 import {MetaDataTabModel} from '../mapping-models/metadata/MetaDataTab.model';
4 import {PackageCreationStore} from '../package-creation.store';
5 import {PackageStore} from '../../configuration-dashboard/package.store';
9 selector: 'app-metadata-tab',
10 templateUrl: './metadata-tab.component.html',
11 styleUrls: ['./metadata-tab.component.css']
13 export class MetadataTabComponent implements OnInit {
16 tags = new Set<string>();
17 customKeysMap = new Map();
19 {name: 'Designer Mode', style: 'mode-icon icon-designer-mode'},
20 {name: 'Scripting Mode', style: 'mode-icon icon-scripting-mode'},
21 {name: 'Generic Script Mode', style: 'mode-icon icon-generic-script-mode'}];
22 private metaDataTab: MetaDataTabModel = new MetaDataTabModel();
23 private errorMessage: string;
25 constructor(private packageCreationService: PackageCreationService, private packageCreationStore: PackageCreationStore,
26 private packageStore: PackageStore) {
31 this.metaDataTab.templateTags = this.tags;
32 this.metaDataTab.mapOfCustomKey = this.customKeysMap;
33 this.packageCreationStore.changeMetaData(this.metaDataTab);
35 this.packageStore.state$.subscribe(element => {
36 if (element && element.configuration) {
37 this.metaDataTab.name = element.configuration.artifactName;
38 this.metaDataTab.version = element.configuration.artifactVersion;
39 this.metaDataTab.tags = element.configuration.tags;
40 this.metaDataTab.description = element.configuration.artifactDescription;
47 // console.log(event);
48 this.tags.delete(value);
52 const value = event.target.value;
54 if (value && value.trim().length > 0) {
55 event.target.value = '';
60 removeKey(event, key) {
62 this.customKeysMap.delete(key);
66 // tslint:disable-next-line: no-string-literal
67 const key = document.getElementsByClassName('mapKey')[0];
68 // tslint:disable-next-line: no-string-literal
69 const value = document.getElementsByClassName('mapValue')[0];
71 // tslint:disable-next-line: no-string-literal
72 if (key['value'] && value['value']) {
73 // tslint:disable-next-line: no-string-literal
74 this.customKeysMap.set(key['value'], value['value']);
75 // tslint:disable-next-line: no-string-literal
77 // tslint:disable-next-line: no-string-literal
82 validatePackageNameAndVersion() {
83 if (this.metaDataTab.name && this.metaDataTab.version) {
84 this.packageCreationService.checkBluePrintNameAndVersion(this.metaDataTab.name, this.metaDataTab.version).then(element => {
86 this.errorMessage = 'the package with name and version is exists';
88 this.errorMessage = ' ';