@c8y/ngx-components 1016.0.379 → 1016.0.383
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/NOTICES +1 -1
- package/core/range-display/range-display.component.d.ts +19 -1
- package/core/realtime/realtime-subject.service.d.ts +4 -0
- package/core/realtime/realtime.service.d.ts +10 -0
- package/device-protocols/device-protocols.factory.d.ts +14 -0
- package/device-protocols/device-protocols.guard.d.ts +12 -0
- package/device-protocols/device-protocols.module.d.ts +8 -0
- package/device-protocols/device-type-detail-edited.service.d.ts +8 -0
- package/device-protocols/device-type-detail.component.d.ts +12 -0
- package/device-protocols/device-type-detail.directive.d.ts +9 -0
- package/device-protocols/index.d.ts +6 -0
- package/esm2020/core/range-display/range-display.component.mjs +87 -4
- package/esm2020/core/realtime/realtime-subject.service.mjs +47 -4
- package/esm2020/core/realtime/realtime.service.mjs +15 -1
- package/esm2020/device-protocols/c8y-ngx-components-device-protocols.mjs +5 -0
- package/esm2020/device-protocols/device-protocols.factory.mjs +31 -0
- package/esm2020/device-protocols/device-protocols.guard.mjs +40 -0
- package/esm2020/device-protocols/device-protocols.module.mjs +38 -0
- package/esm2020/device-protocols/device-type-detail-edited.service.mjs +19 -0
- package/esm2020/device-protocols/device-type-detail.component.mjs +45 -0
- package/esm2020/device-protocols/device-type-detail.directive.mjs +19 -0
- package/esm2020/device-protocols/index.mjs +7 -0
- package/esm2020/ecosystem/application-properties/subscription-modal/subscription-modal.component.mjs +4 -1
- package/esm2020/upgrade/ng1/downgraded.services.mjs +6 -4
- package/esm2020/upgrade/ng1/index.mjs +6 -5
- package/esm2020/upgrade/upgrade.module.mjs +10 -10
- package/fesm2015/c8y-ngx-components-device-protocols.mjs +180 -0
- package/fesm2015/c8y-ngx-components-device-protocols.mjs.map +1 -0
- package/fesm2015/c8y-ngx-components-ecosystem.mjs +3 -0
- package/fesm2015/c8y-ngx-components-ecosystem.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components-upgrade.mjs +91 -88
- package/fesm2015/c8y-ngx-components-upgrade.mjs.map +1 -1
- package/fesm2015/c8y-ngx-components.mjs +144 -4
- package/fesm2015/c8y-ngx-components.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-device-protocols.mjs +177 -0
- package/fesm2020/c8y-ngx-components-device-protocols.mjs.map +1 -0
- package/fesm2020/c8y-ngx-components-ecosystem.mjs +3 -0
- package/fesm2020/c8y-ngx-components-ecosystem.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components-upgrade.mjs +90 -87
- package/fesm2020/c8y-ngx-components-upgrade.mjs.map +1 -1
- package/fesm2020/c8y-ngx-components.mjs +142 -4
- package/fesm2020/c8y-ngx-components.mjs.map +1 -1
- package/locales/locales.pot +1 -1
- package/package.json +10 -2
- package/upgrade/ng1/downgraded.services.d.ts +1 -0
|
@@ -24339,6 +24339,13 @@ class RangeDisplayComponent {
|
|
|
24339
24339
|
this.sanitizer = sanitizer;
|
|
24340
24340
|
this.config = {};
|
|
24341
24341
|
this.display = 'full';
|
|
24342
|
+
this.currentRangeWidthChanged = new Subject();
|
|
24343
|
+
// width of current range is changing within 150ms, see style declaration for .range-display__range__current
|
|
24344
|
+
this.CURRENT_RANGE_WIDTH_TRANSITION_TIME = 150;
|
|
24345
|
+
this.DEFAULT_TOOLTIP_SHIFT = '50%';
|
|
24346
|
+
this.MIN_TOOLTIP_SHIFT = 10;
|
|
24347
|
+
this.tooltipShift = this.DEFAULT_TOOLTIP_SHIFT;
|
|
24348
|
+
this.destroyed$ = new Subject();
|
|
24342
24349
|
}
|
|
24343
24350
|
get inlineStyle() {
|
|
24344
24351
|
this.config = this.config || {};
|
|
@@ -24354,6 +24361,8 @@ class RangeDisplayComponent {
|
|
|
24354
24361
|
return this.sanitizer.bypassSecurityTrustStyle(`
|
|
24355
24362
|
--range-min: ${this.config.min};
|
|
24356
24363
|
--range-max: ${this.config.max};
|
|
24364
|
+
--range-display-tooltip-translate: translate(${this.tooltipShift}, -56px);
|
|
24365
|
+
--range-display-tooltip-bg: ${this.getTooltipBackground()};
|
|
24357
24366
|
--full-range: ${this.config.max - this.config.min};
|
|
24358
24367
|
--measurement-target: ${((this.config.target - this.config.min) * 100) / (this.config.max - this.config.min)}%;
|
|
24359
24368
|
--measurement-current: ${((this.config.current - this.config.min) * 100) / (this.config.max - this.config.min)}%;
|
|
@@ -24367,6 +24376,21 @@ class RangeDisplayComponent {
|
|
|
24367
24376
|
100}%;
|
|
24368
24377
|
`);
|
|
24369
24378
|
}
|
|
24379
|
+
ngOnChanges() {
|
|
24380
|
+
// It's necessary to handle tooltip shifting both in OnChanges and AfterViewInit. In case of Linear gauge widget, view is
|
|
24381
|
+
// rendered first (so as elements needed for calculating shifting) and config orientation is set later on.
|
|
24382
|
+
// In other cases it's possible that orientation is defined on initialization of class and view elements are rendered later.
|
|
24383
|
+
this.setupTooltipShiftingIfPossible();
|
|
24384
|
+
}
|
|
24385
|
+
ngAfterViewInit() {
|
|
24386
|
+
this.setupTooltipShiftingIfPossible();
|
|
24387
|
+
}
|
|
24388
|
+
ngOnDestroy() {
|
|
24389
|
+
var _a;
|
|
24390
|
+
(_a = this.currentRangeWidthObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
24391
|
+
this.destroyed$.next();
|
|
24392
|
+
this.destroyed$.complete();
|
|
24393
|
+
}
|
|
24370
24394
|
checkTarget() {
|
|
24371
24395
|
return (this.config.target !== undefined &&
|
|
24372
24396
|
this.config.target !== null &&
|
|
@@ -24394,12 +24418,65 @@ class RangeDisplayComponent {
|
|
|
24394
24418
|
isRangeDisplayed(rangeMin, rangeMax) {
|
|
24395
24419
|
return rangeMin === 0 || rangeMax === 0 || (rangeMin && rangeMax);
|
|
24396
24420
|
}
|
|
24421
|
+
setupTooltipShifting() {
|
|
24422
|
+
this.currentRangeWidthObserver = new ResizeObserver(([val]) => {
|
|
24423
|
+
if (getComputedStyle(val.target, null).display === 'block') {
|
|
24424
|
+
this.currentRangeWidthChanged.next(val.target);
|
|
24425
|
+
}
|
|
24426
|
+
});
|
|
24427
|
+
this.currentRangeWidthObserver.observe(this.currentRangeElement.nativeElement);
|
|
24428
|
+
this.currentRangeWidthChanged
|
|
24429
|
+
.pipe(debounceTime(this.CURRENT_RANGE_WIDTH_TRANSITION_TIME), map((rangeElement) => parseInt(getComputedStyle(rangeElement, null).width)), distinctUntilChanged(), takeUntil(this.destroyed$))
|
|
24430
|
+
.subscribe(rangeElementWidth => {
|
|
24431
|
+
this.setTooltipShiftValue(rangeElementWidth);
|
|
24432
|
+
});
|
|
24433
|
+
}
|
|
24434
|
+
setTooltipShiftValue(rangeElementWidth) {
|
|
24435
|
+
const tooltipWidth = parseInt(getComputedStyle(this.currentRangeElement.nativeElement, ':after').width);
|
|
24436
|
+
const currentRangeWidth = rangeElementWidth;
|
|
24437
|
+
const rangeDisplayWidth = parseInt(getComputedStyle(this.rangeDisplay.nativeElement, null).getPropertyValue('width'));
|
|
24438
|
+
const rangeDisplayPaddingLeft = parseInt(getComputedStyle(this.rangeDisplay.nativeElement, null).getPropertyValue('padding-left'));
|
|
24439
|
+
const tooltipOverflowsLeftEdge = tooltipWidth / 2 > rangeDisplayPaddingLeft + currentRangeWidth;
|
|
24440
|
+
const tooltipOverflowsRightEdge = tooltipWidth / 2 > rangeDisplayWidth - rangeDisplayPaddingLeft - currentRangeWidth;
|
|
24441
|
+
if (tooltipOverflowsLeftEdge) {
|
|
24442
|
+
this.tooltipShift = `${tooltipWidth - this.MIN_TOOLTIP_SHIFT}px`;
|
|
24443
|
+
}
|
|
24444
|
+
else if (tooltipOverflowsRightEdge) {
|
|
24445
|
+
this.tooltipShift = `${this.MIN_TOOLTIP_SHIFT}px`;
|
|
24446
|
+
}
|
|
24447
|
+
else {
|
|
24448
|
+
this.tooltipShift = this.DEFAULT_TOOLTIP_SHIFT;
|
|
24449
|
+
}
|
|
24450
|
+
}
|
|
24451
|
+
setupTooltipShiftingIfPossible() {
|
|
24452
|
+
var _a;
|
|
24453
|
+
if (((_a = this.config) === null || _a === void 0 ? void 0 : _a.orientation) === 'horizontal' &&
|
|
24454
|
+
!this.currentRangeWidthObserver &&
|
|
24455
|
+
this.rangeDisplay &&
|
|
24456
|
+
this.currentRangeElement) {
|
|
24457
|
+
this.setupTooltipShifting();
|
|
24458
|
+
}
|
|
24459
|
+
}
|
|
24460
|
+
getTooltipBackground() {
|
|
24461
|
+
const current = this.config.current;
|
|
24462
|
+
switch (true) {
|
|
24463
|
+
case this.isValueInRange(current, this.config.redRangeMin, this.config.redRangeMax):
|
|
24464
|
+
return 'var(--input-validation-error, #E0000E)';
|
|
24465
|
+
case this.isValueInRange(current, this.config.yellowRangeMin, this.config.yellowRangeMax):
|
|
24466
|
+
return 'var(--input-validation-warning, #FF801F)';
|
|
24467
|
+
default:
|
|
24468
|
+
return 'var(--gray-3, #394852)';
|
|
24469
|
+
}
|
|
24470
|
+
}
|
|
24471
|
+
isValueInRange(value, min, max) {
|
|
24472
|
+
return min != null && max != null && value >= min && value <= max;
|
|
24473
|
+
}
|
|
24397
24474
|
}
|
|
24398
24475
|
RangeDisplayComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: RangeDisplayComponent, deps: [{ token: i2$5.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component });
|
|
24399
|
-
RangeDisplayComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.6", type: RangeDisplayComponent, selector: "c8y-range-display", inputs: { config: "config", display: "display" }, host: { properties: { "attr.style": "this.inlineStyle" } }, ngImport: i0, template: "<div
|
|
24476
|
+
RangeDisplayComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.6", type: RangeDisplayComponent, selector: "c8y-range-display", inputs: { config: "config", display: "display" }, host: { properties: { "attr.style": "this.inlineStyle" } }, viewQueries: [{ propertyName: "rangeDisplay", first: true, predicate: ["rangeDisplay"], descendants: true }, { propertyName: "currentRangeElement", first: true, predicate: ["currentRangeElement"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div\n [ngClass]=\"{\n 'range-display--vertical': config.orientation === 'vertical',\n 'range-display--compact': display === 'compact',\n 'range-display--inline': display === 'inline'\n }\"\n attr.data-label=\"{{ config.unit }}\"\n>\n <div\n class=\"range-display\"\n #rangeDisplay\n >\n <div class=\"range-display__range\">\n <div class=\"range-display__range__unit\">\n {{ config.unit }}\n </div>\n <div\n *ngIf=\"isYellowRangeDisplayed()\"\n class=\"range-display__range__min\"\n ></div>\n <div\n *ngIf=\"isRedRangeDisplayed()\"\n class=\"range-display__range__max\"\n ></div>\n <div\n *ngIf=\"checkTarget()\"\n class=\"range-display__range__target\"\n attr.data-label=\"{{ config.target }} {{ config.unit }}\"\n title=\"{{ 'Target' | translate }}: {{ config.target }} {{ config.unit }}\"\n ></div>\n <div\n [ngStyle]=\"{\n display:\n config.current != undefined &&\n config.current >= config.min &&\n config.current <= config.max\n ? 'block'\n : 'none'\n }\"\n #currentRangeElement\n class=\"range-display__range__current\"\n attr.data-label=\"{{ config.current }} {{ config.unit }} 
{{ config.time | c8yDate }}\"\n title=\"{{ 'Current' | translate }}: {{ config.current }} {{ config.unit }} | {{\n config.time | c8yDate\n }}\"\n ></div>\n </div>\n <div class=\"range-display__ruler\">\n <div\n *ngFor=\"let x of [].constructor(10); let index = index; trackBy: trackByIndex\"\n attr.data-label=\"{{ rulerCalc(index) }}\"\n class=\"range-display__tick\"\n ></div>\n <div\n attr.data-label=\"{{ config.max || 100 | number }}\"\n class=\"range-display__tick\"\n ></div>\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: i2$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: i2$1.DecimalPipe, name: "number" }, { kind: "pipe", type: DatePipe, name: "c8yDate" }] });
|
|
24400
24477
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: RangeDisplayComponent, decorators: [{
|
|
24401
24478
|
type: Component,
|
|
24402
|
-
args: [{ selector: 'c8y-range-display', template: "<div
|
|
24479
|
+
args: [{ selector: 'c8y-range-display', template: "<div\n [ngClass]=\"{\n 'range-display--vertical': config.orientation === 'vertical',\n 'range-display--compact': display === 'compact',\n 'range-display--inline': display === 'inline'\n }\"\n attr.data-label=\"{{ config.unit }}\"\n>\n <div\n class=\"range-display\"\n #rangeDisplay\n >\n <div class=\"range-display__range\">\n <div class=\"range-display__range__unit\">\n {{ config.unit }}\n </div>\n <div\n *ngIf=\"isYellowRangeDisplayed()\"\n class=\"range-display__range__min\"\n ></div>\n <div\n *ngIf=\"isRedRangeDisplayed()\"\n class=\"range-display__range__max\"\n ></div>\n <div\n *ngIf=\"checkTarget()\"\n class=\"range-display__range__target\"\n attr.data-label=\"{{ config.target }} {{ config.unit }}\"\n title=\"{{ 'Target' | translate }}: {{ config.target }} {{ config.unit }}\"\n ></div>\n <div\n [ngStyle]=\"{\n display:\n config.current != undefined &&\n config.current >= config.min &&\n config.current <= config.max\n ? 'block'\n : 'none'\n }\"\n #currentRangeElement\n class=\"range-display__range__current\"\n attr.data-label=\"{{ config.current }} {{ config.unit }} 
{{ config.time | c8yDate }}\"\n title=\"{{ 'Current' | translate }}: {{ config.current }} {{ config.unit }} | {{\n config.time | c8yDate\n }}\"\n ></div>\n </div>\n <div class=\"range-display__ruler\">\n <div\n *ngFor=\"let x of [].constructor(10); let index = index; trackBy: trackByIndex\"\n attr.data-label=\"{{ rulerCalc(index) }}\"\n class=\"range-display__tick\"\n ></div>\n <div\n attr.data-label=\"{{ config.max || 100 | number }}\"\n class=\"range-display__tick\"\n ></div>\n </div>\n </div>\n</div>\n" }]
|
|
24403
24480
|
}], ctorParameters: function () { return [{ type: i2$5.DomSanitizer }]; }, propDecorators: { config: [{
|
|
24404
24481
|
type: Input
|
|
24405
24482
|
}], display: [{
|
|
@@ -24407,6 +24484,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.6", ngImpor
|
|
|
24407
24484
|
}], inlineStyle: [{
|
|
24408
24485
|
type: HostBinding,
|
|
24409
24486
|
args: ['attr.style']
|
|
24487
|
+
}], rangeDisplay: [{
|
|
24488
|
+
type: ViewChild,
|
|
24489
|
+
args: ['rangeDisplay', { static: false }]
|
|
24490
|
+
}], currentRangeElement: [{
|
|
24491
|
+
type: ViewChild,
|
|
24492
|
+
args: ['currentRangeElement', { static: false }]
|
|
24410
24493
|
}] } });
|
|
24411
24494
|
|
|
24412
24495
|
/**
|
|
@@ -25695,6 +25778,20 @@ class RealtimeService {
|
|
|
25695
25778
|
get active() {
|
|
25696
25779
|
return this.isActive.value;
|
|
25697
25780
|
}
|
|
25781
|
+
/**
|
|
25782
|
+
* An observable emitting a value in case the realtime connection has been interrupted.
|
|
25783
|
+
* Can be used to reload data of e.g. a datapoint graph that wasn't received while realtime was interrupted.
|
|
25784
|
+
*/
|
|
25785
|
+
get reconnect$() {
|
|
25786
|
+
return this.realtimeSubject.reconnect$;
|
|
25787
|
+
}
|
|
25788
|
+
/**
|
|
25789
|
+
* An observable emitting either `connected` or `disconnected` depending on the state of the realtime connection.
|
|
25790
|
+
* Can be used to e.g. inform the user about the interrupted realtime connection.
|
|
25791
|
+
*/
|
|
25792
|
+
get connectionStatus$() {
|
|
25793
|
+
return this.realtimeSubject.connectionStatus$;
|
|
25794
|
+
}
|
|
25698
25795
|
/**
|
|
25699
25796
|
* Get an Observable of all realtime notifications.
|
|
25700
25797
|
*
|
|
@@ -25774,6 +25871,8 @@ class RealtimeSubjectService {
|
|
|
25774
25871
|
constructor(realtime) {
|
|
25775
25872
|
this.realtime = realtime;
|
|
25776
25873
|
this.subjects$ = new Map();
|
|
25874
|
+
this.reconnect$ = this.createObservableForReconnect().pipe(share());
|
|
25875
|
+
this.connectionStatus$ = this.createObservableForConnectionStatus().pipe(distinctUntilChanged(), shareReplay({ refCount: true, bufferSize: 1 }));
|
|
25777
25876
|
}
|
|
25778
25877
|
getObservableForChannel(channel) {
|
|
25779
25878
|
if (this.subjects$.has(channel)) {
|
|
@@ -25786,7 +25885,7 @@ class RealtimeSubjectService {
|
|
|
25786
25885
|
}
|
|
25787
25886
|
createObservableForChannel(channel, realtime) {
|
|
25788
25887
|
return new Observable(observer => {
|
|
25789
|
-
|
|
25888
|
+
let realtimeSubscription = realtime.subscribe(channel, msg => {
|
|
25790
25889
|
const data = {
|
|
25791
25890
|
channel: msg.channel,
|
|
25792
25891
|
data: msg.data.data,
|
|
@@ -25795,13 +25894,54 @@ class RealtimeSubjectService {
|
|
|
25795
25894
|
};
|
|
25796
25895
|
observer.next(data);
|
|
25797
25896
|
});
|
|
25897
|
+
/**
|
|
25898
|
+
* In (rare) case of a re-handshake, resubscribe valid subscriptions.
|
|
25899
|
+
* @see https://docs.cometd.org/current/reference/#_javascript_subscribe_resubscribe
|
|
25900
|
+
*/
|
|
25901
|
+
const reconnectSubscription = this.reconnect$.subscribe(() => {
|
|
25902
|
+
try {
|
|
25903
|
+
realtimeSubscription = this.realtime.resubscribe(realtimeSubscription);
|
|
25904
|
+
}
|
|
25905
|
+
catch (e) {
|
|
25906
|
+
console.warn(`Failed to resubscribe to channel: "${channel}" after reconnect.`, e);
|
|
25907
|
+
observer.error(e);
|
|
25908
|
+
}
|
|
25909
|
+
});
|
|
25798
25910
|
return {
|
|
25799
|
-
unsubscribe() {
|
|
25911
|
+
unsubscribe: () => {
|
|
25912
|
+
reconnectSubscription.unsubscribe();
|
|
25800
25913
|
realtime.unsubscribe(realtimeSubscription);
|
|
25801
25914
|
}
|
|
25802
25915
|
};
|
|
25803
25916
|
});
|
|
25804
25917
|
}
|
|
25918
|
+
createObservableForReconnect() {
|
|
25919
|
+
return new Observable(observer => {
|
|
25920
|
+
const handle = this.realtime.addHandshakeListener(msg => {
|
|
25921
|
+
if (msg.successful && msg.reestablish) {
|
|
25922
|
+
observer.next();
|
|
25923
|
+
}
|
|
25924
|
+
});
|
|
25925
|
+
return {
|
|
25926
|
+
unsubscribe: () => {
|
|
25927
|
+
this.realtime.removeListener(handle);
|
|
25928
|
+
}
|
|
25929
|
+
};
|
|
25930
|
+
});
|
|
25931
|
+
}
|
|
25932
|
+
createObservableForConnectionStatus() {
|
|
25933
|
+
return new Observable(observer => {
|
|
25934
|
+
observer.next(!this.realtime.isDisconnected() ? 'connected' : 'disconnected');
|
|
25935
|
+
const handle = this.realtime.addConnectListener(msg => {
|
|
25936
|
+
observer.next(msg.successful ? 'connected' : 'disconnected');
|
|
25937
|
+
});
|
|
25938
|
+
return {
|
|
25939
|
+
unsubscribe: () => {
|
|
25940
|
+
this.realtime.removeListener(handle);
|
|
25941
|
+
}
|
|
25942
|
+
};
|
|
25943
|
+
});
|
|
25944
|
+
}
|
|
25805
25945
|
}
|
|
25806
25946
|
RealtimeSubjectService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: RealtimeSubjectService, deps: [{ token: i1$2.Realtime }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
25807
25947
|
RealtimeSubjectService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.6", ngImport: i0, type: RealtimeSubjectService, providedIn: 'root' });
|