diff --git a/Display/package-lock.json b/Display/package-lock.json
index 1e4d916..25a981e 100644
--- a/Display/package-lock.json
+++ b/Display/package-lock.json
@@ -2263,6 +2263,14 @@
"integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=",
"dev": true
},
+ "angular-gridster2": {
+ "version": "8.2.0",
+ "resolved": "https://registry.npmjs.org/angular-gridster2/-/angular-gridster2-8.2.0.tgz",
+ "integrity": "sha512-O/LYOFovnDZHlZ6yidO9DDN6XGSGevabQebv37mlaxfbBu5mi/svbO+uhttDhIeKbUZAorbP9CMBWsCn1tzdvw==",
+ "requires": {
+ "tslib": "^1.9.0"
+ }
+ },
"angular-highcharts": {
"version": "8.0.3",
"resolved": "https://registry.npmjs.org/angular-highcharts/-/angular-highcharts-8.0.3.tgz",
diff --git a/Display/package.json b/Display/package.json
index ae62d4b..4041164 100644
--- a/Display/package.json
+++ b/Display/package.json
@@ -23,6 +23,7 @@
"@angular/platform-browser-dynamic": "~8.2.4",
"@angular/router": "~8.2.4",
"@aspnet/signalr": "^1.1.4",
+ "angular-gridster2": "^8.2.0",
"angular-highcharts": "^8.0.3",
"hammerjs": "^2.0.8",
"highcharts": "^7.2.0",
diff --git a/Display/src/app/app.module.ts b/Display/src/app/app.module.ts
index 4d63ef6..cf97fdb 100644
--- a/Display/src/app/app.module.ts
+++ b/Display/src/app/app.module.ts
@@ -14,6 +14,7 @@ import { MatListModule } from '@angular/material/list';
import { MatMomentDateModule } from '@angular/material-moment-adapter';
import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io';
+import { GridsterModule } from 'angular-gridster2';
import { LaundryComponent } from './components/laundry/laundry.component';
import { DashboardComponent } from './components/dashboard/dashboard.component';
@@ -52,7 +53,8 @@ const config: SocketIoConfig = { url: '/api/laundry', options: {} };
FormsModule,
ReactiveFormsModule,
MatMomentDateModule,
- MatProgressSpinnerModule
+ MatProgressSpinnerModule,
+ GridsterModule
],
providers: [],
bootstrap: [AppComponent]
diff --git a/Display/src/app/components/dashboard/dashboard.component.html b/Display/src/app/components/dashboard/dashboard.component.html
index 101bc00..2d4911e 100644
--- a/Display/src/app/components/dashboard/dashboard.component.html
+++ b/Display/src/app/components/dashboard/dashboard.component.html
@@ -1,3 +1,20 @@
-
- dashboard works!
+
diff --git a/Display/src/app/components/dashboard/dashboard.component.scss b/Display/src/app/components/dashboard/dashboard.component.scss
index 20dd4e3..2e497ed 100644
--- a/Display/src/app/components/dashboard/dashboard.component.scss
+++ b/Display/src/app/components/dashboard/dashboard.component.scss
@@ -1,3 +1,17 @@
-.dashboard {
- padding: 20px;
+gridster {
+ background: #fafafa;
+ flex: 1 1 auto;
+}
+
+.content {
+ display: flex;
+ flex-flow: column;
+ height: 100%;
+}
+
+.header {
+ background-color: rgb(250, 250, 250);
+ padding: 10px;
+ flex: 0 0 auto;
+ text-align: right;
}
diff --git a/Display/src/app/components/dashboard/dashboard.component.ts b/Display/src/app/components/dashboard/dashboard.component.ts
index 9787ddf..3c86865 100644
--- a/Display/src/app/components/dashboard/dashboard.component.ts
+++ b/Display/src/app/components/dashboard/dashboard.component.ts
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
+import { GridsterConfig, GridsterItem, GridsterItemComponentInterface } from 'angular-gridster2';
@Component({
selector: 'app-dashboard',
@@ -6,10 +7,73 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./dashboard.component.scss']
})
export class DashboardComponent implements OnInit {
+ public options: GridsterConfig;
+ public dashboard: Array
;
+ public locked = true;
constructor() { }
ngOnInit() {
+ this.options = {
+ itemChangeCallback: () => this.saveOptions(),
+ itemResizeCallback: () => this.saveOptions(),
+ resizable: {
+ enabled: !this.locked
+ },
+ draggable: {
+ enabled: !this.locked
+ },
+ gridType: 'fixed',
+ fixedColWidth: 105,
+ fixedRowHeight: 105,
+ displayGrid: 'none'
+ };
+
+ this.loadOptions();
}
+ changedOptions() {
+ this.options.api.optionsChanged();
+ }
+
+ removeItem(item: GridsterItem) {
+ this.dashboard.splice(this.dashboard.indexOf(item), 1);
+ }
+
+ addItem() {
+ this.dashboard.push({} as GridsterItem);
+ }
+
+ toggleLocked() {
+ this.locked = !this.locked;
+
+ this.options.resizable.enabled = !this.locked;
+ this.options.draggable.enabled = !this.locked;
+
+ this.changedOptions();
+ }
+
+ saveOptions() {
+ localStorage.setItem('dashboard-layout', JSON.stringify(this.dashboard));
+ }
+
+ loadOptions() {
+ const savedLayout = localStorage.getItem('dashboard-layout');
+
+ const defaultLayout = [
+ { cols: 3, rows: 2, y: 0, x: 0 },
+ { cols: 2, rows: 1, y: 0, x: 3 }
+ ];
+
+ if (savedLayout == null) {
+ this.dashboard = defaultLayout;
+ return;
+ }
+
+ try {
+ this.dashboard = JSON.parse(savedLayout);
+ } catch (error) {
+ this.dashboard = defaultLayout;
+ }
+ }
}
diff --git a/Display/src/app/components/weather/current/weather-current.component.html b/Display/src/app/components/weather/current/weather-current.component.html
index 830ddac..af1c122 100644
--- a/Display/src/app/components/weather/current/weather-current.component.html
+++ b/Display/src/app/components/weather/current/weather-current.component.html
@@ -42,7 +42,7 @@
Rain
- {{ latestReading.Rain.toFixed(2) }}
+ {{ latestReading.Rain.toFixed(2) }}"
|