Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
chkr1011 committed Oct 16, 2016
2 parents a7a1050 + dcbd77b commit b518288
Show file tree
Hide file tree
Showing 1,081 changed files with 135,260 additions and 99,282 deletions.
14 changes: 12 additions & 2 deletions App/DeployApps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ while($repeat)

$clearRemoteDirectory = Confirm("Clear remote directory (y/n)?")

# Deploy regular app.
$sourceDir = ".\HA4IoT.WebApp"
$remoteDir = "$package\LocalState\App"

Expand All @@ -128,10 +129,19 @@ while($repeat)
$remoteDir = "$remoteDir\STAGING";
}

#IncreaseVersion -Package "$remoteDir"

Deploy -Source ".\HA4IoT.WebApp" -Target "$remoteDir" -Clear $clearRemoteDirectory

# Deploy management app.
$sourceDir = ".\HA4IoT.ManagementApp"
$remoteDir = "$package\LocalState\ManagementApp"

if ($isStaging)
{
$remoteDir = "$remoteDir\STAGING";
}

Deploy -Source ".\HA4IoT.ManagementApp" -Target "$remoteDir" -Clear $clearRemoteDirectory

if (-Not (Confirm("Deployment completed. Repeat deploy? (y/n)")))
{
return
Expand Down
77 changes: 77 additions & 0 deletions App/HA4IoT.ManagementApp/Areas/AreasOverview.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<div class="row">
<div class="alert alert-info">
This view shows all configured areas from the HA4IoT controller. The areas iteself must be configured using C# and deployed
manually to the device.
</div>
<div class="alert alert-warning">
The Smartphone/Tablet app must be restarted in order to apply the changed settings.
</div>
</div>

<div class="row">

<div ng-class="aoCtrl.SelectedArea===null ? 'col-md-12' : 'col-md-8'">
<h2>Area</h2>
<hr />
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>ID</th>
<th>Visible</th>
<th>Caption</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-class="{active: aoCtrl.SelectedArea.Id === area.Id}" ng-repeat="area in aoCtrl.Areas" ng-click="aoCtrl.selectArea(area)">
<td>
<div class="label label-primary">{{area.Id}}</div>
</td>
<td>
<span class="fa fa-eye grid-icon" aria-hidden="true" ng-show="area.IsVisible"></span>
</td>
<td>
<div>{{area.Caption}}</div>
</td>
<td class="text-center">
<div class="btn-group pull-right" role="group">
<a class="btn btn-default btn-xs glyphicon glyphicon-arrow-up" ng-click="aoCtrl.moveArea(area, 'up')"></a>
<a class="btn btn-default btn-xs glyphicon glyphicon-arrow-down" ng-click="aoCtrl.moveArea(area, 'down')"></a>
</div>
</td>
</tr>
</tbody>
</table>

<div>
<button class="btn btn-default pull-right" ng-click="aoCtrl.save()">Save</button>
</div>
</div>

<div class="col-md-4" ng-show="aoCtrl.SelectedArea!=null">
<h2>Settings</h2>
<hr />

<div class="box">
<form>
<div class="form-group">
<div>
<label>ID</label>
</div>
<div class="label label-primary">{{aoCtrl.SelectedArea.Id}}</div>
</div>

<div class="form-group">
<label>Caption</label>
<input type="text" class="form-control" ng-model="aoCtrl.SelectedArea.Caption">
</div>

<div class="checkbox">
<label><input type="checkbox" ng-model="aoCtrl.SelectedArea.IsVisible">Visible</label>
</div>
</form>
</div>
</div>
</div>

<br />
75 changes: 75 additions & 0 deletions App/HA4IoT.ManagementApp/Areas/AreasOverview.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
(function () {
var module = angular.module("app");

function createController(controllerProxyService, modalService) {

var ctrl = this;

ctrl.Areas = [];
ctrl.SelectedArea = null;

ctrl.moveArea = function (area, direction) {
var sourceIndex = ctrl.Areas.indexOf(area);
ctrl.Areas.moveItem(sourceIndex, direction);
}

ctrl.selectArea = function (area) {
ctrl.SelectedArea = area;
}

ctrl.fetchAreas = function () {

controllerProxyService.get("configuration", null,
function (response) {
ctrl.loadAreas(response);
});
}

ctrl.loadAreas = function (source) {

var areas = [];
$.each(source.Areas, function (id, item) {
var row = {
Id: id,
Caption: item.Settings.Caption,
SortValue: item.Settings.SortValue,
IsVisible: item.Settings.IsVisible
};

areas.push(row);
});

areas = areas.sort(function (a, b) {
return a.SortValue - b.SortValue;
});

ctrl.Areas = areas;
}

ctrl.save = function () {
$.each(ctrl.Areas, function (i, item) {
var payload = {
Uri: "Area/" + item.Id,
Settings: {
Caption: item.Caption,
IsVisible: item.IsVisible,
SortValue: i
}
}

controllerProxyService.execute("Service/ISettingsService/Import", payload);
});

modalService.show("Info", "Area settings successfully saved.");
}

ctrl.fetchAreas();
}

module.component("areas", {
templateUrl: "Areas/AreasOverview.component.html",
controllerAs: "aoCtrl",
controller: ["controllerProxyService", "modalService", createController]
});

})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<div class="row">
<div class="alert alert-info">
This view shows all configured automations from the HA4IoT controller. The automations iteself must be configured using C#
and deployed manually to the device.
</div>
</div>

<div class="row" ng-show="aoCtrl.SelectedAutomation===null">

<div ng-class="aoCtrl.SelectedArea===null ? 'col-md-12' : 'col-md-3'">
<h2>Area</h2>
<hr/>
<ul class="list-group">
<li class="list-group-item" ng-class="{active: aoCtrl.SelectedArea.Id===area.Id}" ng-repeat="area in aoCtrl.Areas" ng-click="aoCtrl.SelectedArea=area">
<span>{{area.Caption}}</span>
</li>
</ul>
</div>

<div class="col-md-9" ng-show="aoCtrl.SelectedArea!=null">
<h2>Automations</h2>
<hr/>

<table class="table table-condensed table-hover">
<thead>
<tr>
<th></th>
<th>ID</th>
<th>Caption</th>
<th>State</th>
</tr>
</thead>
<tbody>
<tr ng-class="{active: aoCtrl.SelectedAutomation.Id===automation.Id}" ng-repeat="automation in aoCtrl.SelectedArea.Automations" ng-click="aoCtrl.selectAutomation(automation)">
<td class="text-center">
<img class="medium-icon" ng-src="Content/Images/{{automation.Settings.Image}}.png"/>
</td>
<td>
<div class="label label-primary">{{automation.Id}}</div>
</td>
<td>
<span>{{automation.Settings.Caption}}</span>
</td>
<td>
<span class="fa fa-check grid-icon" aria-hidden="true" ng-show="automation.Settings.IsEnabled"></span>
</td>
</tr>
</tbody>
</table>

</div>

</div>

<div ng-show="aoCtrl.SelectedAutomation!=null">
<h2>Settings</h2>
<hr />
<div class="box">
<div ng-include="'Automations/GeneralSettings.html'"></div>
<div ng-include="'Automations/TurnOnAndOffAutomationSettings.html'" ng-show="aoCtrl.SelectedAutomation.Type==='TurnOnAndOffAutomation'"></div>
<div ng-include="'Automations/RollerShutterAutomationSettings.html'" ng-show="aoCtrl.SelectedAutomation.Type==='RollerShutterAutomation'"></div>
<hr />
<button class="btn btn-default" ng-click="aoCtrl.save()">Save</button>
<button class="btn btn-default" ng-click="aoCtrl.close()">Close</button>
</div>
</div>

<br />
108 changes: 108 additions & 0 deletions App/HA4IoT.ManagementApp/Automations/AutomationsOverview.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
(function () {
var module = angular.module("app");

function createController(controllerProxyService, modalService) {

var ctrl = this;

ctrl.Areas = [];
ctrl.SelectedArea = null;
ctrl.SelectedAutomation = null;

ctrl.selectAutomation = function (automation) {
ctrl.SelectedAutomation = automation;
}

ctrl.fetchAutomations = function () {

controllerProxyService.get("configuration", null, function (response) {
ctrl.loadAutomations(response);
});
}

ctrl.loadAutomations = function (source) {

var areas = [];
$.each(source.Areas, function (areaId, areaItem) {

var area = {
Id: areaId,
Caption: areaItem.Settings.Caption,
Automations: []
};

$.each(areaItem.Automations,
function (automationId, automationItem) {

var automation = {
Id: automationId,
Type: automationItem.Type,
Settings: automationItem.Settings
};

area.Automations.push(automation);
});

area.Automations = area.Automations.sort(function (a, b) {
return a.Id - b.Id;
});

areas.push(area);
});

areas = areas.sort(function (a, b) {
return a.SortValue - b.SortValue;
});

ctrl.Areas = areas;
}

ctrl.close = function () {
ctrl.SelectedAutomation = null;
}

ctrl.save = function () {
var source = ctrl.SelectedAutomation;

var payload = {
Uri: "Automation/" + source.Id,
Settings: source.Settings
}

var timestampPattern = /^-?\d{1,2}[:][0-5]?\d[:][0-5]?\d$/;

if (source.Type === "TurnOnAndOffAutomation") {
if (!timestampPattern.test(source.Settings.Duration)) {
modalService.show("Error", "Format of field 'Duration' is invalid. Must be '00:01:00' for example.");
return;
}
}
else if (source.Type === "RollerShutterAutomation") {
if (!timestampPattern.test(source.Settings.OpenOnSunriseOffset)) {
modalService.show("Error", "Format of field 'OpenOnSunriseOffset' is invalid. Must be '00:01:00' for example.");
return;
}

if (!timestampPattern.test(source.Settings.CloseOnSunsetOffset)) {
modalService.show("Error", "Format of field 'CloseOnSunsetOffset' is invalid. Must be '00:01:00' for example.");
return;
}
}

controllerProxyService.execute("Service/ISettingsService/Import", payload, function() {
modalService.show("Info", "Settings for automation '" + source.Id + "' successfully saved.");
});

ctrl.close();
}

ctrl.fetchAutomations();
}

module.component("automations", {
templateUrl: "Automations/AutomationsOverview.component.html",
controllerAs: "aoCtrl",
controller: ["controllerProxyService", "modalService", createController]
});

})();
Loading

0 comments on commit b518288

Please sign in to comment.