@@ -54,6 +56,8 @@
+
+
diff --git a/src/main/resources/public/js/angular-sanitize.min.js b/src/main/resources/public/js/angular-sanitize.min.js
new file mode 100644
index 0000000..e8c4226
--- /dev/null
+++ b/src/main/resources/public/js/angular-sanitize.min.js
@@ -0,0 +1,16 @@
+/*
+ AngularJS v1.4.3
+ (c) 2010-2015 Google, Inc. http://angularjs.org
+ License: MIT
+*/
+(function(n,h,p){'use strict';function E(a){var f=[];r(f,h.noop).chars(a);return f.join("")}function g(a,f){var d={},c=a.split(","),b;for(b=0;b
=c;d--)f.end&&f.end(e[d]);e.length=c}}"string"!==typeof a&&(a=null===a||"undefined"===typeof a?"":""+a);var b,k,e=[],m=a,l;for(e.last=function(){return e[e.length-1]};a;){l="";k=!0;if(e.last()&&w[e.last()])a=a.replace(new RegExp("([\\W\\w]*)<\\s*\\/\\s*"+e.last()+"[^>]*>","i"),function(a,b){b=b.replace(H,"$1").replace(I,"$1");f.chars&&f.chars(q(b));return""}),c("",e.last());else{if(0===a.indexOf("\x3c!--"))b=a.indexOf("--",4),0<=b&&a.lastIndexOf("--\x3e",
+b)===b&&(f.comment&&f.comment(a.substring(4,b)),a=a.substring(b+3),k=!1);else if(x.test(a)){if(b=a.match(x))a=a.replace(b[0],""),k=!1}else if(J.test(a)){if(b=a.match(y))a=a.substring(b[0].length),b[0].replace(y,c),k=!1}else K.test(a)&&((b=a.match(z))?(b[4]&&(a=a.substring(b[0].length),b[0].replace(z,d)),k=!1):(l+="<",a=a.substring(1)));k&&(b=a.indexOf("<"),l+=0>b?a:a.substring(0,b),a=0>b?"":a.substring(b),f.chars&&f.chars(q(l)))}if(a==m)throw L("badparse",a);m=a}c()}function q(a){if(!a)return"";A.innerHTML=
+a.replace(//g,">")}function r(a,f){var d=!1,c=h.bind(a,a.push);return{start:function(a,k,e){a=h.lowercase(a);!d&&w[a]&&(d=a);d||!0!==C[a]||(c("<"),c(a),h.forEach(k,function(d,e){var k=h.lowercase(e),g="img"===a&&"src"===k||
+"background"===k;!0!==O[k]||!0===D[k]&&!f(d,g)||(c(" "),c(e),c('="'),c(B(d)),c('"'))}),c(e?"/>":">"))},end:function(a){a=h.lowercase(a);d||!0!==C[a]||(c(""),c(a),c(">"));a==d&&(d=!1)},chars:function(a){d||c(B(a))}}}var L=h.$$minErr("$sanitize"),z=/^<((?:[a-zA-Z])[\w:-]*)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*(>?)/,y=/^<\/\s*([\w:-]+)[^>]*>/,G=/([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g,K=/^,J=/^<\//,H=/\x3c!--(.*?)--\x3e/g,x=/]*?)>/i,
+I=/"\u201d\u2019]/i,d=/^mailto:/i;return function(c,b){function k(a){a&&g.push(E(a))}function e(a,
+c){g.push("');k(c);g.push("")}if(!c)return c;for(var m,l=c,g=[],n,p;m=l.match(f);)n=m[0],m[2]||m[4]||(n=(m[3]?"http://":"mailto:")+n),p=m.index,k(l.substr(0,p)),e(n,m[0].replace(d,"")),l=l.substring(p+m[0].length);k(l);return a(g.join(""))}}])})(window,window.angular);
+//# sourceMappingURL=angular-sanitize.min.js.map
diff --git a/src/main/resources/public/js/ngToast.min.js b/src/main/resources/public/js/ngToast.min.js
new file mode 100644
index 0000000..ddc1e9c
--- /dev/null
+++ b/src/main/resources/public/js/ngToast.min.js
@@ -0,0 +1,6 @@
+/*!
+ * ngToast v1.5.6 (http://tameraydin.github.io/ngToast)
+ * Copyright 2015 Tamer Aydin (http://tamerayd.in)
+ * Licensed under MIT (http://tameraydin.mit-license.org/)
+ */
+!function(a,b,c){"use strict";b.module("ngToast.provider",[]).provider("ngToast",[function(){function a(a){for(var d=Math.floor(1e3*Math.random());c.indexOf(d)>-1;)d=Math.floor(1e3*Math.random());this.id=d,this.count=0,this.animation=e.animation,this.className=e.className,this.additionalClasses=e.additionalClasses,this.dismissOnTimeout=e.dismissOnTimeout,this.timeout=e.timeout,this.dismissButton=e.dismissButton,this.dismissButtonHtml=e.dismissButtonHtml,this.dismissOnClick=e.dismissOnClick,this.compileContent=e.compileContent,b.extend(this,a)}var c=[],d=[],e={animation:!1,className:"success",additionalClasses:null,dismissOnTimeout:!0,timeout:4e3,dismissButton:!1,dismissButtonHtml:"×",dismissOnClick:!0,compileContent:!1,combineDuplications:!1,horizontalPosition:"right",verticalPosition:"top",maxNumber:0};this.configure=function(a){b.extend(e,a)},this.$get=[function(){var b=function(a,b){return b="object"==typeof b?b:{content:b},b.className=a,this.create(b)};return{settings:e,messages:c,dismiss:function(a){if(a){for(var b=c.length-1;b>=0;b--)if(c[b].id===a)return c.splice(b,1),void d.splice(d.indexOf(a),1)}else{for(;c.length>0;)c.pop();d=[]}},create:function(b){if(b="object"==typeof b?b:{content:b},e.combineDuplications)for(var f=d.length-1;f>=0;f--){var g=c[f],h=b.className||"success";if(g.content===b.content&&g.className===h)return void c[f].count++}e.maxNumber>0&&d.length>=e.maxNumber&&this.dismiss(d[0]);var i=new a(b);return"bottom"===e.verticalPosition?c.unshift(i):c.push(i),d.push(i.id),i.id},success:function(a){return b.call(this,"success",a)},info:function(a){return b.call(this,"info",a)},warning:function(a){return b.call(this,"warning",a)},danger:function(a){return b.call(this,"danger",a)}}}]}])}(window,window.angular),function(a,b){"use strict";b.module("ngToast.directives",["ngToast.provider"]).run(["$templateCache",function(a){a.put("ngToast/toast.html",''),a.put("ngToast/toastMessage.html",'{{count + 1}}
')}]).directive("toast",["ngToast","$templateCache","$log",function(a,b,c){return{replace:!0,restrict:"EA",templateUrl:"ngToast/toast.html",compile:function(d,e){if(e.template){var f=b.get(e.template);f?d.replaceWith(f):c.warn("ngToast: Provided template could not be loaded. Please be sure that it is populated before the element is represented.")}return function(b){b.hPos=a.settings.horizontalPosition,b.vPos=a.settings.verticalPosition,b.animation=a.settings.animation,b.messages=a.messages}}}}]).directive("toastMessage",["$timeout","$compile","ngToast",function(a,b,c){return{replace:!0,transclude:!0,restrict:"EA",scope:{message:"=",count:"="},controller:["$scope","ngToast",function(a,b){a.dismiss=function(){b.dismiss(a.message.id)}}],templateUrl:"ngToast/toastMessage.html",link:function(d,e,f,g,h){e.attr("data-message-id",d.message.id);var i,j=d.message.compileContent;if(d.cancelTimeout=function(){a.cancel(i)},d.startTimeout=function(){d.message.dismissOnTimeout&&(i=a(function(){c.dismiss(d.message.id)},d.message.timeout))},d.onMouseEnter=function(){d.cancelTimeout()},d.onMouseLeave=function(){d.startTimeout()},j){var k;h(d,function(a){k=a,e.children().append(k)}),a(function(){b(k.contents())("boolean"==typeof j?d.$parent:j,function(a){k.replaceWith(a)})},0)}d.startTimeout(),d.message.dismissOnClick&&e.bind("click",function(){c.dismiss(d.message.id),d.$apply()})}}}])}(window,window.angular),function(a,b){"use strict";b.module("ngToast",["ngSanitize","ngToast.directives","ngToast.provider"])}(window,window.angular);
\ No newline at end of file
diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js
index 62a3ea7..18feb09 100644
--- a/src/main/resources/public/scripts/app.js
+++ b/src/main/resources/public/scripts/app.js
@@ -1,4 +1,4 @@
-var app = angular.module('habridge', ['ngRoute']);
+var app = angular.module('habridge', ['ngRoute','ngToast']);
app.config(function ($routeProvider) {
$routeProvider.when('/#', {
@@ -36,7 +36,7 @@ app.run( function (bridgeService) {
bridgeService.getHABridgeVersion();
});
-app.service('bridgeService', function ($http, $window) {
+app.service('bridgeService', function ($http, $window, ngToast) {
var self = this;
this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/settings", huebase: window.location.origin + "/api", backups: [], devices: [], device: [], settings: [], olddevicename: "", error: "", showVera: false, showHarmony: false, showNest: false, habridgeversion: ""};
@@ -304,7 +304,7 @@ app.service('bridgeService', function ($http, $window) {
if (error.data) {
$window.alert("Add new Device Error: " + error.data.message);
}
- $window.alert("Add new Device Error: unknown");
+ self.state.error = "Add new Device Error: unknown";
}
);
}
@@ -322,7 +322,7 @@ app.service('bridgeService', function ($http, $window) {
if (error.data) {
self.state.error = error.data.message;
}
- $window.alert("Backup Device Db Error: unknown");
+ self.state.error = "Backup Device Db Error: unknown";
}
);
};
@@ -340,7 +340,7 @@ app.service('bridgeService', function ($http, $window) {
if (error.data) {
self.state.error = error.data.message;
}
- $window.alert("Backup Db Restore Error: unknown");
+ self.state.error = "Backup Db Restore Error: unknown";
}
);
};
@@ -357,7 +357,7 @@ app.service('bridgeService', function ($http, $window) {
if (error.data) {
self.state.error = error.data.message;
}
- $window.alert("Backup Db Frlryr Error: unknown");
+ self.state.error = "Backup Db File Error: unknown";
}
);
};
@@ -372,7 +372,7 @@ app.service('bridgeService', function ($http, $window) {
if (error.data) {
self.state.error = error.data.message;
}
- $window.alert("Delete Device Error: unknown");
+ self.state.error = "Delete Device Error: unknown";
}
);
};
@@ -393,10 +393,14 @@ app.service('bridgeService', function ($http, $window) {
if(type == "on") {
$http.put(this.state.huebase + "/test/lights/" + device.id + "/state", "{\"on\":true}").then(
function (response) {
- $window.alert("Request Exceuted: " + response.statusText);
+ ngToast.create({
+ className: "success",
+ content:"Request Exceuted: " + response.statusText});
},
function (error) {
- $window.alert("Request Error: " + error.statusText + ", with status: " + error.status + ", Pleae look in your console log.");
+ ngToast.create({
+ className: "warning",
+ content:"Request Error: " + error.statusText + ", with status: " + error.status + ", Pleae look in your console log."});
}
);
return;
@@ -404,10 +408,14 @@ app.service('bridgeService', function ($http, $window) {
else {
$http.put(this.state.huebase + "/test/lights/" + device.id + "/state", "{\"on\":false}").then(
function (response) {
- $window.alert("Request Exceuted: " + response.statusText);
+ ngToast.create({
+ className: "success",
+ content:"Request Exceuted: " + response.statusText});
},
function (error) {
- $window.alert("Request Error: " + error.statusText + ", with status: " + error.status + ", Pleae look in your console log.");
+ ngToast.create({
+ className: "warning",
+ content:"Request Error: " + error.statusText + ", with status: " + error.status + ", Pleae look in your console log."});
}
);
return;