@genesislcap/blank-app-seed 3.25.2 → 3.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/blank-app-seed-config",
3
3
  "description": "Genesis Blank App Seed Configuration",
4
- "version": "3.25.2",
4
+ "version": "3.27.0",
5
5
  "license": "Apache-2.0",
6
6
  "scripts": {
7
7
  "lint": "eslint .",
@@ -2,7 +2,7 @@
2
2
  <ng-container *ngIf="hasUserPermission('{{config.permissions.viewRight}}'); else notPermitted{{ config.index }}">
3
3
  <rapid-g2plot-chart
4
4
  type="{{ config.type }}"
5
- [config]="tile{{ config.index }}.chartConfig"
5
+ [config]="chartConfig"
6
6
  >
7
7
  <chart-datasource
8
8
  resourceName="{{ config.resourceName }}"
@@ -0,0 +1,9 @@
1
+ import { ColDef } from '@ag-grid-community/core';
2
+ import { getNumberFormatter, getDateFormatter } from '@genesislcap/foundation-utils';
3
+ {{#if route.FDC3EventHandlersEnabled}}
4
+ import { sendEventOnChannel } from '../../../utils';
5
+ {{/if}}
6
+
7
+ {{#if tile.config.columns}}
8
+ export const columnDefs: ColDef[] = {{{ tile.config.columns }}}
9
+ {{/if}}
@@ -0,0 +1,8 @@
1
+ import { UiSchema } from '@genesislcap/foundation-forms';
2
+
3
+ {{#if tile.config.createFormUiSchema}}
4
+ export const createFormSchema: UiSchema = {{{ tile.config.createFormUiSchema }}}
5
+ {{/if}}
6
+ {{#if tile.config.uischema}}
7
+ export const createFormSchema: UiSchema = {{{ tile.config.uischema }}}
8
+ {{/if}}
@@ -0,0 +1,9 @@
1
+ import { GridOptionsConfig } from '@genesislcap/rapid-grid-pro';
2
+ import { getNumberFormatter, getDateFormatter } from '@genesislcap/foundation-utils';
3
+ {{#if route.FDC3EventHandlersEnabled}}
4
+ import { sendEventOnChannel } from '../../../utils';
5
+ {{/if}}
6
+
7
+ {{#if tile.config.gridOptions}}
8
+ export const gridOptions: GridOptionsConfig = {{{ tile.config.gridOptions }}}
9
+ {{/if}}
@@ -0,0 +1,48 @@
1
+ import { Component, Input, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { getUser } from '@genesislcap/foundation-user';
4
+ import { GridOptionsConfig } from "@genesislcap/rapid-grid-pro";
5
+ import { getViewUpdateRightComponent } from '../../../utils';
6
+ {{#if tile.config.createFormUiSchema}}
7
+ import { createFormSchema } from './{{kebabCase tile.title}}.create.form.schema';
8
+ {{/if}}
9
+ {{#if tile.config.uischema}}
10
+ import { createFormSchema } from './{{kebabCase tile.title}}.create.form.schema';
11
+ {{/if}}
12
+ {{#if tile.config.updateFormUiSchema}}
13
+ import { updateFormSchema } from './{{kebabCase tile.title}}.update.form.schema';
14
+ {{/if}}
15
+ {{#if tile.config.columns}}
16
+ import { columnDefs } from './{{kebabCase tile.title}}.column.defs';
17
+ {{/if}}
18
+ {{#if tile.config.gridOptions}}
19
+ import { gridOptions } from './{{kebabCase tile.title}}.gridOptions';
20
+ {{/if}}
21
+
22
+ @Component({
23
+ selector: 'app-{{kebabCase tile.componentName}}',
24
+ templateUrl: './{{kebabCase tile.title}}.component.html',
25
+ styleUrl: './{{kebabCase tile.title}}.component.css',
26
+ standalone: true,
27
+ imports: [
28
+ CommonModule,
29
+ ],
30
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
31
+ })
32
+ export class {{pascalCase tile.componentName}} {
33
+ hasUserPermission = (permissionCode: string) => getViewUpdateRightComponent(getUser(), permissionCode);{{#if tile.config.createFormUiSchema}}
34
+ createFormSchema = createFormSchema;{{/if}}{{#if tile.config.uischema}}
35
+ uischema = createFormSchema;{{/if}}{{#if tile.config.updateFormUiSchema}}
36
+ updateFormSchema = updateFormSchema;{{/if}}{{#if tile.config.columns}}
37
+ columnDefs = columnDefs;{{/if}}{{#if tile.config.gridOptions}}
38
+ gridOptions = gridOptions as GridOptionsConfig;{{/if}}{{#if tile.config.reqrep}}
39
+ reqrep = { pollingInterval: 5000 };{{/if}}{{#if tile.config.type}}
40
+ chartConfig = { {{#ifEquals this.config.type 'pie'}}
41
+ "radius": 0.75,
42
+ "angleField": "value",
43
+ "colorField": "groupBy",{{else}}
44
+ "xField": "groupBy",
45
+ "yField": "value",{{/ifEquals}}
46
+ };{{/if}}
47
+
48
+ }
@@ -0,0 +1 @@
1
+ export * from './{{kebabCase tile.title}}.component';
@@ -0,0 +1,3 @@
1
+ :host {
2
+ /* insert css styles here */
3
+ }
@@ -0,0 +1 @@
1
+ {{> (lookup tile 'type') tile}}
@@ -0,0 +1,5 @@
1
+ import { UiSchema } from '@genesislcap/foundation-forms';
2
+
3
+ {{#if tile.config.updateFormUiSchema}}
4
+ export const updateFormSchema: UiSchema = {{{ tile.config.updateFormUiSchema }}}
5
+ {{/if}}
@@ -12,13 +12,13 @@
12
12
  {{#if config.createEvent}}
13
13
  [createEvent]="hasUserPermission('{{config.permissions.updateRight}}') ? '{{ config.createEvent }}' : undefined"
14
14
  {{#if config.createFormUiSchema}}
15
- [createFormUiSchema]="tile{{ config.index }}.createFormUiSchema"
15
+ [createFormUiSchema]="createFormSchema"
16
16
  {{/if}}
17
17
  {{/if}}
18
18
  {{#if config.updateEvent}}
19
19
  [updateEvent]="hasUserPermission('{{config.permissions.updateRight}}') ? '{{ config.updateEvent }}' : undefined"
20
20
  {{#if config.updateFormUiSchema}}
21
- [updateFormUiSchema]="tile{{ config.index }}.updateFormUiSchema"
21
+ [updateFormUiSchema]="updateFormSchema"
22
22
  {{/if}}
23
23
  {{/if}}
24
24
  {{#if config.deleteEvent}}
@@ -31,10 +31,10 @@
31
31
  [datasourceConfig]="{ isSnapshot: {{ config.snapshot }} }"
32
32
  {{/if}}
33
33
  {{#if config.reqrep}}
34
- [datasourceConfig]="tile{{ config.index }}.reqrep"
34
+ [datasourceConfig]="reqrep"
35
35
  {{/if}}
36
36
  {{#if config.columns}}
37
- [columns]="tile{{ config.index }}.columns"
37
+ [columns]="columnDefs"
38
38
  {{/if}}
39
39
  {{#if config.modalPosition}}
40
40
  modal-position="{{ config.modalPosition }}"
@@ -4,7 +4,7 @@
4
4
  design-system-prefix="rapid"
5
5
  resourceName="{{config.resourceName}}"
6
6
  {{#if config.uischema}}
7
- [uischema]="tile{{ config.index }}.uischema"
7
+ [uischema]="uischema"
8
8
  {{/if}}
9
9
  >
10
10
  </foundation-form>
@@ -11,14 +11,14 @@
11
11
  isSnapshot="{{config.snapshot}}"
12
12
  {{/if}}
13
13
  {{#if config.reqrep}}
14
- [datasourceConfig]="tile{{ config.index }}.reqrep"
14
+ [datasourceConfig]="reqrep"
15
15
  {{/if}}
16
16
  {{#if config.gridOptions}}
17
- [deferredGridOptions]="{ onRowClicked: tile{{ config.index }}.gridOptions.onRowClicked }"
17
+ [deferredGridOptions]="{ onRowClicked: gridOptions.onRowClicked }"
18
18
  {{/if}}
19
19
  ></grid-pro-genesis-datasource>
20
20
  {{#if config.gridOptions}}
21
- <grid-pro-column *ngFor="let columnDef of tile{{ config.index }}.gridOptions?.columnDefs" [definition]="columnDef"></grid-pro-column>
21
+ <grid-pro-column *ngFor="let columnDef of gridOptions?.columnDefs" [definition]="columnDef"></grid-pro-column>
22
22
  {{/if}}
23
23
  </rapid-grid-pro>
24
24
  <section
@@ -3,12 +3,12 @@
3
3
  {{#each route.tiles}}
4
4
  {{#ifEquals @index 0}}
5
5
  <rapid-layout-item title="{{../title}}">
6
- {{> (lookup ../this 'type') ../this}}
6
+ <app-{{kebabCase ../componentName}}></app-{{kebabCase ../componentName}}>
7
7
  </rapid-layout-item>
8
8
  {{/ifEquals}}
9
9
  {{#ifEquals @index 1}}
10
10
  <rapid-layout-item title="{{../title}}">
11
- {{> (lookup ../this 'type') ../this}}
11
+ <app-{{kebabCase ../componentName}}></app-{{kebabCase ../componentName}}>
12
12
  </rapid-layout-item>
13
13
  {{/ifEquals}}
14
14
  {{/each}}
@@ -17,12 +17,12 @@
17
17
  {{#each route.tiles}}
18
18
  {{#ifEquals @index 2}}
19
19
  <rapid-layout-item title="{{../title}}">
20
- {{> (lookup ../this 'type') ../this}}
20
+ <app-{{kebabCase ../componentName}}></app-{{kebabCase ../componentName}}>
21
21
  </rapid-layout-item>
22
22
  {{/ifEquals}}
23
23
  {{#ifEquals @index 3}}
24
24
  <rapid-layout-item title="{{../title}}">
25
- {{> (lookup ../this 'type') ../this}}
25
+ <app-{{kebabCase ../componentName}}></app-{{kebabCase ../componentName}}>
26
26
  </rapid-layout-item>
27
27
  {{/ifEquals}}
28
28
  {{/each}}
@@ -1,7 +1,7 @@
1
1
  <rapid-layout-region>
2
2
  {{#each route.tiles}}
3
3
  <rapid-layout-item title="{{this.title}}">
4
- {{> (lookup . 'type') }}
4
+ <app-{{kebabCase this.componentName}}></app-{{kebabCase this.componentName}}>
5
5
  </rapid-layout-item>
6
6
  {{/each}}
7
7
  </rapid-layout-region>
@@ -1,20 +1,20 @@
1
1
  import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
- import { User, getUser } from '@genesislcap/foundation-user';
4
- import { GridOptionsConfig } from '@genesislcap/rapid-grid-pro';
5
- import { getNumberFormatter, getDateFormatter } from '@genesislcap/foundation-utils';
6
- import { getViewUpdateRightComponent } from '../../utils';
7
3
  import { ErrorMessageComponent } from '../../components/error-message/error-message.component';
4
+ {{#each route.tiles}}
5
+ import { {{pascalCase this.componentName}} } from './{{kebabCase this.title}}-{{this.componentType}}';
6
+ {{/each}}
8
7
  import { environment } from '../../../environments/environment';
9
- {{#if route.FDC3EventHandlersEnabled}}
10
- import { sendEventOnChannel } from '../../utils';
11
- {{/if}}
8
+
12
9
 
13
10
  @Component({
14
- selector: 'app-{{pascalCase route.name}}',
11
+ selector: 'app-{{kebabCase route.name}}',
15
12
  standalone: true,
16
13
  imports: [
17
14
  ErrorMessageComponent,
15
+ {{#each route.tiles}}
16
+ {{pascalCase this.componentName}},
17
+ {{/each}}
18
18
  CommonModule,
19
19
  ],
20
20
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
@@ -23,26 +23,4 @@ import { sendEventOnChannel } from '../../utils';
23
23
  })
24
24
  export class {{pascalCase route.name}}Component {
25
25
  environment = environment;
26
- hasUserPermission = (permissionCode: string) => getViewUpdateRightComponent(getUser(), permissionCode);
27
- {{#if route.FDC3EventHandlersEnabled}}
28
- sendEventOnChannel = sendEventOnChannel;
29
- {{/if}}
30
-
31
- {{#each route.tiles}}
32
- tile{{this.config.index}} = { {{#if this.config.createFormUiSchema}}
33
- "createFormUiSchema": {{{ this.config.createFormUiSchema }}},{{/if}}{{#if this.config.updateFormUiSchema}}
34
- "updateFormUiSchema": {{{ this.config.updateFormUiSchema }}},{{/if}}{{#if this.config.uischema}}
35
- "uischema": {{{ this.config.uischema }}},{{/if}}{{#if this.config.gridOptions}}
36
- "gridOptions": {{{ this.config.gridOptions }}} as GridOptionsConfig,{{/if}}{{#if this.config.reqrep}}
37
- "reqrep": {{{ this.config.reqrep }}},{{/if}}{{#if this.config.columns}}
38
- "columns": {{{ this.config.columns }}},{{/if}}{{#if this.config.type}}
39
- "chartConfig": { {{#ifEquals this.config.type 'pie'}}
40
- "radius": 0.75,
41
- "angleField": "value",
42
- "colorField": "groupBy",{{else}}
43
- "xField": "groupBy",
44
- "yField": "value",{{/ifEquals}}
45
- },{{/if}}
46
- }{{#unless @last}};{{/unless}}
47
- {{/each}}
48
26
  }
@@ -73,8 +73,13 @@ const generateRoute = (route, { changeCase, writeFileWithData }, framework) => {
73
73
  );
74
74
  });
75
75
 
76
- // Remove condition after adding changes for angular & react
77
- if (framework === FRAMEWORK_WEB_COMPONENTS_ALIAS && route?.tiles?.length) {
76
+ // Remove condition after adding changes for react
77
+ if (
78
+ [FRAMEWORK_WEB_COMPONENTS_ALIAS, FRAMEWORK_ANGULAR_ALIAS].includes(
79
+ framework,
80
+ ) &&
81
+ route?.tiles?.length
82
+ ) {
78
83
  route.tiles.forEach((tile) => {
79
84
  generateTile(tile, route, { changeCase, writeFileWithData }, framework);
80
85
  });
@@ -6,37 +6,44 @@ const {
6
6
  DIR_TEMPLATE_BY_FRAMEWORK,
7
7
  } = require('../static');
8
8
 
9
+ const defaultPathGetters = {
10
+ index: (componentPath) => `${componentPath}/index.ts`,
11
+ addForm: (componentPath, tile) =>
12
+ `${componentPath}/${tile.name}.create.form.schema.ts`,
13
+ updateForm: (componentPath, tile) =>
14
+ `${componentPath}/${tile.name}.update.form.schema.ts`,
15
+ columnDefs: (componentPath, tile) =>
16
+ `${componentPath}/${tile.name}.column.defs.ts`,
17
+ gridOptions: (componentPath, tile) =>
18
+ `${componentPath}/${tile.name}.gridOptions.ts`,
19
+ };
20
+
9
21
  const getPathByFramework = {
10
22
  [FRAMEWORK_WEB_COMPONENTS_ALIAS]: {
23
+ ...defaultPathGetters,
11
24
  clientSrcPath: `../../client/src/routes`,
12
- route: (clientSrcPath, tileName, tileType, routeName) =>
13
- `${clientSrcPath}/${routeName}/${tileName}-${tileType}`,
14
- index: (componentPath) => `${componentPath}/index.ts`,
15
- component: (componentPath, tileName) => `${componentPath}/${tileName}.ts`,
16
- template: (componentPath, tileName) =>
17
- `${componentPath}/${tileName}.template.ts`,
18
- style: (componentPath, tileName) =>
19
- `${componentPath}/${tileName}.styles.ts`,
20
- addForm: (componentPath, tileName) =>
21
- `${componentPath}/${tileName}.create.form.schema.ts`,
22
- updateForm: (componentPath, tileName) =>
23
- `${componentPath}/${tileName}.update.form.schema.ts`,
24
- columnDefs: (componentPath, tileName) =>
25
- `${componentPath}/${tileName}.column.defs.ts`,
26
- gridOptions: (componentPath, tileName) =>
27
- `${componentPath}/${tileName}.gridOptions.ts`,
25
+ route: (clientSrcPath, tile, routeName) =>
26
+ `${clientSrcPath}/${routeName}/${tile.name}-${tile.componentType}`,
27
+ component: (componentPath, tile) => `${componentPath}/${tile.name}.ts`,
28
+ template: (componentPath, tile) =>
29
+ `${componentPath}/${tile.name}.template.ts`,
30
+ style: (componentPath, tile) => `${componentPath}/${tile.name}.styles.ts`,
31
+ },
32
+ [FRAMEWORK_ANGULAR_ALIAS]: {
33
+ ...defaultPathGetters,
34
+ clientSrcPath: `../../client/src/app/pages`,
35
+ route: (clientSrcPath, tile, routeName) =>
36
+ `${clientSrcPath}/${routeName}/${tile.name}-${tile.componentType}`,
37
+ component: (componentPath, tile) =>
38
+ `${componentPath}/${tile.name}.component.ts`,
39
+ template: (componentPath, tile) =>
40
+ `${componentPath}/${tile.name}.component.html`,
41
+ style: (componentPath, tile) =>
42
+ `${componentPath}/${tile.name}.component.css`,
28
43
  },
29
- // Placeholder for angular part
30
- [FRAMEWORK_ANGULAR_ALIAS]: {},
31
44
  };
32
45
 
33
- const getFilesToWrite = (
34
- tile,
35
- tileName,
36
- routeName,
37
- path,
38
- sourceTemplateDir,
39
- ) => {
46
+ const getFilesToWrite = (tileData, routeName, path, sourceTemplateDir) => {
40
47
  const {
41
48
  clientSrcPath,
42
49
  route: getRouteDir,
@@ -50,51 +57,46 @@ const getFilesToWrite = (
50
57
  gridOptions: getGridOptionsTarget,
51
58
  } = path;
52
59
 
53
- const routeDir = getRouteDir(
54
- clientSrcPath,
55
- tileName,
56
- tile.componentType,
57
- routeName,
58
- );
60
+ const routeDir = getRouteDir(clientSrcPath, tileData, routeName);
59
61
 
60
62
  const componentIndexFile = {
61
63
  source: `${sourceTemplateDir}/component/component.index.hbs`,
62
- target: getComponentIndexTarget(routeDir, tileName),
64
+ target: getComponentIndexTarget(routeDir, tileData),
63
65
  };
64
66
 
65
67
  const componentFile = {
66
68
  source: `${sourceTemplateDir}/component/component.hbs`,
67
- target: getComponentTarget(routeDir, tileName),
69
+ target: getComponentTarget(routeDir, tileData),
68
70
  };
69
71
 
70
72
  const componentTemplateFile = {
71
73
  source: `${sourceTemplateDir}/component/component.template.hbs`,
72
- target: getTemplateTarget(routeDir, tileName),
74
+ target: getTemplateTarget(routeDir, tileData),
73
75
  };
74
76
 
75
77
  const componentStylesFile = {
76
78
  source: `${sourceTemplateDir}/component/component.styles.hbs`,
77
- target: getStyleTarget(routeDir, tileName),
79
+ target: getStyleTarget(routeDir, tileData),
78
80
  };
79
81
 
80
82
  const componentAddFormFile = {
81
83
  source: `${sourceTemplateDir}/component/component.create.form.hbs`,
82
- target: getAddFormTarget(routeDir, tileName),
84
+ target: getAddFormTarget(routeDir, tileData),
83
85
  };
84
86
 
85
87
  const componentUpdateFormFile = {
86
88
  source: `${sourceTemplateDir}/component/component.update.form.hbs`,
87
- target: getUpdateFormTarget(routeDir, tileName),
89
+ target: getUpdateFormTarget(routeDir, tileData),
88
90
  };
89
91
 
90
92
  const componentColumnsFile = {
91
93
  source: `${sourceTemplateDir}/component/component.column.defs.hbs`,
92
- target: getColumnDefsTarget(routeDir, tileName),
94
+ target: getColumnDefsTarget(routeDir, tileData),
93
95
  };
94
96
 
95
97
  const componentGridOptionsFile = {
96
98
  source: `${sourceTemplateDir}/component/component.gridOptions.hbs`,
97
- target: getGridOptionsTarget(routeDir, tileName),
99
+ target: getGridOptionsTarget(routeDir, tileData),
98
100
  };
99
101
 
100
102
  const filesToWrite = [
@@ -104,23 +106,23 @@ const getFilesToWrite = (
104
106
  componentStylesFile,
105
107
  ];
106
108
 
107
- switch (tile.type) {
109
+ switch (tileData.type) {
108
110
  case 'entity-manager':
109
- if (tile.config?.columns) {
111
+ if (tileData.config?.columns) {
110
112
  filesToWrite.push(componentColumnsFile);
111
113
  }
112
- if (tile.config?.gridOptions) {
114
+ if (tileData.config?.gridOptions) {
113
115
  filesToWrite.push(componentGridOptionsFile);
114
116
  }
115
- if (tile.config?.createFormUiSchema) {
117
+ if (tileData.config?.createFormUiSchema) {
116
118
  filesToWrite.push(componentAddFormFile);
117
119
  }
118
- if (tile.config?.updateFormUiSchema) {
120
+ if (tileData.config?.updateFormUiSchema) {
119
121
  filesToWrite.push(componentUpdateFormFile);
120
122
  }
121
123
  break;
122
124
  case 'grid-pro':
123
- if (tile.config?.gridOptions) {
125
+ if (tileData.config?.gridOptions) {
124
126
  filesToWrite.push(componentGridOptionsFile);
125
127
  }
126
128
  break;
@@ -140,20 +142,19 @@ const generateTile = (
140
142
  { changeCase, writeFileWithData },
141
143
  framework,
142
144
  ) => {
143
- const tileName = changeCase.paramCase(tile.title);
145
+ const tileData = {
146
+ ...tile,
147
+ name: changeCase.paramCase(tile.title),
148
+ componentType: tile.componentType,
149
+ config: tile.config,
150
+ };
144
151
  const routeName = changeCase.paramCase(route.name);
145
152
  const sourceTemplateDir = `../${DIR_TEMPLATE_BY_FRAMEWORK[framework]}`;
146
153
  const { clientSrcPath, route: getRouteDir } = getPathByFramework[framework];
147
- const routeDir = getRouteDir(
148
- clientSrcPath,
149
- tileName,
150
- tile.componentType,
151
- routeName,
152
- );
154
+ const routeDir = getRouteDir(clientSrcPath, tileData, routeName);
153
155
 
154
156
  const filesToWrite = getFilesToWrite(
155
- tile,
156
- tileName,
157
+ tileData,
157
158
  routeName,
158
159
  getPathByFramework[framework],
159
160
  sourceTemplateDir,
@@ -0,0 +1,8 @@
1
+ const isString = (input) => {
2
+ return (
3
+ typeof input === 'string' &&
4
+ Object.prototype.toString.call(input) === '[object String]'
5
+ );
6
+ };
7
+
8
+ module.exports = isString;
@@ -1,7 +1,12 @@
1
1
  const { FRAMEWORKS_ALIAS } = require('../static');
2
2
  const normalizeFrameworkAlias = require('./normalizeFrameworkAlias');
3
+ const isString = require('./isString');
3
4
 
4
5
  const validateFrameworkAlias = (alias) => {
6
+ if (!isString(alias)) {
7
+ return false;
8
+ }
9
+
5
10
  return FRAMEWORKS_ALIAS.includes(normalizeFrameworkAlias(alias));
6
11
  };
7
12
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.27.0](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v3.26.0...v3.27.0) (2024-07-25)
4
+
5
+
6
+ ### Features
7
+
8
+ * Implement the generated UI code structure proposal (angular) (#287) 6d61502, closes FUI-2099 FUI-2099 FUI-2099
9
+
10
+ ## [3.26.0](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v3.25.2...v3.26.0) (2024-07-24)
11
+
12
+
13
+ ### Features
14
+
15
+ * sso in angular [FUI-2069](https://github.com/genesiscommunitysuccess/blank-app-seed/issues/2069) (#282) 577c5a3
16
+
3
17
  ## [3.25.2](https://github.com/genesiscommunitysuccess/blank-app-seed/compare/v3.25.1...v3.25.2) (2024-07-23)
4
18
 
5
19
 
@@ -0,0 +1,41 @@
1
+ // Set the appHostURL from which the providers are to be fetched.
2
+ const appHostURL = `${location.protocol}//${location.host}/gwf/`;
3
+
4
+ const fetchIDPs = async () => {
5
+ const ipdsEndpoint = `${appHostURL}sso/list`;
6
+ console.log('IPD endpoint', ipdsEndpoint);
7
+ return fetch(ipdsEndpoint)
8
+ .then((res) => {
9
+ if (res.ok) return res;
10
+ throw new Error(res.statusText);
11
+ })
12
+ .then((res) => res.json())
13
+ .then((json) => json.IDPS)
14
+ .catch(() => {
15
+ console.error('Failed to fetch identity providers.');
16
+ return [{ ID: 'error', DESCRIPTION: 'Failed to fetch providers.' }];
17
+ });
18
+ };
19
+
20
+ // If we do not have initSSO token in our sessionStorage,
21
+ // then we check the list of providers and get ssoToken
22
+ if (!sessionStorage.getItem('initSSO')) {
23
+ fetchIDPs().then((allIdps) => {
24
+ console.log('Fetched IDPs', allIdps);
25
+ idps = allIdps.map((idp) => ({
26
+ id: idp.ID,
27
+ type: idp.TYPE,
28
+ }));
29
+
30
+ // Set initSSO token in sessionStorage after the first fetch of providers
31
+ sessionStorage.setItem('initSSO', 'true');
32
+
33
+ // If your environment has more providers and you want to test it - set a number corresponding to the number of your providers
34
+ if (idps.length === 1 && idps[0].type) {
35
+ const ssoLoginRoute = `/gwf/${idps[0].type}/login`;
36
+ const ssoLoginUrl = `${location.protocol}//${new URL(appHostURL).host}${ssoLoginRoute}?idp=${idps[0].id}`;
37
+
38
+ window.open(ssoLoginUrl, '_self');
39
+ }
40
+ });
41
+ }
@@ -6,6 +6,9 @@
6
6
  <base href="/">
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1">
8
8
  <link rel="icon" type="image/x-icon" href="favicon.ico">
9
+ {{#if enableSSO}}
10
+ <script src="assets/initSSO.js"></script>
11
+ {{/if}}
9
12
  </head>
10
13
  <body>
11
14
  <{{rootElement}}></{{rootElement}}>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/blank-app-seed",
3
3
  "description": "Genesis Blank App Seed",
4
- "version": "3.25.2",
4
+ "version": "3.27.0",
5
5
  "license": "Apache-2.0",
6
6
  "scripts": {
7
7
  "release": "semantic-release"