* Added a list to show the repo added.
* Form to add the repo path with the type.
Change-Id: I77ddbf6ef4c7f02abd2e5bc455b3a21e04e5b20d
Signed-off-by: Barath Kumar R <barath.r@tataelxsi.co.in>
loadChildren: async (): Promise<any> => import('./k8s/K8sModule')
.then((m: typeof import('./k8s/K8sModule')) => m.K8sModule),
canActivate: [AuthGuardService]
+ },
+ {
+ path: 'repos',
+ // tslint:disable-next-line: no-any
+ loadChildren: async (): Promise<any> => import('./osm-repositories/OsmRepositoriesModule')
+ .then((m: typeof import('./osm-repositories/OsmRepositoriesModule')) => m.OsmRepositoriesModule),
+ canActivate: [AuthGuardService]
}
]
},
--- /dev/null
+<!--
+Copyright 2020 TATA ELXSI
+
+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.
+
+Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+-->
+<router-outlet></router-outlet>
--- /dev/null
+/*
+ Copyright 2020 TATA ELXSI
+
+ 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.
+
+ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+ */
\ No newline at end of file
--- /dev/null
+/*
+ Copyright 2020 TATA ELXSI
+
+ 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.
+
+ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+*/
+/**
+ * @file OsmRepositoriesComponent.ts
+ */
+import { Component, Injector } from '@angular/core';
+import { Router, RouterEvent } from '@angular/router';
+/**
+ * Creating Component
+ * @Component takes OsmRepositoriesComponent.html as template url
+ */
+@Component({
+ selector: 'app-osmrepositories',
+ templateUrl: './OsmRepositoriesComponent.html',
+ styleUrls: ['./OsmRepositoriesComponent.scss']
+})
+/** Exporting a class @exports OsmRepositoriesComponent */
+export class OsmRepositoriesComponent{
+ /** Invoke service injectors @public */
+ public injector: Injector;
+
+ /** Holds teh instance of router service @private */
+ private router: Router;
+
+ /** creates OSM Repo component */
+ constructor(injector: Injector) {
+ this.injector = injector;
+ this.router = this.injector.get(Router);
+ this.router.events.subscribe((event: RouterEvent) => {
+ this.redirectToList(event.url);
+ });
+ }
+
+ /** Return to osm Repo Details list */
+ public redirectToList(getURL: string): void {
+ if (getURL === '/repos') {
+ this.router.navigate(['/repos/details']).catch();
+ }
+ }
+}
--- /dev/null
+/*
+ Copyright 2020 TATA ELXSI
+
+ 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.
+
+ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+*/
+/**
+ * @file Osm Repository Module.
+ */
+import { CommonModule } from '@angular/common';
+import { HttpClientModule } from '@angular/common/http';
+import { NgModule } from '@angular/core';
+import { FormsModule } from '@angular/forms';
+import { ReactiveFormsModule } from '@angular/forms';
+import { RouterModule, Routes } from '@angular/router';
+import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
+import { NgSelectModule } from '@ng-select/ng-select';
+import { TranslateModule } from '@ngx-translate/core';
+import { DataService } from 'DataService';
+import { LoaderModule } from 'LoaderModule';
+import { Ng2SmartTableModule } from 'ng2-smart-table';
+import { OsmRepoCreateUpdateComponent } from 'OsmRepoCreateUpdate';
+import { OsmRepositoriesComponent } from 'OsmRepositories';
+import { OsmRepositoriesActionComponent } from 'OsmRepositoriesAction';
+import { OsmRepositoriesDetailsComponent } from 'OsmRepositoriesDetails';
+import { PagePerRowModule } from 'PagePerRowModule';
+import { PageReloadModule } from 'PageReloadModule';
+
+/** To halndle project information */
+const projectInfo: {} = { title: '{project}', url: '/' };
+
+/**
+ * configures routers
+ */
+const routes: Routes = [
+ {
+ path: '',
+ component: OsmRepositoriesComponent,
+ children: [
+ {
+ path: 'details',
+ data: {
+ breadcrumb: [{ title: 'PAGE.DASHBOARD.DASHBOARD', url: '/' }, { title: 'PAGE.DASHBOARD.PROJECTS', url: '/projects' },
+ projectInfo, { title: 'PAGE.OSMREPO.MENUOSMREPO', url: null }]
+ },
+ component: OsmRepositoriesDetailsComponent
+ }
+ ]
+ }
+];
+/**
+ * Creating @NgModule component for Modules
+ */
+// tslint:disable-next-line: no-stateless-class
+@NgModule({
+ imports: [FormsModule, ReactiveFormsModule, CommonModule, HttpClientModule, TranslateModule,
+ RouterModule.forChild(routes), NgbModule, PagePerRowModule, Ng2SmartTableModule, LoaderModule, PageReloadModule, NgSelectModule],
+ declarations: [OsmRepositoriesComponent, OsmRepositoriesDetailsComponent, OsmRepositoriesActionComponent, OsmRepoCreateUpdateComponent],
+ providers: [
+ DataService
+ ],
+ entryComponents: [
+ OsmRepoCreateUpdateComponent
+ ]
+})
+/** Exporting a class @exports OsmRepositoriesModule */
+export class OsmRepositoriesModule { }
--- /dev/null
+<!--
+Copyright 2020 TATA ELXSI
+
+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.
+
+Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+-->
+<form [formGroup]="osmrepoForm" (ngSubmit)="osmRepoSubmit();">
+ <div class="modal-header">
+ <h4 class="modal-title" id="modal-basic-title">{{(getCreateupdateType === 'Add' ? 'PAGE.OSMREPO.NEWOSMREPO' : 'PAGE.OSMREPO.EDITOSMREPO') | translate }}</h4>
+ <button class="button-xs" type="button" class="close" aria-label="Close" (click)="activeModal.close()">
+ <i class="fas fa-times-circle text-danger"></i>
+ </button>
+ </div>
+ <div class="modal-body osmrepoadd">
+ <div class="form-group row">
+ <label class="col-sm-12 col-form-label mandatory-label"
+ [ngClass]="{'text-danger': osmrepoForm.invalid === true && submitted === true}">{{'MANDATORYCHECK' | translate}}</label>
+ <label class="col-sm-4 col-form-label" for="name">{{'NAME' | translate}}*</label>
+ <div class="col-sm-8">
+ <input autocomplete="off" class="form-control" placeholder="{{'NAME' | translate}}" type="text"
+ formControlName="name" id="name" [ngClass]="{ 'is-invalid': submitted && f.name.errors }"
+ maxlength="{{sharedService.MAX_LENGTH_NAME}}" required>
+ </div>
+ </div>
+ <div class="form-group row">
+ <label class="col-sm-4 col-form-label" for="type">{{'TYPE' | translate}}*</label>
+ <div class="col-sm-8">
+ <ng-select bindLabel="title" bindValue="value" [items]="osmrepoType"
+ placeholder="{{'SELECT' | translate}} {{'TYPE' | translate}}" formControlName="type" id="type"
+ [ngClass]="{ 'is-invalid': submitted && f.type.errors }" required>
+ </ng-select>
+ </div>
+ </div>
+ <div class="form-group row">
+ <label class="col-sm-4 col-form-label" for="url">{{'URL' | translate}}*</label>
+ <div class="col-sm-8">
+ <input autocomplete="off" class="form-control" placeholder="{{'URL' | translate}}" type="url"
+ formControlName="url" id="url" [ngClass]="{ 'is-invalid': submitted && f.url.errors }" required>
+ <div *ngIf="osmrepoForm.invalid" class="invalid-feedback">
+ <div *ngIf="f.url.errors && f.url.value">{{'DOMVALIDATIONS.INVALIDURL' | translate}}</div>
+ </div>
+ </div>
+ </div>
+ <div class="form-group row">
+ <label class="col-sm-4 col-form-label" for="description">{{'DESCRIPTION' | translate}}*</label>
+ <div class="col-sm-8">
+ <textarea rows="5" cols="50" class="form-control" placeholder="{{'DESCRIPTION' | translate}}" type="text"
+ formControlName="description" id="description" [ngClass]="{ 'is-invalid': submitted && f.description.errors }"
+ maxlength="{{sharedService.MAX_LENGTH_DESCRIPTION}}" required></textarea>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-danger" (click)="activeModal.close()">{{'CANCEL' | translate}}</button>
+ <button type="submit"
+ class="btn btn-primary">{{(getCreateupdateType === 'Add' ? 'ADD' : 'UPDATE') | translate}}</button>
+ </div>
+</form>
+<app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
\ No newline at end of file
--- /dev/null
+/*
+ Copyright 2020 TATA ELXSI
+
+ 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.
+
+ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+ */
\ No newline at end of file
--- /dev/null
+/*
+ Copyright 2020 TATA ELXSI
+
+ 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.
+
+ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+*/
+/**
+ * @file OsmRepoCreateUpdateComponent.ts
+ */
+import { Component, Injector, Input, OnInit } from '@angular/core';
+import { FormBuilder, FormGroup, Validators } from '@angular/forms';
+import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
+import { TranslateService } from '@ngx-translate/core';
+import { NotifierService } from 'angular-notifier';
+import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA, OSMREPO_TYPES, TYPESECTION } from 'CommonModel';
+import { environment } from 'environment';
+import { OSMRepoDetails } from 'OsmRepoModel';
+import { RestService } from 'RestService';
+import { SharedService } from 'SharedService';
+/**
+ * Creating Component
+ * @Component takes OsmRepoCreateUpdateComponent.html as template url
+ */
+@Component({
+ selector: 'app-osm-repo-create-update',
+ templateUrl: './OsmRepoCreateUpdateComponent.html',
+ styleUrls: ['./OsmRepoCreateUpdateComponent.scss']
+})
+export class OsmRepoCreateUpdateComponent implements OnInit {
+ /** To inject services @public */
+ public injector: Injector;
+
+ /** Instance of the rest service @public */
+ public restService: RestService;
+
+ /** Instance for active modal service @public */
+ public activeModal: NgbActiveModal;
+
+ /** Setting OSM Repo types in array @public */
+ public osmrepoType: TYPESECTION[];
+
+ /** FormGroup osm repo added to the form @ html @public */
+ public osmrepoForm: FormGroup;
+
+ /** Form submission Add */
+ public submitted: boolean = false;
+
+ /** Check the loading results for loader status @public */
+ public isLoadingResults: boolean = false;
+
+ /** Give the message for the loading @public */
+ public message: string = 'PLEASEWAIT';
+
+ /** Contains osm repo create or edit @public */
+ public getCreateupdateType: string;
+
+ /** To inject input type services For creation or edit @public */
+ @Input() public createupdateType: string;
+
+ /** To inject input type services for ID @public */
+ @Input() public osmrepoid: string;
+
+ /** Contains all methods related to shared @public */
+ public sharedService: SharedService;
+
+ /** FormBuilder instance added to the formBuilder @private */
+ private formBuilder: FormBuilder;
+
+ /** Notifier service to popup notification @private */
+ private notifierService: NotifierService;
+
+ /** Contains tranlsate instance @private */
+ private translateService: TranslateService;
+
+ constructor(injector: Injector) {
+ this.injector = injector;
+ this.formBuilder = this.injector.get(FormBuilder);
+ this.restService = this.injector.get(RestService);
+ this.activeModal = this.injector.get(NgbActiveModal);
+ this.notifierService = this.injector.get(NotifierService);
+ this.translateService = this.injector.get(TranslateService);
+ this.sharedService = this.injector.get(SharedService);
+ }
+
+ /** convenience getter for easy access to form fields */
+ get f(): FormGroup['controls'] { return this.osmrepoForm.controls; }
+
+ public ngOnInit(): void {
+ this.osmrepoType = OSMREPO_TYPES;
+ this.osmRepoFormInitialize();
+ this.getCreateupdateType = this.createupdateType;
+ if (this.getCreateupdateType === 'Edit') {
+ this.fetchAssigndata();
+ }
+ }
+
+ /** On modal initializing forms @public */
+ public osmRepoFormInitialize(): void {
+ this.osmrepoForm = this.formBuilder.group({
+ name: [null, [Validators.required]],
+ type: [null, [Validators.required]],
+ url: [null, [Validators.required, Validators.pattern(this.sharedService.REGX_URL_PATTERN)]],
+ description: [null, [Validators.required]]
+ });
+ }
+
+ /** Assign and get the osm repo details for edit section @public */
+ public fetchAssigndata(): void {
+ this.isLoadingResults = true;
+ this.restService.getResource(environment.OSMREPOS_URL + '/' + this.osmrepoid).subscribe((data: OSMRepoDetails) => {
+ this.osmrepoForm.setValue({
+ name: data.name,
+ type: data.type,
+ url: data.url,
+ description: data.description
+ });
+ this.isLoadingResults = false;
+ }, (error: ERRORDATA) => {
+ this.restService.handleError(error, 'get');
+ this.isLoadingResults = false;
+ });
+ }
+
+ /** On modal submit osm Repo will called @public */
+ public osmRepoSubmit(): void {
+ this.submitted = true;
+ this.sharedService.cleanForm(this.osmrepoForm);
+ if (this.osmrepoForm.invalid) {
+ return;
+ }
+ this.isLoadingResults = true;
+ const modalData: MODALCLOSERESPONSEDATA = {
+ message: 'Done'
+ };
+ if (this.getCreateupdateType === 'Add') {
+ const apiURLHeader: APIURLHEADER = {
+ url: environment.OSMREPOS_URL
+ };
+ this.addOsmRepo(apiURLHeader, modalData);
+ } else if (this.getCreateupdateType === 'Edit') {
+ const apiURLHeader: APIURLHEADER = {
+ url: environment.OSMREPOS_URL + '/' + this.osmrepoid
+ };
+ this.editOsmRepo(apiURLHeader, modalData);
+ } else {
+ this.notifierService.notify('error', this.translateService.instant('ERROR'));
+ }
+ }
+
+ /** This function used to add the osm repo @public */
+ public addOsmRepo(apiURLHeader: APIURLHEADER, modalData: MODALCLOSERESPONSEDATA): void {
+ this.restService.postResource(apiURLHeader, this.osmrepoForm.value).subscribe(() => {
+ this.activeModal.close(modalData);
+ this.notifierService.notify('success', this.translateService.instant('PAGE.OSMREPO.CREATEDSUCCESSFULLY'));
+ this.isLoadingResults = false;
+ }, (error: ERRORDATA) => {
+ this.isLoadingResults = false;
+ this.restService.handleError(error, 'post');
+ });
+ }
+
+ /** This function used to Edit the osm repo @public */
+ public editOsmRepo(apiURLHeader: APIURLHEADER, modalData: MODALCLOSERESPONSEDATA): void {
+ this.restService.patchResource(apiURLHeader, this.osmrepoForm.value).subscribe(() => {
+ this.activeModal.close(modalData);
+ this.notifierService.notify('success', this.translateService.instant('PAGE.OSMREPO.UPDATEDSUCCESSFULLY'));
+ this.isLoadingResults = false;
+ }, (error: ERRORDATA) => {
+ this.isLoadingResults = false;
+ this.restService.handleError(error, 'patch');
+ });
+ }
+}
--- /dev/null
+<!--
+Copyright 2020 TATA ELXSI
+
+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.
+
+Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+-->
+<div class="row d-flex flex-row justify-content-between">
+ <div class="d-flex align-items-center header-style">{{'PAGE.OSMREPO.OSMREPOTITLE' | translate}}</div>
+ <span class="button">
+ <button class="btn btn-primary" type="button" (click)="addOsmrepo()" placement="top" container="body" ngbTooltip="{{'PAGE.OSMREPO.ADDOSMREPO' | translate}}">
+ <i class="fas fa-plus-circle" aria-hidden="true"></i>
+ {{'PAGE.OSMREPO.ADDOSMREPO' | translate}}
+ </button>
+ </span>
+</div>
+<div class="row mt-2 mb-0 form-group justify-content-end list-utilites-actions">
+ <page-per-row class="mr-2" (pagePerRow)="onChange($event)"></page-per-row>
+ <page-reload></page-reload>
+</div>
+<div class="smarttable-style bg-white mt-1">
+ <ng2-smart-table [settings]="settings" [source]="dataSource" (userRowSelect)="onUserRowSelect($event)">
+ </ng2-smart-table>
+</div>
+<app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
--- /dev/null
+/*
+ Copyright 2020 TATA ELXSI
+
+ 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.
+
+ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+ */
\ No newline at end of file
--- /dev/null
+/*
+ Copyright 2020 TATA ELXSI
+
+ 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.
+
+ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+*/
+/**
+ * @file OsmRepositoriesDetailsComponent.ts
+ */
+import { Component, Injector, OnDestroy, OnInit } from '@angular/core';
+import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
+import { TranslateService } from '@ngx-translate/core';
+import { ERRORDATA, MODALCLOSERESPONSEDATA, OSMREPO_TYPES } from 'CommonModel';
+import { DataService } from 'DataService';
+import { environment } from 'environment';
+import { LocalDataSource } from 'ng2-smart-table';
+import { OsmRepoCreateUpdateComponent } from 'OsmRepoCreateUpdate';
+import { OSMRepoData, OSMRepoDetails } from 'OsmRepoModel';
+import { OsmRepositoriesActionComponent } from 'OsmRepositoriesAction';
+import { RestService } from 'RestService';
+import { Subscription } from 'rxjs';
+import { SharedService } from 'SharedService';
+/**
+ * Creating Component
+ * @Component takes OsmRepositoriesComponent.html as template url
+ */
+@Component({
+ selector: 'app-osm-repositories-details',
+ templateUrl: './OsmRepositoriesDetailsComponent.html',
+ styleUrls: ['./OsmRepositoriesDetailsComponent.scss']
+})
+export class OsmRepositoriesDetailsComponent implements OnInit {
+ /** To inject services @public */
+ public injector: Injector;
+
+ /** handle translate @public */
+ public translateService: TranslateService;
+
+ /** Data of smarttable populate through LocalDataSource @public */
+ public dataSource: LocalDataSource = new LocalDataSource();
+
+ /** Columns list of the smart table @public */
+ public columnLists: object = {};
+
+ /** Settings for smarttable to populate the table with columns @public */
+ public settings: object = {};
+
+ /** Check the loading results @public */
+ public isLoadingResults: boolean = true;
+
+ /** Give the message for the loading @public */
+ public message: string = 'PLEASEWAIT';
+
+ /** Contains osm repo details data @public */
+ public osmRepoData: OSMRepoData[] = [];
+
+ /** Instance of the rest service @private */
+ private restService: RestService;
+
+ /** dataService to pass the data from one component to another @private */
+ private dataService: DataService;
+
+ /** Instance of the modal service @private */
+ private modalService: NgbModal;
+
+ /** Contains all methods related to shared @private */
+ private sharedService: SharedService;
+
+ /** Instance of subscriptions @private */
+ private generateDataSub: Subscription;
+
+ // creates osm repository component
+ constructor(injector: Injector) {
+ this.injector = injector;
+ this.restService = this.injector.get(RestService);
+ this.dataService = this.injector.get(DataService);
+ this.sharedService = this.injector.get(SharedService);
+ this.modalService = this.injector.get(NgbModal);
+ this.translateService = this.injector.get(TranslateService);
+ }
+
+ /** Lifecyle Hooks the trigger before component is instantiate @public */
+ public ngOnInit(): void {
+ this.generateColumns();
+ this.generateSettings();
+ this.generateData();
+ this.generateDataSub = this.sharedService.dataEvent.subscribe(() => { this.generateData(); });
+ }
+
+ /** smart table listing manipulation @private */
+ public onChange(perPageValue: number): void {
+ this.dataSource.setPaging(1, perPageValue, true);
+ }
+
+ /** convert UserRowSelect Function @private */
+ public onUserRowSelect(event: MessageEvent): void {
+ Object.assign(event.data, { page: 'osmrepo' });
+ this.dataService.changeMessage(event.data);
+ }
+
+ /** smart table Header Colums @public */
+ public generateColumns(): void {
+ this.columnLists = {
+ name: { title: this.translateService.instant('NAME'), width: '15%', sortDirection: 'asc' },
+ identifier: { title: this.translateService.instant('IDENTIFIER'), width: '15%' },
+ url: { title: this.translateService.instant('URL'), width: '15%' },
+ type: {
+ title: this.translateService.instant('TYPE'), width: '15%',
+ filter: {
+ type: 'list',
+ config: {
+ selectText: 'Select',
+ list: OSMREPO_TYPES
+ }
+ }
+ },
+ modified: { title: this.translateService.instant('MODIFIED'), width: '15%' },
+ created: { title: this.translateService.instant('CREATED'), width: '15%' },
+ Actions: {
+ name: 'Action', width: '10%', filter: false, sort: false, type: 'custom',
+ title: this.translateService.instant('ACTIONS'),
+ valuePrepareFunction: (cell: OSMRepoData, row: OSMRepoData): OSMRepoData => row,
+ renderComponent: OsmRepositoriesActionComponent
+ }
+ };
+ }
+
+ /** smart table Data Settings @public */
+ public generateSettings(): void {
+ this.settings = {
+ columns: this.columnLists,
+ actions: {
+ add: false,
+ edit: false,
+ delete: false,
+ position: 'right'
+ },
+ attr: this.sharedService.tableClassConfig(),
+ pager: this.sharedService.paginationPagerConfig(),
+ noDataMessage: this.translateService.instant('NODATAMSG')
+ };
+ }
+
+ /** Generate osmRepoData object from loop and return for the datasource @public */
+ public generateOsmRepoData(osmRepo: OSMRepoDetails): OSMRepoData {
+ return {
+ name: osmRepo.name,
+ identifier: osmRepo._id,
+ url: osmRepo.url,
+ type: osmRepo.type,
+ description: osmRepo.description,
+ modified: this.sharedService.convertEpochTime(Number(osmRepo._admin.modified)),
+ created: this.sharedService.convertEpochTime(Number(osmRepo._admin.created))
+ };
+ }
+
+ /** Create a osm repo @public */
+ public addOsmrepo(): void {
+ const modalRef: NgbModalRef = this.modalService.open(OsmRepoCreateUpdateComponent, { backdrop: 'static' });
+ modalRef.componentInstance.createupdateType = 'Add';
+ modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+ if (result) {
+ this.generateData();
+ }
+ }).catch();
+ }
+
+ /**
+ * Lifecyle hook which get trigger on component destruction
+ */
+ public ngOnDestroy(): void {
+ this.generateDataSub.unsubscribe();
+ }
+
+ /** Fetching the data from server to Load in the smarttable @protected */
+ protected generateData(): void {
+ this.isLoadingResults = true;
+ this.restService.getResource(environment.OSMREPOS_URL).subscribe((osmRepoData: OSMRepoDetails[]) => {
+ this.osmRepoData = [];
+ osmRepoData.forEach((osmRepo: OSMRepoDetails) => {
+ const osmRepoDataObj: OSMRepoData = this.generateOsmRepoData(osmRepo);
+ this.osmRepoData.push(osmRepoDataObj);
+ });
+ this.dataSource.load(this.osmRepoData).then((data: boolean) => {
+ this.isLoadingResults = false;
+ }).catch();
+ }, (error: ERRORDATA) => {
+ this.restService.handleError(error, 'get');
+ this.isLoadingResults = false;
+ });
+ }
+}
} else if (data.page === 'k8-repo') {
this.deleteURL = environment.K8REPOS_URL;
this.notifyMessage = 'DELETEDSUCCESSFULLY';
+ } else if (data.page === 'osmrepo') {
+ this.deleteURL = environment.OSMREPOS_URL;
+ this.notifyMessage = 'DELETEDSUCCESSFULLY';
}
}
/** Generate Data function @public */
--- /dev/null
+<!--
+Copyright 2020 TATA ELXSI
+
+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.
+
+Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+-->
+<div class="btn-group list action" role="group">
+ <button type="button" class="btn btn-primary" (click)="editOsmrepo(identifier)" placement="top" container="body"
+ ngbTooltip="{{'EDIT' | translate}} {{osmrepoName}}">
+ <i class="fas fa-edit"></i>
+ </button>
+ <button type="button" class="btn btn-primary" (click)="deleteOsmRepository()" placement="top" container="body"
+ ngbTooltip="{{'DELETE' | translate}} {{osmrepoName}}">
+ <i class="fas fa-trash-alt"></i>
+ </button>
+</div>
\ No newline at end of file
--- /dev/null
+/*
+ Copyright 2020 TATA ELXSI
+
+ 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.
+
+ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+ */
\ No newline at end of file
--- /dev/null
+/*
+ Copyright 2020 TATA ELXSI
+
+ 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.
+
+ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+*/
+/**
+ * @file OsmRepositoriesActionComponent.ts
+ */
+import { Component, Injector, OnInit } from '@angular/core';
+import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
+import { MODALCLOSERESPONSEDATA } from 'CommonModel';
+import { DeleteComponent } from 'DeleteComponent';
+import { OsmRepoCreateUpdateComponent } from 'OsmRepoCreateUpdate';
+import { OSMRepoData } from 'OsmRepoModel';
+import { SharedService } from 'SharedService';
+/**
+ * Creating Component
+ * @Component takes OsmRepositoriesActionComponent.html as template url
+ */
+@Component({
+ selector: 'app-osm-repositories-action',
+ templateUrl: './OsmRepositoriesActionComponent.html',
+ styleUrls: ['./OsmRepositoriesActionComponent.scss']
+})
+/** Exporting a class @exports OsmRepositoriesActionComponent */
+export class OsmRepositoriesActionComponent implements OnInit {
+ /** To get the value from the osm repo via valuePrepareFunction default Property of ng-smarttable @public */
+ public value: OSMRepoData;
+
+ /** To inject services @public */
+ public injector: Injector;
+
+ /** Variables holds OSM repo name @public */
+ public osmrepoName: string;
+
+ /** Variables holds OSM repo id @public */
+ public identifier: string;
+
+ /** Instance of the modal service @private */
+ private modalService: NgbModal;
+
+ /** Contains all methods related to shared @private */
+ private sharedService: SharedService;
+
+ constructor(injector: Injector) {
+ this.injector = injector;
+ this.sharedService = this.injector.get(SharedService);
+ this.modalService = this.injector.get(NgbModal);
+ }
+
+ /** Lifecyle Hooks the trigger before component is instantiate @public */
+ public ngOnInit(): void {
+ this.osmrepoName = this.value.name;
+ this.identifier = this.value.identifier;
+ }
+
+ /** Delete OSM Repository @public */
+ public deleteOsmRepository(): void {
+ const modalRef: NgbModalRef = this.modalService.open(DeleteComponent, { backdrop: 'static' });
+ modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+ if (result) {
+ this.sharedService.callData();
+ }
+ }).catch();
+ }
+
+ /** Edit a osm repo @public */
+ public editOsmrepo(id: string): void {
+ const modalRef: NgbModalRef = this.modalService.open(OsmRepoCreateUpdateComponent, { backdrop: 'static' });
+ modalRef.componentInstance.createupdateType = 'Edit';
+ modalRef.componentInstance.osmrepoid = id;
+ modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+ if (result) {
+ this.sharedService.callData();
+ }
+ }).catch();
+ }
+}
}
]
},
+ {
+ "title": "OSM Repositories",
+ "permissions": [
+ {
+ "operation": "osmrepos",
+ "value": "NA"
+ },
+ {
+ "operation": "osmrepos:get",
+ "value": "NA"
+ },
+ {
+ "operation": "osmrepos:post",
+ "value": "NA"
+ },
+ {
+ "operation": "osmrepos:id:get",
+ "value": "NA"
+ },
+ {
+ "operation": "osmrepos:id:delete",
+ "value": "NA"
+ },
+ {
+ "operation": "osmrepos:id:patch",
+ "value": "NA"
+ }
+ ]
+ },
{
"title": "Users",
"permissions": [
"NEWK8SREPO": "Nieuwe K8s Repository",
"TYPE": "Type",
"URL": "URL"
+ },
+ "OSMREPO": {
+ "MENUOSMREPO": "OSM-Repositorys",
+ "ADDOSMREPO": "Fügen Sie OSM-Repositorys hinzu",
+ "NEWOSMREPO": "Neue OSM-Repositorys",
+ "EDITOSMREPO": "Bearbeiten Sie OSM-Repositorys",
+ "OSMREPOTITLE": "Registriertes OSM-Repository",
+ "CREATEDSUCCESSFULLY": "OSM-Repository erfolgreich hinzugefügt",
+ "UPDATEDSUCCESSFULLY" : "OSM-Repository erfolgreich aktualisiert"
}
},
"HTTPERROR": {
"NEWK8SREPO": "New K8s Repository",
"TYPE": "Type",
"URL": "URL"
+ },
+ "OSMREPO": {
+ "MENUOSMREPO": "OSM Repositories",
+ "ADDOSMREPO": "Add OSM Repositories",
+ "NEWOSMREPO": "New OSM Repositories",
+ "EDITOSMREPO": "Edit OSM Repositories",
+ "OSMREPOTITLE": "Registered OSM repository",
+ "CREATEDSUCCESSFULLY": "OSM Repository Added Successfully",
+ "UPDATEDSUCCESSFULLY" : "OSM Repository Updated Successfully"
}
},
"HTTPERROR": {
"NEWK8SREPO": "Nuevo repositorio K8s",
"TYPE": "Tipo",
"URL": "URL"
+ },
+ "OSMREPO": {
+ "MENUOSMREPO": "Repositorios OSM",
+ "ADDOSMREPO": "Agregar repositorios OSM",
+ "NEWOSMREPO": "Nuevos repositorios OSM",
+ "EDITOSMREPO": "Editar repositorios de OSM",
+ "OSMREPOTITLE": "Repositorio OSM registrado",
+ "CREATEDSUCCESSFULLY": "registrado OSM agregado con éxito",
+ "UPDATEDSUCCESSFULLY" : "El registrado de OSM se actualizó correctamente"
}
},
"HTTPERROR": {
"NEWK8SREPO": "Novo Repositório do K8s",
"TYPE": "Tipo",
"URL": "URL"
+ },
+ "OSMREPO": {
+ "MENUOSMREPO": "Repositórios OSM",
+ "ADDOSMREPO": "Adicionar repositórios OSM",
+ "NEWOSMREPO": "Novos repositórios OSM",
+ "EDITOSMREPO": "Editar repositórios OSM",
+ "OSMREPOTITLE": "Repositório OSM registrado",
+ "CREATEDSUCCESSFULLY": "registrado OSM adicionado com sucesso",
+ "UPDATEDSUCCESSFULLY" : "registrado OSM atualizado com sucesso"
}
},
"HTTPERROR": {
PERMISSIONS_CONFIG_FILE: ASSETS_PATH + 'config/rolePermissions.json',
GRAFANA_URL: GRAFANA_ENDPOINT + '/d',
DOMAIN_URL: OSM_ADMIN_ENDPOINT + 'domains',
- OSM_VERSION_URL: OSM_VERSION
+ OSM_VERSION_URL: OSM_VERSION,
+ OSMREPOS_URL: OSM_ADMIN_ENDPOINT + 'osmrepos'
};
PERMISSIONS_CONFIG_FILE: ASSETS_PATH + 'config/rolePermissions.json',
GRAFANA_URL: GRAFANA_ENDPOINT + '/d',
DOMAIN_URL: OSM_ADMIN_ENDPOINT + 'domains',
- OSM_VERSION_URL: OSM_VERSION
+ OSM_VERSION_URL: OSM_VERSION,
+ OSMREPOS_URL: OSM_ADMIN_ENDPOINT + 'osmrepos'
};
{ value: 'onos_vpls', title: 'ONOS vpls' },
{ value: 'tapi', title: 'TAPI' }
];
+/** Constants of the OSM Repo Types */
+export const OSMREPO_TYPES: TYPESECTION[] = [
+ { value: 'osm', title: 'OSM' }
+];
/** Interface for List, Add WIM & SDN Types */
export interface TYPESECTION {
value: string;
}
]
},
+ {
+ liClass: 'round-edge-top-3 round-edge-bottom-3 mr-top-5',
+ anchorTagClass: 'link round-edge-top-3 round-edge-bottom-3 individual',
+ clickFunction: 'nosubmenu',
+ routerLink: '/repos/details',
+ routerLinkActive: ['parentactive'],
+ routerLinkActiveOptions: true,
+ icon: 'fas fa-fas fa-cloud-download-alt',
+ menuName: 'PAGE.OSMREPO.MENUOSMREPO',
+ isChildExists: false
+ },
{
liClass: 'round-edge-top-3 round-edge-bottom-3 mr-top-5',
anchorTagClass: 'link round-edge-top-3 round-edge-bottom-3 individual',
--- /dev/null
+/*
+ Copyright 2020 TATA ELXSI
+
+ 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.
+
+ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
+ */
+/**
+ * @file Model for OSM Repo related information.
+ */
+
+/** Interface for OSM Repo Details */
+export interface OSMRepoDetails {
+ _admin: Admin;
+ _id: string;
+ name: string;
+ url: string;
+ 'type': string;
+ project_id?: string;
+ description?: string;
+}
+/** Interface for Admin */
+interface Admin {
+ created: number;
+ modified: number;
+}
+/** Interface for OSM Repo data in smarttable */
+export interface OSMRepoData {
+ name: string;
+ identifier: string;
+ url: string;
+ 'type': string;
+ modified: string;
+ created: string;
+ description: string;
+}
// tslint:disable-next-line: max-line-length
public REGX_PASSWORD_PATTERN: RegExp = new RegExp(/^.*(?=.{8,})((?=.*[!@#$%^&*()\-_=+{};:,<.>]){1})(?=.*\d)((?=.*[a-z]){1})((?=.*[A-Z]){1}).*$/);
+ /** Variables to hold maxlength for the description @public */
+ public MAX_LENGTH_DESCRIPTION: number = 500;
+
+ /** Variables to hold maxlength for the name @public */
+ public MAX_LENGTH_NAME: number = 50;
+
/** FormGroup instance added to the form @ html @public */
public formGroup: FormGroup;
"PageReloadModule": ["src/app/utilities/page-reload/PageReloadModule"],
"GoToTopDirective": ["src/directive/GoToTopDirective"],
"VNFLinkComponent": ["src/app/instances/vnf-instances/vnf-link/VNFLinkComponent"],
- "PACKAGEJSON": ["package.json"]
+ "PACKAGEJSON": ["package.json"],
+ "OsmRepositories" : ["src/app/osm-repositories/OsmRepositoriesComponent"],
+ "OsmRepositoriesDetails":["src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent"],
+ "OsmRepositoriesAction" : ["src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent"],
+ "OsmRepoModel": ["src/models/OsmRepoModel"],
+ "OsmRepoCreateUpdate": ["src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent"]
}
}
}
\ No newline at end of file