ngssm-remote-data 22.0.1 → 22.2.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/fesm2022/ngssm-remote-data-testing.mjs +64 -108
- package/fesm2022/ngssm-remote-data-testing.mjs.map +1 -1
- package/fesm2022/ngssm-remote-data.mjs +1046 -611
- package/fesm2022/ngssm-remote-data.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ngssm-remote-data-testing.d.ts +32 -36
- package/types/ngssm-remote-data.d.ts +218 -227
|
@@ -1,646 +1,1081 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import { __decorate } from
|
|
4
|
-
import update from
|
|
5
|
-
import { NgSsmFeatureState, Store, createSignal,
|
|
6
|
-
import { DatePipe } from
|
|
7
|
-
import * as
|
|
8
|
-
import { MatIconModule } from
|
|
9
|
-
import * as i2
|
|
10
|
-
import { MatButtonModule } from
|
|
11
|
-
import * as i3 from
|
|
12
|
-
import { MatTooltipModule } from
|
|
13
|
-
import * as i4 from
|
|
14
|
-
import { MatProgressSpinnerModule } from
|
|
15
|
-
import * as i1 from
|
|
16
|
-
import {
|
|
17
|
-
import * as i3
|
|
18
|
-
import { MatTableModule } from
|
|
19
|
-
import { NgssmNotifierService } from
|
|
20
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Component, EnvironmentInjector, Injectable, InjectionToken, Injector, effect, inject, input, makeEnvironmentProviders, runInInjectionContext, signal } from "@angular/core";
|
|
3
|
+
import { __decorate } from "tslib";
|
|
4
|
+
import update from "immutability-helper";
|
|
5
|
+
import { Logger, NGSSM_STATE_INITIALIZER, NgSsmFeatureState, Store, createSignal, provideEffects, provideReducer, provideReducers } from "ngssm-store";
|
|
6
|
+
import { DatePipe } from "@angular/common";
|
|
7
|
+
import * as i1$1 from "@angular/material/icon";
|
|
8
|
+
import { MatIconModule } from "@angular/material/icon";
|
|
9
|
+
import * as i2 from "@angular/material/button";
|
|
10
|
+
import { MatButtonModule } from "@angular/material/button";
|
|
11
|
+
import * as i3$1 from "@angular/material/tooltip";
|
|
12
|
+
import { MatTooltipModule } from "@angular/material/tooltip";
|
|
13
|
+
import * as i4 from "@angular/material/progress-spinner";
|
|
14
|
+
import { MatProgressSpinnerModule } from "@angular/material/progress-spinner";
|
|
15
|
+
import * as i1 from "@angular/material/dialog";
|
|
16
|
+
import { MatDialog, MatDialogModule } from "@angular/material/dialog";
|
|
17
|
+
import * as i3 from "@angular/material/table";
|
|
18
|
+
import { MatTableModule } from "@angular/material/table";
|
|
19
|
+
import { NgssmNotifierService } from "ngssm-toolkit";
|
|
21
20
|
var DataStatus;
|
|
22
|
-
(function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
(function(DataStatus) {
|
|
22
|
+
DataStatus["none"] = "None";
|
|
23
|
+
DataStatus["loading"] = "Loading";
|
|
24
|
+
DataStatus["loaded"] = "Loaded";
|
|
25
|
+
DataStatus["notFound"] = "NotFound";
|
|
26
|
+
DataStatus["error"] = "Error";
|
|
28
27
|
})(DataStatus || (DataStatus = {}));
|
|
29
|
-
|
|
30
28
|
const getDefaultRemoteData = (defaultValue, defaultStatus = DataStatus.none) => ({
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
status: defaultStatus,
|
|
30
|
+
data: defaultValue
|
|
33
31
|
});
|
|
34
|
-
|
|
35
|
-
const NGSSM_REMOTE_DATA_PROVIDER = new InjectionToken('NGSSM_REMOTE_DATA_PROVIDER');
|
|
32
|
+
const NGSSM_REMOTE_DATA_PROVIDER = new InjectionToken("NGSSM_REMOTE_DATA_PROVIDER");
|
|
36
33
|
const provideRemoteDataProviders = (...providers) => {
|
|
37
|
-
|
|
34
|
+
return makeEnvironmentProviders(providers.map((provider) => ({
|
|
35
|
+
provide: NGSSM_REMOTE_DATA_PROVIDER,
|
|
36
|
+
useClass: provider,
|
|
37
|
+
multi: true
|
|
38
|
+
})));
|
|
38
39
|
};
|
|
39
40
|
const provideRemoteDataFunc = (remoteDataKey, remoteDataLoadingFunc, cacheDurationInSeconds) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
multi: true
|
|
52
|
-
}
|
|
53
|
-
]);
|
|
41
|
+
return makeEnvironmentProviders([{
|
|
42
|
+
provide: NGSSM_REMOTE_DATA_PROVIDER,
|
|
43
|
+
useFactory: () => {
|
|
44
|
+
return {
|
|
45
|
+
remoteDataKey,
|
|
46
|
+
cacheDurationInSeconds,
|
|
47
|
+
get: remoteDataLoadingFunc
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
multi: true
|
|
51
|
+
}]);
|
|
54
52
|
};
|
|
55
|
-
|
|
56
53
|
const selectRemoteDataState = (state) => state[RemoteDataStateSpecification.featureStateKey];
|
|
57
|
-
const updateRemoteDataState = (state, command) => update(state, {
|
|
58
|
-
[RemoteDataStateSpecification.featureStateKey]: command
|
|
59
|
-
});
|
|
54
|
+
const updateRemoteDataState = (state, command) => update(state, { [RemoteDataStateSpecification.featureStateKey]: command });
|
|
60
55
|
let RemoteDataStateSpecification = class RemoteDataStateSpecification {
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
static featureStateKey = "remote-data-state";
|
|
57
|
+
static initialState = {};
|
|
63
58
|
};
|
|
64
|
-
RemoteDataStateSpecification = __decorate([
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
})
|
|
69
|
-
], RemoteDataStateSpecification);
|
|
70
|
-
|
|
59
|
+
RemoteDataStateSpecification = __decorate([NgSsmFeatureState({
|
|
60
|
+
featureStateKey: RemoteDataStateSpecification.featureStateKey,
|
|
61
|
+
initialState: RemoteDataStateSpecification.initialState
|
|
62
|
+
})], RemoteDataStateSpecification);
|
|
71
63
|
const selectRemoteData = (state, remoteDataKey) => selectRemoteDataState(state)[remoteDataKey];
|
|
72
|
-
|
|
73
64
|
var RemoteDataActionType;
|
|
74
|
-
(function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
(function(RemoteDataActionType) {
|
|
66
|
+
RemoteDataActionType["loadRemoteData"] = "[RemoteDataActionType] loadRemoteData";
|
|
67
|
+
RemoteDataActionType["registerLoadedRemoteData"] = "[RemoteDataActionType] registerLoadedRemoteData";
|
|
68
|
+
RemoteDataActionType["displayCaches"] = "[RemoteDataActionType] displayCaches";
|
|
69
|
+
RemoteDataActionType["closeCachesComponent"] = "[RemoteDataActionType] closeCachesComponent";
|
|
79
70
|
})(RemoteDataActionType || (RemoteDataActionType = {}));
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
71
|
+
var LoadRemoteDataAction = class {
|
|
72
|
+
remoteDataKey;
|
|
73
|
+
params;
|
|
74
|
+
type = RemoteDataActionType.loadRemoteData;
|
|
75
|
+
constructor(remoteDataKey, params) {
|
|
76
|
+
this.remoteDataKey = remoteDataKey;
|
|
77
|
+
this.params = params;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var RegisterLoadedRemoteDataAction = class {
|
|
81
|
+
remoteDataKey;
|
|
82
|
+
status;
|
|
83
|
+
data;
|
|
84
|
+
message;
|
|
85
|
+
remoteCallError;
|
|
86
|
+
type = RemoteDataActionType.registerLoadedRemoteData;
|
|
87
|
+
constructor(remoteDataKey, status, data, message, remoteCallError) {
|
|
88
|
+
this.remoteDataKey = remoteDataKey;
|
|
89
|
+
this.status = status;
|
|
90
|
+
this.data = data;
|
|
91
|
+
this.message = message;
|
|
92
|
+
this.remoteCallError = remoteCallError;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var RemoteDataLoadingGuard = class RemoteDataLoadingGuard {
|
|
96
|
+
store = inject(Store);
|
|
97
|
+
canActivate(route) {
|
|
98
|
+
(route.data?.remoteDataItems ?? []).forEach((item) => {
|
|
99
|
+
this.store.dispatchAction(new LoadRemoteDataAction(item.remoteDataKey, { forceReload: item.forceReload === true }));
|
|
100
|
+
});
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
104
|
+
minVersion: "12.0.0",
|
|
105
|
+
version: "22.2.0",
|
|
106
|
+
ngImport: i0,
|
|
107
|
+
type: RemoteDataLoadingGuard,
|
|
108
|
+
deps: [],
|
|
109
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
110
|
+
});
|
|
111
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
112
|
+
minVersion: "12.0.0",
|
|
113
|
+
version: "22.2.0",
|
|
114
|
+
ngImport: i0,
|
|
115
|
+
type: RemoteDataLoadingGuard,
|
|
116
|
+
providedIn: "root"
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
120
|
+
minVersion: "12.0.0",
|
|
121
|
+
version: "22.2.0",
|
|
122
|
+
ngImport: i0,
|
|
123
|
+
type: RemoteDataLoadingGuard,
|
|
124
|
+
decorators: [{
|
|
125
|
+
type: Injectable,
|
|
126
|
+
args: [{ providedIn: "root" }]
|
|
127
|
+
}]
|
|
128
|
+
});
|
|
125
129
|
const ngssmReloadRemoteData = (remoteDataKey, params = { forceReload: true }) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
return () => {
|
|
131
|
+
inject(Store).dispatchAction(new LoadRemoteDataAction(remoteDataKey, params));
|
|
132
|
+
return true;
|
|
133
|
+
};
|
|
130
134
|
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
135
|
+
const datePipe = new DatePipe("en-US");
|
|
136
|
+
var NgssmRemoteDataReloadButtonComponent = class NgssmRemoteDataReloadButtonComponent {
|
|
137
|
+
tooltipMessage = signal("", ...ngDevMode ? [{ debugName: "tooltipMessage" }] : /* istanbul ignore next */ []);
|
|
138
|
+
disabled = signal(true, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
|
|
139
|
+
inLoadingStatus = signal(false, ...ngDevMode ? [{ debugName: "inLoadingStatus" }] : /* istanbul ignore next */ []);
|
|
140
|
+
actionTypes = input([], ...ngDevMode ? [{ debugName: "actionTypes" }] : /* istanbul ignore next */ []);
|
|
141
|
+
remoteDataKeys = input([], ...ngDevMode ? [{ debugName: "remoteDataKeys" }] : /* istanbul ignore next */ []);
|
|
142
|
+
store = inject(Store);
|
|
143
|
+
remoteDataState = createSignal((state) => selectRemoteDataState(state));
|
|
144
|
+
constructor() {
|
|
145
|
+
effect(() => {
|
|
146
|
+
const remoteDataState = this.remoteDataState();
|
|
147
|
+
const keys = this.remoteDataKeys();
|
|
148
|
+
this.inLoadingStatus.set(keys.findIndex((v) => remoteDataState[v]?.status === DataStatus.loading) !== -1);
|
|
149
|
+
this.disabled.set(this.inLoadingStatus() === true || keys.findIndex((v) => !!remoteDataState[v]) === -1);
|
|
150
|
+
let timestamp;
|
|
151
|
+
keys.forEach((key) => {
|
|
152
|
+
const keyTimestamp = remoteDataState[key]?.timestamp;
|
|
153
|
+
if (keyTimestamp) {
|
|
154
|
+
if (!timestamp || timestamp.getTime() > keyTimestamp.getTime()) timestamp = keyTimestamp;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
let tooltiMessage = "Reload data.";
|
|
158
|
+
if (timestamp) tooltiMessage = [tooltiMessage, `Loaded at ${datePipe.transform(timestamp, "mediumTime")}`].join("\n");
|
|
159
|
+
this.tooltipMessage.set(tooltiMessage);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
reload() {
|
|
163
|
+
this.remoteDataKeys().forEach((key) => this.store.dispatchAction(new LoadRemoteDataAction(key, {
|
|
164
|
+
forceReload: true,
|
|
165
|
+
keepStoredGetterParams: true
|
|
166
|
+
})));
|
|
167
|
+
this.actionTypes().forEach((type) => this.store.dispatchActionType(type));
|
|
168
|
+
}
|
|
169
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
170
|
+
minVersion: "12.0.0",
|
|
171
|
+
version: "22.2.0",
|
|
172
|
+
ngImport: i0,
|
|
173
|
+
type: NgssmRemoteDataReloadButtonComponent,
|
|
174
|
+
deps: [],
|
|
175
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
176
|
+
});
|
|
177
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
178
|
+
minVersion: "17.0.0",
|
|
179
|
+
version: "22.2.0",
|
|
180
|
+
type: NgssmRemoteDataReloadButtonComponent,
|
|
181
|
+
isStandalone: true,
|
|
182
|
+
selector: "ngssm-remote-data-reload-button",
|
|
183
|
+
inputs: {
|
|
184
|
+
actionTypes: {
|
|
185
|
+
classPropertyName: "actionTypes",
|
|
186
|
+
publicName: "actionTypes",
|
|
187
|
+
isSignal: true,
|
|
188
|
+
isRequired: false,
|
|
189
|
+
transformFunction: null
|
|
190
|
+
},
|
|
191
|
+
remoteDataKeys: {
|
|
192
|
+
classPropertyName: "remoteDataKeys",
|
|
193
|
+
publicName: "remoteDataKeys",
|
|
194
|
+
isSignal: true,
|
|
195
|
+
isRequired: false,
|
|
196
|
+
transformFunction: null
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
ngImport: i0,
|
|
200
|
+
template: "<button\n mat-icon-button\n color=\"primary\"\n (click)=\"reload()\"\n [matTooltip]=\"tooltipMessage()\"\n [disabled]=\"disabled() === true\"\n id=\"reloadButton\">\n @if (inLoadingStatus()) {\n <mat-spinner [diameter]=\"24\" id=\"loadingSpinner\"></mat-spinner>\n } @else {\n <mat-icon class=\"fa-solid fa-rotate-right\"></mat-icon>\n }\n</button>\n",
|
|
201
|
+
dependencies: [
|
|
202
|
+
{
|
|
203
|
+
kind: "ngmodule",
|
|
204
|
+
type: MatIconModule
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
kind: "component",
|
|
208
|
+
type: i1$1.MatIcon,
|
|
209
|
+
selector: "mat-icon",
|
|
210
|
+
inputs: [
|
|
211
|
+
"color",
|
|
212
|
+
"inline",
|
|
213
|
+
"svgIcon",
|
|
214
|
+
"fontSet",
|
|
215
|
+
"fontIcon"
|
|
216
|
+
],
|
|
217
|
+
exportAs: ["matIcon"]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
kind: "ngmodule",
|
|
221
|
+
type: MatButtonModule
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
kind: "component",
|
|
225
|
+
type: i2.MatIconButton,
|
|
226
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
227
|
+
exportAs: ["matButton", "matAnchor"]
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
kind: "ngmodule",
|
|
231
|
+
type: MatTooltipModule
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
kind: "directive",
|
|
235
|
+
type: i3$1.MatTooltip,
|
|
236
|
+
selector: "[matTooltip]",
|
|
237
|
+
inputs: [
|
|
238
|
+
"matTooltipPosition",
|
|
239
|
+
"matTooltipPositionAtOrigin",
|
|
240
|
+
"matTooltipDisabled",
|
|
241
|
+
"matTooltipShowDelay",
|
|
242
|
+
"matTooltipHideDelay",
|
|
243
|
+
"matTooltipTouchGestures",
|
|
244
|
+
"matTooltip",
|
|
245
|
+
"matTooltipClass"
|
|
246
|
+
],
|
|
247
|
+
exportAs: ["matTooltip"]
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
kind: "ngmodule",
|
|
251
|
+
type: MatProgressSpinnerModule
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
kind: "component",
|
|
255
|
+
type: i4.MatProgressSpinner,
|
|
256
|
+
selector: "mat-progress-spinner, mat-spinner",
|
|
257
|
+
inputs: [
|
|
258
|
+
"color",
|
|
259
|
+
"mode",
|
|
260
|
+
"value",
|
|
261
|
+
"diameter",
|
|
262
|
+
"strokeWidth"
|
|
263
|
+
],
|
|
264
|
+
exportAs: ["matProgressSpinner"]
|
|
265
|
+
}
|
|
266
|
+
]
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
270
|
+
minVersion: "12.0.0",
|
|
271
|
+
version: "22.2.0",
|
|
272
|
+
ngImport: i0,
|
|
273
|
+
type: NgssmRemoteDataReloadButtonComponent,
|
|
274
|
+
decorators: [{
|
|
275
|
+
type: Component,
|
|
276
|
+
args: [{
|
|
277
|
+
selector: "ngssm-remote-data-reload-button",
|
|
278
|
+
imports: [
|
|
279
|
+
MatIconModule,
|
|
280
|
+
MatButtonModule,
|
|
281
|
+
MatTooltipModule,
|
|
282
|
+
MatProgressSpinnerModule
|
|
283
|
+
],
|
|
284
|
+
template: "<button\n mat-icon-button\n color=\"primary\"\n (click)=\"reload()\"\n [matTooltip]=\"tooltipMessage()\"\n [disabled]=\"disabled() === true\"\n id=\"reloadButton\">\n @if (inLoadingStatus()) {\n <mat-spinner [diameter]=\"24\" id=\"loadingSpinner\"></mat-spinner>\n } @else {\n <mat-icon class=\"fa-solid fa-rotate-right\"></mat-icon>\n }\n</button>\n"
|
|
285
|
+
}]
|
|
286
|
+
}],
|
|
287
|
+
ctorParameters: () => [],
|
|
288
|
+
propDecorators: {
|
|
289
|
+
actionTypes: [{
|
|
290
|
+
type: i0.Input,
|
|
291
|
+
args: [{
|
|
292
|
+
isSignal: true,
|
|
293
|
+
alias: "actionTypes",
|
|
294
|
+
required: false
|
|
295
|
+
}]
|
|
296
|
+
}],
|
|
297
|
+
remoteDataKeys: [{
|
|
298
|
+
type: i0.Input,
|
|
299
|
+
args: [{
|
|
300
|
+
isSignal: true,
|
|
301
|
+
alias: "remoteDataKeys",
|
|
302
|
+
required: false
|
|
303
|
+
}]
|
|
304
|
+
}]
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
var NgssmCachesDisplayButtonComponent = class NgssmCachesDisplayButtonComponent {
|
|
308
|
+
store = inject(Store);
|
|
309
|
+
displayCaches() {
|
|
310
|
+
this.store.dispatchActionType(RemoteDataActionType.displayCaches);
|
|
311
|
+
}
|
|
312
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
313
|
+
minVersion: "12.0.0",
|
|
314
|
+
version: "22.2.0",
|
|
315
|
+
ngImport: i0,
|
|
316
|
+
type: NgssmCachesDisplayButtonComponent,
|
|
317
|
+
deps: [],
|
|
318
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
319
|
+
});
|
|
320
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
321
|
+
minVersion: "14.0.0",
|
|
322
|
+
version: "22.2.0",
|
|
323
|
+
type: NgssmCachesDisplayButtonComponent,
|
|
324
|
+
isStandalone: true,
|
|
325
|
+
selector: "ngssm-caches-display-button",
|
|
326
|
+
ngImport: i0,
|
|
327
|
+
template: "<button mat-icon-button matTooltip=\"Display caches\" (click)=\"displayCaches()\">\n <mat-icon class=\"fa-solid fa-cloud-bolt\"></mat-icon>\n</button>\n",
|
|
328
|
+
dependencies: [
|
|
329
|
+
{
|
|
330
|
+
kind: "ngmodule",
|
|
331
|
+
type: MatButtonModule
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
kind: "component",
|
|
335
|
+
type: i2.MatIconButton,
|
|
336
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
337
|
+
exportAs: ["matButton", "matAnchor"]
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
kind: "ngmodule",
|
|
341
|
+
type: MatIconModule
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
kind: "component",
|
|
345
|
+
type: i1$1.MatIcon,
|
|
346
|
+
selector: "mat-icon",
|
|
347
|
+
inputs: [
|
|
348
|
+
"color",
|
|
349
|
+
"inline",
|
|
350
|
+
"svgIcon",
|
|
351
|
+
"fontSet",
|
|
352
|
+
"fontIcon"
|
|
353
|
+
],
|
|
354
|
+
exportAs: ["matIcon"]
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
kind: "ngmodule",
|
|
358
|
+
type: MatTooltipModule
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
kind: "directive",
|
|
362
|
+
type: i3$1.MatTooltip,
|
|
363
|
+
selector: "[matTooltip]",
|
|
364
|
+
inputs: [
|
|
365
|
+
"matTooltipPosition",
|
|
366
|
+
"matTooltipPositionAtOrigin",
|
|
367
|
+
"matTooltipDisabled",
|
|
368
|
+
"matTooltipShowDelay",
|
|
369
|
+
"matTooltipHideDelay",
|
|
370
|
+
"matTooltipTouchGestures",
|
|
371
|
+
"matTooltip",
|
|
372
|
+
"matTooltipClass"
|
|
373
|
+
],
|
|
374
|
+
exportAs: ["matTooltip"]
|
|
375
|
+
}
|
|
376
|
+
]
|
|
377
|
+
});
|
|
378
|
+
};
|
|
379
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
380
|
+
minVersion: "12.0.0",
|
|
381
|
+
version: "22.2.0",
|
|
382
|
+
ngImport: i0,
|
|
383
|
+
type: NgssmCachesDisplayButtonComponent,
|
|
384
|
+
decorators: [{
|
|
385
|
+
type: Component,
|
|
386
|
+
args: [{
|
|
387
|
+
selector: "ngssm-caches-display-button",
|
|
388
|
+
imports: [
|
|
389
|
+
MatButtonModule,
|
|
390
|
+
MatIconModule,
|
|
391
|
+
MatTooltipModule
|
|
392
|
+
],
|
|
393
|
+
template: "<button mat-icon-button matTooltip=\"Display caches\" (click)=\"displayCaches()\">\n <mat-icon class=\"fa-solid fa-cloud-bolt\"></mat-icon>\n</button>\n"
|
|
394
|
+
}]
|
|
395
|
+
}]
|
|
396
|
+
});
|
|
397
|
+
var NgssmCachesComponent = class NgssmCachesComponent {
|
|
398
|
+
caches = createSignal((state) => {
|
|
399
|
+
const remoteDataState = selectRemoteDataState(state);
|
|
400
|
+
return Object.keys(remoteDataState).map((key) => ({
|
|
401
|
+
key,
|
|
402
|
+
value: remoteDataState[key]
|
|
403
|
+
}));
|
|
404
|
+
});
|
|
405
|
+
dataStatus = DataStatus;
|
|
406
|
+
store = inject(Store);
|
|
407
|
+
close() {
|
|
408
|
+
this.store.dispatchActionType(RemoteDataActionType.closeCachesComponent);
|
|
409
|
+
}
|
|
410
|
+
reloadCache(cache) {
|
|
411
|
+
this.store.dispatchAction(new LoadRemoteDataAction(cache.key, {
|
|
412
|
+
forceReload: true,
|
|
413
|
+
keepStoredGetterParams: true
|
|
414
|
+
}));
|
|
415
|
+
}
|
|
416
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
417
|
+
minVersion: "12.0.0",
|
|
418
|
+
version: "22.2.0",
|
|
419
|
+
ngImport: i0,
|
|
420
|
+
type: NgssmCachesComponent,
|
|
421
|
+
deps: [],
|
|
422
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
423
|
+
});
|
|
424
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
425
|
+
minVersion: "17.0.0",
|
|
426
|
+
version: "22.2.0",
|
|
427
|
+
type: NgssmCachesComponent,
|
|
428
|
+
isStandalone: true,
|
|
429
|
+
selector: "ngssm-caches",
|
|
430
|
+
ngImport: i0,
|
|
431
|
+
template: "<h1 mat-dialog-title>List of caches</h1>\n<mat-dialog-content class=\"flex-column-stretch fxFlex\">\n <mat-table [dataSource]=\"caches()\" class=\"fxFlex\">\n <ng-container matColumnDef=\"actions\">\n <mat-header-cell *matHeaderCellDef> </mat-header-cell>\n <mat-cell *matCellDef=\"let element\">\n <button\n mat-icon-button\n [disabled]=\"element.value.status === dataStatus.loading\"\n (click)=\"reloadCache(element)\"\n color=\"primary\"\n id=\"reload_{{ element.key }}\">\n <mat-icon class=\"fa-solid fa-rotate-right\"></mat-icon>\n </button>\n </mat-cell>\n </ng-container>\n\n <ng-container matColumnDef=\"key\">\n <mat-header-cell *matHeaderCellDef> Key </mat-header-cell>\n <mat-cell *matCellDef=\"let element\"> {{ element.key }} </mat-cell>\n </ng-container>\n\n <ng-container matColumnDef=\"status\">\n <mat-header-cell *matHeaderCellDef> Status </mat-header-cell>\n <mat-cell *matCellDef=\"let element\">\n @switch (element.value.status) {\n @case (dataStatus.none) {\n <mat-icon class=\"fa-solid fa-minus\"></mat-icon>\n }\n @case (dataStatus.loaded) {\n <mat-icon class=\"fa-solid fa-check\" color=\"primary\"></mat-icon>\n }\n @case (dataStatus.error) {\n <mat-icon class=\"fa-solid fa-xmark\" color=\"warn\"></mat-icon>\n }\n @case (dataStatus.notFound) {\n <mat-icon class=\"fa-solid fa-xmark\" color=\"warn\"></mat-icon>\n }\n @case (dataStatus.loading) {\n <mat-spinner [diameter]=\"20\"></mat-spinner>\n }\n }\n </mat-cell>\n </ng-container>\n\n <ng-container matColumnDef=\"timestamp\">\n <mat-header-cell *matHeaderCellDef> Timestamp </mat-header-cell>\n <mat-cell *matCellDef=\"let element\"> {{ element.value.timestamp }} </mat-cell>\n </ng-container>\n\n <mat-header-row *matHeaderRowDef=\"['actions', 'status', 'key', 'timestamp']; sticky: true\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: ['actions', 'status', 'key', 'timestamp']\"></mat-row>\n </mat-table>\n</mat-dialog-content>\n<mat-dialog-actions class=\"flex-row-center\">\n <span class=\"fxFlex\"></span>\n <button mat-button (click)=\"close()\" id=\"closeButton\">Close</button>\n</mat-dialog-actions>\n",
|
|
432
|
+
styles: [":host{display:flex;flex-direction:column;min-width:800px;max-width:80vw;min-height:500px;max-height:80vh}:host .mat-column-actions{min-width:50px;max-width:50px;padding-left:0!important}:host .mat-column-status{min-width:60px;max-width:60px}\n"],
|
|
433
|
+
dependencies: [
|
|
434
|
+
{
|
|
435
|
+
kind: "ngmodule",
|
|
436
|
+
type: MatDialogModule
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
kind: "directive",
|
|
440
|
+
type: i1.MatDialogTitle,
|
|
441
|
+
selector: "[mat-dialog-title], [matDialogTitle]",
|
|
442
|
+
inputs: ["id"],
|
|
443
|
+
exportAs: ["matDialogTitle"]
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
kind: "directive",
|
|
447
|
+
type: i1.MatDialogActions,
|
|
448
|
+
selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]",
|
|
449
|
+
inputs: ["align"]
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
kind: "directive",
|
|
453
|
+
type: i1.MatDialogContent,
|
|
454
|
+
selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]"
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
kind: "ngmodule",
|
|
458
|
+
type: MatButtonModule
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
kind: "component",
|
|
462
|
+
type: i2.MatButton,
|
|
463
|
+
selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
|
|
464
|
+
inputs: ["matButton"],
|
|
465
|
+
exportAs: ["matButton", "matAnchor"]
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
kind: "component",
|
|
469
|
+
type: i2.MatIconButton,
|
|
470
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
471
|
+
exportAs: ["matButton", "matAnchor"]
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
kind: "ngmodule",
|
|
475
|
+
type: MatTableModule
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
kind: "component",
|
|
479
|
+
type: i3.MatTable,
|
|
480
|
+
selector: "mat-table, table[mat-table]",
|
|
481
|
+
exportAs: ["matTable"]
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
kind: "directive",
|
|
485
|
+
type: i3.MatHeaderCellDef,
|
|
486
|
+
selector: "[matHeaderCellDef]"
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
kind: "directive",
|
|
490
|
+
type: i3.MatHeaderRowDef,
|
|
491
|
+
selector: "[matHeaderRowDef]",
|
|
492
|
+
inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"]
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
kind: "directive",
|
|
496
|
+
type: i3.MatColumnDef,
|
|
497
|
+
selector: "[matColumnDef]",
|
|
498
|
+
inputs: ["matColumnDef"]
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
kind: "directive",
|
|
502
|
+
type: i3.MatCellDef,
|
|
503
|
+
selector: "[matCellDef]"
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
kind: "directive",
|
|
507
|
+
type: i3.MatRowDef,
|
|
508
|
+
selector: "[matRowDef]",
|
|
509
|
+
inputs: ["matRowDefColumns", "matRowDefWhen"]
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
kind: "directive",
|
|
513
|
+
type: i3.MatHeaderCell,
|
|
514
|
+
selector: "mat-header-cell, th[mat-header-cell]"
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
kind: "directive",
|
|
518
|
+
type: i3.MatCell,
|
|
519
|
+
selector: "mat-cell, td[mat-cell]"
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
kind: "component",
|
|
523
|
+
type: i3.MatHeaderRow,
|
|
524
|
+
selector: "mat-header-row, tr[mat-header-row]",
|
|
525
|
+
exportAs: ["matHeaderRow"]
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
kind: "component",
|
|
529
|
+
type: i3.MatRow,
|
|
530
|
+
selector: "mat-row, tr[mat-row]",
|
|
531
|
+
exportAs: ["matRow"]
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
kind: "ngmodule",
|
|
535
|
+
type: MatIconModule
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
kind: "component",
|
|
539
|
+
type: i1$1.MatIcon,
|
|
540
|
+
selector: "mat-icon",
|
|
541
|
+
inputs: [
|
|
542
|
+
"color",
|
|
543
|
+
"inline",
|
|
544
|
+
"svgIcon",
|
|
545
|
+
"fontSet",
|
|
546
|
+
"fontIcon"
|
|
547
|
+
],
|
|
548
|
+
exportAs: ["matIcon"]
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
kind: "ngmodule",
|
|
552
|
+
type: MatProgressSpinnerModule
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
kind: "component",
|
|
556
|
+
type: i4.MatProgressSpinner,
|
|
557
|
+
selector: "mat-progress-spinner, mat-spinner",
|
|
558
|
+
inputs: [
|
|
559
|
+
"color",
|
|
560
|
+
"mode",
|
|
561
|
+
"value",
|
|
562
|
+
"diameter",
|
|
563
|
+
"strokeWidth"
|
|
564
|
+
],
|
|
565
|
+
exportAs: ["matProgressSpinner"]
|
|
566
|
+
}
|
|
567
|
+
]
|
|
568
|
+
});
|
|
569
|
+
};
|
|
570
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
571
|
+
minVersion: "12.0.0",
|
|
572
|
+
version: "22.2.0",
|
|
573
|
+
ngImport: i0,
|
|
574
|
+
type: NgssmCachesComponent,
|
|
575
|
+
decorators: [{
|
|
576
|
+
type: Component,
|
|
577
|
+
args: [{
|
|
578
|
+
selector: "ngssm-caches",
|
|
579
|
+
imports: [
|
|
580
|
+
MatDialogModule,
|
|
581
|
+
MatButtonModule,
|
|
582
|
+
MatTableModule,
|
|
583
|
+
MatIconModule,
|
|
584
|
+
MatProgressSpinnerModule
|
|
585
|
+
],
|
|
586
|
+
template: "<h1 mat-dialog-title>List of caches</h1>\n<mat-dialog-content class=\"flex-column-stretch fxFlex\">\n <mat-table [dataSource]=\"caches()\" class=\"fxFlex\">\n <ng-container matColumnDef=\"actions\">\n <mat-header-cell *matHeaderCellDef> </mat-header-cell>\n <mat-cell *matCellDef=\"let element\">\n <button\n mat-icon-button\n [disabled]=\"element.value.status === dataStatus.loading\"\n (click)=\"reloadCache(element)\"\n color=\"primary\"\n id=\"reload_{{ element.key }}\">\n <mat-icon class=\"fa-solid fa-rotate-right\"></mat-icon>\n </button>\n </mat-cell>\n </ng-container>\n\n <ng-container matColumnDef=\"key\">\n <mat-header-cell *matHeaderCellDef> Key </mat-header-cell>\n <mat-cell *matCellDef=\"let element\"> {{ element.key }} </mat-cell>\n </ng-container>\n\n <ng-container matColumnDef=\"status\">\n <mat-header-cell *matHeaderCellDef> Status </mat-header-cell>\n <mat-cell *matCellDef=\"let element\">\n @switch (element.value.status) {\n @case (dataStatus.none) {\n <mat-icon class=\"fa-solid fa-minus\"></mat-icon>\n }\n @case (dataStatus.loaded) {\n <mat-icon class=\"fa-solid fa-check\" color=\"primary\"></mat-icon>\n }\n @case (dataStatus.error) {\n <mat-icon class=\"fa-solid fa-xmark\" color=\"warn\"></mat-icon>\n }\n @case (dataStatus.notFound) {\n <mat-icon class=\"fa-solid fa-xmark\" color=\"warn\"></mat-icon>\n }\n @case (dataStatus.loading) {\n <mat-spinner [diameter]=\"20\"></mat-spinner>\n }\n }\n </mat-cell>\n </ng-container>\n\n <ng-container matColumnDef=\"timestamp\">\n <mat-header-cell *matHeaderCellDef> Timestamp </mat-header-cell>\n <mat-cell *matCellDef=\"let element\"> {{ element.value.timestamp }} </mat-cell>\n </ng-container>\n\n <mat-header-row *matHeaderRowDef=\"['actions', 'status', 'key', 'timestamp']; sticky: true\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: ['actions', 'status', 'key', 'timestamp']\"></mat-row>\n </mat-table>\n</mat-dialog-content>\n<mat-dialog-actions class=\"flex-row-center\">\n <span class=\"fxFlex\"></span>\n <button mat-button (click)=\"close()\" id=\"closeButton\">Close</button>\n</mat-dialog-actions>\n",
|
|
587
|
+
styles: [":host{display:flex;flex-direction:column;min-width:800px;max-width:80vw;min-height:500px;max-height:80vh}:host .mat-column-actions{min-width:50px;max-width:50px;padding-left:0!important}:host .mat-column-status{min-width:60px;max-width:60px}\n"]
|
|
588
|
+
}]
|
|
589
|
+
}]
|
|
590
|
+
});
|
|
591
|
+
var CachesDisplayEffect = class CachesDisplayEffect {
|
|
592
|
+
processedActions = [RemoteDataActionType.displayCaches, RemoteDataActionType.closeCachesComponent];
|
|
593
|
+
matDialog = inject(MatDialog);
|
|
594
|
+
dialog;
|
|
595
|
+
processAction(actiondispatcher, state, action) {
|
|
596
|
+
switch (action.type) {
|
|
597
|
+
case RemoteDataActionType.displayCaches:
|
|
598
|
+
this.dialog = this.matDialog.open(NgssmCachesComponent, { disableClose: true });
|
|
599
|
+
break;
|
|
600
|
+
case RemoteDataActionType.closeCachesComponent:
|
|
601
|
+
this.dialog?.close();
|
|
602
|
+
this.dialog = void 0;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
606
|
+
minVersion: "12.0.0",
|
|
607
|
+
version: "22.2.0",
|
|
608
|
+
ngImport: i0,
|
|
609
|
+
type: CachesDisplayEffect,
|
|
610
|
+
deps: [],
|
|
611
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
612
|
+
});
|
|
613
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
614
|
+
minVersion: "12.0.0",
|
|
615
|
+
version: "22.2.0",
|
|
616
|
+
ngImport: i0,
|
|
617
|
+
type: CachesDisplayEffect
|
|
618
|
+
});
|
|
619
|
+
};
|
|
620
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
621
|
+
minVersion: "12.0.0",
|
|
622
|
+
version: "22.2.0",
|
|
623
|
+
ngImport: i0,
|
|
624
|
+
type: CachesDisplayEffect,
|
|
625
|
+
decorators: [{ type: Injectable }]
|
|
626
|
+
});
|
|
627
|
+
var RemoteDataLoadingEffect = class RemoteDataLoadingEffect {
|
|
628
|
+
processedActions = [RemoteDataActionType.loadRemoteData];
|
|
629
|
+
remoteDataProviders = inject(NGSSM_REMOTE_DATA_PROVIDER, { optional: true });
|
|
630
|
+
notifierService = inject(NgssmNotifierService);
|
|
631
|
+
injector = inject(EnvironmentInjector);
|
|
632
|
+
remoteDataProvidersPerKey;
|
|
633
|
+
constructor() {
|
|
634
|
+
this.remoteDataProvidersPerKey = new Map((this.remoteDataProviders ?? []).map((r) => [r.remoteDataKey, r]));
|
|
635
|
+
}
|
|
636
|
+
processAction(actiondispatcher, state, action) {
|
|
637
|
+
const loadRemoteDataAction = action;
|
|
638
|
+
const item = selectRemoteDataState(state)[loadRemoteDataAction.remoteDataKey];
|
|
639
|
+
const provider = this.remoteDataProvidersPerKey.get(loadRemoteDataAction.remoteDataKey);
|
|
640
|
+
if (!item || !provider || item.status !== DataStatus.loading) return;
|
|
641
|
+
runInInjectionContext(this.injector, () => {
|
|
642
|
+
provider.get(item.getterParams).subscribe({
|
|
643
|
+
next: (value) => {
|
|
644
|
+
actiondispatcher.dispatchAction(new RegisterLoadedRemoteDataAction(loadRemoteDataAction.remoteDataKey, DataStatus.loaded, value));
|
|
645
|
+
if (item.getterParams?.callbackAction) actiondispatcher.dispatchActionType(item.getterParams.callbackAction);
|
|
646
|
+
},
|
|
647
|
+
error: (error) => {
|
|
648
|
+
console.error(`Unable to load data for '${loadRemoteDataAction.remoteDataKey}'`, error);
|
|
649
|
+
if (item.getterParams?.errorNotificationMessage) this.notifierService.notifyError(item.getterParams.errorNotificationMessage(error?.error));
|
|
650
|
+
actiondispatcher.dispatchAction(new RegisterLoadedRemoteDataAction(loadRemoteDataAction.remoteDataKey, DataStatus.error, void 0, error?.error));
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
656
|
+
minVersion: "12.0.0",
|
|
657
|
+
version: "22.2.0",
|
|
658
|
+
ngImport: i0,
|
|
659
|
+
type: RemoteDataLoadingEffect,
|
|
660
|
+
deps: [],
|
|
661
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
662
|
+
});
|
|
663
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
664
|
+
minVersion: "12.0.0",
|
|
665
|
+
version: "22.2.0",
|
|
666
|
+
ngImport: i0,
|
|
667
|
+
type: RemoteDataLoadingEffect
|
|
668
|
+
});
|
|
669
|
+
};
|
|
670
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
671
|
+
minVersion: "12.0.0",
|
|
672
|
+
version: "22.2.0",
|
|
673
|
+
ngImport: i0,
|
|
674
|
+
type: RemoteDataLoadingEffect,
|
|
675
|
+
decorators: [{ type: Injectable }],
|
|
676
|
+
ctorParameters: () => []
|
|
677
|
+
});
|
|
678
|
+
var RemoteDataReducer = class RemoteDataReducer {
|
|
679
|
+
processedActions = [RemoteDataActionType.loadRemoteData, RemoteDataActionType.registerLoadedRemoteData];
|
|
680
|
+
remoteDataProviders = inject(NGSSM_REMOTE_DATA_PROVIDER, { optional: true });
|
|
681
|
+
remoteDataProvidersPerKey;
|
|
682
|
+
constructor() {
|
|
683
|
+
this.remoteDataProvidersPerKey = new Map((this.remoteDataProviders ?? []).map((r) => [r.remoteDataKey, r]));
|
|
684
|
+
}
|
|
685
|
+
updateState(state, action) {
|
|
686
|
+
switch (action.type) {
|
|
687
|
+
case RemoteDataActionType.loadRemoteData: {
|
|
688
|
+
const loadRemoteDataAction = action;
|
|
689
|
+
const item = selectRemoteDataState(state)[loadRemoteDataAction.remoteDataKey];
|
|
690
|
+
if (!item) return state;
|
|
691
|
+
const provider = this.remoteDataProvidersPerKey.get(loadRemoteDataAction.remoteDataKey);
|
|
692
|
+
if (!provider) return state;
|
|
693
|
+
if (!provider.cacheDurationInSeconds || loadRemoteDataAction.params?.forceReload === true || item.status === DataStatus.none || item.status === DataStatus.error || item.status === DataStatus.notFound || !item.timestamp || (/* @__PURE__ */ new Date()).getTime() - item.timestamp.getTime() >= 1e3 * provider.cacheDurationInSeconds) return updateRemoteDataState(state, { [loadRemoteDataAction.remoteDataKey]: {
|
|
694
|
+
status: { $set: DataStatus.loading },
|
|
695
|
+
getterParams: { $apply: (value) => {
|
|
696
|
+
if (!loadRemoteDataAction.params || loadRemoteDataAction.params.keepStoredGetterParams !== true) return loadRemoteDataAction.params?.params;
|
|
697
|
+
return value;
|
|
698
|
+
} }
|
|
699
|
+
} });
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
702
|
+
case RemoteDataActionType.registerLoadedRemoteData: {
|
|
703
|
+
const registerLoadedRemoteDataAction = action;
|
|
704
|
+
if (this.remoteDataProvidersPerKey.has(registerLoadedRemoteDataAction.remoteDataKey)) return updateRemoteDataState(state, { [registerLoadedRemoteDataAction.remoteDataKey]: {
|
|
705
|
+
status: { $set: registerLoadedRemoteDataAction.status },
|
|
706
|
+
data: { $set: registerLoadedRemoteDataAction.data },
|
|
707
|
+
timestamp: { $set: /* @__PURE__ */ new Date() },
|
|
708
|
+
message: { $set: registerLoadedRemoteDataAction.message },
|
|
709
|
+
error: { $set: registerLoadedRemoteDataAction.remoteCallError }
|
|
710
|
+
} });
|
|
711
|
+
break;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
return state;
|
|
715
|
+
}
|
|
716
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
717
|
+
minVersion: "12.0.0",
|
|
718
|
+
version: "22.2.0",
|
|
719
|
+
ngImport: i0,
|
|
720
|
+
type: RemoteDataReducer,
|
|
721
|
+
deps: [],
|
|
722
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
723
|
+
});
|
|
724
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
725
|
+
minVersion: "12.0.0",
|
|
726
|
+
version: "22.2.0",
|
|
727
|
+
ngImport: i0,
|
|
728
|
+
type: RemoteDataReducer
|
|
729
|
+
});
|
|
730
|
+
};
|
|
731
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
732
|
+
minVersion: "12.0.0",
|
|
733
|
+
version: "22.2.0",
|
|
734
|
+
ngImport: i0,
|
|
735
|
+
type: RemoteDataReducer,
|
|
736
|
+
decorators: [{ type: Injectable }],
|
|
737
|
+
ctorParameters: () => []
|
|
738
|
+
});
|
|
739
|
+
var RemoteDataStateInitializer = class RemoteDataStateInitializer {
|
|
740
|
+
remoteDataProviders = inject(NGSSM_REMOTE_DATA_PROVIDER, { optional: true });
|
|
741
|
+
initializeState(state) {
|
|
742
|
+
const tempState = state;
|
|
743
|
+
return (this.remoteDataProviders ?? []).reduce((s, provider) => updateRemoteDataState(s, { [provider.remoteDataKey]: { $set: { status: DataStatus.none } } }), tempState);
|
|
744
|
+
}
|
|
745
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
746
|
+
minVersion: "12.0.0",
|
|
747
|
+
version: "22.2.0",
|
|
748
|
+
ngImport: i0,
|
|
749
|
+
type: RemoteDataStateInitializer,
|
|
750
|
+
deps: [],
|
|
751
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
752
|
+
});
|
|
753
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
754
|
+
minVersion: "12.0.0",
|
|
755
|
+
version: "22.2.0",
|
|
756
|
+
ngImport: i0,
|
|
757
|
+
type: RemoteDataStateInitializer
|
|
758
|
+
});
|
|
759
|
+
};
|
|
760
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
761
|
+
minVersion: "12.0.0",
|
|
762
|
+
version: "22.2.0",
|
|
763
|
+
ngImport: i0,
|
|
764
|
+
type: RemoteDataStateInitializer,
|
|
765
|
+
decorators: [{ type: Injectable }]
|
|
766
|
+
});
|
|
370
767
|
const provideNgssmRemoteData = () => {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
768
|
+
return makeEnvironmentProviders([
|
|
769
|
+
provideReducer(RemoteDataReducer),
|
|
770
|
+
provideEffects(CachesDisplayEffect, RemoteDataLoadingEffect),
|
|
771
|
+
{
|
|
772
|
+
provide: NGSSM_STATE_INITIALIZER,
|
|
773
|
+
useClass: RemoteDataStateInitializer,
|
|
774
|
+
multi: true
|
|
775
|
+
}
|
|
776
|
+
]);
|
|
376
777
|
};
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
* carrying both the action type and the associated remote call data.
|
|
387
|
-
*
|
|
388
|
-
* @remarks
|
|
389
|
-
* Implements the `Action` interface.
|
|
390
|
-
*
|
|
391
|
-
* @param type - The type of the action.
|
|
392
|
-
* @param remoteCall - The remote call instance containing the result details.
|
|
393
|
-
*/
|
|
394
|
-
class NgssmRemoteCallResultAction {
|
|
395
|
-
type;
|
|
396
|
-
remoteCall;
|
|
397
|
-
constructor(type, remoteCall) {
|
|
398
|
-
this.type = type;
|
|
399
|
-
this.remoteCall = remoteCall;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* Injection token for providing NGSSM remote call configuration.
|
|
404
|
-
* Used to register and inject RemoteCallConfig objects in Angular's dependency injection system.
|
|
405
|
-
*/
|
|
406
|
-
const NGSSM_REMOTE_CALL_CONFIG = new InjectionToken('NGSSM_REMOTE_CALL_CONFIG');
|
|
407
|
-
/**
|
|
408
|
-
* Provides the configuration for NGSSM remote calls as an Angular provider.
|
|
409
|
-
*
|
|
410
|
-
* @param config - The remote call configuration object to be provided.
|
|
411
|
-
* @returns An Angular provider object that supplies the given configuration for NGSSM remote calls.
|
|
412
|
-
*
|
|
413
|
-
* @remarks
|
|
414
|
-
* This function is intended to be used in Angular module providers to register
|
|
415
|
-
* multiple remote call configurations using the `multi: true` option.
|
|
416
|
-
*/
|
|
778
|
+
var NgssmRemoteCallResultAction = class {
|
|
779
|
+
type;
|
|
780
|
+
remoteCall;
|
|
781
|
+
constructor(type, remoteCall) {
|
|
782
|
+
this.type = type;
|
|
783
|
+
this.remoteCall = remoteCall;
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
const NGSSM_REMOTE_CALL_CONFIG = new InjectionToken("NGSSM_REMOTE_CALL_CONFIG");
|
|
417
787
|
const provideNgssmRemoteCallConfig = (config) => ({
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
788
|
+
provide: NGSSM_REMOTE_CALL_CONFIG,
|
|
789
|
+
useValue: config,
|
|
790
|
+
multi: true
|
|
421
791
|
});
|
|
422
|
-
|
|
423
|
-
// Represents the possible statuses of a remote call.
|
|
424
792
|
var RemoteCallStatus;
|
|
425
|
-
(function
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
793
|
+
(function(RemoteCallStatus) {
|
|
794
|
+
RemoteCallStatus["none"] = "None";
|
|
795
|
+
RemoteCallStatus["inProgress"] = "In progress";
|
|
796
|
+
RemoteCallStatus["done"] = "Done";
|
|
797
|
+
RemoteCallStatus["ko"] = "Ko";
|
|
430
798
|
})(RemoteCallStatus || (RemoteCallStatus = {}));
|
|
431
|
-
/**
|
|
432
|
-
* Returns a default RemoteCall object with the specified status (defaults to 'none').
|
|
433
|
-
* @param status The status to set for the remote call.
|
|
434
|
-
* @returns A RemoteCall object with the given status.
|
|
435
|
-
*/
|
|
436
799
|
const getDefaultRemoteCall = (status = RemoteCallStatus.none) => ({ status });
|
|
437
|
-
|
|
438
800
|
const selectNgssmRemoteCallState = (state) => state[NgssmRemoteCallStateSpecification.featureStateKey];
|
|
439
|
-
const updateNgssmRemoteCallState = (state, command) => update(state, {
|
|
440
|
-
[NgssmRemoteCallStateSpecification.featureStateKey]: command
|
|
441
|
-
});
|
|
801
|
+
const updateNgssmRemoteCallState = (state, command) => update(state, { [NgssmRemoteCallStateSpecification.featureStateKey]: command });
|
|
442
802
|
let NgssmRemoteCallStateSpecification = class NgssmRemoteCallStateSpecification {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
remoteCalls: {}
|
|
446
|
-
};
|
|
803
|
+
static featureStateKey = "ngssm-remote-call-state";
|
|
804
|
+
static initialState = { remoteCalls: {} };
|
|
447
805
|
};
|
|
448
|
-
NgssmRemoteCallStateSpecification = __decorate([
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
806
|
+
NgssmRemoteCallStateSpecification = __decorate([NgSsmFeatureState({
|
|
807
|
+
featureStateKey: NgssmRemoteCallStateSpecification.featureStateKey,
|
|
808
|
+
initialState: NgssmRemoteCallStateSpecification.initialState
|
|
809
|
+
})], NgssmRemoteCallStateSpecification);
|
|
810
|
+
var NgssmRemoteCallStateInitializer = class NgssmRemoteCallStateInitializer {
|
|
811
|
+
remoteCallConfigs = inject(NGSSM_REMOTE_CALL_CONFIG, { optional: true });
|
|
812
|
+
initializeState(state) {
|
|
813
|
+
const tempState = state;
|
|
814
|
+
return (this.remoteCallConfigs ?? []).reduce((s, config) => updateNgssmRemoteCallState(s, { remoteCalls: { [config.id]: { $set: { status: RemoteCallStatus.none } } } }), tempState);
|
|
815
|
+
}
|
|
816
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
817
|
+
minVersion: "12.0.0",
|
|
818
|
+
version: "22.2.0",
|
|
819
|
+
ngImport: i0,
|
|
820
|
+
type: NgssmRemoteCallStateInitializer,
|
|
821
|
+
deps: [],
|
|
822
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
823
|
+
});
|
|
824
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
825
|
+
minVersion: "12.0.0",
|
|
826
|
+
version: "22.2.0",
|
|
827
|
+
ngImport: i0,
|
|
828
|
+
type: NgssmRemoteCallStateInitializer
|
|
829
|
+
});
|
|
830
|
+
};
|
|
831
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
832
|
+
minVersion: "12.0.0",
|
|
833
|
+
version: "22.2.0",
|
|
834
|
+
ngImport: i0,
|
|
835
|
+
type: NgssmRemoteCallStateInitializer,
|
|
836
|
+
decorators: [{ type: Injectable }]
|
|
837
|
+
});
|
|
838
|
+
var RemoteCallReducer = class RemoteCallReducer {
|
|
839
|
+
processedActions = [];
|
|
840
|
+
remoteCallConfigs = inject(NGSSM_REMOTE_CALL_CONFIG, { optional: true });
|
|
841
|
+
constructor() {
|
|
842
|
+
(this.remoteCallConfigs ?? []).forEach((c) => this.processedActions.push(...[...c.triggeredActionTypes, ...c.resultActionTypes]));
|
|
843
|
+
}
|
|
844
|
+
updateState(state, action) {
|
|
845
|
+
const configs = (this.remoteCallConfigs ?? []).filter((c) => c.triggeredActionTypes.includes(action.type) || c.resultActionTypes.includes(action.type));
|
|
846
|
+
let output = state;
|
|
847
|
+
configs.forEach((config) => {
|
|
848
|
+
if (config.triggeredActionTypes.includes(action.type)) output = updateNgssmRemoteCallState(output, { remoteCalls: { [config.id]: { $set: getDefaultRemoteCall(RemoteCallStatus.inProgress) } } });
|
|
849
|
+
else {
|
|
850
|
+
const ngssmRemoteCallResultAction = action;
|
|
851
|
+
output = updateNgssmRemoteCallState(output, { remoteCalls: { [config.id]: { $set: ngssmRemoteCallResultAction.remoteCall } } });
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
return output;
|
|
855
|
+
}
|
|
856
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
857
|
+
minVersion: "12.0.0",
|
|
858
|
+
version: "22.2.0",
|
|
859
|
+
ngImport: i0,
|
|
860
|
+
type: RemoteCallReducer,
|
|
861
|
+
deps: [],
|
|
862
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
863
|
+
});
|
|
864
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
865
|
+
minVersion: "12.0.0",
|
|
866
|
+
version: "22.2.0",
|
|
867
|
+
ngImport: i0,
|
|
868
|
+
type: RemoteCallReducer
|
|
869
|
+
});
|
|
870
|
+
};
|
|
871
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
872
|
+
minVersion: "12.0.0",
|
|
873
|
+
version: "22.2.0",
|
|
874
|
+
ngImport: i0,
|
|
875
|
+
type: RemoteCallReducer,
|
|
876
|
+
decorators: [{ type: Injectable }],
|
|
877
|
+
ctorParameters: () => []
|
|
878
|
+
});
|
|
507
879
|
var NgssmRemoteCallActionType;
|
|
508
|
-
(function
|
|
509
|
-
|
|
880
|
+
(function(NgssmRemoteCallActionType) {
|
|
881
|
+
NgssmRemoteCallActionType["setRemoteCall"] = "[NgssmRemoteCallActionType] setRemoteCall";
|
|
510
882
|
})(NgssmRemoteCallActionType || (NgssmRemoteCallActionType = {}));
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
883
|
+
var SetRemoteCallAction = class {
|
|
884
|
+
remoteCallId;
|
|
885
|
+
remoteCall;
|
|
886
|
+
type = NgssmRemoteCallActionType.setRemoteCall;
|
|
887
|
+
constructor(remoteCallId, remoteCall) {
|
|
888
|
+
this.remoteCallId = remoteCallId;
|
|
889
|
+
this.remoteCall = remoteCall;
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
var RemoteCallSetterReducer = class RemoteCallSetterReducer {
|
|
893
|
+
processedActions = [NgssmRemoteCallActionType.setRemoteCall];
|
|
894
|
+
updateState(state, action) {
|
|
895
|
+
switch (action.type) {
|
|
896
|
+
case NgssmRemoteCallActionType.setRemoteCall: {
|
|
897
|
+
const setRemoteCallAction = action;
|
|
898
|
+
return updateNgssmRemoteCallState(state, { remoteCalls: { [setRemoteCallAction.remoteCallId]: { $set: setRemoteCallAction.remoteCall } } });
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
return state;
|
|
902
|
+
}
|
|
903
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
904
|
+
minVersion: "12.0.0",
|
|
905
|
+
version: "22.2.0",
|
|
906
|
+
ngImport: i0,
|
|
907
|
+
type: RemoteCallSetterReducer,
|
|
908
|
+
deps: [],
|
|
909
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
910
|
+
});
|
|
911
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
912
|
+
minVersion: "12.0.0",
|
|
913
|
+
version: "22.2.0",
|
|
914
|
+
ngImport: i0,
|
|
915
|
+
type: RemoteCallSetterReducer
|
|
916
|
+
});
|
|
917
|
+
};
|
|
918
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
919
|
+
minVersion: "12.0.0",
|
|
920
|
+
version: "22.2.0",
|
|
921
|
+
ngImport: i0,
|
|
922
|
+
type: RemoteCallSetterReducer,
|
|
923
|
+
decorators: [{ type: Injectable }]
|
|
924
|
+
});
|
|
543
925
|
const provideNgssmRemoteCall = () => {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
926
|
+
return makeEnvironmentProviders([{
|
|
927
|
+
provide: NGSSM_STATE_INITIALIZER,
|
|
928
|
+
useClass: NgssmRemoteCallStateInitializer,
|
|
929
|
+
multi: true
|
|
930
|
+
}, provideReducers(RemoteCallSetterReducer, RemoteCallReducer)]);
|
|
548
931
|
};
|
|
549
|
-
|
|
550
932
|
const selectRemoteCall = (state, id) => selectNgssmRemoteCallState(state).remoteCalls[id] ?? getDefaultRemoteCall();
|
|
551
|
-
/**
|
|
552
|
-
* Returns true if the specified remote call is currently in progress, false otherwise.
|
|
553
|
-
* @param state The global application state.
|
|
554
|
-
* @param remoteCallId The unique id of the remote call.
|
|
555
|
-
*/
|
|
556
933
|
const isNgssmRemoteCallInProgress = (state, remoteCallId) => selectRemoteCall(state, remoteCallId)?.status === RemoteCallStatus.inProgress;
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
934
|
+
var RemoteCallResultProcessor = class RemoteCallResultProcessor {
|
|
935
|
+
logger = inject(Logger);
|
|
936
|
+
injector = inject(Injector);
|
|
937
|
+
notifier = inject(NgssmNotifierService);
|
|
938
|
+
processRemoteCallError(remoteCallId, error, errorMessage) {
|
|
939
|
+
this.logger.error(errorMessage, error);
|
|
940
|
+
this.notifier.notifyError(errorMessage, error.message);
|
|
941
|
+
this.injector.get(Store).dispatchAction(new SetRemoteCallAction(remoteCallId, {
|
|
942
|
+
status: RemoteCallStatus.ko,
|
|
943
|
+
httpErrorResponse: error,
|
|
944
|
+
message: errorMessage
|
|
945
|
+
}));
|
|
946
|
+
}
|
|
947
|
+
processRemoteCallSuccess(remoteCallId, message) {
|
|
948
|
+
this.logger.information(message);
|
|
949
|
+
this.notifier.notifySuccess(message);
|
|
950
|
+
this.injector.get(Store).dispatchAction(new SetRemoteCallAction(remoteCallId, { status: RemoteCallStatus.done }));
|
|
951
|
+
}
|
|
952
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
953
|
+
minVersion: "12.0.0",
|
|
954
|
+
version: "22.2.0",
|
|
955
|
+
ngImport: i0,
|
|
956
|
+
type: RemoteCallResultProcessor,
|
|
957
|
+
deps: [],
|
|
958
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
959
|
+
});
|
|
960
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
961
|
+
minVersion: "12.0.0",
|
|
962
|
+
version: "22.2.0",
|
|
963
|
+
ngImport: i0,
|
|
964
|
+
type: RemoteCallResultProcessor,
|
|
965
|
+
providedIn: "root"
|
|
966
|
+
});
|
|
967
|
+
};
|
|
968
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
969
|
+
minVersion: "12.0.0",
|
|
970
|
+
version: "22.2.0",
|
|
971
|
+
ngImport: i0,
|
|
972
|
+
type: RemoteCallResultProcessor,
|
|
973
|
+
decorators: [{
|
|
974
|
+
type: Injectable,
|
|
975
|
+
args: [{ providedIn: "root" }]
|
|
976
|
+
}]
|
|
977
|
+
});
|
|
596
978
|
const processRemoteCallError = (error, errorMessage, remoteCallId, actionDispatcher, logger, notifier) => {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
979
|
+
logger.error(errorMessage, error);
|
|
980
|
+
notifier.notifyError(errorMessage, error.error?.title);
|
|
981
|
+
actionDispatcher.dispatchAction(new SetRemoteCallAction(remoteCallId, {
|
|
982
|
+
status: RemoteCallStatus.ko,
|
|
983
|
+
error: error.error
|
|
984
|
+
}));
|
|
600
985
|
};
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
986
|
+
var NgssmRemoteCallErrorComponent = class NgssmRemoteCallErrorComponent {
|
|
987
|
+
remoteCallId = input("", ...ngDevMode ? [{ debugName: "remoteCallId" }] : /* istanbul ignore next */ []);
|
|
988
|
+
errorContainerRendered = signal(false, ...ngDevMode ? [{ debugName: "errorContainerRendered" }] : /* istanbul ignore next */ []);
|
|
989
|
+
errorDescription = signal("", ...ngDevMode ? [{ debugName: "errorDescription" }] : /* istanbul ignore next */ []);
|
|
990
|
+
remoteCalls = createSignal((state) => selectNgssmRemoteCallState(state).remoteCalls);
|
|
991
|
+
constructor() {
|
|
992
|
+
effect(() => {
|
|
993
|
+
const id = this.remoteCallId();
|
|
994
|
+
const remoteCall = this.remoteCalls()[id];
|
|
995
|
+
this.errorContainerRendered.set(remoteCall?.status === RemoteCallStatus.ko);
|
|
996
|
+
const description = remoteCall?.status !== RemoteCallStatus.ko ? "" : remoteCall.message ? remoteCall.message : remoteCall.httpErrorResponse ? JSON.stringify(remoteCall.httpErrorResponse, null, 2) : remoteCall.error ? JSON.stringify(remoteCall.error, null, 2) : "No error description provided!";
|
|
997
|
+
this.errorDescription.set(description);
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1001
|
+
minVersion: "12.0.0",
|
|
1002
|
+
version: "22.2.0",
|
|
1003
|
+
ngImport: i0,
|
|
1004
|
+
type: NgssmRemoteCallErrorComponent,
|
|
1005
|
+
deps: [],
|
|
1006
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
1007
|
+
});
|
|
1008
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1009
|
+
minVersion: "17.0.0",
|
|
1010
|
+
version: "22.2.0",
|
|
1011
|
+
type: NgssmRemoteCallErrorComponent,
|
|
1012
|
+
isStandalone: true,
|
|
1013
|
+
selector: "ngssm-remote-call-error",
|
|
1014
|
+
inputs: { remoteCallId: {
|
|
1015
|
+
classPropertyName: "remoteCallId",
|
|
1016
|
+
publicName: "remoteCallId",
|
|
1017
|
+
isSignal: true,
|
|
1018
|
+
isRequired: false,
|
|
1019
|
+
transformFunction: null
|
|
1020
|
+
} },
|
|
1021
|
+
host: { classAttribute: "ngssm-remote-call-error" },
|
|
1022
|
+
ngImport: i0,
|
|
1023
|
+
template: "@if (errorContainerRendered()) {\n <div class=\"ngssm-remote-call-error-container\">\n {{ errorDescription() }}\n\n <button mat-icon-button color=\"warn\" class=\"ngssm-remote-call-error-close-button\" (click)=\"errorContainerRendered.set(false)\">\n <mat-icon class=\"fa-solid fa-square-xmark\"></mat-icon>\n </button>\n </div>\n}\n",
|
|
1024
|
+
dependencies: [
|
|
1025
|
+
{
|
|
1026
|
+
kind: "ngmodule",
|
|
1027
|
+
type: MatButtonModule
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
kind: "component",
|
|
1031
|
+
type: i2.MatIconButton,
|
|
1032
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
1033
|
+
exportAs: ["matButton", "matAnchor"]
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
kind: "ngmodule",
|
|
1037
|
+
type: MatIconModule
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
kind: "component",
|
|
1041
|
+
type: i1$1.MatIcon,
|
|
1042
|
+
selector: "mat-icon",
|
|
1043
|
+
inputs: [
|
|
1044
|
+
"color",
|
|
1045
|
+
"inline",
|
|
1046
|
+
"svgIcon",
|
|
1047
|
+
"fontSet",
|
|
1048
|
+
"fontIcon"
|
|
1049
|
+
],
|
|
1050
|
+
exportAs: ["matIcon"]
|
|
1051
|
+
}
|
|
1052
|
+
]
|
|
1053
|
+
});
|
|
1054
|
+
};
|
|
1055
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1056
|
+
minVersion: "12.0.0",
|
|
1057
|
+
version: "22.2.0",
|
|
1058
|
+
ngImport: i0,
|
|
1059
|
+
type: NgssmRemoteCallErrorComponent,
|
|
1060
|
+
decorators: [{
|
|
1061
|
+
type: Component,
|
|
1062
|
+
args: [{
|
|
1063
|
+
selector: "ngssm-remote-call-error",
|
|
1064
|
+
imports: [MatButtonModule, MatIconModule],
|
|
1065
|
+
host: { class: "ngssm-remote-call-error" },
|
|
1066
|
+
template: "@if (errorContainerRendered()) {\n <div class=\"ngssm-remote-call-error-container\">\n {{ errorDescription() }}\n\n <button mat-icon-button color=\"warn\" class=\"ngssm-remote-call-error-close-button\" (click)=\"errorContainerRendered.set(false)\">\n <mat-icon class=\"fa-solid fa-square-xmark\"></mat-icon>\n </button>\n </div>\n}\n"
|
|
1067
|
+
}]
|
|
1068
|
+
}],
|
|
1069
|
+
ctorParameters: () => [],
|
|
1070
|
+
propDecorators: { remoteCallId: [{
|
|
1071
|
+
type: i0.Input,
|
|
1072
|
+
args: [{
|
|
1073
|
+
isSignal: true,
|
|
1074
|
+
alias: "remoteCallId",
|
|
1075
|
+
required: false
|
|
1076
|
+
}]
|
|
1077
|
+
}] }
|
|
1078
|
+
});
|
|
645
1079
|
export { DataStatus, LoadRemoteDataAction, NGSSM_REMOTE_CALL_CONFIG, NGSSM_REMOTE_DATA_PROVIDER, NgssmCachesComponent, NgssmCachesDisplayButtonComponent, NgssmRemoteCallActionType, NgssmRemoteCallErrorComponent, NgssmRemoteCallResultAction, NgssmRemoteCallStateInitializer, NgssmRemoteCallStateSpecification, NgssmRemoteDataReloadButtonComponent, RegisterLoadedRemoteDataAction, RemoteCallResultProcessor, RemoteCallStatus, RemoteDataActionType, RemoteDataLoadingGuard, RemoteDataStateSpecification, SetRemoteCallAction, getDefaultRemoteCall, getDefaultRemoteData, isNgssmRemoteCallInProgress, ngssmReloadRemoteData, processRemoteCallError, provideNgssmRemoteCall, provideNgssmRemoteCallConfig, provideNgssmRemoteData, provideRemoteDataFunc, provideRemoteDataProviders, selectNgssmRemoteCallState, selectRemoteCall, selectRemoteData, selectRemoteDataState, updateNgssmRemoteCallState, updateRemoteDataState };
|
|
646
|
-
|
|
1080
|
+
|
|
1081
|
+
//# sourceMappingURL=ngssm-remote-data.mjs.map
|