@sumaris-net/ngx-components 1.21.0-beta16 → 1.21.0-beta19
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/bundles/sumaris-net.ngx-components.umd.js +94 -86
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/esm2015/src/app/social/user-event/notification/user-event-notification.component.js +6 -33
- package/esm2015/src/app/social/user-event/testing/user-event.testing.service.js +3 -7
- package/esm2015/src/app/social/user-event/user-event.service.js +49 -12
- package/fesm2015/sumaris-net.ngx-components.js +51 -45
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/social/user-event/notification/user-event-notification.component.d.ts +2 -7
- package/src/app/social/user-event/testing/user-event.testing.service.d.ts +0 -2
- package/src/app/social/user-event/user-event.service.d.ts +8 -2
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -30197,6 +30197,38 @@
|
|
|
30197
30197
|
enumerable: false,
|
|
30198
30198
|
configurable: true
|
|
30199
30199
|
});
|
|
30200
|
+
AbstractUserEventService.prototype.ngOnStart = function () {
|
|
30201
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
30202
|
+
var _this = this;
|
|
30203
|
+
return __generator(this, function (_b) {
|
|
30204
|
+
switch (_b.label) {
|
|
30205
|
+
case 0:
|
|
30206
|
+
// Update component when refresh is need (=login events)
|
|
30207
|
+
this._subscriptions.add(rxjs.merge(this.accountService.onLogin, this.accountService.onLogout)
|
|
30208
|
+
.pipe(
|
|
30209
|
+
// Wait account service ready (can be restarted)
|
|
30210
|
+
operators.mergeMap(function () { return _this.accountService.ready(); }), operators.map(function () { return _this.accountService.isLogin(); }), operators.distinctUntilChanged())
|
|
30211
|
+
.subscribe(function (login) {
|
|
30212
|
+
if (login) {
|
|
30213
|
+
_this.onLogin();
|
|
30214
|
+
}
|
|
30215
|
+
else {
|
|
30216
|
+
_this.onLogout();
|
|
30217
|
+
}
|
|
30218
|
+
}));
|
|
30219
|
+
// First attempt if account is ready
|
|
30220
|
+
return [4 /*yield*/, this.accountService.ready()];
|
|
30221
|
+
case 1:
|
|
30222
|
+
// First attempt if account is ready
|
|
30223
|
+
_b.sent();
|
|
30224
|
+
if (this.accountService.isLogin()) {
|
|
30225
|
+
setTimeout(function () { return _this.onLogin(); });
|
|
30226
|
+
}
|
|
30227
|
+
return [2 /*return*/];
|
|
30228
|
+
}
|
|
30229
|
+
});
|
|
30230
|
+
});
|
|
30231
|
+
};
|
|
30200
30232
|
AbstractUserEventService.prototype.ngOnDestroy = function () {
|
|
30201
30233
|
this._subscriptions.unsubscribe();
|
|
30202
30234
|
};
|
|
@@ -30233,7 +30265,7 @@
|
|
|
30233
30265
|
},
|
|
30234
30266
|
arrayFieldName: 'data',
|
|
30235
30267
|
error: { code: SocialErrorCodes.LOAD_USER_EVENTS_ERROR, message: 'SOCIAL.ERROR.LOAD_USER_EVENTS_ERROR' },
|
|
30236
|
-
fetchPolicy: (options === null || options === void 0 ? void 0 : options.fetchPolicy) ||
|
|
30268
|
+
fetchPolicy: (options === null || options === void 0 ? void 0 : options.fetchPolicy) || 'cache-first'
|
|
30237
30269
|
})
|
|
30238
30270
|
.pipe(operators.map(function (res) {
|
|
30239
30271
|
var data = ((res === null || res === void 0 ? void 0 : res.data) || []).map(function (value) { return _this.processUserEvent(value, _this); });
|
|
@@ -30241,8 +30273,6 @@
|
|
|
30241
30273
|
console.debug("" + _this._logPrefix + data.length + " user events loaded in " + (Date.now() - now) + "ms");
|
|
30242
30274
|
now = null;
|
|
30243
30275
|
}
|
|
30244
|
-
// const unreadCount = this.unreadEvents(data);
|
|
30245
|
-
// this._count$.next(unreadCount);
|
|
30246
30276
|
// Must re-order because of listenChanges result will add new event at the end
|
|
30247
30277
|
data = EntityUtils.sort(data, page.sortBy, page.sortDirection);
|
|
30248
30278
|
return {
|
|
@@ -30266,7 +30296,7 @@
|
|
|
30266
30296
|
AbstractUserEventService.prototype.count = function (filter, options) {
|
|
30267
30297
|
var _a;
|
|
30268
30298
|
return __awaiter(this, void 0, void 0, function () {
|
|
30269
|
-
var res
|
|
30299
|
+
var res;
|
|
30270
30300
|
return __generator(this, function (_b) {
|
|
30271
30301
|
switch (_b.label) {
|
|
30272
30302
|
case 0:
|
|
@@ -30289,10 +30319,7 @@
|
|
|
30289
30319
|
})];
|
|
30290
30320
|
case 1:
|
|
30291
30321
|
res = _b.sent();
|
|
30292
|
-
|
|
30293
|
-
// update count
|
|
30294
|
-
this._count$.next(total);
|
|
30295
|
-
return [2 /*return*/, total];
|
|
30322
|
+
return [2 /*return*/, res.total];
|
|
30296
30323
|
}
|
|
30297
30324
|
});
|
|
30298
30325
|
});
|
|
@@ -30356,8 +30383,6 @@
|
|
|
30356
30383
|
query: withContent ? _this.queries.loadAllWithContent : _this.queries.loadAll,
|
|
30357
30384
|
data: updatedData
|
|
30358
30385
|
});
|
|
30359
|
-
// update count
|
|
30360
|
-
// this._count$.next(this.unreadEvents(updatedData));
|
|
30361
30386
|
return updatedData;
|
|
30362
30387
|
}));
|
|
30363
30388
|
};
|
|
@@ -30522,7 +30547,37 @@
|
|
|
30522
30547
|
this.listeners = [];
|
|
30523
30548
|
this.listeners.push(listener);
|
|
30524
30549
|
};
|
|
30550
|
+
AbstractUserEventService.prototype.resetCount = function () {
|
|
30551
|
+
this._count$.next(undefined);
|
|
30552
|
+
};
|
|
30525
30553
|
/* -- protected methods -- */
|
|
30554
|
+
AbstractUserEventService.prototype.onLogin = function () {
|
|
30555
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
30556
|
+
var count;
|
|
30557
|
+
var _this = this;
|
|
30558
|
+
return __generator(this, function (_b) {
|
|
30559
|
+
switch (_b.label) {
|
|
30560
|
+
case 0: return [4 /*yield*/, this.count(undefined)];
|
|
30561
|
+
case 1:
|
|
30562
|
+
count = _b.sent();
|
|
30563
|
+
if (this._debug)
|
|
30564
|
+
console.debug(this._logPrefix + "Receiving user events count", count);
|
|
30565
|
+
// Update count
|
|
30566
|
+
this._count$.next(count);
|
|
30567
|
+
// Then listen changes
|
|
30568
|
+
this._listenSubscription = this.listenCountChanges(undefined).subscribe(function (count) {
|
|
30569
|
+
if (_this._debug)
|
|
30570
|
+
console.debug(_this._logPrefix + "Receiving new user events count", count);
|
|
30571
|
+
});
|
|
30572
|
+
return [2 /*return*/];
|
|
30573
|
+
}
|
|
30574
|
+
});
|
|
30575
|
+
});
|
|
30576
|
+
};
|
|
30577
|
+
AbstractUserEventService.prototype.onLogout = function () {
|
|
30578
|
+
var _a;
|
|
30579
|
+
(_a = this._listenSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
30580
|
+
};
|
|
30526
30581
|
AbstractUserEventService.prototype.processUserEvent = function (source, that) {
|
|
30527
30582
|
var e_2, _b;
|
|
30528
30583
|
that = that || this;
|
|
@@ -31015,11 +31070,10 @@
|
|
|
31015
31070
|
};
|
|
31016
31071
|
|
|
31017
31072
|
var UserEventNotificationComponent = /** @class */ (function () {
|
|
31018
|
-
function UserEventNotificationComponent(userEventService, accountService, popoverController
|
|
31073
|
+
function UserEventNotificationComponent(userEventService, accountService, popoverController) {
|
|
31019
31074
|
this.userEventService = userEventService;
|
|
31020
31075
|
this.accountService = accountService;
|
|
31021
31076
|
this.popoverController = popoverController;
|
|
31022
|
-
this.cd = cd;
|
|
31023
31077
|
this.debug = false;
|
|
31024
31078
|
this.titleI18n = 'SOCIAL.USER_EVENT.NOTIFICATION.TITLE';
|
|
31025
31079
|
this.disabled = false;
|
|
@@ -31038,26 +31092,17 @@
|
|
|
31038
31092
|
return __awaiter(this, void 0, void 0, function () {
|
|
31039
31093
|
var _this = this;
|
|
31040
31094
|
return __generator(this, function (_b) {
|
|
31041
|
-
|
|
31042
|
-
|
|
31043
|
-
|
|
31044
|
-
|
|
31045
|
-
this.disabled = true;
|
|
31046
|
-
return [2 /*return*/];
|
|
31047
|
-
}
|
|
31048
|
-
return [4 /*yield*/, this.accountService.ready()];
|
|
31049
|
-
case 1:
|
|
31050
|
-
_b.sent();
|
|
31051
|
-
// listen login/logout
|
|
31052
|
-
this.accountService.onLogin.subscribe(function () { return _this.onLogin(); });
|
|
31053
|
-
this.accountService.onLogout.subscribe(function () { return _this.onLogout(); });
|
|
31054
|
-
// Subscribe to read event
|
|
31055
|
-
this._readEvent.subscribe(function (value) {
|
|
31056
|
-
// default: mark event as read
|
|
31057
|
-
_this.userEventService.markAsRead(value);
|
|
31058
|
-
});
|
|
31059
|
-
return [2 /*return*/];
|
|
31095
|
+
if (isNil(this.userEventService)) {
|
|
31096
|
+
console.warn(this._logPrefix + "No service injected");
|
|
31097
|
+
this.disabled = true;
|
|
31098
|
+
return [2 /*return*/];
|
|
31060
31099
|
}
|
|
31100
|
+
// Subscribe to read event
|
|
31101
|
+
this._readEvent.subscribe(function (value) {
|
|
31102
|
+
// default: mark event as read
|
|
31103
|
+
_this.userEventService.markAsRead(value);
|
|
31104
|
+
});
|
|
31105
|
+
return [2 /*return*/];
|
|
31061
31106
|
});
|
|
31062
31107
|
});
|
|
31063
31108
|
};
|
|
@@ -31066,19 +31111,22 @@
|
|
|
31066
31111
|
var popover;
|
|
31067
31112
|
return __generator(this, function (_b) {
|
|
31068
31113
|
switch (_b.label) {
|
|
31069
|
-
case 0:
|
|
31070
|
-
|
|
31071
|
-
|
|
31072
|
-
|
|
31073
|
-
|
|
31074
|
-
|
|
31075
|
-
|
|
31076
|
-
|
|
31077
|
-
|
|
31078
|
-
|
|
31079
|
-
|
|
31080
|
-
|
|
31081
|
-
|
|
31114
|
+
case 0:
|
|
31115
|
+
// Reset count
|
|
31116
|
+
this.userEventService.resetCount();
|
|
31117
|
+
return [4 /*yield*/, this.popoverController.create({
|
|
31118
|
+
component: UserEventNotificationList,
|
|
31119
|
+
componentProps: {
|
|
31120
|
+
debug: this.debug,
|
|
31121
|
+
titleI18n: this.titleI18n,
|
|
31122
|
+
readEvent: this._readEvent
|
|
31123
|
+
},
|
|
31124
|
+
backdropDismiss: true,
|
|
31125
|
+
keyboardClose: true,
|
|
31126
|
+
event: event,
|
|
31127
|
+
translucent: true,
|
|
31128
|
+
cssClass: 'popover-large'
|
|
31129
|
+
})];
|
|
31082
31130
|
case 1:
|
|
31083
31131
|
popover = _b.sent();
|
|
31084
31132
|
return [4 /*yield*/, popover.present()];
|
|
@@ -31093,37 +31141,6 @@
|
|
|
31093
31141
|
if (this.debug) {
|
|
31094
31142
|
console.debug(this._logPrefix + "Destroying");
|
|
31095
31143
|
}
|
|
31096
|
-
this.onLogout();
|
|
31097
|
-
};
|
|
31098
|
-
UserEventNotificationComponent.prototype.onLogin = function () {
|
|
31099
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
31100
|
-
var count;
|
|
31101
|
-
var _this = this;
|
|
31102
|
-
return __generator(this, function (_b) {
|
|
31103
|
-
switch (_b.label) {
|
|
31104
|
-
case 0: return [4 /*yield*/, this.userEventService.count(undefined)];
|
|
31105
|
-
case 1:
|
|
31106
|
-
count = _b.sent();
|
|
31107
|
-
if (this.debug)
|
|
31108
|
-
console.debug(this._logPrefix + "Receiving user events count", count);
|
|
31109
|
-
this.markForCheck();
|
|
31110
|
-
// Then listen changes
|
|
31111
|
-
this._listenSubscription = this.userEventService.listenCountChanges(undefined).subscribe(function (count) {
|
|
31112
|
-
if (_this.debug)
|
|
31113
|
-
console.debug(_this._logPrefix + "Receiving new user events count", count);
|
|
31114
|
-
_this.markForCheck();
|
|
31115
|
-
});
|
|
31116
|
-
return [2 /*return*/];
|
|
31117
|
-
}
|
|
31118
|
-
});
|
|
31119
|
-
});
|
|
31120
|
-
};
|
|
31121
|
-
UserEventNotificationComponent.prototype.onLogout = function () {
|
|
31122
|
-
var _a;
|
|
31123
|
-
(_a = this._listenSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
31124
|
-
};
|
|
31125
|
-
UserEventNotificationComponent.prototype.markForCheck = function () {
|
|
31126
|
-
this.cd.markForCheck();
|
|
31127
31144
|
};
|
|
31128
31145
|
return UserEventNotificationComponent;
|
|
31129
31146
|
}());
|
|
@@ -31138,8 +31155,7 @@
|
|
|
31138
31155
|
UserEventNotificationComponent.ctorParameters = function () { return [
|
|
31139
31156
|
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [UserEventServiceToken,] }] },
|
|
31140
31157
|
{ type: AccountService },
|
|
31141
|
-
{ type: i1$5.PopoverController }
|
|
31142
|
-
{ type: i0.ChangeDetectorRef }
|
|
31158
|
+
{ type: i1$5.PopoverController }
|
|
31143
31159
|
]; };
|
|
31144
31160
|
UserEventNotificationComponent.propDecorators = {
|
|
31145
31161
|
debug: [{ type: i0.Input }],
|
|
@@ -31157,7 +31173,6 @@
|
|
|
31157
31173
|
_this.translate = translate;
|
|
31158
31174
|
_this.environment = environment;
|
|
31159
31175
|
_this.userEvents = [];
|
|
31160
|
-
_this.count$ = new rxjs.BehaviorSubject(0);
|
|
31161
31176
|
return _this;
|
|
31162
31177
|
}
|
|
31163
31178
|
UserEventTestService.prototype.fromObject = function (source) {
|
|
@@ -31167,15 +31182,8 @@
|
|
|
31167
31182
|
entity = this.processUserEvent(entity);
|
|
31168
31183
|
entity.id = this.userEvents.length + 1;
|
|
31169
31184
|
this.userEvents.push(entity);
|
|
31170
|
-
this.
|
|
31185
|
+
this._count$.next(this.userEvents.length);
|
|
31171
31186
|
};
|
|
31172
|
-
Object.defineProperty(UserEventTestService.prototype, "userEventCount", {
|
|
31173
|
-
get: function () {
|
|
31174
|
-
return this.count$.asObservable();
|
|
31175
|
-
},
|
|
31176
|
-
enumerable: false,
|
|
31177
|
-
configurable: true
|
|
31178
|
-
});
|
|
31179
31187
|
UserEventTestService.prototype.asFilter = function (filter) {
|
|
31180
31188
|
return filter;
|
|
31181
31189
|
};
|