diff options
Diffstat (limited to 'portal-FE-common/src/app/shared')
37 files changed, 2052 insertions, 0 deletions
diff --git a/portal-FE-common/src/app/shared/services/application-catalog/application-catalog.service.spec.ts b/portal-FE-common/src/app/shared/services/application-catalog/application-catalog.service.spec.ts new file mode 100644 index 00000000..5f789869 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/application-catalog/application-catalog.service.spec.ts @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { TestBed } from '@angular/core/testing'; + +import { ApplicationCatalogService } from './application-catalog.service'; + +describe('ApplicationCatalogService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: ApplicationCatalogService = TestBed.get(ApplicationCatalogService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/application-catalog/application-catalog.service.ts b/portal-FE-common/src/app/shared/services/application-catalog/application-catalog.service.ts new file mode 100644 index 00000000..8dae2a67 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/application-catalog/application-catalog.service.ts @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { GridsterConfig, GridsterItem, DisplayGrid, GridType } from 'angular-gridster2'; +import { UUID } from 'angular2-uuid'; +import { CoreService } from '../core/core.service'; +import { Observable } from 'rxjs'; +import { IApplicationCatalog } from '../../model/application-catalog.model'; +import { environment } from 'src/environments/environment'; +import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class ApplicationCatalogService { + public options: GridsterConfig = { + minCols: 6, + maxCols: 6, + minRows: 7, + //maxRows: 4, + maxItemCols: 50, + minItemCols: 1, + maxItemRows: 50, + minItemRows: 1, + maxItemArea: 2500, + minItemArea: 1, + defaultItemCols: 1, + defaultItemRows: 1, + setGridSize: false, + fixedColWidth: 250, + fixedRowHeight: 250, + gridType: GridType.ScrollVertical, + swap: true, + dynamicColumns: true, + displayGrid: DisplayGrid.None, + itemChangeCallback: this.itemChange, + + + draggable: { + enabled: true + }, + pushItems: true, + resizable: { + enabled: true + } + }; + public layout: GridsterItem[] = []; + constructor(private api: HttpClient) { } + + addItem(appData: any): void { + this.layout.push(appData); + } + getAppCatalog(): Observable<any> { + return this.api.get(environment.api.appCatalog); + } + updateAppCatalog(appData: any): Observable<any> { + return this.api.put(environment.api.appCatalog, appData); + } + updateManualAppSort(appData: any): Observable<any> { + return this.api.put(environment.api.UpdateUserAppsSortManual, appData); + } + getuserAppRolesCatalog(appName: string): Observable<any> { + return this.api.get(environment.api.appCatalogRoles); + } + getAppsFullList(): Observable<any> { + return this.api.get(environment.api.appsFullList); + } + getUserAppsSortTypePreference(): Observable<any> { + const headers = new HttpHeaders().set('Content-Type','text/plain;charset=utf-8'); + return this.api.get(environment.api.userAppsSortTypePreference,{headers,responseType:'text'}); + } + getAppsOrderBySortPref(appSortPrefData: any): Observable<any> { + let httpParam = new HttpParams().set('mparams', appSortPrefData); + return this.api.get(environment.api.userAppsOrderBySortPref, {params: httpParam}); + } + saveAppsSortTypePreference(userPrefData: any): Observable<any> { + return this.api.put(environment.api.saveUserAppsSortingPreference, userPrefData); + } + itemChange(item, itemComponent) { + //console.info('itemChanged', item, itemComponent); + if(this.layout) + { + //console.log("check the layout value "+this.layout.values); + } + } + checkIfUserIsSuperAdmin(): Observable<any> { + let checkIfUserIsSuperAdminURL = environment.api.checkIfUserIsSuperAdmin; + return this.api.get(checkIfUserIsSuperAdminURL); + } + clearCatalog(): void { + this.layout =[]; + } + +} diff --git a/portal-FE-common/src/app/shared/services/external-request-access-service/external-request-access.service.spec.ts b/portal-FE-common/src/app/shared/services/external-request-access-service/external-request-access.service.spec.ts new file mode 100644 index 00000000..d7f33e92 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/external-request-access-service/external-request-access.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { ExternalRequestAccessService } from './external-request-access.service'; + +describe('ExternalRequestAccessService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: ExternalRequestAccessService = TestBed.get(ExternalRequestAccessService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/external-request-access-service/external-request-access.service.ts b/portal-FE-common/src/app/shared/services/external-request-access-service/external-request-access.service.ts new file mode 100644 index 00000000..3d6447b9 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/external-request-access-service/external-request-access.service.ts @@ -0,0 +1,19 @@ +import { Injectable } from '@angular/core'; +import { environment } from 'src/environments/environment'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class ExternalRequestAccessService { + + + + constructor(private api: HttpClient) { } + + getExternalRequestAccessServiceInfo(): Observable<any> { + return this.api.get(environment.api.externalRequestAccessSystem); + } + +} diff --git a/portal-FE-common/src/app/shared/services/functional-menu/functional-menu.service.spec.ts b/portal-FE-common/src/app/shared/services/functional-menu/functional-menu.service.spec.ts new file mode 100644 index 00000000..1280c084 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/functional-menu/functional-menu.service.spec.ts @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { TestBed } from '@angular/core/testing'; + +import { FunctionalMenuService } from './functional-menu.service'; + +describe('FunctionalMenuService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: FunctionalMenuService = TestBed.get(FunctionalMenuService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/functional-menu/functional-menu.service.ts b/portal-FE-common/src/app/shared/services/functional-menu/functional-menu.service.ts new file mode 100644 index 00000000..23029c30 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/functional-menu/functional-menu.service.ts @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { environment } from 'src/environments/environment'; +import { HttpClient } from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class FunctionalMenuService { + + constructor(private http: HttpClient) { } + apiUrl = environment.api; + + getManagedRolesMenu(appId: any) { + return this.http.get(this.apiUrl.appRoles.replace(':appId', appId)); + } + + getAvailableApplications() { + return this.http.get(this.apiUrl.allAvailableApps); + } + + getFunctionalMenu(menuId: any) { + return this.http.get(this.apiUrl.functionalMenuItemDetails.replace(':menuId', menuId)); + } + + getManagedFunctionalMenu() { + return this.http.get(this.apiUrl.functionalMenuForEditing); + } + + getManagedFunctionalMenuForNotificationTree() { + return this.http.get(this.apiUrl.functionalMenuForNotificationTree); + } + + regenerateFunctionalMenuAncestors() { + return this.http.get(this.apiUrl.regenerateFunctionalMenuAncestors); + } + + saveEditedMenuItem(menuData: any) { + return this.http.put(this.apiUrl.functionalMenuItem, menuData); + } + + saveMenuItem(menuData: any) { + return this.http.post(this.apiUrl.functionalMenuItem, menuData); + } + + deleteMenuItem(menuId: any){ + return this.http.delete(this.apiUrl.functionalMenuItem + '/' + menuId); + } + + getFunctionalMenuRole(){ + return this.http.get(this.apiUrl.getFunctionalMenuRole); + } + + saveBulkFunction(appId, appFunction){ + return this.http.post(this.apiUrl.saveRoleFunction.replace(':appId', appId), appFunction); + } + + saveBulkRole(appId, appRole){ + return this.http.post(this.apiUrl.saveRole.replace(':appId', appId), appRole); + } + + updateBulkRoleFunction(appId, roleFunction){ + return this.http.post(this.apiUrl.uploadRoleFunction.replace(':appId', appId), roleFunction); + } + +} diff --git a/portal-FE-common/src/app/shared/services/get-access/get-access.service.spec.ts b/portal-FE-common/src/app/shared/services/get-access/get-access.service.spec.ts new file mode 100644 index 00000000..2f0c96a8 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/get-access/get-access.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { GetAccessService } from './get-access.service'; + +describe('GetAccessService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: GetAccessService = TestBed.get(GetAccessService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/get-access/get-access.service.ts b/portal-FE-common/src/app/shared/services/get-access/get-access.service.ts new file mode 100644 index 00000000..5de2412b --- /dev/null +++ b/portal-FE-common/src/app/shared/services/get-access/get-access.service.ts @@ -0,0 +1,16 @@ +import { Injectable } from '@angular/core'; +import { environment } from 'src/environments/environment'; +import { HttpClient } from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class GetAccessService { + + constructor(private http: HttpClient) { } + apiUrl = environment.api; + + getListOfApp() { + return this.http.get(this.apiUrl.listOfApp); + } +} diff --git a/portal-FE-common/src/app/shared/services/index.ts b/portal-FE-common/src/app/shared/services/index.ts new file mode 100644 index 00000000..2297d3ae --- /dev/null +++ b/portal-FE-common/src/app/shared/services/index.ts @@ -0,0 +1,57 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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============================================ + * + * + */ +export * from './sidebar/sidebar.service'; +export * from './portal-admins/portal-admin.service'; +export * from './admins/admins.service'; +export * from './users/users.service'; +export * from './role/role.service'; +export * from './applications/applications.service'; +export * from './functional-menu/functional-menu.service' +export * from './microservice/microservice.service'; +export * from './widget-onboarding/widget-onboarding.service'; +export * from './basic-auth-account/basic-auth-account.service'; +export * from './contact-us/contact-us.service'; +export * from './webAnalytics/web-analytics.service'; +export * from './user-profile/user-profile.service'; +export * from './notification/notification.service'; +export * from './menus/menus.service'; +export * from './manifest/manifest.service'; +export * from './get-access/get-access.service'; +export * from './userbar/userbar.service'; +export * from './scheduler/scheduler.service'; +export * from './utils/utils.service';
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/services/manifest/manifest.service.spec.ts b/portal-FE-common/src/app/shared/services/manifest/manifest.service.spec.ts new file mode 100644 index 00000000..a5ad81b1 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/manifest/manifest.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { ManifestService } from './manifest.service'; + +describe('ManifestService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: ManifestService = TestBed.get(ManifestService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/manifest/manifest.service.ts b/portal-FE-common/src/app/shared/services/manifest/manifest.service.ts new file mode 100644 index 00000000..76a2f0f5 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/manifest/manifest.service.ts @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { environment } from 'src/environments/environment'; + +@Injectable({ + providedIn: 'root' +}) +export class ManifestService { + + api = environment.api; + constructor(public httpClient: HttpClient) { } + + getManifest() { + return this.httpClient.get(this.api.getManifest); + } +} diff --git a/portal-FE-common/src/app/shared/services/menus/menus.service.spec.ts b/portal-FE-common/src/app/shared/services/menus/menus.service.spec.ts new file mode 100644 index 00000000..b624236a --- /dev/null +++ b/portal-FE-common/src/app/shared/services/menus/menus.service.spec.ts @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { TestBed } from '@angular/core/testing'; + +import { MenusService } from './menus.service'; + +describe('MenusService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: MenusService = TestBed.get(MenusService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/menus/menus.service.ts b/portal-FE-common/src/app/shared/services/menus/menus.service.ts new file mode 100644 index 00000000..f0c16d68 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/menus/menus.service.ts @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { environment } from 'src/environments/environment'; +import { HttpClient } from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class MenusService { + + apiUrl = environment.api; + constructor(private http: HttpClient) { } + + getFunctionalMenuForUser() { + return this.http.get(this.apiUrl.functionalMenuForAuthUser); + } + + getPortalTitle() { + return this.http.get(this.apiUrl.portalTitle); + } + + getFavoriteItems() { + return this.http.get(this.apiUrl.getFavoriteItems + '?date=' + new Date().getTime()); + } + + setFavoriteItem(menuId) { + return this.http.post(this.apiUrl.setFavoriteItem, menuId); + + } + + removeFavoriteItem(menuId) { + return this.http.delete(this.apiUrl.removeFavoriteItem.replace(':menuId', menuId)); + } + + logout(appStr) { + // this.$log.info('SessionService::logout from App'); + // this.$log.info('SessionService appStr: ', appStr); + + var eaccessPattern = '\https?\:\/\/[^/]+/[^/]+/[^/]+'; + var standardPattern = '\https?\:\/\/[^/]+/[^/]+'; + + if (appStr.includes('e-access')) { + standardPattern = eaccessPattern; + } + + var contextUrl = appStr.match(new RegExp(standardPattern)); + var logoutUrl = contextUrl + '/logout.htm'; + // this.$sce.trustAsResourceUrl(logoutUrl); + console.log('logoutUrl ' + logoutUrl); + jQuery('#reg-logout-div').append("<iframe style='display:none' src='" + logoutUrl + "' />"); + + } + +} diff --git a/portal-FE-common/src/app/shared/services/notification/notification.service.spec.ts b/portal-FE-common/src/app/shared/services/notification/notification.service.spec.ts new file mode 100644 index 00000000..b8f0d334 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/notification/notification.service.spec.ts @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { TestBed } from '@angular/core/testing'; + +import { NotificationService } from './notification.service'; + +describe('NotificationService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: NotificationService = TestBed.get(NotificationService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/notification/notification.service.ts b/portal-FE-common/src/app/shared/services/notification/notification.service.ts new file mode 100644 index 00000000..2dfe2396 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/notification/notification.service.ts @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { environment } from '../../../../environments/environment'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class NotificationService { + + api = environment.api; + + constructor(private http: HttpClient) { } + + getNotificationRate(): Observable<any>{ + let getNotificationRateURL = this.api.notificationUpdateRate; + return this.http.get(getNotificationRateURL); + } + + getNotification(): Observable<any>{ + let getNotificationURL = this.api.getNotifications; + return this.http.get(getNotificationURL); + } + + getNotificationHistory(): Observable<any>{ + let getNotificationHistoryURL = this.api.getNotificationHistory; + return this.http.get(getNotificationHistoryURL); + } + + getAdminNotification(): Observable<any>{ + let getAdminNotificationURL = this.api.getAdminNotifications; + return this.http.get(getAdminNotificationURL); + } + + getMessageRecipients(notificationId: any): Observable<any>{ + let getMessageRecipientsURL = this.api.getMessageRecipients+"?notificationId="+notificationId; + return this.http.get(getMessageRecipientsURL); + } + + getAppRoleIds(): Observable<any>{ + let getAppRoleIdsURL = this.api.getAllAppRoleIds; + return this.http.get(getAppRoleIdsURL); + } + + getNotificationRoles(notificationId: any): Observable<any>{ + let getNotificationRolesURL = this.api.getNotificationRoles + '/'+notificationId+'/roles'; + return this.http.get(getNotificationRolesURL); + } + + addAdminNotification(newAdminNotification: any): Observable<any>{ + let addAdminNotificationURL = this.api.saveNotification; + return this.http.post(addAdminNotificationURL, newAdminNotification); + } + + updateAdminNotification(adminNotification: any): Observable<any>{ + let updateAdminNotificationURL = this.api.saveNotification; + return this.http.post(updateAdminNotificationURL, adminNotification); + } + + setNotificationRead(notificationId: any): Observable<any>{ + let setNotificationReadURL = this.api.notificationRead+"?notificationId="+notificationId; + return this.http.get(setNotificationReadURL); + } + +} diff --git a/portal-FE-common/src/app/shared/services/portal-admins/portal-admin.service.spec.ts b/portal-FE-common/src/app/shared/services/portal-admins/portal-admin.service.spec.ts new file mode 100644 index 00000000..e984467e --- /dev/null +++ b/portal-FE-common/src/app/shared/services/portal-admins/portal-admin.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { PortalAdminsService } from './portal-admin.service'; + +describe('AdminsService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: PortalAdminsService = TestBed.get(PortalAdminsService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/portal-admins/portal-admin.service.ts b/portal-FE-common/src/app/shared/services/portal-admins/portal-admin.service.ts new file mode 100644 index 00000000..90ae5c30 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/portal-admins/portal-admin.service.ts @@ -0,0 +1,25 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { environment } from 'src/environments/environment'; + +@Injectable({ + providedIn: 'root' +}) +export class PortalAdminsService { + apiUrl = environment.api; + constructor(private http: HttpClient) { } + + getPortalAdmins() { + return this.http.get(this.apiUrl.portalAdmins); + } + + addPortalAdmin(selectedUser: string) { + return this.http.post(this.apiUrl.portalAdmin, selectedUser); + } + + removePortalAdmin(userId: number, orUserId: string) { + let userInfo = userId + "-" + orUserId; + return this.http.delete(this.apiUrl.portalAdmin + '/' + userInfo); + } + +} diff --git a/portal-FE-common/src/app/shared/services/role/role.service.spec.ts b/portal-FE-common/src/app/shared/services/role/role.service.spec.ts new file mode 100644 index 00000000..e5935616 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/role/role.service.spec.ts @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { TestBed } from '@angular/core/testing'; + +import { RoleService } from './role.service'; + +describe('RoleService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: RoleService = TestBed.get(RoleService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/role/role.service.ts b/portal-FE-common/src/app/shared/services/role/role.service.ts new file mode 100644 index 00000000..b65a662d --- /dev/null +++ b/portal-FE-common/src/app/shared/services/role/role.service.ts @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { environment } from 'src/environments/environment'; +import { HttpClient } from '@angular/common/http'; + +@Injectable({ + providedIn: 'root' +}) +export class RoleService { + + api = environment.api; + + constructor(private http: HttpClient) { } + + getRoles(appId: string) { + return this.http.get(this.api.getRoles.replace(':appId', appId)); + } + + saveRoleFunction(appId: string) { + return this.http.post(this.api.saveRoleFunction.replace(':appId', appId), {}); + } + + getRoleFunctionList(appId) { + return this.http.get(this.api.getRoleFunctions.replace(':appId', appId)); + } + + getFnMenuItems() { + return this.http.get('admin_fn_menu'); + } + + getCacheRegions() { + return this.http.get('get_regions'); + } + + getUsageList() { + return this.http.get('get_usage_list'); + } + + getBroadcastList() { + return this.http.get('get_broadcast_list'); + } + + getBroadcast(messageLocationId, messageLocation, messageId) { + return this.http.get('get_broadcast?message_location_id=' + messageLocationId + '&message_location=' + messageLocation + ((messageId != null) ? '&message_id=' + messageId : '')); + } + + getCollaborateList() { + return this.http.get('get_collaborate_list'); + } + + getRole(appId, roleId) { + return this.http.get(this.api.getRole + '/' + appId + '/' + roleId); + } + + saveRole(appId) { + return this.http.post(this.api.saveRole.replace(':appId', appId), {}); + } + + getCentralizedApps(userId) { + return this.http.get(this.api.centralizedApps + '?userId=' + userId); + } + +} diff --git a/portal-FE-common/src/app/shared/services/scheduler/scheduler.service.spec.ts b/portal-FE-common/src/app/shared/services/scheduler/scheduler.service.spec.ts new file mode 100644 index 00000000..dbeb9b6a --- /dev/null +++ b/portal-FE-common/src/app/shared/services/scheduler/scheduler.service.spec.ts @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { TestBed } from '@angular/core/testing'; + +import { SchedulerService } from './scheduler.service'; + +describe('SchedulerService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: SchedulerService = TestBed.get(SchedulerService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/scheduler/scheduler.service.ts b/portal-FE-common/src/app/shared/services/scheduler/scheduler.service.ts new file mode 100644 index 00000000..9bd3e821 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/scheduler/scheduler.service.ts @@ -0,0 +1,101 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright © 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { HttpClient, HttpParams } from '@angular/common/http'; +import { environment } from '../../../../environments/environment'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class SchedulerService { + + api = environment.api; + + constructor(private http: HttpClient) { } + + /** get scheduler uuID **/ + getStatusSchedulerId(schedulerInfo:any): Observable<any> { + let getStatusSchedulerByIdURL = this.api.getSchedulerId+'?r='+ Math.random(); + return this.http.post(getStatusSchedulerByIdURL,schedulerInfo); + } + + /** get time slots for Range scheduler **/ + getTimeslotsForScheduler(schedulerID:any): Observable<any> { + let getTimeslotsForSchedulerURL = this.api.getTimeslotsForScheduler + '/' + schedulerID + '?r=' + Math.random(); + return this.http.get(getTimeslotsForSchedulerURL); + } + + /** postSubmitForApprovedTimeslots **/ + postSubmitForApprovedTimeslots(approvedTimeSlotsObj:any): Observable<any> { + let getStatusSchedulerByIdURL = this.api.postSubmitForApprovedTimeslots+'?r='+ Math.random(); + return this.http.post(getStatusSchedulerByIdURL,approvedTimeSlotsObj); + } + + /** Get policy information from BE **/ + getPolicyInfo(): Observable<any> { + let getPolicyInfoURL = this.api.getPolicy+'?r='+ Math.random(); + return this.http.get<Map<String, any>>(getPolicyInfoURL); + } + + /** get Scheduler UI constants from BE **/ + getSchedulerConstants(): Observable<any> { + let getSchedulerConstantsURL = this.api.getSchedulerConstants; + return this.http.get(getSchedulerConstantsURL); + } + + /** getWidgetData **/ + getWidgetData(widgetId: any,widgetData: any, widgetParam: any){ + let widgetInfo={ + id: widgetId, + data: widgetData, + param: widgetParam + } + return widgetInfo; + } + + showWidget(widgetId: any,widgetData: any, widgetParam: any) { + let widgetInfo={ + id: widgetId, + data: widgetData, + param: widgetParam + } + //Need to open popup here + } +} diff --git a/portal-FE-common/src/app/shared/services/sidebar/sidebar.service.spec.ts b/portal-FE-common/src/app/shared/services/sidebar/sidebar.service.spec.ts new file mode 100644 index 00000000..065e6e56 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/sidebar/sidebar.service.spec.ts @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { TestBed } from '@angular/core/testing'; + +import { SidebarService } from './sidebar.service'; + +describe('SidenavService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: SidebarService = TestBed.get(SidebarService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/sidebar/sidebar.service.ts b/portal-FE-common/src/app/shared/services/sidebar/sidebar.service.ts new file mode 100644 index 00000000..b0b21b3b --- /dev/null +++ b/portal-FE-common/src/app/shared/services/sidebar/sidebar.service.ts @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { environment } from '../../../../environments/environment' + +@Injectable({ + providedIn: 'root' +}) +export class SidebarService { + api = environment.api; + + constructor(private http: HttpClient) { } + getLeftMenu() { + return this.http.get(this.api.leftmenuItems); + + } + +} diff --git a/portal-FE-common/src/app/shared/services/tab/add-tab-function.service.spec.ts b/portal-FE-common/src/app/shared/services/tab/add-tab-function.service.spec.ts new file mode 100644 index 00000000..70ae8043 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/tab/add-tab-function.service.spec.ts @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { TestBed } from '@angular/core/testing'; + +import { AddTabFunctionService } from './add-tab-function.service'; + +describe('AddTabFunctionService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: AddTabFunctionService = TestBed.get(AddTabFunctionService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/tab/add-tab-function.service.ts b/portal-FE-common/src/app/shared/services/tab/add-tab-function.service.ts new file mode 100644 index 00000000..15ff6367 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/tab/add-tab-function.service.ts @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; +import { Subject } from 'rxjs/Subject'; + +@Injectable({ + providedIn: 'root' +}) +export class AddTabFunctionService { + + constructor() { } + + private _listners = new Subject<any>(); + + listen(): Observable<any> { + return this._listners.asObservable(); + } + + filter(filterBy: any) { + this._listners.next(filterBy); + } +} diff --git a/portal-FE-common/src/app/shared/services/user-profile/user-profile.service.spec.ts b/portal-FE-common/src/app/shared/services/user-profile/user-profile.service.spec.ts new file mode 100644 index 00000000..b1d5e6bd --- /dev/null +++ b/portal-FE-common/src/app/shared/services/user-profile/user-profile.service.spec.ts @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { TestBed } from '@angular/core/testing'; + +import { UserProfileService } from './user-profile.service'; + +describe('UserProfileService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: UserProfileService = TestBed.get(UserProfileService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/user-profile/user-profile.service.ts b/portal-FE-common/src/app/shared/services/user-profile/user-profile.service.ts new file mode 100644 index 00000000..2b86c8d7 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/user-profile/user-profile.service.ts @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { HttpClient, HttpParams } from '@angular/common/http'; +import { environment } from 'src/environments/environment'; + +@Injectable({ + providedIn: 'root' +}) +export class UserProfileService { + + api = environment.api; + + constructor(private http: HttpClient) { } + + getUserProfile() { + return this.http.get(this.api.userProfile); + } + + getFunctionalMenuStaticInfo() { + return this.http.get(this.api.functionalMenuStaticInfo); + + } + + getActiveUser() { + return this.http.get(this.api.getActiveUser); + } + + + getUserAppRoles(userId) { + let httpParams = new HttpParams() + .set('userId', userId); + return this.http.get(this.api.userApplicationRoles, { params: httpParams }); + } +} diff --git a/portal-FE-common/src/app/shared/services/userbar/userbar.service.spec.ts b/portal-FE-common/src/app/shared/services/userbar/userbar.service.spec.ts new file mode 100644 index 00000000..24329626 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/userbar/userbar.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { UserbarService } from './userbar.service'; + +describe('UserbarService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: UserbarService = TestBed.get(UserbarService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/userbar/userbar.service.ts b/portal-FE-common/src/app/shared/services/userbar/userbar.service.ts new file mode 100644 index 00000000..de42ce36 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/userbar/userbar.service.ts @@ -0,0 +1,33 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { environment } from 'src/environments/environment'; + +@Injectable({ + providedIn: 'root' +}) +export class UserbarService { + refreshCount: number; + maxCount: number; + apiUrl = environment.api; + constructor(public http: HttpClient) { + this.refreshCount = 0; + this.maxCount = 0; + } + + getRefreshCount() { + return this.refreshCount; + } + setRefreshCount(count) { + this.refreshCount = count; + } + setMaxRefreshCount(count) { + this.maxCount = count; + } + decrementRefreshCount() { + this.refreshCount = this.refreshCount - 1; + } + + getOnlineUserUpdateRate(){ + return this.http.get(this.apiUrl.onlineUserUpdateRate); + } +} diff --git a/portal-FE-common/src/app/shared/services/users/users.service.spec.ts b/portal-FE-common/src/app/shared/services/users/users.service.spec.ts new file mode 100644 index 00000000..c1f41d8a --- /dev/null +++ b/portal-FE-common/src/app/shared/services/users/users.service.spec.ts @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { TestBed } from '@angular/core/testing'; + +import { UsersService } from './users.service'; + +describe('UsersService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: UsersService = TestBed.get(UsersService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/users/users.service.ts b/portal-FE-common/src/app/shared/services/users/users.service.ts new file mode 100644 index 00000000..38ebedd8 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/users/users.service.ts @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { environment } from '../../../../environments/environment' +import { HttpClient, HttpParams } from '@angular/common/http'; +import { Observable, from } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class UsersService { + api = environment.api; + + constructor(private http: HttpClient) { } + + searchUsers(queryString: string) { + let httpParams = new HttpParams() + .set('search', queryString); + return this.http.get(this.api.queryUsers, { params: httpParams, responseType: 'json' }); + } + + getAccountUsers(appId: any) { + return this.http.get(this.api.accountUsers.replace(':appId', appId)); + } + + getUserAppRoles(appid: any, orgUserId: string, extRequestValue: any, isSystemUser: any) { + return this.http.get(this.api.userAppRoles, { params: { 'user': orgUserId, 'app': appid, 'externalRequest': extRequestValue, 'isSystemUser': isSystemUser } }); + } + + updateUserAppRoles(newUserAppRoles) { + return this.http.put(this.api.userAppRoles, newUserAppRoles); + } + + //Not used in dev.json + getLoggedInUser() { } + + //Not used in dev.jon + modifyLoggedInUser() { } + + getUserProfile(): Observable<any> { + return this.http.get(environment.api.userProfile); + } + + addNewUser(newUserData){ + console.log("User service : ", newUserData); + return this.http.post(this.api.saveNewUser, newUserData).subscribe((response)=>{ + }); + } + +} diff --git a/portal-FE-common/src/app/shared/services/utils/utils.service.spec.ts b/portal-FE-common/src/app/shared/services/utils/utils.service.spec.ts new file mode 100644 index 00000000..102bf3d4 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/utils/utils.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { UtilsService } from './utils.service'; + +describe('UtilsService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: UtilsService = TestBed.get(UtilsService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/utils/utils.service.ts b/portal-FE-common/src/app/shared/services/utils/utils.service.ts new file mode 100644 index 00000000..8d5eff10 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/utils/utils.service.ts @@ -0,0 +1,22 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class UtilsService { + + constructor() { } + + isValidJSON(json) { + try { + var checkJSON = JSON.parse(JSON.stringify(json)); + if (checkJSON && typeof checkJSON === 'object' && checkJSON !== null) { + // this.$log.debug('UtilsService::isValidJSON: JSON is valid!'); + return true; + } + } catch (err) { + // this.$log.debug('UtilsService::isValidJSON: json passed is not valid: ' + JSON.stringify(err)); + } + return false; +} +} diff --git a/portal-FE-common/src/app/shared/services/webAnalytics/web-analytics.service.spec.ts b/portal-FE-common/src/app/shared/services/webAnalytics/web-analytics.service.spec.ts new file mode 100644 index 00000000..0c9b86bf --- /dev/null +++ b/portal-FE-common/src/app/shared/services/webAnalytics/web-analytics.service.spec.ts @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { TestBed } from '@angular/core/testing'; + +import { WebAnalyticsService } from './web-analytics.service'; + +describe('WebAnalyticsService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: WebAnalyticsService = TestBed.get(WebAnalyticsService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/webAnalytics/web-analytics.service.ts b/portal-FE-common/src/app/shared/services/webAnalytics/web-analytics.service.ts new file mode 100644 index 00000000..0632a23c --- /dev/null +++ b/portal-FE-common/src/app/shared/services/webAnalytics/web-analytics.service.ts @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { HttpClient, HttpParams } from '@angular/common/http'; +import { environment } from '../../../../environments/environment'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class WebAnalyticsService { + + api = environment.api; + + constructor(private http: HttpClient) { } + + getWebAnalyticsAppReports(): Observable<any> { + let getWebAnalyticsAppReportsURL = this.api.getUserAppsWebAnalytics; + return this.http.get(getWebAnalyticsAppReportsURL, { withCredentials: true }); + } + + getWebAnalyticsReportOfApplication(appName: any) { + let httpParam = new HttpParams() + .append('appName', appName); + let getWebAnalyticsReportOfApplicationURL = this.api.getWebAnalyticsOfApp; + return this.http.get(getWebAnalyticsReportOfApplicationURL, {params: httpParam, withCredentials: true}); + } + + getUserJourneyList(appName: any){ + let httpParam = new HttpParams() + .append('appName', appName); + let getUserJourneyListURL = this.api.getUserJourneyAnalyticsReport + return this.http.get(getUserJourneyListURL, {params: httpParam, withCredentials: true}); + } + + save(reportSource: any): Observable<any> { + let saveURL = this.api.addWebAnalyticsReport; + return this.http.post(saveURL, reportSource, {withCredentials: true}) + } + + updateWebAnalyticsReport(reportSource: any): Observable<any> { + let updateWebAnalyticsReportURL = this.api.modifyWebAnalyticsReport; + return this.http.put(updateWebAnalyticsReportURL, reportSource, {withCredentials: true}) + } + + getAllWebAnalyticsReport(){ + let updateWebAnalyticsReportURL = this.api.getAllWebAnalytics; + return this.http.get(updateWebAnalyticsReportURL, { withCredentials: true }); + } + + deleteWebAnalyticsReport(webAnalyticsReport){ + let deleteWebAnalyticsReportURL = this.api.deleteWebAnalyticsReport +'?' + 'resourceId='+ webAnalyticsReport.resourceId; + return this.http.delete(deleteWebAnalyticsReportURL, { withCredentials: true }); + } + + getAllApplications(){ + let getAllApplicationsURL = this.api.appsFullList; + return this.http.get(getAllApplicationsURL, { withCredentials: true }); + } + +} diff --git a/portal-FE-common/src/app/shared/services/widget-catalog/widget-catalog.service.spec.ts b/portal-FE-common/src/app/shared/services/widget-catalog/widget-catalog.service.spec.ts new file mode 100644 index 00000000..fb87e8b9 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/widget-catalog/widget-catalog.service.spec.ts @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { TestBed } from '@angular/core/testing'; + +import { WidgetCatalogService } from './widget-catalog.service'; + +describe('WidgetCatalogService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: WidgetCatalogService = TestBed.get(WidgetCatalogService); + expect(service).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/services/widget-catalog/widget-catalog.service.ts b/portal-FE-common/src/app/shared/services/widget-catalog/widget-catalog.service.ts new file mode 100644 index 00000000..8cb31785 --- /dev/null +++ b/portal-FE-common/src/app/shared/services/widget-catalog/widget-catalog.service.ts @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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 { Injectable } from '@angular/core'; +import { IWidgetCatalog } from '../../model/widget-catalog.model'; +import { Observable, from } from 'rxjs'; +import { GridsterConfig, GridsterItem, CompactType, DisplayGrid, GridType } from 'angular-gridster2'; +import { CoreService } from '../core/core.service'; +import { environment } from 'src/environments/environment'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; + + + +@Injectable({ + providedIn: 'root' +}) +export class WidgetCatalogService { + public options: GridsterConfig = { + minCols: 6, + maxCols: 6, + minRows: 7, + //maxRows: 4, + maxItemCols: 50, + minItemCols: 1, + maxItemRows: 50, + minItemRows: 1, + maxItemArea: 2500, + minItemArea: 1, + defaultItemCols: 2, + defaultItemRows: 2, + setGridSize: false, + fixedColWidth: 250, + fixedRowHeight: 250, + gridType: GridType.ScrollVertical, + swap: true, + dynamicColumns: true, + displayGrid: DisplayGrid.None, + + + draggable: { + enabled: true + }, + pushItems: true, + resizable: { + enabled: true + } + }; + public layout: GridsterItem[] = []; + constructor(private api: HttpClient) { } + addItem(widgetData: any): void { + this.layout.push(widgetData); + } + widgetCatalogData: IWidgetCatalog[] = [{ + widgetId: '1', + widgetName: 'TestData1', + widgetStatus: 'TestStatus1', + imageLink: 'week_1.png', + select: true + }, + { + widgetId: '2', + widgetName: 'TestData1', + widgetStatus: 'TestStatus1', + imageLink: 'week_1.png', + select: true + }, + { + widgetId: '3', + widgetName: 'TestData1', + widgetStatus: 'TestStatus1', + imageLink: 'week_1.png', + select: true + }, + { + widgetId: '4', + widgetName: 'TestData1', + widgetStatus: 'TestStatus1', + imageLink: 'week_1.png', + select: true + }, + { + widgetId: '5', + widgetName: 'TestData1', + widgetStatus: 'TestStatus1', + imageLink: 'week_1.png', + select: true + }, + { + widgetId: '6', + widgetName: 'TestData1', + widgetStatus: 'TestStatus1', + imageLink: 'week_1.png', + select: true + }, + { + widgetId: '7', + widgetName: 'TestData1', + widgetStatus: 'TestStatus1', + imageLink: 'week_1.png', + select: true + }, + { + widgetId: '8', + widgetName: 'TestData1', + widgetStatus: 'TestStatus1', + imageLink: 'week_1.png', + select: true + }]; + + + public getWidgetCatalog(): any { + const widgetCatalogObservable = new Observable(observer => { + setTimeout(() => { + observer.next(this.widgetCatalogData); + }, 1000); + }); + + return widgetCatalogObservable; + } + getUserWidgets(loginName: string): Observable<any> { + return this.api.get(environment.api.widgetCommon + '/widgetCatalog' + '/' + loginName); + } + getManagedWidgets(): Observable<any> { + return this.api.get(environment.api.widgetCommon + '/widgetCatalog'); + } + getUploadFlag(): Observable<any> { + return this.api.get(environment.api.widgetCommon + '/uploadFlag'); + } + // createWidget(newWidget: any, widgetNameparam: string): Observable<any> { + // return this.api.post(environment.api.widgetCommon + '/widgetCatalog', newWidget, widgetNameparam); + // } + + // updateWidgetWithFile(newWidget: any, widgetNameparam: string, widgetIdParam: string): Observable<any> { + // return this.api.post(environment.api.widgetCommon + '/widgetCatalog/' + widgetIdParam, newWidget, widgetNameparam); + // } + + updateWidget(newWidget: any, widgetIdParam: string): Observable<any> { + return this.api.put(environment.api.widgetCommon + '/widgetCatalog/' + widgetIdParam, newWidget); + } + updateWidgetCatalog(appData: any): Observable<any> { + const headers = new HttpHeaders().set('X-Widgets-Type','all'); + return this.api.put(environment.api.widgetCatalogSelection, appData,{headers}); + } +} |