diff options
Diffstat (limited to 'portal-FE-common/src/app/shared')
33 files changed, 1788 insertions, 0 deletions
diff --git a/portal-FE-common/src/app/shared/helpers/must-match-validator.ts b/portal-FE-common/src/app/shared/helpers/must-match-validator.ts new file mode 100644 index 00000000..70e9e1a4 --- /dev/null +++ b/portal-FE-common/src/app/shared/helpers/must-match-validator.ts @@ -0,0 +1,21 @@ +import { FormGroup } from '@angular/forms'; + +// custom validator to check that two fields match +export function MustMatch(controlName: string, matchingControlName: string) { + return (formGroup: FormGroup) => { + const control = formGroup.controls[controlName]; + const matchingControl = formGroup.controls[matchingControlName]; + + if (matchingControl.errors && !matchingControl.errors.mustMatch) { + // return if another validator has already found an error on the matchingControl + return; + } + + // set error on matchingControl if validation fails + if (control.value !== matchingControl.value) { + matchingControl.setErrors({ mustMatch: true }); + } else { + matchingControl.setErrors(null); + } + } +}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/model/Admins.ts b/portal-FE-common/src/app/shared/model/Admins.ts new file mode 100644 index 00000000..258c42a5 --- /dev/null +++ b/portal-FE-common/src/app/shared/model/Admins.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============================================ + * + * + */ +export class Admins { + firstName: string; + lastName: string; + user_Id: number; + orgUserId: string; + apps: Apps[]; +} + +export class Apps { + appId: number; + appName: string; +}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/model/AllApps.ts b/portal-FE-common/src/app/shared/model/AllApps.ts new file mode 100644 index 00000000..fcf9f7b0 --- /dev/null +++ b/portal-FE-common/src/app/shared/model/AllApps.ts @@ -0,0 +1,44 @@ +/*- + * ============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============================================ + * + * + */ +export class AllApps { + enabled: boolean; + index: number; + restrictedApp: boolean; + title: string; + value: string; +}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/model/PortalAdmin.ts b/portal-FE-common/src/app/shared/model/PortalAdmin.ts new file mode 100644 index 00000000..f826d45c --- /dev/null +++ b/portal-FE-common/src/app/shared/model/PortalAdmin.ts @@ -0,0 +1,44 @@ +/*- + * ============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============================================ + * + * + */ +export class PortalAdmin { + firstName: string; + lastName: string; + userId: number; + loginId: string; + orgUserId: string; +}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/model/Role.ts b/portal-FE-common/src/app/shared/model/Role.ts new file mode 100644 index 00000000..5badf9e9 --- /dev/null +++ b/portal-FE-common/src/app/shared/model/Role.ts @@ -0,0 +1,51 @@ +/*- + * ============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 { RoleFunction } from './RoleFunction'; + +export class Role { + name: string; + priority: any; + childRoles: ChildRoles[]; + roleFunctions: RoleFunction[]; +} + +export class ChildRoles { + name: string; + priority: any; +} + diff --git a/portal-FE-common/src/app/shared/model/RoleFunction.ts b/portal-FE-common/src/app/shared/model/RoleFunction.ts new file mode 100644 index 00000000..68f055c0 --- /dev/null +++ b/portal-FE-common/src/app/shared/model/RoleFunction.ts @@ -0,0 +1,51 @@ +/*- + * ============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============================================ + * + * + */ +export class RoleFunction { + type: string; + code: string; + action: string; + name: string; + + //constructor + constructor(type: string, code: string, action: string, name: string) { + this.type = type; + this.code = code; + this.action = action; + this.name = name; + } +}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/model/UserAccessRoles.ts b/portal-FE-common/src/app/shared/model/UserAccessRoles.ts new file mode 100644 index 00000000..ed180883 --- /dev/null +++ b/portal-FE-common/src/app/shared/model/UserAccessRoles.ts @@ -0,0 +1,44 @@ +/*- + * ============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============================================ + * + * + */ +export class UserAccessRoles { + isApplied: boolean; + roleId: number; + roleName: string; + appId: number; + appName: string; +}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/model/UserAdminApps.ts b/portal-FE-common/src/app/shared/model/UserAdminApps.ts new file mode 100644 index 00000000..1617beaf --- /dev/null +++ b/portal-FE-common/src/app/shared/model/UserAdminApps.ts @@ -0,0 +1,42 @@ +/*- + * ============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============================================ + * + * + */ +export class UserAdminApps { + id: number; + name: string; + restrictedApp: string; +}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/model/application-catalog.model.ts b/portal-FE-common/src/app/shared/model/application-catalog.model.ts new file mode 100644 index 00000000..a0f368c4 --- /dev/null +++ b/portal-FE-common/src/app/shared/model/application-catalog.model.ts @@ -0,0 +1,49 @@ +/* + * ============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============================================ + * + * + */ +export interface IApplicationCatalog { + id: number; + name: string; + mlAppName: string; + imageUrl: string; + url: string; + restricted: boolean; + open: boolean; + access: boolean; + select: boolean; + pending: boolean; +}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/model/applications-onboarding/applications.ts b/portal-FE-common/src/app/shared/model/applications-onboarding/applications.ts new file mode 100644 index 00000000..a0a93a22 --- /dev/null +++ b/portal-FE-common/src/app/shared/model/applications-onboarding/applications.ts @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 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 interface IApplications { + id ?: any; + name ?: any; + imageUrl ?: any; + imageLink ?: any; + description ?: any; + notes ?: any; + url ?: any + alternateUrl ?: any; + restUrl ?: any; + isOpen ?: any; + isEnabled ?: any; + motsId ?: any; + myLoginsAppName ?: any; + myLoginsAppOwner ?: any; + username ?: any; + appPassword ?: any; + thumbnail ?: any; + uebTopicName ?: any; + uebKey ?: any; + uebSecret ?: any; + restrictedApp ?: any; + isCentralAuth ?: any; + nameSpace ?: any +}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/model/dynamic-component-manifest/dynamic-component-manifest.ts b/portal-FE-common/src/app/shared/model/dynamic-component-manifest/dynamic-component-manifest.ts new file mode 100644 index 00000000..176e16eb --- /dev/null +++ b/portal-FE-common/src/app/shared/model/dynamic-component-manifest/dynamic-component-manifest.ts @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 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 interface IDynamicComponentManifest { + componentId: string; + path: string; + loadChildren: string; +}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/model/global-search-item.model.ts b/portal-FE-common/src/app/shared/model/global-search-item.model.ts new file mode 100644 index 00000000..626a8d2d --- /dev/null +++ b/portal-FE-common/src/app/shared/model/global-search-item.model.ts @@ -0,0 +1,45 @@ +/* + * ============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============================================ + * + * + */ +export interface GlobalSearchItem { + rowId: number; + category: string; + name: string; + target: string; + uuid: boolean; + +} diff --git a/portal-FE-common/src/app/shared/model/index.ts b/portal-FE-common/src/app/shared/model/index.ts new file mode 100644 index 00000000..f8572b8c --- /dev/null +++ b/portal-FE-common/src/app/shared/model/index.ts @@ -0,0 +1,44 @@ +/*- + * ============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============================================ + * + * + */ +export * from './Admins'; +export * from './AllApps' +export * from './PortalAdmin'; +export * from './UserAdminApps'; +export * from './UserAccessRoles'; +export * from './Role'; +export * from './RoleFunction';
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/model/widget-catalog.model.ts b/portal-FE-common/src/app/shared/model/widget-catalog.model.ts new file mode 100644 index 00000000..f30a4e3c --- /dev/null +++ b/portal-FE-common/src/app/shared/model/widget-catalog.model.ts @@ -0,0 +1,44 @@ +/* + * ============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 interface IWidgetCatalog { + widgetId: string; + widgetName: String; + widgetStatus: string; + imageLink: string; + select: boolean; +}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/model/widget-onboarding/widget.ts b/portal-FE-common/src/app/shared/model/widget-onboarding/widget.ts new file mode 100644 index 00000000..ba1842f5 --- /dev/null +++ b/portal-FE-common/src/app/shared/model/widget-onboarding/widget.ts @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified?: any; all software contained herein is licensed + * under the Apache License?: any; 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?: any; software + * distributed under the License is distributed on an "AS IS" BASIS?: any; + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND?: any; either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified?: any; all documentation contained herein is licensed + * under the Creative Commons License?: any; 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?: any; documentation + * distributed under the License is distributed on an "AS IS" BASIS?: any; + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND?: any; either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ +export interface IWidget { + id ?: any; + name ?: any; + desc ?: any; + fileLocation ?: any; + allowAllUser ?: any; + serviceId ?: any; + serviceURL ?: any; + sortOrder ?: any; + statusCode ?: any; + widgetRoles ?: any; + appContent ?: any; + appName ?: any + file ?: any; + allUser ?: boolean; + saving ?: any +}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/pipes/application-pipes.module.ts b/portal-FE-common/src/app/shared/pipes/application-pipes.module.ts new file mode 100644 index 00000000..3e19fa2b --- /dev/null +++ b/portal-FE-common/src/app/shared/pipes/application-pipes.module.ts @@ -0,0 +1,57 @@ +/*- + * ============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 { ElipsisPipe } from "./elipsis/elipsis.pipe"; +import { NgModule } from "@angular/core"; + +// application-pipes.module.ts +// other imports + + +@NgModule({ + imports: [ + // dep modules + ], + declarations: [ + ElipsisPipe + ], + exports: [ + ElipsisPipe + ] +}) +export class ApplicationPipesModule {}
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/pipes/elipsis/elipsis.pipe.spec.ts b/portal-FE-common/src/app/shared/pipes/elipsis/elipsis.pipe.spec.ts new file mode 100644 index 00000000..22a477d3 --- /dev/null +++ b/portal-FE-common/src/app/shared/pipes/elipsis/elipsis.pipe.spec.ts @@ -0,0 +1,45 @@ +/*- + * ============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 { ElipsisPipe } from './elipsis.pipe'; + +describe('ElipsisPipe', () => { + it('create an instance', () => { + const pipe = new ElipsisPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/pipes/elipsis/elipsis.pipe.ts b/portal-FE-common/src/app/shared/pipes/elipsis/elipsis.pipe.ts new file mode 100644 index 00000000..d749626a --- /dev/null +++ b/portal-FE-common/src/app/shared/pipes/elipsis/elipsis.pipe.ts @@ -0,0 +1,61 @@ +/*- + * ============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 { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'elipsis' +}) +export class ElipsisPipe implements PipeTransform { + + transform(value: any, args: string): any { + if (!value) { + return value; + } + + var noOfChar = parseInt(args); + + if (!noOfChar || value.length <= noOfChar) { + return value; + } + + value = value.substr(0, noOfChar); + + return value + '...'; + } + +} diff --git a/portal-FE-common/src/app/shared/plugin/dynamic-widget/dynamic-widget.module.ts b/portal-FE-common/src/app/shared/plugin/dynamic-widget/dynamic-widget.module.ts new file mode 100644 index 00000000..baab502d --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/dynamic-widget/dynamic-widget.module.ts @@ -0,0 +1,57 @@ +/*- + * ============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 { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { ListWidgetComponent } from './list-widget/list-widget.component'; +import { HttpClientModule } from '@angular/common/http'; +import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; + +@NgModule({ + declarations: [ListWidgetComponent], + imports: [ + CommonModule, + HttpClientModule + ], + exports: [ListWidgetComponent], + providers: [HttpClient], + entryComponents: [ListWidgetComponent] +}) +export class DynamicWidgetModule { + static entry = ListWidgetComponent; +} diff --git a/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.html b/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.html new file mode 100644 index 00000000..82f4f35d --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.html @@ -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============================================ + + + --> + +<div id="widget-news" class="widget-news-main"> + <div onap-gridster-item-body class="information-section-gridsterContent"> + <div class="resources"> + <ul *ngIf="newsData && newsData.length!=0"> + <li *ngFor="let item of newsData"><a href="{{item.href}}" target="_blank">{{item.title}}</a></li> + </ul> + <div *ngIf="newsData && newsData.length!=0"> + <div class="activity-error-container" + style="background: rgb(255, 255, 255); overflow: hidden !important; width: 100%;"> + <div class="activity-error-block"> + <i class="icon-information full-linear-icon-information" style="margin-left: 125px; font-size: 90px"></i> + <br> + <div class="activity-error-msg1">There's currently no + news available.</div> + </div> + </div> + </div> + </div> + </div> +</div> diff --git a/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.scss b/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.scss new file mode 100644 index 00000000..7a773398 --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.scss @@ -0,0 +1,37 @@ +/*- + * ============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============================================ + * + * + */
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.spec.ts b/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.spec.ts new file mode 100644 index 00000000..d7991933 --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.spec.ts @@ -0,0 +1,63 @@ +/*- + * ============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 { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ListWidgetComponent } from './list-widget.component'; + +describe('ListWidgetComponent', () => { + let component: ListWidgetComponent; + let fixture: ComponentFixture<ListWidgetComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ListWidgetComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ListWidgetComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.ts b/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.ts new file mode 100644 index 00000000..1d28026f --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/dynamic-widget/list-widget/list-widget.component.ts @@ -0,0 +1,61 @@ +/*- + * ============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 { Component, OnInit } from '@angular/core'; +import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +@Component({ + selector: 'app-list-widget', + templateUrl: './list-widget.component.html', + styleUrls: ['./list-widget.component.scss'] +}) +export class ListWidgetComponent implements OnInit { + newsData: any[]; + + constructor(private api: HttpClient) { } + + ngOnInit() { + this.getNewsWidgetCatalog(); + } + + getNewsWidgetCatalog() { + //console.log("getNewsWidgetCatalog called"); + } + +} diff --git a/portal-FE-common/src/app/shared/plugin/plugin-loader/client-plugin-loader.service.ts b/portal-FE-common/src/app/shared/plugin/plugin-loader/client-plugin-loader.service.ts new file mode 100644 index 00000000..2666a523 --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/plugin-loader/client-plugin-loader.service.ts @@ -0,0 +1,86 @@ +/*- + * ============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, NgModuleFactory } from '@angular/core'; +import { PluginLoaderService } from './plugin-loader.service'; +import { PLUGIN_EXTERNALS_MAP } from './plugin-externals'; +import { PluginsConfigProvider } from '../plugins-config.provider'; + +const SystemJs = window.System; + +@Injectable({ + providedIn: 'root', +}) +export class ClientPluginLoaderService extends PluginLoaderService { + constructor(private configProvider: PluginsConfigProvider) { + super(); + configProvider.loadConfig() + .toPromise() + .then(config => { + configProvider.config = config; + console.log(config); + }); + } + + provideExternals() { + Object.keys(PLUGIN_EXTERNALS_MAP).forEach(externalKey => + window.define(externalKey, [], () => PLUGIN_EXTERNALS_MAP[externalKey]) + ); + } + + load<T>(pluginName): Promise<NgModuleFactory<T>> { + + const { config } = this.configProvider; + if (!config[pluginName]) { + throw Error(`Can't find appropriate plugin`); + } + + const depsPromises = (config[pluginName].deps || []).map(dep => { + return SystemJs.import(window['base'] + config[dep].path).then(m => { + window['define'](dep, [], () => m.default); + }); + }); + + return Promise.all(depsPromises).then(() => { + + return SystemJs.import(window['base'] + config[pluginName].path).then( + module => module.default.default + ); + }); + } +} diff --git a/portal-FE-common/src/app/shared/plugin/plugin-loader/plugin-externals.ts b/portal-FE-common/src/app/shared/plugin/plugin-loader/plugin-externals.ts new file mode 100644 index 00000000..3bd5a133 --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/plugin-loader/plugin-externals.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 * as core from '@angular/core'; +import * as common from '@angular/common'; +import * as forms from '@angular/forms'; +import * as router from '@angular/router'; +import * as rxjs from 'rxjs'; +import * as tslib from 'tslib'; + +export const PLUGIN_EXTERNALS_MAP = { + 'ng.core': core, + 'ng.common': common, + 'ng.forms': forms, + 'ng.router': router, + rxjs, + tslib +}; diff --git a/portal-FE-common/src/app/shared/plugin/plugin-loader/plugin-loader.service.ts b/portal-FE-common/src/app/shared/plugin/plugin-loader/plugin-loader.service.ts new file mode 100644 index 00000000..1d79b65f --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/plugin-loader/plugin-loader.service.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 { NgModuleFactory } from '@angular/core'; + +export abstract class PluginLoaderService { + protected constructor() { + this.provideExternals(); + } + + abstract provideExternals(): void; + + abstract load<T>(pluginName): Promise<NgModuleFactory<T>>; +} diff --git a/portal-FE-common/src/app/shared/plugin/plugin.component.html b/portal-FE-common/src/app/shared/plugin/plugin.component.html new file mode 100644 index 00000000..e2aeaf18 --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/plugin.component.html @@ -0,0 +1,48 @@ +<!-- + ============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============================================ + + + --> + +<p> plugin works</p> +<button (click)="loadPlugin('listWidgetPlugin')">Load News</button> +<div> + <div class="plugins"> + <ng-template #targetRef></ng-template> + </div> +</div> +<!-- +<app-list-widget></app-list-widget> +--> diff --git a/portal-FE-common/src/app/shared/plugin/plugin.component.scss b/portal-FE-common/src/app/shared/plugin/plugin.component.scss new file mode 100644 index 00000000..fa57ecbf --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/plugin.component.scss @@ -0,0 +1,38 @@ +/*- + * ============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============================================ + * + * + */ +
\ No newline at end of file diff --git a/portal-FE-common/src/app/shared/plugin/plugin.component.spec.ts b/portal-FE-common/src/app/shared/plugin/plugin.component.spec.ts new file mode 100644 index 00000000..cc5810c1 --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/plugin.component.spec.ts @@ -0,0 +1,63 @@ +/*- + * ============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 { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PluginComponent } from './plugin.component'; + +describe('PluginComponent', () => { + let component: PluginComponent; + let fixture: ComponentFixture<PluginComponent>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ PluginComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(PluginComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/portal-FE-common/src/app/shared/plugin/plugin.component.ts b/portal-FE-common/src/app/shared/plugin/plugin.component.ts new file mode 100644 index 00000000..b64ea7c9 --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/plugin.component.ts @@ -0,0 +1,75 @@ +/*- + * ============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 { + Component, + Injector, + OnInit, + ViewChild, + ViewContainerRef +} from '@angular/core'; +import { PluginLoaderService } from './plugin-loader/plugin-loader.service'; + +@Component({ + selector: 'app-plugin', + templateUrl: './plugin.component.html', + styleUrls: ['./plugin.component.scss'] +}) +export class PluginComponent implements OnInit { + @ViewChild('targetRef', { read: ViewContainerRef }) vcRef: ViewContainerRef; + + constructor( + private injector: Injector, + private pluginLoader: PluginLoaderService + ) {} + + ngOnInit() { + //this.loadPlugin('plugin1'); + } + + loadPlugin(pluginName: string) { + this.pluginLoader.load(pluginName).then(moduleFactory => { + const moduleRef = moduleFactory.create(this.injector); + const entryComponent = (moduleFactory.moduleType as any).entry; + const compFactory = moduleRef.componentFactoryResolver.resolveComponentFactory( + entryComponent + ); + this.vcRef.createComponent(compFactory); + }); + } +} diff --git a/portal-FE-common/src/app/shared/plugin/plugin.module.ts b/portal-FE-common/src/app/shared/plugin/plugin.module.ts new file mode 100644 index 00000000..de366627 --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/plugin.module.ts @@ -0,0 +1,89 @@ +/*- + * ============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 { + BrowserModule, + BrowserTransferStateModule, TransferState +} from '@angular/platform-browser'; +import { APP_INITIALIZER, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core'; +import { HttpClientModule } from '@angular/common/http'; +import { DynamicWidgetModule } from './dynamic-widget/dynamic-widget.module'; + + + +import { ClientPluginLoaderService } from './plugin-loader/client-plugin-loader.service'; +import { PluginsConfigProvider } from './plugins-config.provider'; +import { TransferStateService } from './transfer-state.service'; +import { PluginLoaderService } from './plugin-loader/plugin-loader.service'; +import { PluginComponent } from './plugin.component'; +import { ListWidgetComponent } from './dynamic-widget/list-widget/list-widget.component'; + +import { config } from 'rxjs'; + +@NgModule({ + declarations: [PluginComponent], + imports: [ + HttpClientModule, + //BrowserModule.withServerTransition({ appId: 'serverApp' }), + BrowserTransferStateModule + ], + providers: [ + { provide: PluginLoaderService, useClass: ClientPluginLoaderService }, + //PluginsConfigProvider, + TransferStateService, + { + provide: APP_BOOTSTRAP_LISTENER, + useFactory: (provider: PluginsConfigProvider) => () => + provider + .loadConfig() + .toPromise() + .then(config => { + provider.config = config; + console.log(config); + } + ), + multi: true, + deps: [PluginsConfigProvider] + } + ], + bootstrap: [PluginComponent], + exports: [PluginComponent] +}) +export class PluginModule { + constructor(transferStateService: TransferStateService) {} +} diff --git a/portal-FE-common/src/app/shared/plugin/plugins-config.provider.ts b/portal-FE-common/src/app/shared/plugin/plugins-config.provider.ts new file mode 100644 index 00000000..8c2a2e7d --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/plugins-config.provider.ts @@ -0,0 +1,75 @@ +/*- + * ============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 { Inject, Injectable, Optional, PLATFORM_ID } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { tap } from 'rxjs/operators'; +import { preserveServerState } from './transfer-state.service'; +import { isPlatformBrowser } from '@angular/common'; + +interface PluginsConfig { + [key: string]: { + name: string; + path: string; + deps: string[]; + }; +} + +@Injectable({ + providedIn: 'root', +}) +export class PluginsConfigProvider { + config: PluginsConfig; + + constructor( + private http: HttpClient, + @Inject(PLATFORM_ID) private platformId: {}, + @Inject('APP_BASE_URL') @Optional() private readonly baseUrl: string + ) { + if (isPlatformBrowser(platformId)) { + this.baseUrl = document.location.origin; + } + } + + @preserveServerState('PLUGIN_CONFIGS') + loadConfig() { + return this.http.get<PluginsConfig>( + `assets/plugins-config.json` + ); + } +} diff --git a/portal-FE-common/src/app/shared/plugin/transfer-state.service.ts b/portal-FE-common/src/app/shared/plugin/transfer-state.service.ts new file mode 100644 index 00000000..e42abcb8 --- /dev/null +++ b/portal-FE-common/src/app/shared/plugin/transfer-state.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 { Inject, Injectable, PLATFORM_ID } from '@angular/core'; +import { makeStateKey, TransferState } from '@angular/platform-browser'; +import { isPlatformBrowser, isPlatformServer } from '@angular/common'; +import { of } from 'rxjs'; +import { tap } from 'rxjs/operators'; + +let isBrowser: boolean; +let isServer: boolean; +let transferState: TransferState; + +@Injectable({ + providedIn: 'root' +}) +export class TransferStateService { + constructor( + private state: TransferState, + @Inject(PLATFORM_ID) private platformId: any + ) { + transferState = state; + isBrowser = isPlatformBrowser(this.platformId); + isServer = isPlatformServer(this.platformId); + } +} + +export const preserveServerState = ( + keyName: string, + emptyResult: any = null +) => { + const key = makeStateKey(keyName); + return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => { + const method = descriptor.value; + descriptor.value = function() { + if (isBrowser && transferState.hasKey(key)) { + const state = transferState.get(key, emptyResult); + return of(state); + } + + return method.apply(this, arguments).pipe( + tap(res => { + // if (isServer) { + transferState.set(key, res); + // } + }) + ); + }; + }; +}; |