oip-common 0.1.6 → 0.1.8

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/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import * as i0 from '@angular/core';
2
- import { OnInit, OnDestroy, WritableSignal, Type, Provider, InjectionToken, EventEmitter, Renderer2, OnChanges, SimpleChanges, PipeTransform } from '@angular/core';
2
+ import { OnInit, OnDestroy, WritableSignal, OnChanges, SimpleChanges, Type, Provider, InjectionToken, EventEmitter, Renderer2, EnvironmentProviders, PipeTransform } from '@angular/core';
3
3
  import { MessageService, ToastMessageOptions, MenuItem, ConfirmationService, FilterMetadata } from 'primeng/api';
4
4
  import { ActivatedRoute, QueryParamsHandling, IsActiveMatchOptions, Params, Router, UrlTree } from '@angular/router';
5
- import { TranslateService, InterpolationParameters, Translation, TranslationObject } from '@ngx-translate/core';
5
+ import { InterpolationParameters, Translation, TranslationObject, TranslateService } from '@ngx-translate/core';
6
6
  import * as rxjs from 'rxjs';
7
7
  import { Subscription, Subject, Observable, BehaviorSubject } from 'rxjs';
8
8
  import { LoginResponse, AuthOptions, OidcSecurityService, LogoutAuthOptions, AbstractSecurityStorage, StsConfigHttpLoader } from 'angular-auth-oidc-client';
9
9
  import { ContextMenu } from 'primeng/contextmenu';
10
+ import { PaletteDesignToken, Preset } from '@primeuix/themes/types';
10
11
  import { PrimeNG } from 'primeng/config';
11
12
  import { Table } from 'primeng/table';
12
13
  import { HttpInterceptorFn, HttpClient as HttpClient$1 } from '@angular/common/http';
