Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Experimental: use custom widgets for drawer and headers #216

Merged
merged 3 commits into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions web/app/dashboard/dashboard.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
<i class="glyphicon glyphicon-menu-hamburger"></i>
</a>

<a class="btn pull-right" ng-click="vm.goFullscreen()" title="Toggle full screen" ng-if="!settings.hide_fullscreen_button">
<a class="btn pull-right" ng-click="vm.goFullscreen()" title="Toggle full screen" ng-if="!settings.hide_fullscreen_button && !vm.dashboard.header.use_custom_widget">
<i class="glyphicon glyphicon-resize-full"></i>
</a>
<a class="btn pull-right" ng-click="vm.refresh()" title="Refresh" ng-if="!settings.hide_refresh_button">
<a class="btn pull-right" ng-click="vm.refresh()" title="Refresh" ng-if="!settings.hide_refresh_button && !vm.dashboard.header.use_custom_widget">
<i class="glyphicon glyphicon-refresh"></i>
</a>
<a class="btn pull-right"
ng-if="vm.supportsSpeech && !settings.floating_speech && !settings.hide_speak_button"
ng-if="vm.supportsSpeech && !settings.floating_speech && !settings.hide_speak_button && !vm.dashboard.header.use_custom_widget"
ng-click="vm.isListening ? vm.stopListening() : vm.listen()"
title="Speak">
<i class="glyphicon" ng-class="vm.isListening ? 'glyphicon-stop' : 'glyphicon-comment'"></i>
</a>
<h2 class="dashboard-title">
<h2 class="dashboard-title" ng-if="!vm.dashboard.header.use_custom_widget">
<small class="header-clock" ng-if="settings.show_header_clock"><ds-widget-clock show-digital digital-format="settings.header_clock_format || 'HH:mm'"></ds-widget-clock></small>
<span>{{vm.dashboard.name}}
<a class="btn btn-link btn-edit-dashboard"
Expand All @@ -26,6 +26,11 @@ <h2 class="dashboard-title">
</a>
</span>
</h2>
<div ng-if="vm.dashboard.header.use_custom_widget"
ng-init="customHeaderWidgetModel = { id: vm.dashboard.id, name: vm.dashboard.name, nobackground: true, customwidget: vm.dashboard.header.custom_widget, dontwrap: true, config: vm.dashboard.header.custom_widget_config }">>
<widget-template ng-model="customHeaderWidgetModel">
</widget-template>
</div>
</div>
<span ng-if="vm.isListening" class="speech-output">{{vm.speechOutput}}</span>
<a class="btn fab"
Expand Down
11 changes: 8 additions & 3 deletions web/app/menu/drawer.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
<widget-icon iconset="'freepik-housethings'" icon="'house-building'" size="40"></widget-icon> {{settings.panel_name || 'HABPanel'}}
</li>
<li ng-if="settings.drawer_heading_image" ng-click="goHome()" style="padding: 0">
<img src="{{settings.drawer_heading_image}}" />
<img ng-src="{{settings.drawer_heading_image}}" />
</li>
<li ng-repeat="dash in dashboards | orderBy:['row', 'col']" ng-class="{ active: isActive(dash.id) }" ng-click="goToDashboard(dash.id)">
<widget-icon ng-if="dash.tile.iconset && dash.tile.icon" style="position:absolute; right: 20px" iconset="dash.tile.iconset" icon="dash.tile.icon" inline="true" size="24"></widget-icon>
{{dash.name}}
<widget-icon ng-if="dash.tile.iconset && dash.tile.icon && !dash.drawer.use_custom_widget" style="position:absolute; right: 20px" iconset="dash.tile.iconset" icon="dash.tile.icon" inline="true" size="24"></widget-icon>
<span ng-if="!dash.drawer.use_custom_widget">{{dash.name}}</span>
<div ng-if="dash.drawer.use_custom_widget" ng-click="vm.viewDashboard(dash)" class="card-title" style="cursor: pointer; height: 100%"
ng-init="customDrawerWidgetsModels[dash.id] = { id: dash.id, name: dash.name, nobackground: true, customwidget: dash.drawer.custom_widget, dontwrap: true, config: dash.drawer.custom_widget_config }">
<widget-template ng-model="customDrawerWidgetsModels[dash.id]">
</widget-template>
</div>
</li>
</ul>
<footer ng-if="!settings.hide_drawer_footer">
Expand Down
46 changes: 34 additions & 12 deletions web/app/menu/menu.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
vm.dashboards = dashboards;
vm.editMode = false;
vm.customWidgetsModels = {};

