Skip to content

Commit

Permalink
Add template for start of namespace for TOSCA components
Browse files Browse the repository at this point in the history
Signed-off-by: Philipp Meyer <meyer.github@gmail.com>
  • Loading branch information
meyerpp committed Oct 20, 2017
1 parent 529b513 commit cdf9432
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 67 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -40,6 +40,7 @@ This is similar to [Angular's CHANGELOG.md](https://github.com/angular/angular/b
- Added initial CLI. Current funtionality: Consistency check of the repository.
- Rewrote the Backend UI using Angular
- org.eclipse.winery.model.tosca was extended with builders and some helper classes
- Add template start of namespace for the creation of tosca components
- Fixed wrong output of "CSAR Export mode. Putting XSD into CSAR" if in CSAR export mode
- New project `org.eclipse.winery.repository.rest` for separating REST resources from the backend
- Add support of [Splitting](http://eclipse.github.io/winery/user/Splitting)
Expand Down
Expand Up @@ -29,8 +29,8 @@ <h4 class="modal-title">Delete Property</h4>
</p>
</winery-modal-body>
<winery-modal-footer (onOk)="deleteNamespace();"
[closeButtonLabel]="'No'"
[okButtonLabel]="'Yes'">
[closeButtonLabel]="'No'"
[okButtonLabel]="'Yes'">
</winery-modal-footer>
</winery-modal>

Expand Down Expand Up @@ -70,15 +70,17 @@ <h4 class="modal-title">Add Property</h4>
[isRequired]="true"
[typeAheadListLimit]="20"
required
pattern="^\S*$">
pattern="^\S*$"
[useStartNamespace]="false">
</winery-namespace-selector>

</form>

</winery-modal-body>
<winery-modal-footer (onOk)="addNamespace(namespace.selectedNamespace, prefixName.value); addNamespaceForm.reset();"
[closeButtonLabel]="'Cancel'"
[okButtonLabel]="'Add'"
[disableOkButton]="!addNamespaceForm?.form.valid">
<winery-modal-footer
(onOk)="addNamespace(); addNamespaceForm.reset();"
[closeButtonLabel]="'Cancel'"
[okButtonLabel]="'Add'"
[disableOkButton]="!addNamespaceForm?.form.valid">
</winery-modal-footer>
</winery-modal>
</div>
Expand Up @@ -27,8 +27,8 @@ import { ModalDirective } from 'ngx-bootstrap';
export class NamespacesComponent implements OnInit {

loading = true;
adminNamespaces: Array<any> = [];
newNamespace: any = { namespace: '', prefix: '' };
adminNamespaces: Array<NamespaceWithPrefix> = [];
newNamespace: NamespaceWithPrefix = { prefix: '', namespace: '' };
validatorObjectPrefix: WineryValidatorObject;
validatorObjectNamespace: WineryValidatorObject;

Expand Down Expand Up @@ -61,11 +61,8 @@ export class NamespacesComponent implements OnInit {
this.getNamespaces();
}

addNamespace(namespace: string, prefix: string) {
this.adminNamespaces.push({
namespace: namespace,
prefix: prefix
});
addNamespace() {
this.adminNamespaces.push(this.newNamespace);
this.save();
}

Expand Down
Expand Up @@ -58,7 +58,8 @@
pattern="^\S*$"
[isRequired]="true"
[typeAheadListLimit]="20"
[(ngModel)]="selectedNamespace">
[(ngModel)]="selectedNamespace"
[toscaType]="implementationOrTemplate">
</winery-namespace-selector>
</div>
</form>
Expand All @@ -68,7 +69,6 @@
[okButtonLabel]="'Add'"
[disableOkButton]="!addImplForm?.form.valid">
</winery-modal-footer>

</winery-modal>

<winery-modal bsModal #confirmDeleteModal="bs-modal" [modalRef]="confirmDeleteModal">
Expand Down
Expand Up @@ -63,7 +63,9 @@
<div class="wrapperTabButtom">
<!-- pattern parameter is required to enable form validation -->
<winery-namespace-selector
[(ngModel)]="resourceApiData.winerysPropertiesDefinition.namespace" pattern="^\S*$"></winery-namespace-selector>
[(ngModel)]="resourceApiData.winerysPropertiesDefinition.namespace" pattern="^\S*$"
[useStartNamespace]="false">
</winery-namespace-selector>
</div>
</tab>
</tabset>
Expand Down
Expand Up @@ -88,13 +88,14 @@
</div>
</div>
<!-- pattern parameter is required to enable form validation -->
<winery-namespace-selector #ns
<winery-namespace-selector #namespaceInput
name="namespace"
required
pattern="^\S*$"
[(ngModel)]="newComponentNamespace"
(onChange)="namespaceChanged($event)"
[isRequired]="true">
[isRequired]="true"
[useStartNamespace]="true"
[toscaType]="toscaType">
</winery-namespace-selector>
<div class="form-group" *ngIf="types">
<label for="typeSelect" class="control-label">Type</label>
Expand All @@ -107,7 +108,7 @@
(onOk)="addComponent()"
[closeButtonLabel]="'Cancel'"
[okButtonLabel]="'Add'"
[disableOkButton]="!formValid">
[disableOkButton]="!addComponentForm.valid">
</winery-modal-footer>
</winery-modal>

Expand Down
Expand Up @@ -23,6 +23,7 @@ import { Response } from '@angular/http';
import { ToscaTypes } from '../wineryInterfaces/enums';
import { Utils } from '../wineryUtils/utils';
import { WineryUploaderComponent } from '../wineryUploader/wineryUploader.component';
import { WineryNamespaceSelectorComponent } from '../wineryNamespaceSelector/wineryNamespaceSelector.component';

const showAll = 'Show all Items';
const showGrouped = 'Group by Namespace';
Expand Down Expand Up @@ -72,6 +73,8 @@ export class SectionComponent implements OnInit, OnDestroy {
@ViewChild('addYamlModal') addYamlModal: ModalDirective;
@ViewChild('fileUploader') fileUploader: WineryUploaderComponent;

@ViewChild('namespaceInput') namespaceInput: WineryNamespaceSelectorComponent;

constructor(private route: ActivatedRoute,
private change: ChangeDetectorRef,
private router: Router,
Expand Down Expand Up @@ -118,8 +121,10 @@ export class SectionComponent implements OnInit, OnDestroy {
this.change.detectChanges();
this.addComponentForm.reset();

this.newComponentNamespace = (this.showNamespace !== 'all' && this.showNamespace !== 'group') ? this.showNamespace : '';
this.newComponentSelectedType = this.types ? this.types[0].children[0] : null;
this.newComponentNamespace = (this.showNamespace !== 'all' && this.showNamespace !== 'group') ? this.showNamespace : '';
this.namespaceInput.writeValue(this.newComponentNamespace);

this.addModal.show();
}

Expand Down Expand Up @@ -163,7 +168,7 @@ export class SectionComponent implements OnInit, OnDestroy {

this.fileUploader.getUploader().setOptions({
url: this.fileUploadUrl,
additionalParameter: {'overwrite': this.overwriteValue}
additionalParameter: { 'overwrite': this.overwriteValue }
});
}

Expand Down Expand Up @@ -235,8 +240,4 @@ export class SectionComponent implements OnInit, OnDestroy {
this.notify.error(error.toString());
}

namespaceChanged(event: any) {
this.namespaceValid = event;
this.formValid = this.namespaceValid && this.addComponentForm.valid;
}
}
Expand Up @@ -27,6 +27,7 @@
name="artifactNamespace"
[(ngModel)]="generateData.namespace"
(onChange)="checkImplementationExists();"
[useStartNamespace]="false"
pattern="^\S*$">
</winery-namespace-selector>
</div>
Expand Down
41 changes: 23 additions & 18 deletions org.eclipse.winery.repository.ui/src/app/wineryInterfaces/enums.ts
Expand Up @@ -9,7 +9,7 @@

export enum YesNoEnum {
YES = 'YES',
NO = 'NO'
NO = 'NO'
}

/**
Expand All @@ -20,37 +20,42 @@ export enum YesNoEnum {
* Default is assumed ToscaTypes.Admin.
*/
export enum ToscaTypes {
ServiceTemplate = 'servicetemplates',
NodeType = 'nodetypes',
RelationshipType = 'relationshiptypes',
ArtifactType = 'artifacttypes',
ArtifactTemplate = 'artifacttemplates',
RequirementType = 'requirementtypes',
CapabilityType = 'capabilitytypes',
NodeTypeImplementation = 'nodetypeimplementations',
ServiceTemplate = 'servicetemplates',
NodeType = 'nodetypes',
RelationshipType = 'relationshiptypes',
ArtifactType = 'artifacttypes',
ArtifactTemplate = 'artifacttemplates',
RequirementType = 'requirementtypes',
CapabilityType = 'capabilitytypes',
NodeTypeImplementation = 'nodetypeimplementations',
RelationshipTypeImplementation = 'relationshiptypeimplementations',
PolicyType = 'policytypes',
PolicyTemplate = 'policytemplates',
Imports = 'imports',
Admin = 'admin'
PolicyType = 'policytypes',
PolicyTemplate = 'policytemplates',
Imports = 'imports',
Admin = 'admin'
}

/**
* ServiceTemplateTemplateTypes represent the instance types which are available in a Service Template.
* The types of these templates can be retrieved by using the {@link Utils.getTypeOfServiceTemplateTemplate} method.
*/
export enum ServiceTemplateTemplateTypes {
CapabilityTemplate = 'capabilityTemplates',
NodeTemplate = 'nodeTemplates',
CapabilityTemplate = 'capabilityTemplates',
NodeTemplate = 'nodeTemplates',
RelationshipTemplate = 'relationshipTemplates',
RequirementTemplate = 'requirementTemplates'
RequirementTemplate = 'requirementTemplates'
}

export enum StartNamespaces {
LocalStorageEntry = 'defaultNamespace',
DefaultStartNamespace = 'http://www.example.org/tosca'
}

/**
* BackendAvailabilityStates defines the states for the availability of the backend.
*/
export enum BackendAvailabilityStates {
Available = 1,
Available = 1,
Unavailable = 0,
Undefined = -1
Undefined = -1
}
Expand Up @@ -14,14 +14,14 @@
<div *ngIf="!loading" class="form-group">
<label for="namespace">Namespace</label>
<input #namespaceInput
id="namespace"
id="namespace"
class="form-control"
name="namespace"
autocomplete=off
[typeahead]="allNamespaces"
typeaheadOptionField="namespace"
[typeaheadOptionsLimit]="typeAheadListLimit"
[(ngModel)]="selectedNamespace"
[(ngModel)]="namespaceValue"
#namespace="ngModel"
[required]="isRequired"
pattern="^\S*$">
Expand All @@ -34,4 +34,28 @@
Namespace must not contain spaces!
</div>
</div>
<div *ngIf="useStartNamespace" style="margin-top: 20px">
<label for="initNamespace" class="control-label">Template: Start of namespace URI - used for automatic
namespace URI generation</label>
<div style="display: flex;">
<input #initNamespace
type="text"
class="form-control"
id="initNamespace"
name="initNamespace"
#namespaceStart="ngModel"
[(ngModel)]="initNamespaceString">
<button style="margin-left: 10px; width: 15%;" class="bnt btn-primary" (click)="applyNamespace()">Apply
</button>
</div>
<div *ngIf="namespaceStart.errors && (namespaceStart.dirty || namespaceStart.touched)"
class="alert alert-danger">
<div [hidden]="!namespaceStart.errors.required">
Namespace is required!
</div>
<div [hidden]="!namespaceStart.errors.pattern">
Namespace must not contain spaces!
</div>
</div>
</div>
</div>

0 comments on commit cdf9432

Please sign in to comment.