@haloduck/core 2.0.11 → 2.1.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.
- package/package.json +8 -12
- package/fesm2022/haloduck-core.mjs +0 -960
- package/fesm2022/haloduck-core.mjs.map +0 -1
- package/haloduck-core-2.0.11.tgz +0 -0
- package/index.d.ts +0 -541
|
@@ -1,960 +0,0 @@
|
|
|
1
|
-
import { from, switchMap, of, distinctUntilChanged, map, catchError, withLatestFrom, tap, forkJoin } from 'rxjs';
|
|
2
|
-
import { fetchAuthSession } from 'aws-amplify/auth';
|
|
3
|
-
import * as i0 from '@angular/core';
|
|
4
|
-
import { inject, isDevMode, Pipe, Injectable, InjectionToken, Inject } from '@angular/core';
|
|
5
|
-
import { createFeatureSelector, createSelector, Store, createAction, props, createReducer, on } from '@ngrx/store';
|
|
6
|
-
import { HttpClient } from '@angular/common/http';
|
|
7
|
-
import { map as map$1, catchError as catchError$1, withLatestFrom as withLatestFrom$1, mergeMap, finalize } from 'rxjs/operators';
|
|
8
|
-
import { ComponentStore } from '@ngrx/component-store';
|
|
9
|
-
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
|
10
|
-
|
|
11
|
-
const authGuard = (route, state) => {
|
|
12
|
-
return from(fetchAuthSession()).pipe(switchMap((session) => {
|
|
13
|
-
if (session.tokens?.idToken) {
|
|
14
|
-
return of(true);
|
|
15
|
-
}
|
|
16
|
-
window.location.href = '/authenticate';
|
|
17
|
-
return of(false);
|
|
18
|
-
}));
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// deprecated
|
|
22
|
-
const dummyMemberIdInterceptor = (req, next) => {
|
|
23
|
-
const dummyMemberId = localStorage.getItem('dummyMemberId');
|
|
24
|
-
if (req.url.startsWith('http://localhost')) {
|
|
25
|
-
if (dummyMemberId) {
|
|
26
|
-
const clonedRequest = req.clone({
|
|
27
|
-
setHeaders: {
|
|
28
|
-
'X-Dummy-Member-Id': dummyMemberId || '',
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
return next(clonedRequest);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return next(req);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
var GlobalSelectors;
|
|
38
|
-
(function (GlobalSelectors) {
|
|
39
|
-
GlobalSelectors.selectGlobalState = createFeatureSelector('global');
|
|
40
|
-
GlobalSelectors.isInitiated = createSelector(GlobalSelectors.selectGlobalState, (state) => state.initiated);
|
|
41
|
-
GlobalSelectors.selectIsAuthenticated = createSelector(GlobalSelectors.selectGlobalState, (state) => state.isAuthenticated);
|
|
42
|
-
GlobalSelectors.selectProfile = createSelector(GlobalSelectors.selectGlobalState, (state) => state.profile);
|
|
43
|
-
GlobalSelectors.selectIsLoading = createSelector(GlobalSelectors.selectGlobalState, (state) => state.loadingReference > 0);
|
|
44
|
-
GlobalSelectors.selectAcl = createSelector(GlobalSelectors.selectGlobalState, (state) => state.acl);
|
|
45
|
-
GlobalSelectors.selectListMenuItem = createSelector(GlobalSelectors.selectGlobalState, (state) => state.listMenuItem);
|
|
46
|
-
GlobalSelectors.selectIsSideMenuOpen = createSelector(GlobalSelectors.selectGlobalState, (state) => state.isSideMenuOpen);
|
|
47
|
-
GlobalSelectors.selectLanguage = createSelector(GlobalSelectors.selectGlobalState, (state) => state.language);
|
|
48
|
-
GlobalSelectors.canActivate = (resource, action, shouldStripTag) => createSelector(GlobalSelectors.selectAcl, (acl) => {
|
|
49
|
-
const allowedActions = [];
|
|
50
|
-
switch (action) {
|
|
51
|
-
case 'delete':
|
|
52
|
-
allowedActions.push('delete');
|
|
53
|
-
break;
|
|
54
|
-
case 'create':
|
|
55
|
-
allowedActions.push('delete');
|
|
56
|
-
allowedActions.push('create');
|
|
57
|
-
break;
|
|
58
|
-
case 'update':
|
|
59
|
-
allowedActions.push('delete');
|
|
60
|
-
allowedActions.push('create');
|
|
61
|
-
allowedActions.push('update');
|
|
62
|
-
break;
|
|
63
|
-
case 'read':
|
|
64
|
-
allowedActions.push('delete');
|
|
65
|
-
allowedActions.push('create');
|
|
66
|
-
allowedActions.push('update');
|
|
67
|
-
allowedActions.push('read');
|
|
68
|
-
}
|
|
69
|
-
const result = Object.keys(acl).some((aclKey) => {
|
|
70
|
-
return ['delete', 'create', 'update', 'read'].some((_action) => {
|
|
71
|
-
if (undefined === acl[aclKey][_action]) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
let [_resource, _conditionsRaw] = resource.split(':');
|
|
75
|
-
const _conditions = _conditionsRaw ? _conditionsRaw.split('|') : [];
|
|
76
|
-
_resource =
|
|
77
|
-
shouldStripTag && _resource.includes('/') ? _resource.split('/')[0] : _resource;
|
|
78
|
-
const _resourceAclArray = acl[aclKey][_action];
|
|
79
|
-
return _resourceAclArray.some((_resourceAclRaw) => {
|
|
80
|
-
const [_resourceAcl, _conditionsAclRaw] = _resourceAclRaw.split(':');
|
|
81
|
-
const _conditionsAcl = _conditionsAclRaw ? _conditionsAclRaw.split('|') : [];
|
|
82
|
-
if (_resourceAcl === '*') {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
if (_resource === _resourceAcl &&
|
|
86
|
-
allowedActions.includes(_action) &&
|
|
87
|
-
(_conditions.length === 0 ||
|
|
88
|
-
_conditionsAcl.some((_condition) => _conditions.includes(_condition)))) {
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
return false;
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
return result;
|
|
96
|
-
});
|
|
97
|
-
GlobalSelectors.selectCurrentGroupId = createSelector(GlobalSelectors.selectGlobalState, (state) => state.currentGroup?.id);
|
|
98
|
-
GlobalSelectors.selectCurrentGroup = createSelector(GlobalSelectors.selectGlobalState, (state) => state.currentGroup);
|
|
99
|
-
})(GlobalSelectors || (GlobalSelectors = {}));
|
|
100
|
-
|
|
101
|
-
// deprecated
|
|
102
|
-
const groupIdInterceptor = (req, next) => {
|
|
103
|
-
const store = inject((Store));
|
|
104
|
-
const groupId$ = store.select(GlobalSelectors.selectCurrentGroupId);
|
|
105
|
-
if (req.url.endsWith('/member/me'))
|
|
106
|
-
return next(req);
|
|
107
|
-
if (req.url.endsWith('/menu'))
|
|
108
|
-
return next(req);
|
|
109
|
-
if (req.url.endsWith('/acl'))
|
|
110
|
-
return next(req);
|
|
111
|
-
if (req.url.startsWith('https://api') || req.url.startsWith('http://localhost')) {
|
|
112
|
-
return groupId$.pipe(switchMap((groupId) => {
|
|
113
|
-
if (groupId) {
|
|
114
|
-
const clonedRequest = req.clone({
|
|
115
|
-
setHeaders: {
|
|
116
|
-
'X-Group-Id': groupId || '',
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
return next(clonedRequest);
|
|
120
|
-
}
|
|
121
|
-
return next(req);
|
|
122
|
-
}));
|
|
123
|
-
}
|
|
124
|
-
return next(req);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const idTokenInterceptor = (req, next) => {
|
|
128
|
-
if (req.url.endsWith('/oauth2/token'))
|
|
129
|
-
return next(req);
|
|
130
|
-
if (req.url.startsWith('https://api')) {
|
|
131
|
-
return from(fetchAuthSession()).pipe(switchMap((session) => {
|
|
132
|
-
if (session.tokens?.idToken) {
|
|
133
|
-
const clonedRequest = req.clone({
|
|
134
|
-
setHeaders: {
|
|
135
|
-
Authorization: `Bearer ${session.tokens.idToken}`,
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
return next(clonedRequest);
|
|
139
|
-
}
|
|
140
|
-
return next(req);
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
143
|
-
else if (req.url.startsWith('https://auth') || req.url.startsWith('https://eleven-auth')) {
|
|
144
|
-
return from(fetchAuthSession()).pipe(switchMap((session) => {
|
|
145
|
-
if (session.tokens?.accessToken) {
|
|
146
|
-
const clonedRequest = req.clone({
|
|
147
|
-
setHeaders: {
|
|
148
|
-
Authorization: `Bearer ${session.tokens.accessToken}`,
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
return next(clonedRequest);
|
|
152
|
-
}
|
|
153
|
-
return next(req);
|
|
154
|
-
}));
|
|
155
|
-
}
|
|
156
|
-
return next(req);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
var SearchParams;
|
|
160
|
-
(function (SearchParams) {
|
|
161
|
-
SearchParams.SortDirectionAsc = 'asc';
|
|
162
|
-
SearchParams.SortDirectionDesc = 'desc';
|
|
163
|
-
// export interface OrderAndPage{
|
|
164
|
-
// size: number;
|
|
165
|
-
// sort: Order[];
|
|
166
|
-
// searchAfter?: any[];
|
|
167
|
-
// }
|
|
168
|
-
})(SearchParams || (SearchParams = {}));
|
|
169
|
-
|
|
170
|
-
function responseHandler(response) {
|
|
171
|
-
if (!response) {
|
|
172
|
-
errorHandler({
|
|
173
|
-
error: 'empty response',
|
|
174
|
-
message: 'empty response',
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
if (response.error != '00') {
|
|
178
|
-
errorHandler({
|
|
179
|
-
error: response.error,
|
|
180
|
-
message: response.message,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
return response;
|
|
184
|
-
}
|
|
185
|
-
function errorHandler(err) {
|
|
186
|
-
isDevMode() && console.error('API Error: ', err);
|
|
187
|
-
throw err;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
class DisplayNamePipe {
|
|
191
|
-
transform(member) {
|
|
192
|
-
if (!member)
|
|
193
|
-
return '';
|
|
194
|
-
return member.nickname?.trim() || member.fullName || '' || (member.email || '').split('@')[0];
|
|
195
|
-
}
|
|
196
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: DisplayNamePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
197
|
-
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.1.4", ngImport: i0, type: DisplayNamePipe, isStandalone: true, name: "displayName" });
|
|
198
|
-
}
|
|
199
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: DisplayNamePipe, decorators: [{
|
|
200
|
-
type: Pipe,
|
|
201
|
-
args: [{
|
|
202
|
-
name: 'displayName',
|
|
203
|
-
}]
|
|
204
|
-
}] });
|
|
205
|
-
|
|
206
|
-
var GlobalActions;
|
|
207
|
-
(function (GlobalActions) {
|
|
208
|
-
GlobalActions.markInitiated = createAction('[Global] Mark Initiated', props());
|
|
209
|
-
GlobalActions.clearAuthentication = createAction('[Global] Clear Authentication');
|
|
210
|
-
GlobalActions.setAuthenticated = createAction('[Global] Set Authenticated', props());
|
|
211
|
-
GlobalActions.setProfile = createAction('[Global] Set Profile', props());
|
|
212
|
-
GlobalActions.increaseLoadingReference = createAction('[Global] Increase Loading Reference');
|
|
213
|
-
GlobalActions.decreaseLoadingReference = createAction('[Global] Decrease Loading Reference');
|
|
214
|
-
GlobalActions.setAcl = createAction('[Global] Set Acl', props());
|
|
215
|
-
GlobalActions.setListMenuItem = createAction('[Global] Set List Menu Item', props());
|
|
216
|
-
GlobalActions.toggleSideMenu = createAction('[Global] Toggle Side Menu');
|
|
217
|
-
GlobalActions.closeSideMenu = createAction('[Global] Close Side Menu');
|
|
218
|
-
GlobalActions.setLanguage = createAction('[Global] Set Language', props());
|
|
219
|
-
GlobalActions.setCurrentGroup = createAction('[Global] Set Current Group', props());
|
|
220
|
-
})(GlobalActions || (GlobalActions = {}));
|
|
221
|
-
|
|
222
|
-
class AuthService {
|
|
223
|
-
globalStore = inject((Store));
|
|
224
|
-
canActivate(resource, action, shouldStripTag) {
|
|
225
|
-
return this.globalStore
|
|
226
|
-
.select(GlobalSelectors.canActivate(resource, action, shouldStripTag))
|
|
227
|
-
.pipe(distinctUntilChanged());
|
|
228
|
-
}
|
|
229
|
-
getProfile() {
|
|
230
|
-
return this.globalStore.select(GlobalSelectors.selectProfile);
|
|
231
|
-
}
|
|
232
|
-
setProfile(profile) {
|
|
233
|
-
return this.globalStore.dispatch(GlobalActions.setProfile({ profile }));
|
|
234
|
-
}
|
|
235
|
-
isAuthenticated() {
|
|
236
|
-
return this.globalStore
|
|
237
|
-
.select(GlobalSelectors.selectIsAuthenticated)
|
|
238
|
-
.pipe(distinctUntilChanged());
|
|
239
|
-
}
|
|
240
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
241
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
242
|
-
}
|
|
243
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: AuthService, decorators: [{
|
|
244
|
-
type: Injectable,
|
|
245
|
-
args: [{
|
|
246
|
-
providedIn: 'root',
|
|
247
|
-
}]
|
|
248
|
-
}] });
|
|
249
|
-
|
|
250
|
-
const defaultLanguage = { id: 'en', value: 'English' };
|
|
251
|
-
const supportedLanguages = [defaultLanguage, { id: 'ko', value: '한국어' }];
|
|
252
|
-
const HALODUCK_CORE_CONFIG = new InjectionToken('HALODUCK_CORE_CONFIG', {
|
|
253
|
-
providedIn: 'root',
|
|
254
|
-
factory: () => ({
|
|
255
|
-
stage: 'local',
|
|
256
|
-
appName: 'please-register-app-name-via-provideHaloduckCoreConfig',
|
|
257
|
-
defaultLanguage: defaultLanguage.id,
|
|
258
|
-
dateFormat: {
|
|
259
|
-
long: 'yyyy-MM-dd',
|
|
260
|
-
short: 'yyMMdd',
|
|
261
|
-
},
|
|
262
|
-
apiUrl: 'https://please-register-via-provideHaloduckCoreConfig.com',
|
|
263
|
-
cdnUrl: 'https://please-register-via-provideHaloduckCoreConfig.com',
|
|
264
|
-
map: {
|
|
265
|
-
mapId: 'please-register-map-id-via-provideHaloduckCoreConfig',
|
|
266
|
-
googleApiKey: 'please-register-google-api-key-via-provideHaloduckCoreConfig',
|
|
267
|
-
defaultLngLat: {
|
|
268
|
-
lat: 37.575971,
|
|
269
|
-
lng: 126.9768,
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
}),
|
|
273
|
-
});
|
|
274
|
-
function provideHaloduckCoreConfig(config) {
|
|
275
|
-
return {
|
|
276
|
-
provide: HALODUCK_CORE_CONFIG,
|
|
277
|
-
useValue: config,
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
class CoreService {
|
|
281
|
-
config = inject(HALODUCK_CORE_CONFIG);
|
|
282
|
-
constructor() { }
|
|
283
|
-
getStage() {
|
|
284
|
-
return this.config.stage;
|
|
285
|
-
}
|
|
286
|
-
getAppName() {
|
|
287
|
-
return this.config.appName;
|
|
288
|
-
}
|
|
289
|
-
getDefaultLanguage() {
|
|
290
|
-
return this.config.defaultLanguage;
|
|
291
|
-
}
|
|
292
|
-
getApiUrl() {
|
|
293
|
-
return this.config.apiUrl;
|
|
294
|
-
}
|
|
295
|
-
getCdnUrl() {
|
|
296
|
-
return this.config.cdnUrl;
|
|
297
|
-
}
|
|
298
|
-
getDateFormatLong() {
|
|
299
|
-
return this.config.dateFormat.long;
|
|
300
|
-
}
|
|
301
|
-
getDateFormatShort() {
|
|
302
|
-
return this.config.dateFormat.short;
|
|
303
|
-
}
|
|
304
|
-
getGoogleApiKey() {
|
|
305
|
-
return this.config.map.googleApiKey;
|
|
306
|
-
}
|
|
307
|
-
getMapId() {
|
|
308
|
-
return this.config.map.mapId;
|
|
309
|
-
}
|
|
310
|
-
getDefaultLngLat() {
|
|
311
|
-
return this.config.map.defaultLngLat;
|
|
312
|
-
}
|
|
313
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: CoreService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
314
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: CoreService, providedIn: 'root' });
|
|
315
|
-
}
|
|
316
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: CoreService, decorators: [{
|
|
317
|
-
type: Injectable,
|
|
318
|
-
args: [{
|
|
319
|
-
providedIn: 'root',
|
|
320
|
-
}]
|
|
321
|
-
}], ctorParameters: () => [] });
|
|
322
|
-
|
|
323
|
-
class BaseEntityApiService {
|
|
324
|
-
coreService = inject(CoreService);
|
|
325
|
-
http = inject(HttpClient);
|
|
326
|
-
apiUrl = this.coreService.getApiUrl();
|
|
327
|
-
createEntity(entity, parent) {
|
|
328
|
-
return this.http
|
|
329
|
-
.put(`${this.apiUrl}/${parent ? parent.name + '/' + parent.id + '/' : ''}${this.getEntityName()}`, entity)
|
|
330
|
-
.pipe(map((response) => responseHandler(response)), catchError((error) => errorHandler(error)));
|
|
331
|
-
}
|
|
332
|
-
getListEntity(searchParams, parent) {
|
|
333
|
-
const filter = JSON.stringify(searchParams.filter);
|
|
334
|
-
const sort = JSON.stringify(searchParams.sort);
|
|
335
|
-
const page = searchParams.page ? JSON.stringify(searchParams.page) : '';
|
|
336
|
-
return this.http
|
|
337
|
-
.get(`${this.apiUrl}/${parent ? parent.name + '/' + parent.id + '/' : ''}${this.getEntityName()}`, {
|
|
338
|
-
params: { filter, sort, page },
|
|
339
|
-
})
|
|
340
|
-
.pipe(map((response) => responseHandler(response)), catchError((error) => errorHandler(error)));
|
|
341
|
-
}
|
|
342
|
-
getEntityById(id, parent) {
|
|
343
|
-
return this.http
|
|
344
|
-
.get(`${this.apiUrl}/${parent ? parent.name + '/' + parent.id + '/' : ''}${this.getEntityName()}/${id}`)
|
|
345
|
-
.pipe(map((response) => responseHandler(response)), catchError((error) => errorHandler(error)));
|
|
346
|
-
}
|
|
347
|
-
updateEntityById(id, entity, parent) {
|
|
348
|
-
return this.http
|
|
349
|
-
.patch(`${this.apiUrl}/${parent ? parent.name + '/' + parent.id + '/' : ''}${this.getEntityName()}/${id}`, entity)
|
|
350
|
-
.pipe(map((response) => responseHandler(response)), catchError((error) => errorHandler(error)));
|
|
351
|
-
}
|
|
352
|
-
deleteEntityById(id, parent) {
|
|
353
|
-
return this.http
|
|
354
|
-
.delete(`${this.apiUrl}/${parent ? parent.name + '/' + parent.id + '/' : ''}${this.getEntityName()}/${id}`)
|
|
355
|
-
.pipe(map((response) => responseHandler(response)), catchError((error) => errorHandler(error)));
|
|
356
|
-
}
|
|
357
|
-
getEntityName() {
|
|
358
|
-
throw new Error('Method not implemented.');
|
|
359
|
-
}
|
|
360
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: BaseEntityApiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
361
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: BaseEntityApiService, providedIn: 'root' });
|
|
362
|
-
}
|
|
363
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: BaseEntityApiService, decorators: [{
|
|
364
|
-
type: Injectable,
|
|
365
|
-
args: [{
|
|
366
|
-
providedIn: 'root',
|
|
367
|
-
}]
|
|
368
|
-
}] });
|
|
369
|
-
|
|
370
|
-
class CdnApiService {
|
|
371
|
-
coreService = inject(CoreService);
|
|
372
|
-
http = inject(HttpClient);
|
|
373
|
-
apiUrl = this.coreService.getApiUrl();
|
|
374
|
-
upload(file, keyPrefix) {
|
|
375
|
-
return this.getPresignedPutUrl(`${keyPrefix}/${file.name}`).pipe(switchMap((response) => {
|
|
376
|
-
const presignedUrl = response.data.url;
|
|
377
|
-
const key = response.data.key;
|
|
378
|
-
return this.uploadFile(presignedUrl, file).pipe(map(() => {
|
|
379
|
-
return key;
|
|
380
|
-
}), catchError((error) => {
|
|
381
|
-
console.error('Upload error:', error);
|
|
382
|
-
return errorHandler(error);
|
|
383
|
-
}));
|
|
384
|
-
}), catchError((error) => {
|
|
385
|
-
console.error('Error getting presigned URL:', error);
|
|
386
|
-
return errorHandler(error);
|
|
387
|
-
}));
|
|
388
|
-
}
|
|
389
|
-
getPresignedPutUrl(key) {
|
|
390
|
-
return this.http
|
|
391
|
-
.get(`${this.apiUrl}/tool/presignedPutUrl`, {
|
|
392
|
-
params: { key },
|
|
393
|
-
})
|
|
394
|
-
.pipe(map((response) => responseHandler(response)), catchError((error) => errorHandler(error)));
|
|
395
|
-
}
|
|
396
|
-
uploadFile(presignedUrl, file) {
|
|
397
|
-
return this.http
|
|
398
|
-
.put(presignedUrl, file, {
|
|
399
|
-
headers: { 'x-amz-tagging': 'expire1D=true' },
|
|
400
|
-
})
|
|
401
|
-
.pipe(catchError((error) => errorHandler(error)));
|
|
402
|
-
}
|
|
403
|
-
getPresignedGetUrl(key) {
|
|
404
|
-
return this.http
|
|
405
|
-
.get(`${this.apiUrl}/tool/presignedGetUrl`, {
|
|
406
|
-
params: { key },
|
|
407
|
-
})
|
|
408
|
-
.pipe(map((response) => responseHandler(response)), catchError((error) => errorHandler(error)), map((response) => response.data.url));
|
|
409
|
-
}
|
|
410
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: CdnApiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
411
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: CdnApiService, providedIn: 'root' });
|
|
412
|
-
}
|
|
413
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: CdnApiService, decorators: [{
|
|
414
|
-
type: Injectable,
|
|
415
|
-
args: [{
|
|
416
|
-
providedIn: 'root',
|
|
417
|
-
}]
|
|
418
|
-
}] });
|
|
419
|
-
|
|
420
|
-
class GlobalApiService {
|
|
421
|
-
coreService = inject(CoreService);
|
|
422
|
-
http = inject(HttpClient);
|
|
423
|
-
apiUrl = this.coreService.getApiUrl();
|
|
424
|
-
getAcl() {
|
|
425
|
-
return this.http.get(`${this.apiUrl}/acl`).pipe(map((response) => responseHandler(response)), catchError((error) => errorHandler(error)));
|
|
426
|
-
}
|
|
427
|
-
getListMenuItem() {
|
|
428
|
-
return this.http.get(`${this.apiUrl}/menu`).pipe(map((response) => responseHandler(response)), catchError((error) => errorHandler(error)));
|
|
429
|
-
}
|
|
430
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GlobalApiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
431
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GlobalApiService, providedIn: 'root' });
|
|
432
|
-
}
|
|
433
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GlobalApiService, decorators: [{
|
|
434
|
-
type: Injectable,
|
|
435
|
-
args: [{
|
|
436
|
-
providedIn: 'root',
|
|
437
|
-
}]
|
|
438
|
-
}] });
|
|
439
|
-
|
|
440
|
-
class GroupApiService extends BaseEntityApiService {
|
|
441
|
-
getEntityName() {
|
|
442
|
-
return 'group';
|
|
443
|
-
}
|
|
444
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GroupApiService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
445
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GroupApiService, providedIn: 'root' });
|
|
446
|
-
}
|
|
447
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GroupApiService, decorators: [{
|
|
448
|
-
type: Injectable,
|
|
449
|
-
args: [{
|
|
450
|
-
providedIn: 'root',
|
|
451
|
-
}]
|
|
452
|
-
}] });
|
|
453
|
-
|
|
454
|
-
class MemberApiService extends BaseEntityApiService {
|
|
455
|
-
getEntityName() {
|
|
456
|
-
return 'member';
|
|
457
|
-
}
|
|
458
|
-
getProfile() {
|
|
459
|
-
return this.http.get(`${this.apiUrl}/${this.getEntityName()}/me`).pipe(map$1((response) => responseHandler(response)), catchError$1((error) => errorHandler(error)));
|
|
460
|
-
}
|
|
461
|
-
checkMemberByEmail(email) {
|
|
462
|
-
return this.http
|
|
463
|
-
.get(`${this.apiUrl}/${this.getEntityName()}/check/email/${email}`)
|
|
464
|
-
.pipe(map$1((response) => responseHandler(response)), catchError$1((error) => errorHandler(error)));
|
|
465
|
-
}
|
|
466
|
-
checkMemberByNickname(nickname) {
|
|
467
|
-
return this.http
|
|
468
|
-
.get(`${this.apiUrl}/${this.getEntityName()}/check/nickname/${nickname}`)
|
|
469
|
-
.pipe(map$1((response) => responseHandler(response)), catchError$1((error) => errorHandler(error)));
|
|
470
|
-
}
|
|
471
|
-
registration(member) {
|
|
472
|
-
return this.http
|
|
473
|
-
.put(`${this.apiUrl}/${this.getEntityName()}/registration`, member)
|
|
474
|
-
.pipe(map$1((response) => responseHandler(response)), catchError$1((error) => errorHandler(error)));
|
|
475
|
-
}
|
|
476
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: MemberApiService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
477
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: MemberApiService, providedIn: 'root' });
|
|
478
|
-
}
|
|
479
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: MemberApiService, decorators: [{
|
|
480
|
-
type: Injectable,
|
|
481
|
-
args: [{
|
|
482
|
-
providedIn: 'root',
|
|
483
|
-
}]
|
|
484
|
-
}] });
|
|
485
|
-
|
|
486
|
-
class DeviceApiService extends BaseEntityApiService {
|
|
487
|
-
getEntityName() {
|
|
488
|
-
return 'device';
|
|
489
|
-
}
|
|
490
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: DeviceApiService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
491
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: DeviceApiService, providedIn: 'root' });
|
|
492
|
-
}
|
|
493
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: DeviceApiService, decorators: [{
|
|
494
|
-
type: Injectable,
|
|
495
|
-
args: [{
|
|
496
|
-
providedIn: 'root',
|
|
497
|
-
}]
|
|
498
|
-
}] });
|
|
499
|
-
|
|
500
|
-
const ITableStateStatusCreating = 'creating';
|
|
501
|
-
const ITableStateStatusCreated = 'created';
|
|
502
|
-
const ITableStateStatusFailedToCreate = 'failedToCreate';
|
|
503
|
-
const ITableStateStatusUpdating = 'updating';
|
|
504
|
-
const ITableStateStatusUpdated = 'updated';
|
|
505
|
-
const ITableStateStatusFailedToUpdate = 'failedToUpdate';
|
|
506
|
-
const ITableStateStatusDeleting = 'deleting';
|
|
507
|
-
const ITableStateStatusDeleted = 'deleted';
|
|
508
|
-
const ITableStateStatusFailedToDelete = 'failedToDelete';
|
|
509
|
-
const ITableStateStatusLoading = 'loading';
|
|
510
|
-
const ITableStateStatusLoaded = 'loaded';
|
|
511
|
-
const ITableStateStatusFailedToLoad = 'failedToLoad';
|
|
512
|
-
class TableStore extends ComponentStore {
|
|
513
|
-
initialState;
|
|
514
|
-
apiService;
|
|
515
|
-
// selectors
|
|
516
|
-
status$ = this.select((state) => state.status);
|
|
517
|
-
parent$ = this.select((state) => state.parent);
|
|
518
|
-
filter$ = this.select((state) => state.filter);
|
|
519
|
-
sort$ = this.select((state) => state.sort);
|
|
520
|
-
page$ = this.select((state) => state.page);
|
|
521
|
-
listEntity$ = this.select((state) => state.listEntity);
|
|
522
|
-
totalCount$ = this.select((state) => state.totalCount);
|
|
523
|
-
currentCount$ = this.select((state) => state.currentCount);
|
|
524
|
-
isLoading$ = this.select((state) => state.isLoading);
|
|
525
|
-
lastEvaluatedKey$ = this.select((state) => state.lastEvaluatedKey);
|
|
526
|
-
// effects
|
|
527
|
-
loadListEntity = this.effect((trigger$) => trigger$.pipe(withLatestFrom(this.listEntity$, this.filter$, this.sort$, this.page$, this.parent$), switchMap(([, listEntity, filter, sort, page, parent]) => {
|
|
528
|
-
this.updateStatus(ITableStateStatusLoading);
|
|
529
|
-
return this.apiService.getListEntity({ filter, sort, page }, parent).pipe(tap((response) => {
|
|
530
|
-
this.patchState({
|
|
531
|
-
listEntity: [...listEntity, ...(response.data ? response.data : [])],
|
|
532
|
-
totalCount: listEntity.length === 0 ? response.total : this.get()?.totalCount,
|
|
533
|
-
currentCount: listEntity.length + (response.data ? response.data.length : 0),
|
|
534
|
-
lastEvaluatedKey: response.lastEvaluatedKey,
|
|
535
|
-
});
|
|
536
|
-
this.updateStatus(ITableStateStatusLoaded);
|
|
537
|
-
}), catchError(() => {
|
|
538
|
-
this.updateStatus(ITableStateStatusFailedToLoad);
|
|
539
|
-
return [];
|
|
540
|
-
}));
|
|
541
|
-
})));
|
|
542
|
-
createEntity = this.effect((trigger$) => trigger$.pipe(withLatestFrom(this.listEntity$, this.parent$), switchMap(([data, listEntity, parent]) => {
|
|
543
|
-
this.updateStatus(ITableStateStatusCreating);
|
|
544
|
-
return this.apiService.createEntity(data, parent).pipe(tap((response) => {
|
|
545
|
-
this.patchState({
|
|
546
|
-
listEntity: (() => {
|
|
547
|
-
if (response.data?.parentId) {
|
|
548
|
-
const updatedListEntity = listEntity.map((entity) => {
|
|
549
|
-
if (entity.id === response.data.parentId) {
|
|
550
|
-
return {
|
|
551
|
-
...entity,
|
|
552
|
-
children: [
|
|
553
|
-
...(entity.children
|
|
554
|
-
? [response.data, ...entity.children]
|
|
555
|
-
: [response.data]),
|
|
556
|
-
],
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
return entity;
|
|
560
|
-
});
|
|
561
|
-
const parentExists = updatedListEntity.some((entity) => entity.id === response.data.parentId);
|
|
562
|
-
if (!parentExists) {
|
|
563
|
-
return updatedListEntity.map((entity) => ({
|
|
564
|
-
...entity,
|
|
565
|
-
children: entity.children?.map((child) => child.id === response.data.parentId
|
|
566
|
-
? {
|
|
567
|
-
...child,
|
|
568
|
-
children: [
|
|
569
|
-
...(child.children
|
|
570
|
-
? [response.data, ...child.children]
|
|
571
|
-
: [response.data]),
|
|
572
|
-
],
|
|
573
|
-
}
|
|
574
|
-
: child),
|
|
575
|
-
}));
|
|
576
|
-
}
|
|
577
|
-
return updatedListEntity;
|
|
578
|
-
}
|
|
579
|
-
return [...(response.data ? [response.data] : []), ...listEntity];
|
|
580
|
-
})(),
|
|
581
|
-
});
|
|
582
|
-
this.updateStatus(ITableStateStatusCreated);
|
|
583
|
-
}), catchError(() => {
|
|
584
|
-
this.updateStatus(ITableStateStatusFailedToCreate);
|
|
585
|
-
return [];
|
|
586
|
-
}));
|
|
587
|
-
})));
|
|
588
|
-
getEntityById = this.effect((trigger$) => trigger$.pipe(withLatestFrom(this.listEntity$, this.parent$), switchMap(([id, listEntity, parent]) => {
|
|
589
|
-
this.updateStatus(ITableStateStatusLoading);
|
|
590
|
-
return this.apiService.getEntityById(id, parent).pipe(tap((response) => {
|
|
591
|
-
this.patchState({
|
|
592
|
-
listEntity: (() => {
|
|
593
|
-
if (response.data?.parentId) {
|
|
594
|
-
const updatedListEntity = listEntity.map((entity) => {
|
|
595
|
-
if (entity.id === response.data.parentId) {
|
|
596
|
-
return {
|
|
597
|
-
...entity,
|
|
598
|
-
children: [
|
|
599
|
-
...(entity.children
|
|
600
|
-
? [response.data, ...entity.children]
|
|
601
|
-
: [response.data]),
|
|
602
|
-
],
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
return entity;
|
|
606
|
-
});
|
|
607
|
-
const parentExists = updatedListEntity.some((entity) => entity.id === response.data.parentId);
|
|
608
|
-
if (!parentExists) {
|
|
609
|
-
return updatedListEntity.map((entity) => ({
|
|
610
|
-
...entity,
|
|
611
|
-
children: entity.children?.map((child) => child.id === response.data.parentId
|
|
612
|
-
? {
|
|
613
|
-
...child,
|
|
614
|
-
children: [
|
|
615
|
-
...(child.children
|
|
616
|
-
? [response.data, ...child.children]
|
|
617
|
-
: [response.data]),
|
|
618
|
-
],
|
|
619
|
-
}
|
|
620
|
-
: child),
|
|
621
|
-
}));
|
|
622
|
-
}
|
|
623
|
-
return updatedListEntity;
|
|
624
|
-
}
|
|
625
|
-
return listEntity.map((e) => (e.id === response.data.id ? response.data : e));
|
|
626
|
-
})(),
|
|
627
|
-
});
|
|
628
|
-
this.updateStatus(ITableStateStatusLoaded);
|
|
629
|
-
}), catchError(() => {
|
|
630
|
-
this.updateStatus(ITableStateStatusFailedToLoad);
|
|
631
|
-
return [];
|
|
632
|
-
}));
|
|
633
|
-
})));
|
|
634
|
-
updateEntityById = this.effect((trigger$) => trigger$.pipe(withLatestFrom(this.listEntity$, this.parent$), switchMap(([data, listEntity, parent]) => {
|
|
635
|
-
this.updateStatus(ITableStateStatusUpdating);
|
|
636
|
-
return this.apiService.updateEntityById(data.id, data.entity, parent).pipe(tap((response) => {
|
|
637
|
-
this.patchState({
|
|
638
|
-
listEntity: (() => {
|
|
639
|
-
if (response.data?.parentId) {
|
|
640
|
-
const updatedListEntity = listEntity.map((entity) => {
|
|
641
|
-
if (entity.id === response.data.parentId) {
|
|
642
|
-
return {
|
|
643
|
-
...entity,
|
|
644
|
-
children: entity.children?.map((child) => child.id === response.data.id ? response.data : child),
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
return entity;
|
|
648
|
-
});
|
|
649
|
-
const parentExists = updatedListEntity.some((entity) => entity.id === response.data.parentId);
|
|
650
|
-
if (!parentExists) {
|
|
651
|
-
return updatedListEntity.map((entity) => ({
|
|
652
|
-
...entity,
|
|
653
|
-
children: entity.children?.map((child) => child.id === response.data.parentId
|
|
654
|
-
? {
|
|
655
|
-
...child,
|
|
656
|
-
children: child.children?.map((grandChild) => grandChild.id === response.data.id ? response.data : grandChild),
|
|
657
|
-
}
|
|
658
|
-
: child),
|
|
659
|
-
}));
|
|
660
|
-
}
|
|
661
|
-
return updatedListEntity;
|
|
662
|
-
}
|
|
663
|
-
return listEntity.map((e) => (e.id === response.data.id ? response.data : e));
|
|
664
|
-
})(),
|
|
665
|
-
});
|
|
666
|
-
this.updateStatus(ITableStateStatusUpdated);
|
|
667
|
-
}), catchError(() => {
|
|
668
|
-
this.updateStatus(ITableStateStatusFailedToUpdate);
|
|
669
|
-
return [];
|
|
670
|
-
}));
|
|
671
|
-
})));
|
|
672
|
-
deleteEntityById = this.effect((trigger$) => trigger$.pipe(withLatestFrom(this.listEntity$, this.parent$), switchMap(([id, listEntity, parent]) => {
|
|
673
|
-
this.updateStatus(ITableStateStatusDeleting);
|
|
674
|
-
return this.apiService.deleteEntityById(id, parent).pipe(tap(() => {
|
|
675
|
-
this.patchState({
|
|
676
|
-
listEntity: listEntity.filter((e) => e.id !== id),
|
|
677
|
-
});
|
|
678
|
-
this.updateStatus(ITableStateStatusDeleted);
|
|
679
|
-
}), catchError(() => {
|
|
680
|
-
this.updateStatus(ITableStateStatusFailedToDelete);
|
|
681
|
-
return [];
|
|
682
|
-
}));
|
|
683
|
-
})));
|
|
684
|
-
// actions
|
|
685
|
-
updateEntity = this.updater((state, data) => ({
|
|
686
|
-
...state,
|
|
687
|
-
listEntity: state.listEntity.map((e) => {
|
|
688
|
-
return e.id === data.id ? data : e;
|
|
689
|
-
}),
|
|
690
|
-
}));
|
|
691
|
-
updateStatus = this.updater((state, status) => ({
|
|
692
|
-
...state,
|
|
693
|
-
status,
|
|
694
|
-
}));
|
|
695
|
-
setParent = this.updater((state, parent) => ({
|
|
696
|
-
...state,
|
|
697
|
-
parent,
|
|
698
|
-
}));
|
|
699
|
-
updateSortField = this.updater((state, sort) => ({
|
|
700
|
-
...state,
|
|
701
|
-
sort: [sort],
|
|
702
|
-
}));
|
|
703
|
-
updateFilter = this.updater((state, filter) => ({
|
|
704
|
-
...state,
|
|
705
|
-
filter,
|
|
706
|
-
}));
|
|
707
|
-
updatePage = this.updater((state, page) => ({
|
|
708
|
-
...state,
|
|
709
|
-
page,
|
|
710
|
-
}));
|
|
711
|
-
setExpandMode = this.updater((state, { id, mode }) => ({
|
|
712
|
-
...state,
|
|
713
|
-
listEntity: state.listEntity.map((e) => ({
|
|
714
|
-
...e,
|
|
715
|
-
expandMode: e.id === id ? mode : e.expandMode,
|
|
716
|
-
})),
|
|
717
|
-
}));
|
|
718
|
-
toggleExpanded = this.updater((state, { id }) => ({
|
|
719
|
-
...state,
|
|
720
|
-
listEntity: state.listEntity.map((e) => ({
|
|
721
|
-
...e,
|
|
722
|
-
isExpanded: e.id === id ? !(e.isExpanded || false) : e.isExpanded,
|
|
723
|
-
})),
|
|
724
|
-
}));
|
|
725
|
-
showExpanded = this.updater((state, { id }) => ({
|
|
726
|
-
...state,
|
|
727
|
-
listEntity: state.listEntity.map((e) => ({
|
|
728
|
-
...e,
|
|
729
|
-
isExpanded: e.id === id ? true : e.isExpanded,
|
|
730
|
-
})),
|
|
731
|
-
}));
|
|
732
|
-
hideExpanded = this.updater((state, { id }) => ({
|
|
733
|
-
...state,
|
|
734
|
-
listEntity: state.listEntity.map((e) => ({
|
|
735
|
-
...e,
|
|
736
|
-
isExpanded: e.id === id ? false : e.isExpanded,
|
|
737
|
-
})),
|
|
738
|
-
}));
|
|
739
|
-
toggleSelected = this.updater((state, { id }) => ({
|
|
740
|
-
...state,
|
|
741
|
-
listEntity: state.listEntity.map((e) => ({
|
|
742
|
-
...e,
|
|
743
|
-
isSelected: e.id === id ? !(e.isSelected || false) : e.isSelected,
|
|
744
|
-
})),
|
|
745
|
-
}));
|
|
746
|
-
constructor(initialState, apiService) {
|
|
747
|
-
super(initialState);
|
|
748
|
-
this.initialState = initialState;
|
|
749
|
-
this.apiService = apiService;
|
|
750
|
-
// this.loadListEntity();
|
|
751
|
-
}
|
|
752
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: TableStore, deps: [{ token: 'initialState' }, { token: 'apiService' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
753
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: TableStore });
|
|
754
|
-
}
|
|
755
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: TableStore, decorators: [{
|
|
756
|
-
type: Injectable
|
|
757
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
758
|
-
type: Inject,
|
|
759
|
-
args: ['initialState']
|
|
760
|
-
}] }, { type: undefined, decorators: [{
|
|
761
|
-
type: Inject,
|
|
762
|
-
args: ['apiService']
|
|
763
|
-
}] }] });
|
|
764
|
-
|
|
765
|
-
class GroupStore extends TableStore {
|
|
766
|
-
constructor() {
|
|
767
|
-
super({
|
|
768
|
-
isLoading: false,
|
|
769
|
-
filter: {
|
|
770
|
-
dateRange: undefined,
|
|
771
|
-
organizationId: [],
|
|
772
|
-
id: [],
|
|
773
|
-
type: [],
|
|
774
|
-
active: null,
|
|
775
|
-
approved: null,
|
|
776
|
-
keyword: '',
|
|
777
|
-
},
|
|
778
|
-
sort: [
|
|
779
|
-
{
|
|
780
|
-
field: 'created_timestamp',
|
|
781
|
-
direction: SearchParams.SortDirectionDesc,
|
|
782
|
-
},
|
|
783
|
-
],
|
|
784
|
-
page: {
|
|
785
|
-
limit: 10,
|
|
786
|
-
},
|
|
787
|
-
listEntity: [],
|
|
788
|
-
}, inject(GroupApiService));
|
|
789
|
-
}
|
|
790
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GroupStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
791
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GroupStore });
|
|
792
|
-
}
|
|
793
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GroupStore, decorators: [{
|
|
794
|
-
type: Injectable
|
|
795
|
-
}], ctorParameters: () => [] });
|
|
796
|
-
|
|
797
|
-
class MemberStore extends TableStore {
|
|
798
|
-
constructor() {
|
|
799
|
-
super({
|
|
800
|
-
isLoading: false,
|
|
801
|
-
filter: {
|
|
802
|
-
dateRange: undefined,
|
|
803
|
-
organizationId: [],
|
|
804
|
-
groupId: [],
|
|
805
|
-
type: [],
|
|
806
|
-
active: null,
|
|
807
|
-
keyword: '',
|
|
808
|
-
},
|
|
809
|
-
sort: [
|
|
810
|
-
{
|
|
811
|
-
field: 'created_timestamp',
|
|
812
|
-
direction: SearchParams.SortDirectionDesc,
|
|
813
|
-
},
|
|
814
|
-
],
|
|
815
|
-
page: {
|
|
816
|
-
limit: 10,
|
|
817
|
-
},
|
|
818
|
-
listEntity: [],
|
|
819
|
-
}, inject(MemberApiService));
|
|
820
|
-
}
|
|
821
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: MemberStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
822
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: MemberStore });
|
|
823
|
-
}
|
|
824
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: MemberStore, decorators: [{
|
|
825
|
-
type: Injectable
|
|
826
|
-
}], ctorParameters: () => [] });
|
|
827
|
-
|
|
828
|
-
var Device;
|
|
829
|
-
(function (Device) {
|
|
830
|
-
class DeviceStore extends TableStore {
|
|
831
|
-
constructor() {
|
|
832
|
-
super({
|
|
833
|
-
isLoading: false,
|
|
834
|
-
filter: {
|
|
835
|
-
campaignId: undefined,
|
|
836
|
-
type: [],
|
|
837
|
-
keyword: undefined,
|
|
838
|
-
},
|
|
839
|
-
sort: [
|
|
840
|
-
{
|
|
841
|
-
field: 'created_timestamp',
|
|
842
|
-
direction: SearchParams.SortDirectionDesc,
|
|
843
|
-
},
|
|
844
|
-
],
|
|
845
|
-
page: {
|
|
846
|
-
limit: 10,
|
|
847
|
-
},
|
|
848
|
-
listEntity: [],
|
|
849
|
-
}, inject(DeviceApiService));
|
|
850
|
-
}
|
|
851
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: DeviceStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
852
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: DeviceStore });
|
|
853
|
-
}
|
|
854
|
-
Device.DeviceStore = DeviceStore;
|
|
855
|
-
})(Device || (Device = {}));
|
|
856
|
-
|
|
857
|
-
// Injection token for GlobalEffects options
|
|
858
|
-
const GLOBAL_EFFECTS_OPTIONS = new InjectionToken('GLOBAL_EFFECTS_OPTIONS');
|
|
859
|
-
// Provider function for easier configuration in ApplicationConfig
|
|
860
|
-
function provideGlobalEffectsOptions(options) {
|
|
861
|
-
return {
|
|
862
|
-
provide: GLOBAL_EFFECTS_OPTIONS,
|
|
863
|
-
useValue: options,
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
class GlobalEffects {
|
|
867
|
-
actions$ = inject(Actions);
|
|
868
|
-
memberApiService = inject(MemberApiService);
|
|
869
|
-
globalApiService = inject(GlobalApiService);
|
|
870
|
-
groupApiService = inject(GroupApiService);
|
|
871
|
-
store = inject((Store));
|
|
872
|
-
options = inject(GLOBAL_EFFECTS_OPTIONS, { optional: true });
|
|
873
|
-
setAuthenticated$ = createEffect(() => this.actions$.pipe(ofType(GlobalActions.setAuthenticated), withLatestFrom$1(this.store.select(GlobalSelectors.selectIsAuthenticated)), mergeMap(([action, isAuthenticated]) => {
|
|
874
|
-
if (isAuthenticated) {
|
|
875
|
-
this.store.dispatch(GlobalActions.increaseLoadingReference());
|
|
876
|
-
return forkJoin({
|
|
877
|
-
profile: this.options?.getProfile?.() || this.memberApiService.getProfile(),
|
|
878
|
-
acl: this.globalApiService.getAcl(),
|
|
879
|
-
listMenuItem: this.globalApiService.getListMenuItem(),
|
|
880
|
-
}).pipe(mergeMap(({ profile, acl, listMenuItem }) => {
|
|
881
|
-
const groupId = profile.data.groupId;
|
|
882
|
-
return this.groupApiService.getEntityById(groupId).pipe(mergeMap((group) => [
|
|
883
|
-
GlobalActions.setProfile({ profile: profile.data }),
|
|
884
|
-
GlobalActions.setAcl({ acl: acl.data }),
|
|
885
|
-
GlobalActions.setListMenuItem({
|
|
886
|
-
listMenuItem: listMenuItem.data,
|
|
887
|
-
}),
|
|
888
|
-
GlobalActions.setCurrentGroup({ group: group.data }),
|
|
889
|
-
GlobalActions.markInitiated({ initiated: true }),
|
|
890
|
-
]));
|
|
891
|
-
}), catchError$1(() => of(GlobalActions.clearAuthentication())), finalize(() => {
|
|
892
|
-
this.store.dispatch(GlobalActions.decreaseLoadingReference());
|
|
893
|
-
}));
|
|
894
|
-
}
|
|
895
|
-
return of(GlobalActions.clearAuthentication());
|
|
896
|
-
})));
|
|
897
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GlobalEffects, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
898
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GlobalEffects });
|
|
899
|
-
}
|
|
900
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: GlobalEffects, decorators: [{
|
|
901
|
-
type: Injectable
|
|
902
|
-
}] });
|
|
903
|
-
|
|
904
|
-
const initialState = {
|
|
905
|
-
initiated: false,
|
|
906
|
-
isAuthenticated: false,
|
|
907
|
-
loadingReference: 0,
|
|
908
|
-
acl: {},
|
|
909
|
-
listMenuItem: [],
|
|
910
|
-
isSideMenuOpen: false,
|
|
911
|
-
language: 'en', // TODO: Use a proper language management system
|
|
912
|
-
profile: undefined,
|
|
913
|
-
currentGroup: undefined,
|
|
914
|
-
};
|
|
915
|
-
|
|
916
|
-
const globalReducer = createReducer(initialState, on(GlobalActions.markInitiated, (state) => ({
|
|
917
|
-
...state,
|
|
918
|
-
initiated: true,
|
|
919
|
-
})), on(GlobalActions.setAuthenticated, (state, { isAuthenticated }) => ({
|
|
920
|
-
...state,
|
|
921
|
-
isAuthenticated,
|
|
922
|
-
})), on(GlobalActions.setProfile, (state, { profile }) => ({
|
|
923
|
-
...state,
|
|
924
|
-
profile,
|
|
925
|
-
})), on(GlobalActions.increaseLoadingReference, (state) => ({
|
|
926
|
-
...state,
|
|
927
|
-
loadingReference: state.loadingReference + 1,
|
|
928
|
-
})), on(GlobalActions.decreaseLoadingReference, (state) => ({
|
|
929
|
-
...state,
|
|
930
|
-
loadingReference: Math.max(state.loadingReference - 1, 0),
|
|
931
|
-
})), on(GlobalActions.setAcl, (state, { acl }) => ({
|
|
932
|
-
...state,
|
|
933
|
-
acl,
|
|
934
|
-
})), on(GlobalActions.setListMenuItem, (state, { listMenuItem }) => ({
|
|
935
|
-
...state,
|
|
936
|
-
listMenuItem,
|
|
937
|
-
})), on(GlobalActions.toggleSideMenu, (state) => ({
|
|
938
|
-
...state,
|
|
939
|
-
isSideMenuOpen: !state.isSideMenuOpen,
|
|
940
|
-
})), on(GlobalActions.closeSideMenu, (state) => ({
|
|
941
|
-
...state,
|
|
942
|
-
isSideMenuOpen: false,
|
|
943
|
-
})), on(GlobalActions.setLanguage, (state, { language }) => ({
|
|
944
|
-
...state,
|
|
945
|
-
language,
|
|
946
|
-
})), on(GlobalActions.setCurrentGroup, (state, { group }) => ({
|
|
947
|
-
...state,
|
|
948
|
-
currentGroup: group,
|
|
949
|
-
})));
|
|
950
|
-
|
|
951
|
-
/*
|
|
952
|
-
* Public API Surface of core
|
|
953
|
-
*/
|
|
954
|
-
|
|
955
|
-
/**
|
|
956
|
-
* Generated bundle index. Do not edit.
|
|
957
|
-
*/
|
|
958
|
-
|
|
959
|
-
export { AuthService, BaseEntityApiService, CdnApiService, CoreService, Device, DeviceApiService, DisplayNamePipe, GLOBAL_EFFECTS_OPTIONS, GlobalActions, GlobalApiService, GlobalEffects, GlobalSelectors, GroupApiService, GroupStore, HALODUCK_CORE_CONFIG, ITableStateStatusCreated, ITableStateStatusCreating, ITableStateStatusDeleted, ITableStateStatusDeleting, ITableStateStatusFailedToCreate, ITableStateStatusFailedToDelete, ITableStateStatusFailedToLoad, ITableStateStatusFailedToUpdate, ITableStateStatusLoaded, ITableStateStatusLoading, ITableStateStatusUpdated, ITableStateStatusUpdating, MemberApiService, MemberStore, SearchParams, TableStore, authGuard, defaultLanguage, dummyMemberIdInterceptor, errorHandler, globalReducer, groupIdInterceptor, idTokenInterceptor, initialState, provideGlobalEffectsOptions, provideHaloduckCoreConfig, responseHandler, supportedLanguages };
|
|
960
|
-
//# sourceMappingURL=haloduck-core.mjs.map
|