@sumaris-net/ngx-components 1.21.0-beta25 → 1.21.0-beta28
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 +31 -63
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/esm2015/src/app/shared/pipes/date-diff-duration.pipe.js +8 -4
- package/esm2015/src/app/social/user-event/notification/user-event-notification.list.js +2 -2
- package/esm2015/src/app/social/user-event/user-event.service.js +23 -51
- package/fesm2015/sumaris-net.ngx-components.js +30 -53
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/shared/pipes/date-diff-duration.pipe.d.ts +6 -2
- package/src/app/social/user-event/user-event.service.d.ts +1 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -2328,17 +2328,21 @@
|
|
|
2328
2328
|
return '';
|
|
2329
2329
|
var startDate = this.dateAdapter.parse(value.startValue, DATE_ISO_PATTERN);
|
|
2330
2330
|
var endDate = this.dateAdapter.parse(value.endValue, DATE_ISO_PATTERN);
|
|
2331
|
-
return this.format(startDate, endDate);
|
|
2331
|
+
return this.format(startDate, endDate, args);
|
|
2332
2332
|
};
|
|
2333
|
-
DateDiffDurationPipe.prototype.format = function (startDate, endDate) {
|
|
2333
|
+
DateDiffDurationPipe.prototype.format = function (startDate, endDate, args) {
|
|
2334
2334
|
var duration = moment.duration(endDate.diff(startDate));
|
|
2335
2335
|
if (duration.asMinutes() < 0)
|
|
2336
2336
|
return '';
|
|
2337
|
+
var withSeconds = args === null || args === void 0 ? void 0 : args.seconds;
|
|
2337
2338
|
var timeDuration = moment(0)
|
|
2338
2339
|
.hour(duration.hours())
|
|
2339
2340
|
.minute(duration.minutes());
|
|
2341
|
+
if (withSeconds) {
|
|
2342
|
+
timeDuration.second(duration.seconds());
|
|
2343
|
+
}
|
|
2340
2344
|
var days = Math.floor(duration.asDays());
|
|
2341
|
-
return (days > 0 ? days.toString() + (this.dayUnit + ' ') : '') + timeDuration.format('HH:mm');
|
|
2345
|
+
return (days > 0 ? days.toString() + (this.dayUnit + ' ') : '') + timeDuration.format(withSeconds ? 'HH:mm:ss' : 'HH:mm');
|
|
2342
2346
|
};
|
|
2343
2347
|
return DateDiffDurationPipe;
|
|
2344
2348
|
}());
|
|
@@ -30448,19 +30452,11 @@
|
|
|
30448
30452
|
};
|
|
30449
30453
|
AbstractUserEventService.prototype.save = function (entity, options) {
|
|
30450
30454
|
return __awaiter(this, void 0, void 0, function () {
|
|
30451
|
-
var
|
|
30455
|
+
var withContent, json, now;
|
|
30452
30456
|
var _this = this;
|
|
30453
30457
|
return __generator(this, function (_b) {
|
|
30454
30458
|
switch (_b.label) {
|
|
30455
30459
|
case 0:
|
|
30456
|
-
if (!!this.mutations.save) return [3 /*break*/, 2];
|
|
30457
|
-
if (!this.mutations.saveAll)
|
|
30458
|
-
throw new Error('Not implemented');
|
|
30459
|
-
return [4 /*yield*/, this.saveAll([entity], options)];
|
|
30460
|
-
case 1:
|
|
30461
|
-
allData = _b.sent();
|
|
30462
|
-
return [2 /*return*/, allData === null || allData === void 0 ? void 0 : allData[0]];
|
|
30463
|
-
case 2:
|
|
30464
30460
|
this.fillDefaultProperties(entity);
|
|
30465
30461
|
withContent = !!entity.content;
|
|
30466
30462
|
json = entity.asObject();
|
|
@@ -30497,7 +30493,7 @@
|
|
|
30497
30493
|
}
|
|
30498
30494
|
}
|
|
30499
30495
|
})];
|
|
30500
|
-
case
|
|
30496
|
+
case 1:
|
|
30501
30497
|
_b.sent();
|
|
30502
30498
|
return [2 /*return*/, entity];
|
|
30503
30499
|
}
|
|
@@ -30506,55 +30502,10 @@
|
|
|
30506
30502
|
};
|
|
30507
30503
|
AbstractUserEventService.prototype.saveAll = function (entities, opts) {
|
|
30508
30504
|
return __awaiter(this, void 0, void 0, function () {
|
|
30509
|
-
var json, now;
|
|
30510
30505
|
var _this = this;
|
|
30511
30506
|
return __generator(this, function (_b) {
|
|
30512
|
-
|
|
30513
|
-
|
|
30514
|
-
if (isEmptyArray(entities))
|
|
30515
|
-
return [2 /*return*/, entities];
|
|
30516
|
-
if (!this.mutations.saveAll) {
|
|
30517
|
-
if (!this.mutations.save)
|
|
30518
|
-
throw new Error('Not implemented');
|
|
30519
|
-
// Save one by one
|
|
30520
|
-
return [2 /*return*/, chainPromises(entities.map(function (entity) { return function () { return _this.save(entity, opts); }; }))];
|
|
30521
|
-
}
|
|
30522
|
-
json = entities.map(function (entity) {
|
|
30523
|
-
_this.fillDefaultProperties(entity);
|
|
30524
|
-
return entity.asObject();
|
|
30525
|
-
});
|
|
30526
|
-
now = Date.now();
|
|
30527
|
-
if (this._debug)
|
|
30528
|
-
console.debug(this._logPrefix + "Saving user events...", json);
|
|
30529
|
-
return [4 /*yield*/, this.graphql.mutate({
|
|
30530
|
-
mutation: this.mutations.saveAll,
|
|
30531
|
-
variables: {
|
|
30532
|
-
data: json
|
|
30533
|
-
},
|
|
30534
|
-
error: { code: SocialErrorCodes.SAVE_USER_EVENT_ERROR, message: 'SOCIAL.ERROR.SAVE_USER_EVENT_ERROR' },
|
|
30535
|
-
update: function (proxy, _b) {
|
|
30536
|
-
var data = _b.data;
|
|
30537
|
-
// Update entity
|
|
30538
|
-
var savedEntities = (data === null || data === void 0 ? void 0 : data.data) || [];
|
|
30539
|
-
if (savedEntities.length) {
|
|
30540
|
-
if (_this._debug)
|
|
30541
|
-
console.debug(_this._logPrefix + "User events saved in " + (Date.now() - now) + "ms", savedEntities);
|
|
30542
|
-
entities.forEach(function (entity) {
|
|
30543
|
-
var savedEntity = savedEntities.find(function (e) { return EntityUtils.equals(e, entity, 'id'); });
|
|
30544
|
-
_this.copyIdAndUpdateDate(savedEntity, entity);
|
|
30545
|
-
});
|
|
30546
|
-
// Add to cache (assuming all with content)
|
|
30547
|
-
_this.insertIntoMutableCachedQueries(proxy, {
|
|
30548
|
-
query: _this.queries.loadAllWithContent,
|
|
30549
|
-
data: savedEntities
|
|
30550
|
-
});
|
|
30551
|
-
}
|
|
30552
|
-
}
|
|
30553
|
-
})];
|
|
30554
|
-
case 1:
|
|
30555
|
-
_b.sent();
|
|
30556
|
-
return [2 /*return*/, entities];
|
|
30557
|
-
}
|
|
30507
|
+
return [2 /*return*/, Promise.all(entities
|
|
30508
|
+
.map(function (entity) { return _this.save(entity, opts); }))];
|
|
30558
30509
|
});
|
|
30559
30510
|
});
|
|
30560
30511
|
};
|
|
@@ -30720,8 +30671,9 @@
|
|
|
30720
30671
|
return target;
|
|
30721
30672
|
};
|
|
30722
30673
|
AbstractUserEventService.prototype.defaultMarkAsRead = function (userEvents) {
|
|
30674
|
+
var _a;
|
|
30723
30675
|
return __awaiter(this, void 0, void 0, function () {
|
|
30724
|
-
var localEntities, remoteEntities;
|
|
30676
|
+
var localEntities, remoteEntities, ids, now;
|
|
30725
30677
|
return __generator(this, function (_b) {
|
|
30726
30678
|
switch (_b.label) {
|
|
30727
30679
|
case 0:
|
|
@@ -30740,9 +30692,25 @@
|
|
|
30740
30692
|
// TODO !!!!!!!!!!!!!
|
|
30741
30693
|
}
|
|
30742
30694
|
if (!remoteEntities.length) return [3 /*break*/, 2];
|
|
30743
|
-
|
|
30695
|
+
if (!((_a = this.mutations) === null || _a === void 0 ? void 0 : _a.markAsRead)) {
|
|
30696
|
+
console.warn(this._logPrefix + "Mutation query 'markAsRead' not provided, skip.");
|
|
30697
|
+
return [2 /*return*/];
|
|
30698
|
+
}
|
|
30699
|
+
ids = remoteEntities.map(function (value) { return value.id; });
|
|
30700
|
+
now = Date.now();
|
|
30701
|
+
if (this._debug)
|
|
30702
|
+
console.debug(this._logPrefix + "Mark user events as read...", ids);
|
|
30703
|
+
return [4 /*yield*/, this.graphql.mutate({
|
|
30704
|
+
mutation: this.mutations.markAsRead,
|
|
30705
|
+
variables: {
|
|
30706
|
+
ids: ids
|
|
30707
|
+
},
|
|
30708
|
+
error: { code: SocialErrorCodes.SAVE_USER_EVENT_ERROR, message: 'SOCIAL.ERROR.SAVE_USER_EVENT_ERROR' },
|
|
30709
|
+
})];
|
|
30744
30710
|
case 1:
|
|
30745
30711
|
_b.sent();
|
|
30712
|
+
if (this._debug)
|
|
30713
|
+
console.debug(this._logPrefix + "User events marked as read in " + (Date.now() - now) + "ms", ids);
|
|
30746
30714
|
_b.label = 2;
|
|
30747
30715
|
case 2: return [2 /*return*/];
|
|
30748
30716
|
}
|
|
@@ -31180,7 +31148,7 @@
|
|
|
31180
31148
|
UserEventNotificationList.decorators = [
|
|
31181
31149
|
{ type: i0.Component, args: [{
|
|
31182
31150
|
selector: 'app-user-event-notification-list',
|
|
31183
|
-
template: "\n<ion-list class=\"ion-list-popover\">\n\n <ion-row class=\"ion-list-header column\">\n <ion-col>\n <ion-label>{{titleI18n | translate}}</ion-label>\n </ion-col>\n </ion-row>\n\n <ion-item *ngIf=\"!(userEvents | async)?.length\">\n {{'SOCIAL.USER_EVENT.NOTIFICATION.EMPTY' | translate}}\n </ion-item>\n <ion-item\n *ngFor=\"let userEvent of userEvents | async\"\n (click)=\"read($event, userEvent)\"\n >\n\n <ion-avatar slot=\"start\">\n\n <img *ngIf=\"userEvent.avatar; else avatarIcon\" src=\"{{ userEvent.avatar }}\">\n\n <ng-template #avatarIcon>\n <app-icon\n *ngIf=\"userEvent.avatarIcon\"\n [ref]=\"userEvent.avatarIcon\"\n height=\"40\"\n width=\"40\"\n ></app-icon>\n </ng-template>\n\n </ion-avatar>\n\n <ion-grid class=\"ion-no-margin ion-no-padding\">\n <ion-row>\n <ion-col>\n <p [class.unread]=\"!userEvent.readDate\"
|
|
31151
|
+
template: "\n<ion-list class=\"ion-list-popover\">\n\n <ion-row class=\"ion-list-header column\">\n <ion-col>\n <ion-label>{{titleI18n | translate}}</ion-label>\n </ion-col>\n </ion-row>\n\n <ion-item *ngIf=\"!(userEvents | async)?.length\">\n {{'SOCIAL.USER_EVENT.NOTIFICATION.EMPTY' | translate}}\n </ion-item>\n <ion-item\n *ngFor=\"let userEvent of userEvents | async\"\n (click)=\"read($event, userEvent)\"\n >\n\n <ion-avatar slot=\"start\">\n\n <img *ngIf=\"userEvent.avatar; else avatarIcon\" src=\"{{ userEvent.avatar }}\">\n\n <ng-template #avatarIcon>\n <app-icon\n *ngIf=\"userEvent.avatarIcon\"\n [ref]=\"userEvent.avatarIcon\"\n height=\"40\"\n width=\"40\"\n ></app-icon>\n </ng-template>\n\n </ion-avatar>\n\n <ion-grid class=\"ion-no-margin ion-no-padding\">\n <ion-row>\n <ion-col>\n <p [class.unread]=\"!userEvent.readDate\" [innerHTML]=\"userEvent.message\"></p>\n </ion-col>\n </ion-row>\n <ion-row *ngIf=\"userEvent.actions?.length\">\n <ion-col>\n <span *ngFor=\"let action of userEvent.actions\">\n <a\n [style.margin-right.px]=\"10\"\n [style.cursor]=\"'pointer'\"\n (click)=\"executeAction(action, userEvent)\"\n >\n <app-icon *ngIf=\"action.iconRef\" slot=\"start\" [ref]=\"action.iconRef\" style=\"vertical-align: middle\"></app-icon>\n {{ action.name }}\n </a>\n </span>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col>\n <app-icon\n *ngIf=\"userEvent.icon\"\n [ref]=\"userEvent.icon\"\n height=\"16\"\n width=\"16\"\n style=\"vertical-align: sub; margin-right: 3px\"\n ></app-icon>\n <small>\n <span>{{userEvent.creationDate|dateFromNow}}</span>\n <span [style.color]=\"'gray'\">{{ ' | ' + (userEvent.creationDate|dateFormat:{time:true}) }}</span>\n </small>\n </ion-col>\n </ion-row>\n </ion-grid>\n </ion-item>\n\n <ion-row class=\"ion-list-footer column\">\n <ion-col>\n <a style=\"cursor: pointer\" (click)=\"readAll($event)\">{{'SOCIAL.USER_EVENT.NOTIFICATION.READ_ALL' | translate}}</a>\n </ion-col>\n </ion-row>\n\n</ion-list>\n",
|
|
31184
31152
|
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
31185
31153
|
styles: [":host(.popover-viewport){overflow-y:auto;-webkit-user-select:none;-moz-user-select:none;user-select:none}.unread{font-weight:700}"]
|
|
31186
31154
|
},] }
|