vm.customDrawerWidgetsModels = {};

activate();

Expand Down Expand Up @@ -140,6 +140,8 @@
function DashboardSettingsCtrl($scope, $timeout, $rootScope, $modalInstance, dashboard, OHService, PersistenceService) {
$scope.dashboard = dashboard;
if (!$scope.dashboard.tile) $scope.dashboard.tile = {};
if (!$scope.dashboard.drawer) $scope.dashboard.drawer = {};
if (!$scope.dashboard.header) $scope.dashboard.header = {};
//$scope.items = OHService.getItems();

$scope.form = {
Expand Down Expand Up @@ -169,7 +171,17 @@
custom_widget: dashboard.tile.custom_widget,
custom_widget_dontwrap: dashboard.tile.custom_widget_dontwrap,
custom_widget_nobackground: dashboard.tile.custom_widget_nobackground,
custom_widget_config: dashboard.tile.custom_widget_config || {},
custom_widget_config: dashboard.tile.custom_widget_config || {}
},
drawer: {
use_custom_widget: dashboard.drawer.use_custom_widget,
custom_widget: dashboard.drawer.custom_widget,
custom_widget_config: dashboard.drawer.custom_widget_config || {}
},
header: {
use_custom_widget: dashboard.header.use_custom_widget,
custom_widget: dashboard.header.custom_widget,
custom_widget_config: dashboard.header.custom_widget_config || {}
}
};

Expand All @@ -184,17 +196,19 @@
});
};

$scope.updateCustomWidgetSettings = function(erase_config) {
delete $scope.widgetsettings;
if ($scope.form.tile && $scope.form.tile.use_custom_widget && $scope.form.tile.custom_widget) {
if ($rootScope.configWidgets[$scope.form.tile.custom_widget]) {
$scope.widgetsettings = $rootScope.configWidgets[$scope.form.tile.custom_widget].settings;
} else if ($rootScope.customwidgets[$scope.form.tile.custom_widget]) {
$scope.widgetsettings = $rootScope.customwidgets[$scope.form.tile.custom_widget].settings;
$scope.updateCustomWidgetSettings = function(erase_config, type) {
if (!$scope.widgetsettings)
$scope.widgetsettings = {};
delete $scope.widgetsettings[type];
if ($scope.form[type] && $scope.form[type].use_custom_widget && $scope.form[type].custom_widget) {
if ($rootScope.configWidgets[$scope.form[type].custom_widget]) {
$scope.widgetsettings[type] = $rootScope.configWidgets[$scope.form[type].custom_widget].settings;
} else if ($rootScope.customwidgets[$scope.form[type].custom_widget]) {
$scope.widgetsettings[type] = $rootScope.customwidgets[$scope.form[type].custom_widget].settings;
}
}
if (erase_config && $scope.form.tile.custom_widget_config) {
$scope.form.tile.custom_widget_config = {};
if (erase_config && $scope.form[type].custom_widget_config) {
$scope.form[type].custom_widget_config = {};
}
};

Expand All @@ -211,6 +225,12 @@
delete dashboard.tile.custom_widget_dontwrap;
delete dashboard.tile.custom_widget_nobackground;
}
if (!dashboard.drawer.use_custom_widget) {
delete dashboard.drawer;
}
if (!dashboard.header.use_custom_widget) {
delete dashboard.header;
}

PersistenceService.saveDashboards().then(function () {
$rootScope.dashboards = null;
Expand All @@ -220,7 +240,9 @@
});
};

$scope.updateCustomWidgetSettings(false);
$scope.updateCustomWidgetSettings(false, 'tile');
$scope.updateCustomWidgetSettings(false, 'drawer');
$scope.updateCustomWidgetSettings(false, 'header');
}

})();
5 changes: 3 additions & 2 deletions web/app/menu/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ <h3 ng-if="!tile.use_custom_widget" ng-style="{ color:(tile.title_color && tile.
</h3>
<div ng-if="tile.use_custom_widget" ng-click="vm.viewDashboard(dash)" class="card-title" style="cursor: pointer; height: 100%"
ng-init="customWidgetsModels[dash.id] = { id: dash.id, name: dash.name, nobackground: tile.custom_widget_nobackground, customwidget: tile.custom_widget, dontwrap: tile.custom_widget_dontwrap, config: tile.custom_widget_config }">
<widget-template ng-model="customWidgetsModels[dash.id]">
</widget-template>
<widget-template ng-model="customWidgetsModels[dash.id]">
</widget-template>
</div>
</div>
</div>
</div>
Expand Down
Loading