Merge branch 'feature/entities-version-control' of github.com:thingsboard/thingsboard into feature/entities-version-control
This commit is contained in:
commit
7b6cdd8e09
@ -81,6 +81,13 @@
|
|||||||
(click)="isFullscreen = !isFullscreen">
|
(click)="isFullscreen = !isFullscreen">
|
||||||
<mat-icon>{{ isFullscreen ? 'fullscreen_exit' : 'fullscreen' }}</mat-icon>
|
<mat-icon>{{ isFullscreen ? 'fullscreen_exit' : 'fullscreen' }}</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
|
<button [fxShow]="currentDashboardId && isEdit && isTenantAdmin()" mat-icon-button
|
||||||
|
#versionControlButton
|
||||||
|
matTooltip="{{'version-control.version-control' | translate}}"
|
||||||
|
matTooltipPosition="below"
|
||||||
|
(click)="toggleVersionControl($event, versionControlButton)">
|
||||||
|
<mat-icon>history</mat-icon>
|
||||||
|
</button>
|
||||||
<button [fxShow]="currentDashboardId && !isEdit && !isMobileApp && isTenantAdmin() && displayUpdateDashboardImage()" mat-icon-button
|
<button [fxShow]="currentDashboardId && !isEdit && !isMobileApp && isTenantAdmin() && displayUpdateDashboardImage()" mat-icon-button
|
||||||
matTooltip="{{'dashboard.update-image' | translate}}"
|
matTooltip="{{'dashboard.update-image' | translate}}"
|
||||||
matTooltipPosition="below"
|
matTooltipPosition="below"
|
||||||
|
|||||||
@ -17,13 +17,13 @@
|
|||||||
import {
|
import {
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
Component, ElementRef, HostBinding,
|
Component, ElementRef, EventEmitter, HostBinding,
|
||||||
Inject,
|
Inject,
|
||||||
Injector,
|
Injector,
|
||||||
Input,
|
Input,
|
||||||
NgZone,
|
NgZone,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit, Optional,
|
OnInit, Optional, Renderer2,
|
||||||
StaticProvider,
|
StaticProvider,
|
||||||
ViewChild,
|
ViewChild,
|
||||||
ViewContainerRef,
|
ViewContainerRef,
|
||||||
@ -135,6 +135,10 @@ import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
|||||||
import cssjs from '@core/css/css';
|
import cssjs from '@core/css/css';
|
||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
import { IAliasController } from '@core/api/widget-api.models';
|
import { IAliasController } from '@core/api/widget-api.models';
|
||||||
|
import { MatButton } from '@angular/material/button';
|
||||||
|
import { VersionControlComponent } from '@home/components/vc/version-control.component';
|
||||||
|
import { TbPopoverService } from '@shared/components/popover.service';
|
||||||
|
import { tap } from 'rxjs/operators';
|
||||||
|
|
||||||
// @dynamic
|
// @dynamic
|
||||||
@Component({
|
@Component({
|
||||||
@ -290,6 +294,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateBreadcrumbs = new EventEmitter();
|
||||||
|
|
||||||
private rxSubscriptions = new Array<Subscription>();
|
private rxSubscriptions = new Array<Subscription>();
|
||||||
|
|
||||||
get toolbarOpened(): boolean {
|
get toolbarOpened(): boolean {
|
||||||
@ -329,6 +335,8 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
|||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
|
private popoverService: TbPopoverService,
|
||||||
|
private renderer: Renderer2,
|
||||||
private ngZone: NgZone,
|
private ngZone: NgZone,
|
||||||
@Optional() @Inject('embeddedValue') private embeddedValue,
|
@Optional() @Inject('embeddedValue') private embeddedValue,
|
||||||
private overlay: Overlay,
|
private overlay: Overlay,
|
||||||
@ -1392,4 +1400,52 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleVersionControl($event: Event, versionControlButton: MatButton) {
|
||||||
|
if ($event) {
|
||||||
|
$event.stopPropagation();
|
||||||
|
}
|
||||||
|
const trigger = versionControlButton._elementRef.nativeElement;
|
||||||
|
if (this.popoverService.hasPopover(trigger)) {
|
||||||
|
this.popoverService.hidePopover(trigger);
|
||||||
|
} else {
|
||||||
|
const versionControlPopover = this.popoverService.displayPopover(trigger, this.renderer,
|
||||||
|
this.viewContainerRef, VersionControlComponent, 'leftTop', true, null,
|
||||||
|
{
|
||||||
|
detailsMode: true,
|
||||||
|
active: true,
|
||||||
|
singleEntityMode: true,
|
||||||
|
externalEntityId: this.dashboard.externalId || this.dashboard.id,
|
||||||
|
entityId: this.dashboard.id,
|
||||||
|
entityName: this.dashboard.name,
|
||||||
|
onBeforeCreateVersion: () => {
|
||||||
|
return this.dashboardService.saveDashboard(this.dashboard).pipe(
|
||||||
|
tap((dashboard) => {
|
||||||
|
this.dashboard = this.dashboardUtils.validateAndUpdateDashboard(dashboard);
|
||||||
|
this.prevDashboard = deepClone(this.dashboard);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, {}, {}, {}, true);
|
||||||
|
versionControlPopover.tbComponentRef.instance.popoverComponent = versionControlPopover;
|
||||||
|
versionControlPopover.tbComponentRef.instance.versionRestored.subscribe(() => {
|
||||||
|
this.dashboardService.getDashboard(this.currentDashboardId).subscribe((dashboard) => {
|
||||||
|
dashboard = this.dashboardUtils.validateAndUpdateDashboard(dashboard);
|
||||||
|
const data = {
|
||||||
|
dashboard,
|
||||||
|
widgetEditMode: false,
|
||||||
|
currentDashboardId: this.currentDashboardId
|
||||||
|
} as any;
|
||||||
|
this.init(data);
|
||||||
|
this.dashboardCtx.stateController.cleanupPreservedStates();
|
||||||
|
this.dashboardCtx.stateController.resetState();
|
||||||
|
this.setEditMode(true, false);
|
||||||
|
this.updateBreadcrumbs.emit();
|
||||||
|
this.ngZone.run(() => {
|
||||||
|
this.cd.detectChanges();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user