diff --git a/ui-ngx/package.json b/ui-ngx/package.json index 775a685ae8..89b38ead12 100644 --- a/ui-ngx/package.json +++ b/ui-ngx/package.json @@ -47,6 +47,7 @@ "flot": "git://github.com/thingsboard/flot.git#0.9-work", "flot.curvedlines": "git://github.com/MichaelZinsmaier/CurvedLines.git#master", "font-awesome": "^4.7.0", + "html2canvas": "^1.0.0-rc.7", "jquery": "^3.5.1", "jquery.terminal": "^2.18.3", "js-beautify": "^1.13.0", diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-image-dialog.component.html b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-image-dialog.component.html new file mode 100644 index 0000000000..f37e2991f3 --- /dev/null +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-image-dialog.component.html @@ -0,0 +1,66 @@ + +
diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-image-dialog.component.scss b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-image-dialog.component.scss new file mode 100644 index 0000000000..7960026d56 --- /dev/null +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-image-dialog.component.scss @@ -0,0 +1,54 @@ +/** + * Copyright © 2016-2021 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +$previewSize: 300px !default; + +:host { + .tb-image-preview { + width: auto; + max-width: $previewSize - 2; + height: auto; + max-height: $previewSize - 2; + } + + .tb-image-preview-container { + position: relative; + float: left; + width: $previewSize; + height: $previewSize; + margin-right: 12px; + vertical-align: top; + border: solid 1px; + + div { + width: 100%; + font-size: 18px; + text-align: center; + } + + div, + .tb-image-preview { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + } + } + + .taking-screenshot-progress { + background-color: rgba(255, 255, 255, 0.65); + } +} diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-image-dialog.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-image-dialog.component.ts new file mode 100644 index 0000000000..3586f781d5 --- /dev/null +++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-image-dialog.component.ts @@ -0,0 +1,132 @@ +/// +/// Copyright © 2016-2021 The Thingsboard Authors +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// + +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { Store } from '@ngrx/store'; +import { AppState } from '@core/core.state'; +import { FormBuilder, FormGroup } from '@angular/forms'; +import { Router } from '@angular/router'; +import { DialogComponent } from '@app/shared/components/dialog.component'; +import { DashboardId } from '@shared/models/id/dashboard-id'; +import { DashboardService } from '@core/http/dashboard.service'; +import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; +import html2canvas from 'html2canvas'; +import { map, share } from 'rxjs/operators'; +import { BehaviorSubject, from } from 'rxjs'; + +export interface DashboardImageDialogData { + dashboardId: DashboardId; + currentImage?: string; + dashboardElement: HTMLElement; +} + +export interface DashboardImageDialogResult { + image?: string; +} + +@Component({ + selector: 'tb-dashboard-image-dialog', + templateUrl: './dashboard-image-dialog.component.html', + styleUrls: ['./dashboard-image-dialog.component.scss'] +}) +export class DashboardImageDialogComponent extends DialogComponent