@@ -44,6 +45,9 @@ declare class MsgService {
44
45
  warn(detail: any, summary?: any, life?: number): void;
45
46
  error(detail: any, summary?: any, life?: number): void;
46
47
  extractErrorMessage(error: unknown, fallback: string): string;
48
+ private extractValidationMessage;
49
+ private toValidationMessages;
50
+ private getObjectProperty;
47
51
  errorFromException(error: unknown, fallback: string, summary?: string, life?: number): void;
48
52
  contrast(detail: any, summary?: any, life?: number): void;
49
53
  secondary(detail: any, summary?: any, life?: number): void;
@@ -176,9 +180,64 @@ declare class LayoutService {
176
180
  static ɵprov: i0.ɵɵInjectableDeclaration<LayoutService>;
177
181
  }
178
182
 
183
+ interface LanguageDto {
184
+ code: string;
185
+ name: string;
186
+ icon: string;
187
+ }
188
+ /**
189
+ * Service for managing translation loading in the application
190
+ */
191
+ declare class L10nService {
192
+ private loadedTranslations;
193
+ private httpClient;
194
+ private translateService;
195
+ private readonly primeNg;
196
+ private readonly layoutService;
197
+ availableLanguages: LanguageDto[];
198
+ /**
199
+ * Loads translations for a specific component
200
+ * @param component - Name of the component to load translations for
201
+ */
202
+ loadComponentTranslations(component: string): void;
203
+ /**
204
+ * Gets the translated value of a key (or an array of keys)
205
+ * @returns the translated key, or an object of translated keys
206
+ */
207
+ get(key: string): rxjs.Observable<any>;
208
+ /**
209
+ * Internal method to load translations from JSON files
210
+ * @param component - Component or translation namespace
211
+ * @param lang - Language code to load translations for
212
+ */
213
+ private loadTranslations;
214
+ /**
215
+ * Changes the lang currently used
216
+ */
217
+ use(selectedLanguage: string, key?: string): void;
218
+ init(languages: LanguageDto[]): void;
219
+ instant(key: string | string[], interpolateParams?: InterpolationParameters): Translation | TranslationObject;
220
+ static ɵfac: i0.ɵɵFactoryDeclaration<L10nService, never>;
221
+ static ɵprov: i0.ɵɵInjectableDeclaration<L10nService>;
222
+ }
223
+
224
+ interface SecurityDto {
225
+ code: string;
226
+ name: string;
227
+ description: string;
228
+ roles: string[];
229
+ }
230
+
179
231
  declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSettings> implements OnInit, OnDestroy {
232
+ private static readonly readRight;
233
+ private static readonly editRight;
234
+ private static readonly deleteRight;
180
235
  private isInitialized;
181
236
  private moduleInstanceReloadPromise;
237
+ private rightsSubscription?;
238
+ private readonly destroyRef;
239
+ private readonly securityDataService;
240
+ private readonly securityService;
182
241
  /**
183
242
  * Provide access to app settings
184
243
  */
@@ -246,6 +305,12 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
246
305
  * @type {string}
247
306
  */
248
307
  title: string;
308
+ l10nService: L10nService;
309
+ l10n$: Observable<Translation | TranslationObject>;
310
+ canRead: boolean;
311
+ canEdit: boolean;
312
+ canDelete: boolean;
313
+ securityRightsLoaded: boolean;
249
314
  /**
250
315
  * Updates local settings and persists them to local storage.
251
316
  * @return {void}
@@ -281,6 +346,10 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
281
346
  * Defines the top bar items.
282
347
  */
283
348
  topBarItems: TopBarDto[];
349
+ /**
350
+ * Gets an instant translation for a key or an array of keys.
351
+ */
352
+ t(key: string | string[], interpolateParams?: InterpolationParameters): Translation | TranslationObject;
284
353
  /**
285
354
  * Initializes the component and subscribes to local settings updates.
286
355
  */
@@ -315,23 +384,37 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
315
384
  * Derived components can override this to refresh module-specific data.
316
385
  */
317
386
  protected onModuleInstanceChange(): Promise<void>;
387
+ /**
388
+ * Called whenever current user rights for the active module instance are recalculated.
389
+ */
390
+ protected onSecurityRightsChange(): void;
391
+ /**
392
+ * Starts watching current token roles and maps them to module instance security settings.
393
+ */
394
+ protected watchSecurityRights(controller?: string, id?: number | undefined): void;
395
+ private resetRightsState;
396
+ private updateRightsState;
397
+ protected hasSecurityRight(roles: string[], securitySettings: SecurityDto[], code: string): boolean;
318
398
  private reloadModuleInstance;
319
399
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseModuleComponent<any, any>, never>;
320
400
  static ɵcmp: i0.ɵɵComponentDeclaration<BaseModuleComponent<any, any>, "ng-component", never, {}, {}, never, never, true, never>;
321
401
  }
322
402
 
323
- declare class SecurityComponent implements OnInit, OnDestroy {
403
+ declare class SecurityComponent implements OnChanges, OnInit, OnDestroy {
324
404
  private readonly msgService;
325
405
  private readonly dataService;
326
406
  private readonly translateService;
407
+ private securityLoadToken;
327
408
  securityData: any[];
328
- id: number;
329
- controller: string;
409
+ id?: number;
410
+ controller?: string;
330
411
  roles: string[];
331
412
  ngOnDestroy(): void;
413
+ ngOnChanges(changes: SimpleChanges): void;
332
414
  ngOnInit(): void;
333
415
  saveClick(): void;
334
416
  saveKeyDown($event: KeyboardEvent): void;
417
+ private loadSecurity;
335
418
  static ɵfac: i0.ɵɵFactoryDeclaration<SecurityComponent, never>;
336
419
  static ɵcmp: i0.ɵɵComponentDeclaration<SecurityComponent, "security", never, { "id": { "alias": "id"; "required": false; }; "controller": { "alias": "controller"; "required": false; }; }, {}, never, never, true, never>;
337
420
  }
@@ -925,47 +1008,6 @@ declare class LogoComponent {
925
1008
  static ɵcmp: i0.ɵɵComponentDeclaration<LogoComponent, "logo", never, { "width": { "alias": "width"; "required": false; }; "height": { "alias": "height"; "required": false; }; }, {}, never, never, true, never>;
926
1009
  }
927
1010
 
928
- interface LanguageDto {
929
- code: string;
930
- name: string;
931
- icon: string;
932
- }
933
- /**
934
- * Service for managing translation loading in the application
935
- */
936
- declare class L10nService {
937
- private loadedTranslations;
938
- private httpClient;
939
- private translateService;
940
- private readonly primeNg;
941
- private readonly layoutService;
942
- availableLanguages: LanguageDto[];
943
- /**
944
- * Loads translations for a specific component
945
- * @param component - Name of the component to load translations for
946
- */
947
- loadComponentTranslations(component: string): void;
948
- /**
949
- * Gets the translated value of a key (or an array of keys)
950
- * @returns the translated key, or an object of translated keys
951
- */
952
- get(key: string): rxjs.Observable<any>;
953
- /**
954
- * Internal method to load translations from JSON files
955
- * @param component - Component or translation namespace
956
- * @param lang - Language code to load translations for
957
- */
958
- private loadTranslations;
959
- /**
960
- * Changes the lang currently used
961
- */
962
- use(selectedLanguage: string, key?: string): void;
963
- init(languages: LanguageDto[]): void;
964
- instant(key: string | string[], interpolateParams?: InterpolationParameters): Translation | TranslationObject;
965
- static ɵfac: i0.ɵɵFactoryDeclaration<L10nService, never>;
966
- static ɵprov: i0.ɵɵInjectableDeclaration<L10nService>;
967
- }
968
-
969
1011
  declare class NotfoundComponent {
970
1012
  constructor(l10nService: L10nService);
971
1013
  static ɵfac: i0.ɵɵFactoryDeclaration<NotfoundComponent, never>;
@@ -1041,7 +1083,6 @@ interface MigrationDto {
1041
1083
  }
1042
1084
  declare class DbMigrationComponent extends BaseModuleComponent<NoSettingsDto, NoSettingsDto> implements OnInit, OnDestroy {
1043
1085
  data: MigrationDto[];
1044
- l10nService: L10nService;
1045
1086
  constructor();
1046
1087
  ngOnInit(): Promise<void>;
1047
1088
  refreshAction(): Promise<void>;
@@ -1090,20 +1131,7 @@ declare class AppModulesComponent implements OnInit {
1090
1131
 
1091
1132
  declare type SurfacesType = {
1092
1133
  name?: string;
1093
- palette?: {
1094
- 0?: string;
1095
- 50?: string;
1096
- 100?: string;
1097
- 200?: string;
1098
- 300?: string;
1099
- 400?: string;
1100
- 500?: string;
1101
- 600?: string;
1102
- 700?: string;
1103
- 800?: string;
1104
- 900?: string;
1105
- 950?: string;
1106
- };
1134
+ palette?: PaletteDesignToken;
1107
1135
  };
1108
1136
  declare class AppConfiguratorComponent implements OnInit {
1109
1137
  router: Router;
@@ -1111,7 +1139,16 @@ declare class AppConfiguratorComponent implements OnInit {
1111
1139
  layoutService: LayoutService;
1112
1140
  platformId: Object;
1113
1141
  primeng: PrimeNG;
1114
- presets: string[];
1142
+ private readonly injectedThemePresets;
1143
+ private readonly themePresetMergeMode;
1144
+ private readonly themePresets;
1145
+ private readonly themePresetsMap;
1146
+ private readonly defaultThemePreset;
1147
+ private readonly fallbackPrimaryColors;
1148
+ presets: {
1149
+ label: string;
1150
+ value: string;
1151
+ }[];
1115
1152
  showMenuModeButton: i0.WritableSignal<boolean>;
1116
1153
  menuModeOptions: {
1117
1154
  label: string;
@@ -1124,22 +1161,10 @@ declare class AppConfiguratorComponent implements OnInit {
1124
1161
  selectedPreset: i0.Signal<string>;
1125
1162
  menuMode: i0.Signal<string>;
1126
1163
  primaryColors: i0.Signal<SurfacesType[]>;
1164
+ surfaceColors: i0.Signal<SurfacesType[]>;
1127
1165
  getPresetExt(): {
1128
1166
  semantic: {
1129
- primary: {
1130
- 0?: string;
1131
- 50?: string;
1132
- 100?: string;
1133
- 200?: string;
1134
- 300?: string;
1135
- 400?: string;
1136
- 500?: string;
1137
- 600?: string;
1138
- 700?: string;
1139
- 800?: string;
1140
- 900?: string;
1141
- 950?: string;
1142
- };
1167
+ primary: PaletteDesignToken;
1143
1168
  colorScheme: {
1144
1169
  light: {
1145
1170
  primary: {
@@ -1172,6 +1197,11 @@ declare class AppConfiguratorComponent implements OnInit {
1172
1197
  };
1173
1198
  };
1174
1199
  };
1200
+ private getThemePresets;
1201
+ private getThemeById;
1202
+ private getPrimaryColorOptions;
1203
+ private getSurfaceColorOptions;
1204
+ private ensureValidThemeId;
1175
1205
  updateColors(event: MouseEvent, type: string, color: SurfacesType): void;
1176
1206
  applyTheme(type: string, color: SurfacesType): void;
1177
1207
  onPresetChange(event: string): void;
@@ -1423,13 +1453,6 @@ declare class DiscussionComponent implements OnChanges, OnDestroy, OnInit {
1423
1453
  static ɵcmp: i0.ɵɵComponentDeclaration<DiscussionComponent, "discussion", never, { "objectTypeId": { "alias": "objectTypeId"; "required": true; }; "objectId": { "alias": "objectId"; "required": true; }; }, {}, never, never, true, never>;
1424
1454
  }
1425
1455
 
1426
- interface SecurityDto {
1427
- code: string;
1428
- name: string;
1429
- description: string;
1430
- roles: string[];
1431
- }
1432
-
1433
1456
  interface PutSecurityDto {
1434
1457
  id: number;
1435
1458
  securities: SecurityDto[];
@@ -1522,6 +1545,24 @@ declare class TableFilterService {
1522
1545
  static ɵprov: i0.ɵɵInjectableDeclaration<TableFilterService>;
1523
1546
  }
1524
1547
 
1548
+ interface AppThemePreset {
1549
+ id: string;
1550
+ label?: string;
1551
+ preset: Preset;
1552
+ primaryColors?: Record<string, PaletteDesignToken | undefined>;
1553
+ surfaceColors?: Record<string, PaletteDesignToken | undefined>;
1554
+ }
1555
+ type AppThemePresetMergeMode = 'mergeWithDefaults' | 'replaceDefaults';
1556
+ declare const APP_THEME_PRESETS: InjectionToken<readonly AppThemePreset[]>;
1557
+ declare const APP_THEME_PRESETS_MERGE_MODE: InjectionToken<AppThemePresetMergeMode>;
1558
+
1559
+ interface ProvideAppThemesOptions {
1560
+ mode?: AppThemePresetMergeMode;
1561
+ }
1562
+ declare function provideAppThemes(themes: AppThemePreset[], options?: ProvideAppThemesOptions): EnvironmentProviders;
1563
+ declare function mergeWithDefaults(themes: AppThemePreset[]): EnvironmentProviders;
1564
+ declare function replaceDefaults(themes: AppThemePreset[]): EnvironmentProviders;
1565
+
1525
1566
  type OipFrontendAppMode = 'standalone' | 'distributed';
1526
1567
  interface OipFrontendConfig {
1527
1568
  appMode: OipFrontendAppMode;
@@ -1548,5 +1589,5 @@ declare class SecurePipe implements PipeTransform {
1548
1589
  */
1549
1590
  declare const httpLoaderAuthFactory: (httpClient: HttpClient$1) => StsConfigHttpLoader;
1550
1591
 
1551
- 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 };
1552
- export type { AppConfig, LanguageDto, MenuChangeEvent, NoSettingsDto, OipFrontendAppMode, OipFrontendConfig, PutSecurityDto, RequestParams, SecurityDto, TopBarDto };
1592
+ export { APP_THEME_PRESETS, APP_THEME_PRESETS_MERGE_MODE, 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, mergeWithDefaults, provideAppThemes, provideLogoComponent, replaceDefaults };
1593
+ export type { AppConfig, AppThemePreset, AppThemePresetMergeMode, LanguageDto, MenuChangeEvent, NoSettingsDto, OipFrontendAppMode, OipFrontendConfig, PutSecurityDto, RequestParams, SecurityDto, TopBarDto };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oip-common",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "A template for cross-platform web applications based on sakai-ng and primeNG",
5
5
  "main": "index.js",
6
6
  "keywords": [