From 403234ed6120ba4bc01578b3ec237fa5fd4c0f6d Mon Sep 17 00:00:00 2001 From: Barath Kumar R Date: Tue, 7 Jul 2020 15:48:58 +0530 Subject: [PATCH] NG-UI Added support for the OSM Repository * 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 --- src/app/approutes.module.ts | 7 + .../OsmRepositoriesComponent.html | 18 ++ .../OsmRepositoriesComponent.scss | 17 ++ .../OsmRepositoriesComponent.ts | 55 +++++ .../osm-repositories/OsmRepositoriesModule.ts | 78 +++++++ .../OsmRepoCreateUpdateComponent.html | 70 ++++++ .../OsmRepoCreateUpdateComponent.scss | 17 ++ .../OsmRepoCreateUpdateComponent.ts | 184 ++++++++++++++++ .../OsmRepositoriesDetailsComponent.html | 35 +++ .../OsmRepositoriesDetailsComponent.scss | 17 ++ .../OsmRepositoriesDetailsComponent.ts | 203 ++++++++++++++++++ src/app/utilities/delete/DeleteComponent.ts | 3 + .../OsmRepositoriesActionComponent.html | 27 +++ .../OsmRepositoriesActionComponent.scss | 17 ++ .../OsmRepositoriesActionComponent.ts | 90 ++++++++ src/assets/config/rolePermissions.json | 29 +++ src/assets/i18n/de.json | 9 + src/assets/i18n/en.json | 9 + src/assets/i18n/es.json | 9 + src/assets/i18n/pt.json | 9 + src/environments/environment.prod.ts | 3 +- src/environments/environment.ts | 3 +- src/models/CommonModel.ts | 4 + src/models/MenuModel.ts | 11 + src/models/OsmRepoModel.ts | 46 ++++ src/services/SharedService.ts | 6 + tsconfig.json | 7 +- 27 files changed, 980 insertions(+), 3 deletions(-) create mode 100644 src/app/osm-repositories/OsmRepositoriesComponent.html create mode 100644 src/app/osm-repositories/OsmRepositoriesComponent.scss create mode 100644 src/app/osm-repositories/OsmRepositoriesComponent.ts create mode 100644 src/app/osm-repositories/OsmRepositoriesModule.ts create mode 100644 src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.html create mode 100644 src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.scss create mode 100644 src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.ts create mode 100644 src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent.html create mode 100644 src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent.scss create mode 100644 src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent.ts create mode 100644 src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent.html create mode 100644 src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent.scss create mode 100644 src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent.ts create mode 100644 src/models/OsmRepoModel.ts diff --git a/src/app/approutes.module.ts b/src/app/approutes.module.ts index e2f863c..6145aae 100644 --- a/src/app/approutes.module.ts +++ b/src/app/approutes.module.ts @@ -104,6 +104,13 @@ export const appRoutes: Routes = [ loadChildren: async (): Promise => import('./k8s/K8sModule') .then((m: typeof import('./k8s/K8sModule')) => m.K8sModule), canActivate: [AuthGuardService] + }, + { + path: 'repos', + // tslint:disable-next-line: no-any + loadChildren: async (): Promise => import('./osm-repositories/OsmRepositoriesModule') + .then((m: typeof import('./osm-repositories/OsmRepositoriesModule')) => m.OsmRepositoriesModule), + canActivate: [AuthGuardService] } ] }, diff --git a/src/app/osm-repositories/OsmRepositoriesComponent.html b/src/app/osm-repositories/OsmRepositoriesComponent.html new file mode 100644 index 0000000..06b8876 --- /dev/null +++ b/src/app/osm-repositories/OsmRepositoriesComponent.html @@ -0,0 +1,18 @@ + + diff --git a/src/app/osm-repositories/OsmRepositoriesComponent.scss b/src/app/osm-repositories/OsmRepositoriesComponent.scss new file mode 100644 index 0000000..0ecd95d --- /dev/null +++ b/src/app/osm-repositories/OsmRepositoriesComponent.scss @@ -0,0 +1,17 @@ +/* + 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 diff --git a/src/app/osm-repositories/OsmRepositoriesComponent.ts b/src/app/osm-repositories/OsmRepositoriesComponent.ts new file mode 100644 index 0000000..5f42eee --- /dev/null +++ b/src/app/osm-repositories/OsmRepositoriesComponent.ts @@ -0,0 +1,55 @@ +/* + 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(); + } + } +} diff --git a/src/app/osm-repositories/OsmRepositoriesModule.ts b/src/app/osm-repositories/OsmRepositoriesModule.ts new file mode 100644 index 0000000..20901e4 --- /dev/null +++ b/src/app/osm-repositories/OsmRepositoriesModule.ts @@ -0,0 +1,78 @@ +/* + 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 { } diff --git a/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.html b/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.html new file mode 100644 index 0000000..38c753b --- /dev/null +++ b/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.html @@ -0,0 +1,70 @@ + +
+ + + +
+ \ No newline at end of file diff --git a/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.scss b/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.scss new file mode 100644 index 0000000..0ecd95d --- /dev/null +++ b/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.scss @@ -0,0 +1,17 @@ +/* + 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 diff --git a/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.ts b/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.ts new file mode 100644 index 0000000..e653e7c --- /dev/null +++ b/src/app/osm-repositories/osm-repo-create-update/OsmRepoCreateUpdateComponent.ts @@ -0,0 +1,184 @@ +/* + 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'); + }); + } +} diff --git a/src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent.html b/src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent.html new file mode 100644 index 0000000..29cdbaa --- /dev/null +++ b/src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent.html @@ -0,0 +1,35 @@ + +
+
{{'PAGE.OSMREPO.OSMREPOTITLE' | translate}}
+ + + +
+
+ + +
+
+ + +
+ diff --git a/src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent.scss b/src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent.scss new file mode 100644 index 0000000..0ecd95d --- /dev/null +++ b/src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent.scss @@ -0,0 +1,17 @@ +/* + 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 diff --git a/src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent.ts b/src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent.ts new file mode 100644 index 0000000..3415484 --- /dev/null +++ b/src/app/osm-repositories/osm-repositories-details/OsmRepositoriesDetailsComponent.ts @@ -0,0 +1,203 @@ +/* + 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; + }); + } +} diff --git a/src/app/utilities/delete/DeleteComponent.ts b/src/app/utilities/delete/DeleteComponent.ts index 4baee64..014b66a 100644 --- a/src/app/utilities/delete/DeleteComponent.ts +++ b/src/app/utilities/delete/DeleteComponent.ts @@ -171,6 +171,9 @@ export class DeleteComponent { } 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 */ diff --git a/src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent.html b/src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent.html new file mode 100644 index 0000000..1666c7b --- /dev/null +++ b/src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent.html @@ -0,0 +1,27 @@ + +
+ + +
\ No newline at end of file diff --git a/src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent.scss b/src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent.scss new file mode 100644 index 0000000..0ecd95d --- /dev/null +++ b/src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent.scss @@ -0,0 +1,17 @@ +/* + 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 diff --git a/src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent.ts b/src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent.ts new file mode 100644 index 0000000..1f3523d --- /dev/null +++ b/src/app/utilities/osm-repositories-action/OsmRepositoriesActionComponent.ts @@ -0,0 +1,90 @@ +/* + 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(); + } +} diff --git a/src/assets/config/rolePermissions.json b/src/assets/config/rolePermissions.json index 7111144..4421fc4 100644 --- a/src/assets/config/rolePermissions.json +++ b/src/assets/config/rolePermissions.json @@ -568,6 +568,35 @@ } ] }, + { + "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": [ diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json index cc22546..bde25ba 100644 --- a/src/assets/i18n/de.json +++ b/src/assets/i18n/de.json @@ -415,6 +415,15 @@ "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": { diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 4bcf7a8..8861820 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -415,6 +415,15 @@ "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": { diff --git a/src/assets/i18n/es.json b/src/assets/i18n/es.json index f80d529..084782f 100644 --- a/src/assets/i18n/es.json +++ b/src/assets/i18n/es.json @@ -415,6 +415,15 @@ "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": { diff --git a/src/assets/i18n/pt.json b/src/assets/i18n/pt.json index b2e995f..87a7554 100644 --- a/src/assets/i18n/pt.json +++ b/src/assets/i18n/pt.json @@ -415,6 +415,15 @@ "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": { diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 6592b10..a9be3ad 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -80,5 +80,6 @@ export const environment = { 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' }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index dbc2c98..d2e5575 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -80,5 +80,6 @@ export const environment = { 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' }; diff --git a/src/models/CommonModel.ts b/src/models/CommonModel.ts index 508a96a..627074b 100644 --- a/src/models/CommonModel.ts +++ b/src/models/CommonModel.ts @@ -202,6 +202,10 @@ export const WIM_TYPES: TYPESECTION[] = [ { 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; diff --git a/src/models/MenuModel.ts b/src/models/MenuModel.ts index dd77e0d..0b49db8 100644 --- a/src/models/MenuModel.ts +++ b/src/models/MenuModel.ts @@ -193,6 +193,17 @@ export const MENU_ITEMS: MENUITEMS[] = [ } ] }, + { + 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', diff --git a/src/models/OsmRepoModel.ts b/src/models/OsmRepoModel.ts new file mode 100644 index 0000000..2f2114b --- /dev/null +++ b/src/models/OsmRepoModel.ts @@ -0,0 +1,46 @@ +/* + 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; +} diff --git a/src/services/SharedService.ts b/src/services/SharedService.ts index 8aee513..41f3d76 100644 --- a/src/services/SharedService.ts +++ b/src/services/SharedService.ts @@ -64,6 +64,12 @@ export class SharedService { // 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; diff --git a/tsconfig.json b/tsconfig.json index fca2693..ba5b667 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -133,7 +133,12 @@ "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 -- 2.17.1