Skip to content

Commit

Permalink
Merge branch 'feature/history' into contactless
Browse files Browse the repository at this point in the history
Conflicts:
	.gitignore
	debian/changelog
  • Loading branch information
evgeny-boger committed Oct 5, 2015
2 parents 8b22037 + f43b603 commit 601e164
Show file tree
Hide file tree
Showing 38 changed files with 9,999 additions and 95 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ debian/wb-mqtt-homeui.debhelper.log
debian/wb-mqtt-homeui.substvars
debian/wb-mqtt-homeui/

debian/wb-mqtt-homeui*
34 changes: 33 additions & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<link rel="stylesheet" href="bower_components/angular-toggle-switch/angular-toggle-switch.css" />
<link rel="stylesheet" href="bower_components/spectrum/spectrum.css" />
<link rel="stylesheet" href="bower_components/codemirror/lib/codemirror.css" />
<link rel="stylesheet" href="bower_components/c3/c3.css" type="text/css">
<link rel="stylesheet" href="bower_components/css-spinners/css/spinner/spinner.css">
<link rel="stylesheet" href="styles/main.css">
</head>
<body ng-app="homeuiApp">
Expand Down Expand Up @@ -70,6 +72,9 @@
<li ng-class="{ active: isActive('/widgets') }">
<a href="#/widgets"><i class="glyphicon glyphicon-list-alt"></i> Widgets</a>
</li>
<li ng-class="{ active: isActive('/history') }">
<a href="#/history"><i class="glyphicon glyphicon-stats"></i> History</a>
</li>
<!--
<li ng-class="{ active: isActive('/widget_templates') }">
<a href="#/widget_templates"><i class="glyphicon glyphicon-list-alt"></i>Widget Templates</a>
Expand Down Expand Up @@ -109,6 +114,19 @@
</li>
</ul>
</li>
<li ng-if="isConnected()" ng-class="{ active: isActive('/configs') }" class="list-menu config-menu">
<a href="#/configs"><i class="glyphicon glyphicon-file"></i> Configs</a>
<a href="javascript:;" data-toggle="collapse" data-target="#configs-menu"><i class="glyphicon glyphicon-menu-down"></i></a>
<ul id="configs-menu" class="collapse">
<li ng-repeat="config in getConfigs()">
<a href="#/configs/edit{{ config.configPath }}"
ng-class="{ active: isActive('/configs/edit{{ config.configPath }}'), error: !!config.error }">
{{ config.title }}
<span class="glyphicon glyphicon-alert" ng-show="!!config.error"></span>
</a>
</li>
</ul>
</li>
<li ng-class="{ active: isActive('/settings') }">
<a href="#/settings"><i class="glyphicon glyphicon-wrench"></i> Settings</a>
</li>
Expand All @@ -124,7 +142,7 @@
<!-- Page Heading -->
<div class="row">
<div class="col-lg-12">
<div class="alert alert-success" role="alert" ng-show='showCreated'>
<div class="alert alert-success" role="alert" ng-show='showCreated' ng-cloak>
<strong>Changes</strong> successfully saved.
</div>
<div class="alert alert-danger" role="alert" ng-cloak ng-controller="AlertCtrl" ng-show="visible">
Expand Down Expand Up @@ -174,6 +192,8 @@
<script src="bower_components/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="bower_components/codemirror/lib/codemirror.js"></script>
<script type="text/javascript" src="bower_components/codemirror/mode/javascript/javascript.js"></script>
<script type="text/javascript" src="bower_components/d3/d3.js"></script>
<script type="text/javascript" src="bower_components/c3/c3.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
Expand All @@ -186,16 +206,25 @@
<script src="bower_components/angular-spectrum-colorpicker/dist/angular-spectrum-colorpicker.js"></script>
<script src="bower_components/angular-order-object-by/src/ng-order-object-by.js"></script>
<script src="bower_components/angular-ui-codemirror/ui-codemirror.js"></script>
<script src="bower_components/c3-angular/c3js-directive.js"></script>

<script src="scripts/3rdparty/angular-json-editor.js"></script>
<script src="scripts/3rdparty/ui-bootstrap.js"></script>
<script src="scripts/3rdparty/jsoneditor.js"></script>

