diff options
Diffstat (limited to 'mod2/ui/src/app/ms-instance-add')
4 files changed, 401 insertions, 0 deletions
diff --git a/mod2/ui/src/app/ms-instance-add/ms-instance-add.component.css b/mod2/ui/src/app/ms-instance-add/ms-instance-add.component.css new file mode 100644 index 0000000..8ecfc18 --- /dev/null +++ b/mod2/ui/src/app/ms-instance-add/ms-instance-add.component.css @@ -0,0 +1,48 @@ +/* + * # ============LICENSE_START======================================================= + * # Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. + * # ================================================================================ + * # Licensed under the Apache License, Version 2.0 (the "License"); + * # you may not use this file except in compliance with the License. + * # You may obtain a copy of the License at + * # + * # http://www.apache.org/licenses/LICENSE-2.0 + * # + * # Unless required by applicable law or agreed to in writing, software + * # distributed under the License is distributed on an "AS IS" BASIS, + * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * # See the License for the specific language governing permissions and + * # limitations under the License. + * # ============LICENSE_END========================================================= + */ + +.input{ + padding-top: 8px; +} + +.inputLabel { + font-weight: 600; + margin-left: 20px; + width: 165px; +} + +.inputFieldXSm { + width: 75px; + height: 30px; + padding-left: 6px; +} +.inputFieldSm { + width: 200px; + height: 30px; + padding-left: 6px; +} +.inputFieldMed { + width: 300px; + height: 30px; + padding-left: 6px; +} +.inputFieldLg { + width: 400px; + height: 30px; + padding-left: 6px; +}
\ No newline at end of file diff --git a/mod2/ui/src/app/ms-instance-add/ms-instance-add.component.html b/mod2/ui/src/app/ms-instance-add/ms-instance-add.component.html new file mode 100644 index 0000000..804de33 --- /dev/null +++ b/mod2/ui/src/app/ms-instance-add/ms-instance-add.component.html @@ -0,0 +1,93 @@ +<!-- + # ============LICENSE_START======================================================= + # Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. + # ================================================================================ + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + # ============LICENSE_END========================================================= + --> + +<p-dialog [(visible)]="visible" [header]="guiHeader" appendTo="body" [modal]="true" [transitionOptions]="'300ms'" [style]="{width: '720px'}" [baseZIndex]="10000" + [closable]="false" (onHide)="closeDialog()"> + + <!-- "Add / Change MS Instance" Error Message --> + <p-toast key="instanceAddChangeError"></p-toast> + + <form [formGroup]="msInstanceAddForm"> + <!-- * * * Name * * * --> + <div class="input"> + <label class="inputLabel">MS Name</label> + <b>{{msName}}</b> + </div> + <!-- * * * Release * * * --> + <div class="input"> + <label class="inputLabel">Release<span style="color:red">*</span></label> + <p-dropdown [options]="msInstanceReleases" placeholder="Select Release" formControlName="release"></p-dropdown> + </div> + <!-- * * * Scrum Lead / UID * * * --> + <div class="input"> + <label class="inputLabel">Scrum Lead/UID</label> + <input class="inputFieldLg" type="text" pInputText formControlName="scrumLead" /> / <input class="inputFieldXSm" type="text" pInputText formControlName="scrumLeadId" /> + </div> + <!-- * * * Systems Engineer / UID * * * --> + <div class="input"> + <label class="inputLabel">Systems Engineer/UID</label> + <input class="inputFieldLg" type="text" pInputText formControlName="systemsEngineer" /> / <input class="inputFieldXSm" type="text" pInputText formControlName="systemsEngineerId" /> + </div> + <!-- * * * Developer / UID * * * --> + <div class="input"> + <label class="inputLabel">Developer<span style="color:red">*</span>/UID<span style="color:red">*</span></label> + <input class="inputFieldLg" type="text" pInputText formControlName="developer" /> / <input class="inputFieldXSm" type="text" pInputText formControlName="developerId" /> + </div> + <!-- * * * PST Due Date * * * --> + <div class="input"> + <label class="inputLabel">PST Due Date</label> + <p-calendar appendTo="body" [baseZIndex]="10001" dateFormat="yy-mm-dd" formControlName="pstDueDate" [showIcon]="true"></p-calendar> + </div> + <!-- * * * PST Due Iteration * * * --> + <div class="input"> + <label class="inputLabel">PST Due Iteration</label> + <input class="inputFieldSm" type="text" pInputText formControlName="pstDueIteration" /> + </div> + <!-- * * * ETE Due Date * * * --> + <div class="input"> + <label class="inputLabel">ETE Due Date</label> + <p-calendar appendTo="body" [baseZIndex]="10001" dateFormat="yy-mm-dd" formControlName="eteDueDate" [showIcon]="true"></p-calendar> + </div> + <!-- * * * ETE Due Iteration * * * --> + <div class="input"> + <label class="inputLabel">ETE Due Iteration</label> + <input class="inputFieldSm" type="text" pInputText formControlName="eteDueIteration" /> + </div> + <!-- * * * Labels * * * --> + <div class="input"> + <label class="inputLabel">Labels</label> + <input class="inputFieldLg" type="text" pInputText formControlName="labels" /> + </div> + <span style="padding: 0px 0px 0px 188px; font-size: 13px;">(Separate labels with a space)</span> + <!-- * * * Notes * * * --> + <div class="input"> + <label class="inputLabel" style="vertical-align: top">Notes</label> + <textarea class="inputFieldLg" [rows]="1" [cols]="30" pInputTextarea autoResize="autoResize" formControlName="notes"></textarea> + </div> + + <!-- * * * ADD and Cancel buttons * * * --> + <div style="float: right; padding: 10px 25px 5px;"> + <button pButton type="button" (click)="closeDialog()" label="Cancel"></button> + <button pButton type="submit" (click)="submitMsInstance()" class="ui-button-success" [label]="addOrUpdate" style="width: 77px" + [disabled]="!msInstanceAddForm.valid || + !msInstanceAddForm.value['developer'].trim() || + !msInstanceAddForm.value['developerId'].trim()"></button> + </div> + </form> + +</p-dialog>
\ No newline at end of file diff --git a/mod2/ui/src/app/ms-instance-add/ms-instance-add.component.spec.ts b/mod2/ui/src/app/ms-instance-add/ms-instance-add.component.spec.ts new file mode 100644 index 0000000..2318a2c --- /dev/null +++ b/mod2/ui/src/app/ms-instance-add/ms-instance-add.component.spec.ts @@ -0,0 +1,71 @@ +/* + * # ============LICENSE_START======================================================= + * # Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. + * # ================================================================================ + * # Licensed under the Apache License, Version 2.0 (the "License"); + * # you may not use this file except in compliance with the License. + * # You may obtain a copy of the License at + * # + * # http://www.apache.org/licenses/LICENSE-2.0 + * # + * # Unless required by applicable law or agreed to in writing, software + * # distributed under the License is distributed on an "AS IS" BASIS, + * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * # See the License for the specific language governing permissions and + * # limitations under the License. + * # ============LICENSE_END========================================================= + */ + +import { DatePipe } from '@angular/common'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { RouterTestingModule } from '@angular/router/testing'; +import { JwtHelperService, JWT_OPTIONS } from '@auth0/angular-jwt'; +import { MessageService } from 'primeng/api'; +import { ButtonModule } from 'primeng/button'; +import { CalendarModule } from 'primeng/calendar'; +import { DialogModule } from 'primeng/dialog'; +import { DropdownModule } from 'primeng/dropdown'; +import { ToastModule } from 'primeng/toast'; + +import { MsInstanceAddComponent } from './ms-instance-add.component'; + +describe('MsInstanceAddComponent', () => { + let component: MsInstanceAddComponent; + let fixture: ComponentFixture<MsInstanceAddComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [MsInstanceAddComponent], + imports: [ + DialogModule, + DropdownModule, + ToastModule, + FormsModule, + ReactiveFormsModule, + ButtonModule, + HttpClientTestingModule, + RouterTestingModule, + CalendarModule, + ], + providers: [ + MessageService, + DatePipe, + { provide: JWT_OPTIONS, useValue: JWT_OPTIONS }, + JwtHelperService + ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(MsInstanceAddComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/mod2/ui/src/app/ms-instance-add/ms-instance-add.component.ts b/mod2/ui/src/app/ms-instance-add/ms-instance-add.component.ts new file mode 100644 index 0000000..228ddc1 --- /dev/null +++ b/mod2/ui/src/app/ms-instance-add/ms-instance-add.component.ts @@ -0,0 +1,189 @@ +/* + * # ============LICENSE_START======================================================= + * # Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. + * # ================================================================================ + * # Licensed under the Apache License, Version 2.0 (the "License"); + * # you may not use this file except in compliance with the License. + * # You may obtain a copy of the License at + * # + * # http://www.apache.org/licenses/LICENSE-2.0 + * # + * # Unless required by applicable law or agreed to in writing, software + * # distributed under the License is distributed on an "AS IS" BASIS, + * # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * # See the License for the specific language governing permissions and + * # limitations under the License. + * # ============LICENSE_END========================================================= + */ + +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { MicroserviceInstanceService } from '../services/microservice-instance.service'; +import { MessageService } from 'primeng/api'; +import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms'; +import { AuthService } from '../services/auth.service'; +import { DatePipe } from '@angular/common'; + +@Component({ + selector: 'app-ms-instance-add', + templateUrl: './ms-instance-add.component.html', + styleUrls: ['./ms-instance-add.component.css'] +}) +export class MsInstanceAddComponent implements OnInit { + + guiHeader: string = "Microservice Instance ADD"; + // Used for the Add/Update button label + addOrUpdate: string = "Add"; + + msInstanceAddForm: FormGroup; + msInstanceToAdd: AddMsInstance; + addInstanceTo: string = ""; + username: string; + msInstanceReleases: { label: string, value: string }[] = [ + { label: '2004', value: '2004' }, + { label: '2006', value: '2006' }, + { label: '2008', value: '2008' }, + { label: '2009', value: '2009' }, + { label: '2010', value: '2010' }, + { label: '2011', value: '2011' }, + { label: '2012', value: '2012' } + ] + + @Input() visible: boolean; + @Input() msName: string; + @Input() msInstanceChange: string; // Use to differentiate Add from Change, since currentRow can be problematic + @Input() currentRow: any; + @Output() handler: EventEmitter<any> = new EventEmitter(); + + constructor(private addChangeMsInstanceApi: MicroserviceInstanceService, private messageService: MessageService, private fb: FormBuilder, private authService: AuthService, private datePipe: DatePipe) { } + + ngOnInit() { + this.username = this.authService.getUser().username; + + this.msInstanceAddForm = new FormGroup({ + name: new FormControl(), + release: new FormControl(), + scrumLead: new FormControl(), + scrumLeadId: new FormControl(), + systemsEngineer: new FormControl(), + systemsEngineerId: new FormControl(), + developer: new FormControl(), + developerId: new FormControl(), + status: new FormControl(), + pstDueDate: new FormControl(), + pstDueIteration: new FormControl(), + eteDueDate: new FormControl(), + eteDueIteration: new FormControl(), + labels: new FormControl(), + notes: new FormControl() + }); + + this.msInstanceAddForm = this.fb.group({ + name: ['', []], + release: ['', [Validators.required]], + scrumLead: ['', []], + scrumLeadId: ['', []], + systemsEngineer: ['', []], + systemsEngineerId: ['', []], + developer: ['', [Validators.required]], + developerId: ['', [Validators.required]], + status: ['', []], + pstDueDate: ['', []], + pstDueIteration: ['', []], + eteDueDate: ['', []], + eteDueIteration: ['', []], + labels: ['', []], + notes: ['', []] + }); + + if (this.msInstanceChange) { + this.guiHeader = "Microservice Instance Update"; + this.addOrUpdate = "Update"; + this.populateFields(); + } + } + + populateFields() { + this.msName = this.currentRow['name']; + + let labelsStr: string; + if (this.currentRow['metadata']['labels']) { + labelsStr = this.currentRow['metadata']['labels'].join(' ') + } + + this.msInstanceAddForm.patchValue({ + release: this.currentRow['release'], + scrumLead: this.currentRow['metadata']['scrumLead'], + scrumLeadId: this.currentRow['metadata']['scrumLeadId'], + systemsEngineer: this.currentRow['metadata']['systemsEngineer'], + systemsEngineerId: this.currentRow['metadata']['systemsEngineerId'], + developer: this.currentRow['metadata']['developer'], + developerId: this.currentRow['metadata']['developerId'], + pstDueDate: this.currentRow['pstDueDate'], + pstDueIteration: this.currentRow['pstDueIteration'], + eteDueDate: this.currentRow['eteDueDate'], + eteDueIteration: this.currentRow['eteDueIteration'], + labels: labelsStr, + notes: this.currentRow['metadata']['notes'] + }) +} + + /* * * * On click of cancel * * * */ + closeDialog() { + this.visible = false; + this.handler.emit(null) + } + + /* * * * On click of add * * * */ + submitMsInstance() { + // Prevent error on "split" if record existed before "labels" were implemented + let labels: string[] = [] + if (!this.msInstanceAddForm.value['labels']){ + labels = [] + } else { + labels = this.msInstanceAddForm.value['labels'].trim().replace(/\s{2,}/g, ' ').split(" ") + } + + //build request body + this.msInstanceToAdd = { + name: this.msName, + release: this.msInstanceAddForm.value['release'], + metadata: { + scrumLead: this.msInstanceAddForm.value['scrumLead'], + scrumLeadId: this.msInstanceAddForm.value['scrumLeadId'], + systemsEngineer: this.msInstanceAddForm.value['systemsEngineer'], + systemsEngineerId: this.msInstanceAddForm.value['systemsEngineerId'], + developer: this.msInstanceAddForm.value['developer'], + developerId: this.msInstanceAddForm.value['developerId'], + pstDueDate: this.msInstanceAddForm.value['pstDueDate'], + pstDueIteration: this.msInstanceAddForm.value['pstDueIteration'], + eteDueDate: this.msInstanceAddForm.value['eteDueDate'], + eteDueIteration: this.msInstanceAddForm.value['eteDueIteration'], + labels: labels, + notes: this.msInstanceAddForm.value['notes'] + }, + user: this.username + } + + this.handler.emit(this.msInstanceToAdd) //return request body back to parent + } +} + +export interface AddMsInstance { + name: string, + release: string, + metadata: { + scrumLead: string, + scrumLeadId: string, + systemsEngineer: string, + systemsEngineerId: string, + developer: string, + developerId: string, + pstDueDate: any, + pstDueIteration: string, + eteDueDate: any, + eteDueIteration: string, + labels: string[], + notes: string + } + user: string +}
\ No newline at end of file |