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;
26 private packageCreationService: PackageCreationService,
27 private packageCreationStore: PackageCreationStore,
28 private packageStore: PackageStore) {
33 this.metaDataTab.templateTags = this.tags;
34 this.metaDataTab.mapOfCustomKey = this.customKeysMap;
35 this.packageCreationStore.changeMetaData(this.metaDataTab);
37 this.packageStore.state$.subscribe(element => {
38 if (element && element.configuration) {
39 console.log('from element2');
41 this.metaDataTab.name = element.configuration.artifactName;
42 this.metaDataTab.version = element.configuration.artifactVersion;
43 this.metaDataTab.description = element.configuration.artifactDescription;
44 this.tags = new Set(element.configuration.tags.split(','));
51 // console.log(event);
52 this.tags.delete(value);
56 const value = event.target.value;
58 if (value && value.trim().length > 0) {
59 event.target.value = '';
64 removeKey(event, key) {
66 this.customKeysMap.delete(key);
70 // tslint:disable-next-line: no-string-literal
71 const key = document.getElementsByClassName('mapKey')[0];
72 // tslint:disable-next-line: no-string-literal
73 const value = document.getElementsByClassName('mapValue')[0];
75 // tslint:disable-next-line: no-string-literal
76 if (key['value'] && value['value']) {
77 // tslint:disable-next-line: no-string-literal
78 this.customKeysMap.set(key['value'], value['value']);
79 // tslint:disable-next-line: no-string-literal
81 // tslint:disable-next-line: no-string-literal
86 validatePackageNameAndVersion() {
87 if (this.metaDataTab.name && this.metaDataTab.version) {
88 this.packageCreationService.checkBluePrintNameAndVersion(this.metaDataTab.name, this.metaDataTab.version).then(element => {
90 this.errorMessage = 'the package with name and version is exists';
92 this.errorMessage = ' ';