<script src="scripts/app.js"></script>
<script src="scripts/services/errors.js"></script>
<script src="scripts/services/mqttService.js"></script>
<script src="scripts/services/dataService.js"></script>
<script src="scripts/services/commonService.js"></script>
<script src="scripts/services/editorProxy.js"></script>
<script src="scripts/services/configEditorProxy.js"></script>
<script src="scripts/services/historyProxy.js"></script>
<script src="scripts/services/rpc.js"></script>
<script src="scripts/services/gotoDefStart.js"></script>
<script src="scripts/services/time.js"></script>
<script src="scripts/services/spinner.js"></script>
<script src="scripts/services/dumbtemplate.js"></script>
<script src="scripts/directives/console.js"></script>
<script src="scripts/controllers/alertController.js"></script>
<script src="scripts/controllers/homeController.js"></script>
Expand All @@ -209,6 +238,9 @@
<script src="scripts/controllers/loginController.js"></script>
<script src="scripts/controllers/scriptController.js"></script>
<script src="scripts/controllers/scriptsController.js"></script>
<script src="scripts/controllers/historyController.js"></script>
<script src="scripts/controllers/configsController.js"></script>
<script src="scripts/controllers/configController.js"></script>
<script src="scripts/filters/metaTypeFilter.js"></script>
</body>
</html>
145 changes: 145 additions & 0 deletions app/scripts/3rdparty/angular-json-editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Based off 0.1.8 version of https://github.com/rodikh/angular-json-editor
// This version does actually call onChange handler

'use strict';

angular.module('angular-json-editor', []).provider('JSONEditor', function () {
var configuration = {
defaults: {
options: {
iconlib: 'bootstrap3',
theme: 'bootstrap3'
}
}
};

this.configure = function (options) {
extendDeep(configuration, options);
};

this.$get = ['$window', function ($window) {
var JSONEditor = $window.JSONEditor;
extendDeep(JSONEditor, configuration);
return $window.JSONEditor;
}];

function extendDeep(dst) {
angular.forEach(arguments, function (obj) {
if (obj !== dst) {
angular.forEach(obj, function (value, key) {
if (dst[key] && dst[key].constructor && dst[key].constructor === Object) {
extendDeep(dst[key], value);
} else {
dst[key] = value;
}
});
}
});
return dst;
}

}).directive('jsonEditor', ['$q', 'JSONEditor', function ($q, JSONEditor) {

return {
restrict: 'E',
transclude: true,
scope: {
schema: '=',
startval: '=',
buttonsController: '@',
onChange: '&'
},
controller: ['$scope', '$attrs', '$controller', function ($scope, $attrs, $controller) {

var controller, controllerScope, controllerName = $attrs.buttonsController;
if (angular.isString(controllerName) && controllerName !== '') {
controllerScope = {
$scope: $scope
};

try {
controller = $controller(controllerName, controllerScope);
} catch (e) {
// Any exceptions thrown will probably be because the controller specified does not exist
throw new Error('json-editor: buttons-controller attribute must be a valid controller.');
}
}

}],
link: function (scope, element, attrs, controller, transclude) {
var valueToResolve,
startValPromise = $q.when({}),
schemaPromise = $q.when(null);

scope.isValid = false;

if (!angular.isString(attrs.schema)) {
throw new Error('json-editor: schema attribute has to be defined.');
}
if (angular.isObject(scope.schema)) {
schemaPromise = $q.when(scope.schema);
}
if (angular.isObject(scope.startval)) {
// Support both $http (i.e. $q) and $resource promises, and also normal object.
valueToResolve = scope.startval;
if (angular.isDefined(valueToResolve.$promise)) {
startValPromise = $q.when(valueToResolve.$promise);

} else {
startValPromise = $q.when(valueToResolve);
}
}

// Wait for the start value and schema to resolve before building the editor.
$q.all([schemaPromise, startValPromise]).then(function (result) {

// Support $http promise response with the 'data' property.
var schema = result[0] ? result[0].data || result[0] : null,
startVal = result[1];
if (schema === null) {
throw new Error('json-editor: could not resolve schema data.');
}

// Commit changes in text fields immediately.
// FIXME: should make this an option (and perhaps file a pull request for JSONEditor)
// FIXME: ipv4 input type seems to be an invention of JSONEditor author
element.on("input", "input[type=text], input[type=ipv4], textarea", function () {
var e = document.createEvent("HTMLEvents");
e.initEvent("change", false, true);
this.dispatchEvent(e);
});

scope.editor = new JSONEditor(element[0], {
startval: startVal,
schema: schema
});

var editor = scope.editor;

editor.on('ready', function () {
scope.isValid = (editor.validate().length === 0);
});

editor.on('change', function () {
scope.$apply(function () {
var errors = editor.validate();
scope.isValid = (errors.length === 0);
// Fire the onChange callback
var onChange = scope.onChange();
if (typeof onChange === 'function') {
onChange(editor.getValue(), errors, editor);
}
});
});

// Transclude the buttons at the bottom.
var buttons = transclude(scope, function (clone) {
return clone;
});

element.append(buttons);
});
}
};

}]);
Loading

0 comments on commit 601e164

Please sign in to comment.