@singularsystems/neo-core 1.0.0-beta.2 → 1.0.0-beta.4
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/dist/Data/Paging/PageManager.d.ts +10 -3
- package/dist/Data/Paging/PageManager.js +34 -15
- package/dist/Extensions.js +6 -1
- package/dist/Model/BaseModels/UserEvent.js +7 -3
- package/dist/Security/Oidc/OidcAuthService.d.ts +1 -0
- package/dist/Security/Oidc/OidcAuthService.js +31 -15
- package/dist/Settings.d.ts +2 -0
- package/dist/Settings.js +2 -0
- package/dist/Utils.d.ts +4 -0
- package/dist/Utils.js +11 -3
- package/package.json +1 -1
|
@@ -82,7 +82,7 @@ export interface IPageManager {
|
|
|
82
82
|
/**
|
|
83
83
|
* Refresh the data only if the page manager has initialised.
|
|
84
84
|
*/
|
|
85
|
-
invalidateData(
|
|
85
|
+
invalidateData(): void;
|
|
86
86
|
/**
|
|
87
87
|
* Refresh the data by calling the api endpoint with the current criteria.
|
|
88
88
|
* This will not reset the page index, and will not update the total record count, therefore should only be called if your criteria has not changed since the last full fetch using refreshData().
|
|
@@ -101,6 +101,7 @@ export declare class PageManager<TCriteria extends ValueObject, TModel extends I
|
|
|
101
101
|
private _totalRecords;
|
|
102
102
|
private currentData;
|
|
103
103
|
private initialFetchState;
|
|
104
|
+
private isInvalidated;
|
|
104
105
|
/**
|
|
105
106
|
* Gets or sets the criteria.
|
|
106
107
|
*/
|
|
@@ -125,6 +126,8 @@ export declare class PageManager<TCriteria extends ValueObject, TModel extends I
|
|
|
125
126
|
* Called by the pager component on first display. Will fetch data if options.fetchInitial is set to true.
|
|
126
127
|
*/
|
|
127
128
|
initialise(): void;
|
|
129
|
+
/** Called after a bound ui component has rendered. Used to refetch data if invalidateData() was called. */
|
|
130
|
+
afterRender(): void;
|
|
128
131
|
/**
|
|
129
132
|
* Refresh the data by calling the api endpoint with the current criteria.
|
|
130
133
|
* Note: the page index will be reset to zero. Use this when your criteria has changed
|
|
@@ -133,9 +136,9 @@ export declare class PageManager<TCriteria extends ValueObject, TModel extends I
|
|
|
133
136
|
*/
|
|
134
137
|
refreshData(getCount?: boolean, taskRunner?: ITaskRunner): Promise<void>;
|
|
135
138
|
/**
|
|
136
|
-
* Refresh the data only if the page manager has initialised.
|
|
139
|
+
* Refresh the data only if the page manager has initialised, and is currently being rendered.
|
|
137
140
|
*/
|
|
138
|
-
invalidateData(
|
|
141
|
+
invalidateData(): void;
|
|
139
142
|
/**
|
|
140
143
|
* Refresh the data by calling the api endpoint with the current criteria.
|
|
141
144
|
* This will not reset the page index, and will not update the total record count, therefore should only be called if your criteria has not changed since the last full fetch using refreshData().
|
|
@@ -144,6 +147,10 @@ export declare class PageManager<TCriteria extends ValueObject, TModel extends I
|
|
|
144
147
|
refreshPage(taskRunner?: ITaskRunner): Promise<void>;
|
|
145
148
|
private fetchAndSetData;
|
|
146
149
|
setData(pageRecords: PartialPlainObject<TModel>[], totalRecords?: number): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Adds an item to the current page, and increments the total record count.
|
|
152
|
+
*/
|
|
153
|
+
addRecord(item: TModel | Model.PlainObject<TModel>): void;
|
|
147
154
|
/**
|
|
148
155
|
* Resets the page manager to its initial state and clears the current data.
|
|
149
156
|
*/
|
|
@@ -16,6 +16,7 @@ export var PageManager = /** @class */ (function (_super) {
|
|
|
16
16
|
_this._totalRecords = -1;
|
|
17
17
|
_this.currentData = new List(_this.modelType);
|
|
18
18
|
_this.initialFetchState = "none";
|
|
19
|
+
_this.isInvalidated = false;
|
|
19
20
|
_this.options = options || {};
|
|
20
21
|
_this.allowSort = _this.options.allowSort !== false;
|
|
21
22
|
_this.performsRemoteSorting = true;
|
|
@@ -59,6 +60,7 @@ export var PageManager = /** @class */ (function (_super) {
|
|
|
59
60
|
if (this.initialFetchState === "loading") {
|
|
60
61
|
return null;
|
|
61
62
|
}
|
|
63
|
+
void this.isInvalidated;
|
|
62
64
|
return this.initialFetchState === "complete";
|
|
63
65
|
},
|
|
64
66
|
enumerable: false,
|
|
@@ -126,10 +128,21 @@ export var PageManager = /** @class */ (function (_super) {
|
|
|
126
128
|
PageManager.prototype.initialise = function () {
|
|
127
129
|
if (!this.hasInitialised) {
|
|
128
130
|
this.hasInitialised = true;
|
|
131
|
+
this.isInvalidated = false;
|
|
129
132
|
if (this.options.fetchInitial) {
|
|
130
133
|
this.refreshData(true, this.options.initialTaskRunner);
|
|
131
134
|
}
|
|
132
135
|
}
|
|
136
|
+
else {
|
|
137
|
+
this.afterRender();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
/** Called after a bound ui component has rendered. Used to refetch data if invalidateData() was called. */
|
|
141
|
+
PageManager.prototype.afterRender = function () {
|
|
142
|
+
if (this.isInvalidated) {
|
|
143
|
+
this.isInvalidated = false;
|
|
144
|
+
this.refreshPage();
|
|
145
|
+
}
|
|
133
146
|
};
|
|
134
147
|
/**
|
|
135
148
|
* Refresh the data by calling the api endpoint with the current criteria.
|
|
@@ -167,22 +180,12 @@ export var PageManager = /** @class */ (function (_super) {
|
|
|
167
180
|
});
|
|
168
181
|
};
|
|
169
182
|
/**
|
|
170
|
-
* Refresh the data only if the page manager has initialised.
|
|
183
|
+
* Refresh the data only if the page manager has initialised, and is currently being rendered.
|
|
171
184
|
*/
|
|
172
|
-
PageManager.prototype.invalidateData = function (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
case 0:
|
|
177
|
-
if (!this.hasInitialised) return [3 /*break*/, 2];
|
|
178
|
-
return [4 /*yield*/, this.refreshData(true, taskRunner)];
|
|
179
|
-
case 1:
|
|
180
|
-
_a.sent();
|
|
181
|
-
_a.label = 2;
|
|
182
|
-
case 2: return [2 /*return*/];
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
});
|
|
185
|
+
PageManager.prototype.invalidateData = function () {
|
|
186
|
+
if (this.hasInitialised) {
|
|
187
|
+
this.isInvalidated = true;
|
|
188
|
+
}
|
|
186
189
|
};
|
|
187
190
|
/**
|
|
188
191
|
* Refresh the data by calling the api endpoint with the current criteria.
|
|
@@ -254,6 +257,18 @@ export var PageManager = /** @class */ (function (_super) {
|
|
|
254
257
|
});
|
|
255
258
|
});
|
|
256
259
|
};
|
|
260
|
+
/**
|
|
261
|
+
* Adds an item to the current page, and increments the total record count.
|
|
262
|
+
*/
|
|
263
|
+
PageManager.prototype.addRecord = function (item) {
|
|
264
|
+
this._totalRecords += 1;
|
|
265
|
+
if (item.meta) {
|
|
266
|
+
this.data.push(item);
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
this.data.push(this.modelType.fromJSObject(item));
|
|
270
|
+
}
|
|
271
|
+
};
|
|
257
272
|
/**
|
|
258
273
|
* Resets the page manager to its initial state and clears the current data.
|
|
259
274
|
*/
|
|
@@ -345,6 +360,10 @@ export var PageManager = /** @class */ (function (_super) {
|
|
|
345
360
|
Observable(),
|
|
346
361
|
__metadata("design:type", String)
|
|
347
362
|
], PageManager.prototype, "initialFetchState", void 0);
|
|
363
|
+
__decorate([
|
|
364
|
+
Observable(),
|
|
365
|
+
__metadata("design:type", Object)
|
|
366
|
+
], PageManager.prototype, "isInvalidated", void 0);
|
|
348
367
|
PageManager = __decorate([
|
|
349
368
|
NeoModel,
|
|
350
369
|
__metadata("design:paramtypes", [Object, Function, Function, Object])
|
package/dist/Extensions.js
CHANGED
|
@@ -88,7 +88,12 @@ Array.prototype.sortBy = function (valueFnOrKey, direction, dataType) {
|
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
var array = this;
|
|
92
|
+
if (this.addNew) {
|
|
93
|
+
// Mobx6 doesn't allow the array to be sorted in place, must create a new one.
|
|
94
|
+
array = this.slice();
|
|
95
|
+
}
|
|
96
|
+
return array.sort(comparer);
|
|
92
97
|
};
|
|
93
98
|
Array.prototype.remove = function (item) {
|
|
94
99
|
var index = this.indexOf(item);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { __decorate, __extends } from "tslib";
|
|
1
|
+
import { __decorate, __extends, __metadata } from "tslib";
|
|
2
2
|
import ValueObject from '../ValueObject';
|
|
3
|
+
import { Date as DateAttribute } from '../Decorators';
|
|
3
4
|
import NeoModel from '../NeoModel';
|
|
4
|
-
var UserEventBase = /** @class */ (function (_super) {
|
|
5
|
+
export var UserEventBase = /** @class */ (function (_super) {
|
|
5
6
|
__extends(UserEventBase, _super);
|
|
6
7
|
function UserEventBase() {
|
|
7
8
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
@@ -16,9 +17,12 @@ var UserEventBase = /** @class */ (function (_super) {
|
|
|
16
17
|
enumerable: false,
|
|
17
18
|
configurable: true
|
|
18
19
|
});
|
|
20
|
+
__decorate([
|
|
21
|
+
DateAttribute(),
|
|
22
|
+
__metadata("design:type", Object)
|
|
23
|
+
], UserEventBase.prototype, "on", void 0);
|
|
19
24
|
return UserEventBase;
|
|
20
25
|
}(ValueObject));
|
|
21
|
-
export { UserEventBase };
|
|
22
26
|
export var UserEvent = /** @class */ (function (_super) {
|
|
23
27
|
__extends(UserEvent, _super);
|
|
24
28
|
function UserEvent() {
|
|
@@ -38,6 +38,7 @@ export default abstract class OidcAuthService<TUser extends OidcUser = OidcUser>
|
|
|
38
38
|
endSignInSilent(): Promise<any>;
|
|
39
39
|
private onUserLoaded;
|
|
40
40
|
protected afterUserLoaded(): Promise<void> | void;
|
|
41
|
+
private completeAfterUserLoaded;
|
|
41
42
|
protected createUser(user: IOidcUser): OidcUser;
|
|
42
43
|
private onUserUnloaded;
|
|
43
44
|
private setUser;
|
|
@@ -37,11 +37,14 @@ var OidcAuthService = /** @class */ (function () {
|
|
|
37
37
|
case 0: return [4 /*yield*/, this.userManager.getUser()];
|
|
38
38
|
case 1:
|
|
39
39
|
user = _a.sent();
|
|
40
|
-
if (user)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
if (!user) return [3 /*break*/, 3];
|
|
41
|
+
// Get user does not raise the onUserLoaded event, so we call it manually.
|
|
42
|
+
this.onUserLoaded(user);
|
|
43
|
+
return [4 /*yield*/, this.completeAfterUserLoaded()];
|
|
44
|
+
case 2:
|
|
45
|
+
_a.sent();
|
|
46
|
+
_a.label = 3;
|
|
47
|
+
case 3: return [2 /*return*/, this.user];
|
|
45
48
|
}
|
|
46
49
|
});
|
|
47
50
|
});
|
|
@@ -102,24 +105,21 @@ var OidcAuthService = /** @class */ (function () {
|
|
|
102
105
|
loginErrorHandler = Misc.Globals.appService.get(NeoTypes.Security.LoginErrorHandler);
|
|
103
106
|
if (!(!stateKey || window.localStorage.getItem("oidc." + stateKey) === null)) return [3 /*break*/, 1];
|
|
104
107
|
loginErrorHandler.onMissingLoginState();
|
|
105
|
-
return [3 /*break*/,
|
|
108
|
+
return [3 /*break*/, 5];
|
|
106
109
|
case 1:
|
|
107
|
-
_a.trys.push([1,
|
|
110
|
+
_a.trys.push([1, 4, , 5]);
|
|
108
111
|
return [4 /*yield*/, this.endSignIn()];
|
|
109
112
|
case 2:
|
|
110
113
|
redirectPath = _a.sent();
|
|
111
|
-
|
|
112
|
-
return [4 /*yield*/, this.afterUserLoadedPromise];
|
|
114
|
+
return [4 /*yield*/, this.completeAfterUserLoaded()];
|
|
113
115
|
case 3:
|
|
114
116
|
_a.sent();
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
case 4: return [2 /*return*/, new SignInResult(true, redirectPath)];
|
|
118
|
-
case 5:
|
|
117
|
+
return [2 /*return*/, new SignInResult(true, redirectPath)];
|
|
118
|
+
case 4:
|
|
119
119
|
e_2 = _a.sent();
|
|
120
120
|
loginErrorHandler.onException(e_2);
|
|
121
|
-
return [3 /*break*/,
|
|
122
|
-
case
|
|
121
|
+
return [3 /*break*/, 5];
|
|
122
|
+
case 5: return [2 /*return*/, new SignInResult(false, "")];
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
125
|
});
|
|
@@ -133,6 +133,22 @@ var OidcAuthService = /** @class */ (function () {
|
|
|
133
133
|
};
|
|
134
134
|
OidcAuthService.prototype.afterUserLoaded = function () {
|
|
135
135
|
};
|
|
136
|
+
OidcAuthService.prototype.completeAfterUserLoaded = function () {
|
|
137
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
138
|
+
return __generator(this, function (_a) {
|
|
139
|
+
switch (_a.label) {
|
|
140
|
+
case 0:
|
|
141
|
+
if (!this.afterUserLoadedPromise) return [3 /*break*/, 2];
|
|
142
|
+
return [4 /*yield*/, this.afterUserLoadedPromise];
|
|
143
|
+
case 1:
|
|
144
|
+
_a.sent();
|
|
145
|
+
this.afterUserLoadedPromise = undefined;
|
|
146
|
+
_a.label = 2;
|
|
147
|
+
case 2: return [2 /*return*/];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
};
|
|
136
152
|
OidcAuthService.prototype.createUser = function (user) {
|
|
137
153
|
return new OidcUser(user);
|
|
138
154
|
};
|
package/dist/Settings.d.ts
CHANGED
package/dist/Settings.js
CHANGED
package/dist/Utils.d.ts
CHANGED
|
@@ -61,6 +61,10 @@ export declare class Utils {
|
|
|
61
61
|
* Converts a string like 'user' to 'fa fa-user' or 'fa-user' to 'fa fa-user' or 'far-user' to 'far fa-user'
|
|
62
62
|
*/
|
|
63
63
|
static getFontAwesomeClass(faString: string): string;
|
|
64
|
+
static getFontAwesomeIconProps(faString: string): {
|
|
65
|
+
name: string;
|
|
66
|
+
isSolid: boolean | undefined;
|
|
67
|
+
};
|
|
64
68
|
/** Concatenates an array of strings together, putting spaces in-between them. */
|
|
65
69
|
static joinWithSpaces(arg0?: string, ...args: (string | undefined)[]): string;
|
|
66
70
|
/**
|
package/dist/Utils.js
CHANGED
|
@@ -116,15 +116,23 @@ var Utils = /** @class */ (function () {
|
|
|
116
116
|
* Converts a string like 'user' to 'fa fa-user' or 'fa-user' to 'fa fa-user' or 'far-user' to 'far fa-user'
|
|
117
117
|
*/
|
|
118
118
|
Utils.getFontAwesomeClass = function (faString) {
|
|
119
|
-
var
|
|
119
|
+
var props = this.getFontAwesomeIconProps(faString);
|
|
120
|
+
return (props.isSolid === false ? 'far ' : (props.isSolid === true ? 'fas ' : 'fa ')) + 'fa-' + props.name;
|
|
121
|
+
};
|
|
122
|
+
Utils.getFontAwesomeIconProps = function (faString) {
|
|
123
|
+
var isSolid;
|
|
120
124
|
if (faString.indexOf("fa-") === 0) {
|
|
121
125
|
faString = faString.substring(3);
|
|
122
126
|
}
|
|
123
127
|
else if (faString.indexOf("far-") === 0) {
|
|
124
|
-
|
|
128
|
+
isSolid = false;
|
|
129
|
+
faString = faString.substring(4);
|
|
130
|
+
}
|
|
131
|
+
else if (faString.indexOf("fas-") === 0) {
|
|
132
|
+
isSolid = true;
|
|
125
133
|
faString = faString.substring(4);
|
|
126
134
|
}
|
|
127
|
-
return
|
|
135
|
+
return { name: faString, isSolid: isSolid };
|
|
128
136
|
};
|
|
129
137
|
/** Concatenates an array of strings together, putting spaces in-between them. */
|
|
130
138
|
Utils.joinWithSpaces = function (arg0) {
|