14 changed files with 354 additions and 65 deletions
@ -0,0 +1,44 @@ |
|||||
|
diff --git a/node_modules/angular-gridster2/fesm2020/angular-gridster2.mjs b/node_modules/angular-gridster2/fesm2020/angular-gridster2.mjs
|
||||
|
index cf4e220..4275d11 100644
|
||||
|
--- a/node_modules/angular-gridster2/fesm2020/angular-gridster2.mjs
|
||||
|
+++ b/node_modules/angular-gridster2/fesm2020/angular-gridster2.mjs
|
||||
|
@@ -208,6 +208,7 @@ const GridsterConfigService = {
|
||||
|
useTransformPositioning: true, |
||||
|
scrollSensitivity: 10, |
||||
|
scrollSpeed: 20, |
||||
|
+ colWidthUpdateCallback: undefined,
|
||||
|
initCallback: undefined, |
||||
|
destroyCallback: undefined, |
||||
|
gridSizeChangedCallback: undefined, |
||||
|
@@ -1243,6 +1244,9 @@ class GridsterComponent {
|
||||
|
this.renderer.setStyle(this.el, 'padding-right', this.$options.margin + 'px'); |
||||
|
} |
||||
|
this.curColWidth = (this.curWidth - marginWidth) / this.columns; |
||||
|
+ if (this.options.colWidthUpdateCallback) {
|
||||
|
+ this.curColWidth = this.options.colWidthUpdateCallback(this.curColWidth);
|
||||
|
+ }
|
||||
|
let marginHeight = -this.$options.margin; |
||||
|
if (this.$options.outerMarginTop !== null) { |
||||
|
marginHeight += this.$options.outerMarginTop; |
||||
|
@@ -1266,6 +1270,9 @@ class GridsterComponent {
|
||||
|
} |
||||
|
else { |
||||
|
this.curColWidth = (this.curWidth + this.$options.margin) / this.columns; |
||||
|
+ if (this.options.colWidthUpdateCallback) {
|
||||
|
+ this.curColWidth = this.options.colWidthUpdateCallback(this.curColWidth);
|
||||
|
+ }
|
||||
|
this.curRowHeight = |
||||
|
((this.curHeight + this.$options.margin) / this.rows) * |
||||
|
this.$options.rowHeightRatio; |
||||
|
diff --git a/node_modules/angular-gridster2/lib/gridsterConfig.interface.d.ts b/node_modules/angular-gridster2/lib/gridsterConfig.interface.d.ts
|
||||
|
index 1d7cdf0..a712b35 100644
|
||||
|
--- a/node_modules/angular-gridster2/lib/gridsterConfig.interface.d.ts
|
||||
|
+++ b/node_modules/angular-gridster2/lib/gridsterConfig.interface.d.ts
|
||||
|
@@ -73,6 +73,7 @@ export interface GridsterConfig {
|
||||
|
useTransformPositioning?: boolean; |
||||
|
scrollSensitivity?: number | null; |
||||
|
scrollSpeed?: number; |
||||
|
+ colWidthUpdateCallback?: (colWidth: number) => number;
|
||||
|
initCallback?: (gridster: GridsterComponentInterface) => void; |
||||
|
destroyCallback?: (gridster: GridsterComponentInterface) => void; |
||||
|
gridSizeChangedCallback?: (gridster: GridsterComponentInterface) => void; |
||||
@ -0,0 +1,60 @@ |
|||||
|
<!-- |
||||
|
|
||||
|
Copyright © 2016-2024 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. |
||||
|
|
||||
|
--> |
||||
|
<form (ngSubmit)="move()"> |
||||
|
<mat-toolbar color="primary"> |
||||
|
<h2 translate>dashboard.move-all-widgets</h2> |
||||
|
<span fxFlex></span> |
||||
|
<button mat-icon-button |
||||
|
(click)="cancel()" |
||||
|
type="button"> |
||||
|
<mat-icon class="material-icons">close</mat-icon> |
||||
|
</button> |
||||
|
</mat-toolbar> |
||||
|
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async"> |
||||
|
</mat-progress-bar> |
||||
|
<div mat-dialog-content class="tb-form-panel no-border no-padding" [formGroup]="moveWidgetsFormGroup"> |
||||
|
<div class="tb-form-row space-between column-xs"> |
||||
|
<div translate>dashboard.move-by</div> |
||||
|
<div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px"> |
||||
|
<mat-form-field appearance="outline" class="number" subscriptSizing="dynamic"> |
||||
|
<input required matInput formControlName="cols" |
||||
|
type="number" step="1" placeholder="{{ 'widget-config.set' | translate }}"> |
||||
|
<span translate matSuffix>dashboard.cols</span> |
||||
|
</mat-form-field> |
||||
|
<mat-form-field appearance="outline" class="number" subscriptSizing="dynamic"> |
||||
|
<input required matInput formControlName="rows" |
||||
|
type="number" step="1" placeholder="{{ 'widget-config.set' | translate }}"> |
||||
|
<span translate matSuffix>dashboard.rows</span> |
||||
|
</mat-form-field> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div mat-dialog-actions fxLayoutAlign="end center"> |
||||
|
<button mat-button color="primary" |
||||
|
type="button" |
||||
|
[disabled]="(isLoading$ | async)" |
||||
|
(click)="cancel()" cdkFocusInitial> |
||||
|
{{ 'action.cancel' | translate }} |
||||
|
</button> |
||||
|
<button mat-raised-button color="primary" |
||||
|
type="submit" |
||||
|
[disabled]="(isLoading$ | async) || moveWidgetsFormGroup.invalid || !moveWidgetsFormGroup.dirty"> |
||||
|
{{ 'action.move' | translate }} |
||||
|
</button> |
||||
|
</div> |
||||
|
</form> |
||||
@ -0,0 +1,62 @@ |
|||||
|
///
|
||||
|
/// Copyright © 2016-2024 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 } from '@angular/core'; |
||||
|
import { MatDialog, MatDialogRef } from '@angular/material/dialog'; |
||||
|
import { Store } from '@ngrx/store'; |
||||
|
import { AppState } from '@core/core.state'; |
||||
|
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; |
||||
|
import { Router } from '@angular/router'; |
||||
|
import { DialogComponent } from '@app/shared/components/dialog.component'; |
||||
|
|
||||
|
export interface MoveWidgetsDialogResult { |
||||
|
cols: number; |
||||
|
rows: number; |
||||
|
} |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'tb-move-widgets-dialog', |
||||
|
templateUrl: './move-widgets-dialog.component.html', |
||||
|
providers: [], |
||||
|
styleUrls: [] |
||||
|
}) |
||||
|
export class MoveWidgetsDialogComponent extends DialogComponent<MoveWidgetsDialogComponent, MoveWidgetsDialogResult> { |
||||
|
|
||||
|
moveWidgetsFormGroup: UntypedFormGroup; |
||||
|
|
||||
|
constructor(protected store: Store<AppState>, |
||||
|
protected router: Router, |
||||
|
protected dialogRef: MatDialogRef<MoveWidgetsDialogComponent, MoveWidgetsDialogResult>, |
||||
|
private fb: UntypedFormBuilder, |
||||
|
private dialog: MatDialog) { |
||||
|
super(store, router, dialogRef); |
||||
|
|
||||
|
this.moveWidgetsFormGroup = this.fb.group({ |
||||
|
cols: [0, [Validators.required]], |
||||
|
rows: [0, [Validators.required]] |
||||
|
} |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
cancel(): void { |
||||
|
this.dialogRef.close(null); |
||||
|
} |
||||
|
|
||||
|
move(): void { |
||||
|
const result: MoveWidgetsDialogResult = this.moveWidgetsFormGroup.value; |
||||
|
this.dialogRef.close(result); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue