@sumaris-net/ngx-components 1.21.0-beta15 → 1.21.0-beta18
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 +74 -61
- 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 +4 -32
- package/esm2015/src/app/social/user-event/user-event.service.js +46 -12
- package/fesm2015/sumaris-net.ngx-components.js +45 -38
- 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 -6
- package/src/app/social/user-event/user-event.service.d.ts +4 -0
- 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
|
};
|
|
@@ -30523,6 +30548,33 @@
|
|
|
30523
30548
|
this.listeners.push(listener);
|
|
30524
30549
|
};
|
|
30525
30550
|
/* -- protected methods -- */
|
|
30551
|
+
AbstractUserEventService.prototype.onLogin = function () {
|
|
30552
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
30553
|
+
var count;
|
|
30554
|
+
var _this = this;
|
|
30555
|
+
return __generator(this, function (_b) {
|
|
30556
|
+
switch (_b.label) {
|
|
30557
|
+
case 0: return [4 /*yield*/, this.count(undefined)];
|
|
30558
|
+
case 1:
|
|
30559
|
+
count = _b.sent();
|
|
30560
|
+
if (this._debug)
|
|
30561
|
+
console.debug(this._logPrefix + "Receiving user events count", count);
|
|
30562
|
+
// Update count
|
|
30563
|
+
this._count$.next(count);
|
|
30564
|
+
// Then listen changes
|
|
30565
|
+
this._listenSubscription = this.listenCountChanges(undefined).subscribe(function (count) {
|
|
30566
|
+
if (_this._debug)
|
|
30567
|
+
console.debug(_this._logPrefix + "Receiving new user events count", count);
|
|
30568
|
+
});
|
|
30569
|
+
return [2 /*return*/];
|
|
30570
|
+
}
|
|
30571
|
+
});
|
|
30572
|
+
});
|
|
30573
|
+
};
|
|
30574
|
+
AbstractUserEventService.prototype.onLogout = function () {
|
|
30575
|
+
var _a;
|
|
30576
|
+
(_a = this._listenSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
30577
|
+
};
|
|
30526
30578
|
AbstractUserEventService.prototype.processUserEvent = function (source, that) {
|
|
30527
30579
|
var e_2, _b;
|
|
30528
30580
|
that = that || this;
|
|
@@ -31015,15 +31067,13 @@
|
|
|
31015
31067
|
};
|
|
31016
31068
|
|
|
31017
31069
|
var UserEventNotificationComponent = /** @class */ (function () {
|
|
31018
|
-
function UserEventNotificationComponent(userEventService, accountService, popoverController
|
|
31070
|
+
function UserEventNotificationComponent(userEventService, accountService, popoverController) {
|
|
31019
31071
|
this.userEventService = userEventService;
|
|
31020
31072
|
this.accountService = accountService;
|
|
31021
31073
|
this.popoverController = popoverController;
|
|
31022
|
-
this.cd = cd;
|
|
31023
31074
|
this.debug = false;
|
|
31024
31075
|
this.titleI18n = 'SOCIAL.USER_EVENT.NOTIFICATION.TITLE';
|
|
31025
31076
|
this.disabled = false;
|
|
31026
|
-
this._subscriptions = new rxjs.Subscription();
|
|
31027
31077
|
this._logPrefix = '[user-event-notification] ';
|
|
31028
31078
|
this._readEvent = new i0.EventEmitter();
|
|
31029
31079
|
}
|
|
@@ -31039,49 +31089,17 @@
|
|
|
31039
31089
|
return __awaiter(this, void 0, void 0, function () {
|
|
31040
31090
|
var _this = this;
|
|
31041
31091
|
return __generator(this, function (_b) {
|
|
31042
|
-
|
|
31043
|
-
|
|
31044
|
-
|
|
31045
|
-
|
|
31046
|
-
this.disabled = true;
|
|
31047
|
-
return [2 /*return*/];
|
|
31048
|
-
}
|
|
31049
|
-
return [4 /*yield*/, this.accountService.ready()];
|
|
31050
|
-
case 1:
|
|
31051
|
-
_b.sent();
|
|
31052
|
-
// listen login/logout
|
|
31053
|
-
this._loginSubscription = this.accountService.onLogin.subscribe(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
31054
|
-
var count;
|
|
31055
|
-
var _this = this;
|
|
31056
|
-
return __generator(this, function (_b) {
|
|
31057
|
-
switch (_b.label) {
|
|
31058
|
-
case 0: return [4 /*yield*/, this.userEventService.count(undefined)];
|
|
31059
|
-
case 1:
|
|
31060
|
-
count = _b.sent();
|
|
31061
|
-
if (this.debug)
|
|
31062
|
-
console.debug(this._logPrefix + "Receiving user events count", count);
|
|
31063
|
-
this.markForCheck();
|
|
31064
|
-
// Then listen changes
|
|
31065
|
-
return [2 /*return*/, this.userEventService.listenCountChanges(undefined).subscribe(function (count) {
|
|
31066
|
-
if (_this.debug)
|
|
31067
|
-
console.debug(_this._logPrefix + "Receiving new user events count", count);
|
|
31068
|
-
_this.markForCheck();
|
|
31069
|
-
})];
|
|
31070
|
-
}
|
|
31071
|
-
});
|
|
31072
|
-
}); });
|
|
31073
|
-
this._subscriptions.add(this._loginSubscription);
|
|
31074
|
-
this._subscriptions.add(this.accountService.onLogout.subscribe(function () {
|
|
31075
|
-
if (_this._loginSubscription)
|
|
31076
|
-
_this._subscriptions.remove(_this._loginSubscription);
|
|
31077
|
-
}));
|
|
31078
|
-
// Subscribe to read event
|
|
31079
|
-
this._readEvent.subscribe(function (value) {
|
|
31080
|
-
// default: mark event as read
|
|
31081
|
-
_this.userEventService.markAsRead(value);
|
|
31082
|
-
});
|
|
31083
|
-
return [2 /*return*/];
|
|
31092
|
+
if (isNil(this.userEventService)) {
|
|
31093
|
+
console.warn(this._logPrefix + "No service injected");
|
|
31094
|
+
this.disabled = true;
|
|
31095
|
+
return [2 /*return*/];
|
|
31084
31096
|
}
|
|
31097
|
+
// Subscribe to read event
|
|
31098
|
+
this._readEvent.subscribe(function (value) {
|
|
31099
|
+
// default: mark event as read
|
|
31100
|
+
_this.userEventService.markAsRead(value);
|
|
31101
|
+
});
|
|
31102
|
+
return [2 /*return*/];
|
|
31085
31103
|
});
|
|
31086
31104
|
});
|
|
31087
31105
|
};
|
|
@@ -31113,14 +31131,10 @@
|
|
|
31113
31131
|
});
|
|
31114
31132
|
});
|
|
31115
31133
|
};
|
|
31116
|
-
UserEventNotificationComponent.prototype.markForCheck = function () {
|
|
31117
|
-
this.cd.markForCheck();
|
|
31118
|
-
};
|
|
31119
31134
|
UserEventNotificationComponent.prototype.ngOnDestroy = function () {
|
|
31120
31135
|
if (this.debug) {
|
|
31121
31136
|
console.debug(this._logPrefix + "Destroying");
|
|
31122
31137
|
}
|
|
31123
|
-
this._subscriptions.unsubscribe();
|
|
31124
31138
|
};
|
|
31125
31139
|
return UserEventNotificationComponent;
|
|
31126
31140
|
}());
|
|
@@ -31135,8 +31149,7 @@
|
|
|
31135
31149
|
UserEventNotificationComponent.ctorParameters = function () { return [
|
|
31136
31150
|
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [UserEventServiceToken,] }] },
|
|
31137
31151
|
{ type: AccountService },
|
|
31138
|
-
{ type: i1$5.PopoverController }
|
|
31139
|
-
{ type: i0.ChangeDetectorRef }
|
|
31152
|
+
{ type: i1$5.PopoverController }
|
|
31140
31153
|
]; };
|
|
31141
31154
|
UserEventNotificationComponent.propDecorators = {
|
|
31142
31155
|
debug: [{ type: i0.Input }],
|