oip-common 0.0.37 → 0.1.1
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.
- package/fesm2022/oip-common.mjs +61 -7
- package/fesm2022/oip-common.mjs.map +1 -1
- package/index.d.ts +27 -2
- package/package.json +1 -1
package/fesm2022/oip-common.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, inject, signal, computed, effect, ChangeDetectorRef, Component, Input, PLATFORM_ID,
|
|
2
|
+
import { Injectable, inject, InjectionToken, signal, computed, effect, ChangeDetectorRef, Component, Input, PLATFORM_ID, HostBinding, EventEmitter, Output, ViewChild, Renderer2, SecurityContext, ChangeDetectionStrategy, Pipe } from '@angular/core';
|
|
3
3
|
import * as i2$6 from 'primeng/api';
|
|
4
4
|
import { MessageService, ConfirmationService, PrimeIcons, SharedModule } from 'primeng/api';
|
|
5
5
|
import { HttpErrorResponse, HttpClient as HttpClient$1, HttpHeaders } from '@angular/common/http';
|
|
@@ -197,6 +197,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
197
197
|
args: [{ providedIn: 'root' }]
|
|
198
198
|
}] });
|
|
199
199
|
|
|
200
|
+
const DEFAULT_OIP_FRONTEND_CONFIG = {
|
|
201
|
+
appMode: 'standalone',
|
|
202
|
+
apiBaseUrl: '',
|
|
203
|
+
notificationHubUrl: ''
|
|
204
|
+
};
|
|
205
|
+
const OIP_FRONTEND_CONFIG = new InjectionToken('OIP_FRONTEND_CONFIG', {
|
|
206
|
+
factory: () => DEFAULT_OIP_FRONTEND_CONFIG
|
|
207
|
+
});
|
|
208
|
+
|
|
200
209
|
/**
|
|
201
210
|
* BaseDataService provides a unified interface for sending HTTP requests
|
|
202
211
|
* using Angular's HttpClient. It supports standard HTTP methods and automatic
|
|
@@ -205,12 +214,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
205
214
|
class BaseDataService {
|
|
206
215
|
constructor() {
|
|
207
216
|
this.http = inject(HttpClient$1);
|
|
217
|
+
this.frontendConfig = inject(OIP_FRONTEND_CONFIG);
|
|
208
218
|
}
|
|
209
219
|
/**
|
|
210
220
|
* Gets the base URL of the application from the HTML <base> tag.
|
|
211
221
|
*/
|
|
212
222
|
get baseUrl() {
|
|
213
|
-
return document.getElementsByTagName('base')[0].href;
|
|
223
|
+
return this.normalizeBaseUrl(this.frontendConfig.apiBaseUrl || document.getElementsByTagName('base')[0].href);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Builds a fully-qualified application URL based on frontend mode.
|
|
227
|
+
*/
|
|
228
|
+
buildUrl(path) {
|
|
229
|
+
const normalizedPath = path.startsWith('/') ? path.substring(1) : path;
|
|
230
|
+
return `${this.baseUrl}${normalizedPath}`;
|
|
214
231
|
}
|
|
215
232
|
/**
|
|
216
233
|
* Sends an HTTP request with the specified method and data.
|
|
@@ -258,6 +275,9 @@ class BaseDataService {
|
|
|
258
275
|
const result = this.http.get(url, httpOptions);
|
|
259
276
|
return lastValueFrom(result);
|
|
260
277
|
}
|
|
278
|
+
normalizeBaseUrl(baseUrl) {
|
|
279
|
+
return baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
|
|
280
|
+
}
|
|
261
281
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: BaseDataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
262
282
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: BaseDataService }); }
|
|
263
283
|
}
|
|
@@ -565,6 +585,9 @@ class BaseModuleComponent {
|
|
|
565
585
|
if (localStorageSettingsString != null) {
|
|
566
586
|
this.localSettings.set(JSON.parse(localStorageSettingsString));
|
|
567
587
|
}
|
|
588
|
+
else {
|
|
589
|
+
this.localSettings.set({});
|
|
590
|
+
}
|
|
568
591
|
}
|
|
569
592
|
catch (error) {
|
|
570
593
|
this.msgService.error(error, 'Error parsing layoutConfig:');
|
|
@@ -596,6 +619,8 @@ class BaseModuleComponent {
|
|
|
596
619
|
* Initializes the component and subscribes to local settings updates.
|
|
597
620
|
*/
|
|
598
621
|
constructor() {
|
|
622
|
+
this.isInitialized = false;
|
|
623
|
+
this.moduleInstanceReloadPromise = Promise.resolve();
|
|
599
624
|
/**
|
|
600
625
|
* Provide access to app settings
|
|
601
626
|
*/
|
|
@@ -681,8 +706,14 @@ class BaseModuleComponent {
|
|
|
681
706
|
this.controller = url[0].path;
|
|
682
707
|
}));
|
|
683
708
|
this.subscriptions.push(this.route.paramMap.subscribe((params) => {
|
|
684
|
-
|
|
709
|
+
const routeId = params.get('id');
|
|
710
|
+
const nextId = routeId != null ? +routeId : undefined;
|
|
711
|
+
const idChanged = this.id !== nextId;
|
|
712
|
+
this.id = nextId;
|
|
685
713
|
this.getLocalStorageSettings();
|
|
714
|
+
if (this.isInitialized && idChanged) {
|
|
715
|
+
void this.reloadModuleInstance();
|
|
716
|
+
}
|
|
686
717
|
}));
|
|
687
718
|
}
|
|
688
719
|
/**
|
|
@@ -710,7 +741,8 @@ class BaseModuleComponent {
|
|
|
710
741
|
}));
|
|
711
742
|
this.topBarService.setTopBarItems(this.topBarItems);
|
|
712
743
|
this.topBarService.activeId = this.topBarItems[0].id;
|
|
713
|
-
|
|
744
|
+
this.isInitialized = true;
|
|
745
|
+
await this.reloadModuleInstance();
|
|
714
746
|
this.subscriptions.push(this.appTitleService.title$.subscribe((title) => {
|
|
715
747
|
this.title = title;
|
|
716
748
|
this.changeDetectorRef.detectChanges();
|
|
@@ -746,6 +778,18 @@ class BaseModuleComponent {
|
|
|
746
778
|
this.msgService.error(error);
|
|
747
779
|
});
|
|
748
780
|
}
|
|
781
|
+
/**
|
|
782
|
+
* Called whenever the module instance changes, including the first load.
|
|
783
|
+
* Derived components can override this to refresh module-specific data.
|
|
784
|
+
*/
|
|
785
|
+
async onModuleInstanceChange() { }
|
|
786
|
+
async reloadModuleInstance() {
|
|
787
|
+
this.moduleInstanceReloadPromise = this.moduleInstanceReloadPromise.then(async () => {
|
|
788
|
+
await this.getSettings();
|
|
789
|
+
await this.onModuleInstanceChange();
|
|
790
|
+
});
|
|
791
|
+
await this.moduleInstanceReloadPromise;
|
|
792
|
+
}
|
|
749
793
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: BaseModuleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
750
794
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.16", type: BaseModuleComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: '', isInline: true }); }
|
|
751
795
|
}
|
|
@@ -1537,7 +1581,7 @@ class UserService {
|
|
|
1537
1581
|
* and updates the `photo` and `photoLoaded` properties accordingly.
|
|
1538
1582
|
*/
|
|
1539
1583
|
getUserPhoto() {
|
|
1540
|
-
const url =
|
|
1584
|
+
const url = this.baseDataService.buildUrl(`api/user-profile/get-user-photo?email=${this.securityService.getCurrentUser().email}`);
|
|
1541
1585
|
this.baseDataService.getBlob(url).then((data) => {
|
|
1542
1586
|
this.createImageFromBlob(data);
|
|
1543
1587
|
this.photoLoaded = true;
|
|
@@ -5872,6 +5916,7 @@ class NotificationService {
|
|
|
5872
5916
|
constructor() {
|
|
5873
5917
|
this.securityService = inject(SecurityService);
|
|
5874
5918
|
this.msgService = inject(MsgService);
|
|
5919
|
+
this.frontendConfig = inject(OIP_FRONTEND_CONFIG);
|
|
5875
5920
|
this.securityService.getAccessToken().subscribe((token) => {
|
|
5876
5921
|
this.securityData = token;
|
|
5877
5922
|
if (token) {
|
|
@@ -5881,7 +5926,7 @@ class NotificationService {
|
|
|
5881
5926
|
}
|
|
5882
5927
|
});
|
|
5883
5928
|
this.connection = new signalR.HubConnectionBuilder()
|
|
5884
|
-
.withUrl(
|
|
5929
|
+
.withUrl(this.resolveHubUrl(), {
|
|
5885
5930
|
accessTokenFactory: () => this.securityData,
|
|
5886
5931
|
skipNegotiation: true,
|
|
5887
5932
|
transport: signalR.HttpTransportType.WebSockets
|
|
@@ -5898,6 +5943,15 @@ class NotificationService {
|
|
|
5898
5943
|
this.msgService.add(opt);
|
|
5899
5944
|
});
|
|
5900
5945
|
}
|
|
5946
|
+
resolveHubUrl() {
|
|
5947
|
+
if (this.frontendConfig.notificationHubUrl) {
|
|
5948
|
+
return this.frontendConfig.notificationHubUrl;
|
|
5949
|
+
}
|
|
5950
|
+
if (this.frontendConfig.apiBaseUrl) {
|
|
5951
|
+
return `${this.frontendConfig.apiBaseUrl.replace(/\/$/, '')}/hubs/notification`;
|
|
5952
|
+
}
|
|
5953
|
+
return '/hubs/notification';
|
|
5954
|
+
}
|
|
5901
5955
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: NotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
5902
5956
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: NotificationService, providedIn: 'root' }); }
|
|
5903
5957
|
}
|
|
@@ -6036,5 +6090,5 @@ const httpLoaderAuthFactory = (httpClient) => {
|
|
|
6036
6090
|
* Generated bundle index. Do not edit.
|
|
6037
6091
|
*/
|
|
6038
6092
|
|
|
6039
|
-
export { AppConfiguratorComponent, AppFloatingConfiguratorComponent, AppLayoutComponent, AppModulesComponent, AppTopbar, AuthGuardService, BaseDataService, BaseModuleComponent, ConfigComponent, ContentType, DbMigrationComponent, DiscussionComponent, ErrorComponent, FooterComponent, HttpClient, KeycloakSecurityService, L10nService, LOGO_COMPONENT_TOKEN, LayoutService, LogoComponent, LogoService, MenuComponent, MenuService, MsgService, NotfoundComponent, NotificationService, ProfileComponent, SecurePipe, SecurityComponent, SecurityDataService, SecurityService, SecurityStorageService, SidebarComponent, TableFilterService, TopBarService, UnauthorizedComponent, UserService, httpLoaderAuthFactory, langIntercept, provideLogoComponent };
|
|
6093
|
+
export { AppConfiguratorComponent, AppFloatingConfiguratorComponent, AppLayoutComponent, AppModulesComponent, AppTopbar, AuthGuardService, BaseDataService, BaseModuleComponent, ConfigComponent, ContentType, DEFAULT_OIP_FRONTEND_CONFIG, DbMigrationComponent, DiscussionComponent, ErrorComponent, FooterComponent, HttpClient, KeycloakSecurityService, L10nService, LOGO_COMPONENT_TOKEN, LayoutService, LogoComponent, LogoService, MenuComponent, MenuService, MsgService, NotfoundComponent, NotificationService, OIP_FRONTEND_CONFIG, ProfileComponent, SecurePipe, SecurityComponent, SecurityDataService, SecurityService, SecurityStorageService, SidebarComponent, TableFilterService, TopBarService, UnauthorizedComponent, UserService, httpLoaderAuthFactory, langIntercept, provideLogoComponent };
|
|
6040
6094
|
//# sourceMappingURL=oip-common.mjs.map
|