UNPKG

pimatic-angular-material-frontend

Version:

Provides an AngularJS webinterface for Pimatic with material design.

8 lines 22.9 kB
/*! * Name: pimatic-angular-material-frontend * Description: Provides an AngularJS webinterface for Pimatic with material design. * Version: 0.3.3 * Homepage: http://github.com/denniss17/pimatic-angular-material-frontend * Date: 2016-12-27 */ angular.module("pimaticApp.configuration",[]),angular.module("pimaticApp.devices",[]),angular.module("pimaticApp.settings",[]),angular.module("pimaticApp.adapters",["pimaticApp.configuration"]),angular.module("pimaticApp.services",["pimaticApp.adapters","pimaticApp.configuration"]),angular.module("pimaticApp",["ngMaterial","ngRoute","ngMessages","pimaticApp.configuration","pimaticApp.devices","pimaticApp.services","pimaticApp.settings","pascalprecht.translate","mdThemeColors"]),angular.module("pimaticApp.configuration").provider("config",function(){this.environment="production",this.production={title:"",version:"production",pimaticHost:"",adapterName:"websocketAdapter",debug:!1},this.development={title:"Pimatic frontend - DEV",version:"develop",pimaticHost:"",adapterName:"fixtureAdapter",debug:!0},this.testing=this.development,this.$get=function(){var a=this.production;switch(this.environment){case"testing":a=this.testing;case"development":a=this.development}return"@@title"==a.title&&(a.title="Pimatic"),a}}),angular.module("pimaticApp").config(["$routeProvider",function(a){a.when("/home",{templateUrl:"partials/home.html",controller:"HomeController"}).when("/loading",{templateUrl:"partials/loading.html"}).when("/about",{templateUrl:"partials/about.html"}).when("/login",{templateUrl:"partials/login.html",controller:"LoginController"}).when("/home/:pageId",{templateUrl:"partials/home.html",controller:"HomeController"}).when("/settings/groups",{templateUrl:"partials/settings/groups/index.html",controller:"GroupsController"}).when("/settings/groups/create",{templateUrl:"partials/settings/groups/create.html",controller:"GroupsCreateController"}).when("/settings/groups/:id",{templateUrl:"partials/settings/groups/edit.html",controller:"GroupsEditController"}).when("/settings/devices",{templateUrl:"partials/settings/devices/index.html",controller:"DevicesController"}).otherwise({redirectTo:"/loading"})}]),angular.module("pimaticApp").config(["$mdThemingProvider",function(a){a.theme("default").primaryPalette("blue").accentPalette("orange")}]),angular.module("pimaticApp.adapters").factory("baseAdapter",["$q",function(a){return{store:null,toQueryString:function(a,b){var c=this,d=[];return angular.forEach(a,function(a,e){var f=angular.isUndefined(b)?encodeURIComponent(e):b+"["+encodeURIComponent(e)+"]";d.push(angular.isObject(a)?c.toQueryString(a,f):f+"="+encodeURIComponent(a))}),d.join("&")},setStore:function(a){this.store=a},deviceAction:function(){return a(function(a,b){b()})},login:function(){return a(function(a,b){b("Not implemented")})},logout:function(){return a(function(a,b){b("Not implemented")})},start:function(){},load:function(){return a(function(a,b){b("Not implemented")})},add:function(){return a(function(a,b){b("Not implemented")})},update:function(){return a(function(a,b){b("Not implemented")})},remove:function(){return a(function(a,b){b("Not implemented")})}}}]),angular.module("pimaticApp.adapters").factory("fixtureAdapter",["$http","$q","$rootScope","baseAdapter",function(a,b,c,d){var e={},f={};return angular.extend({},d,{start:function(){var b=this;this.store.setUser({username:"admin",role:"admin",permissions:{pages:"write",rules:"write",variables:"write",messages:"write",events:"write",devices:"write",groups:"write",plugins:"write",updates:"write",controlDevices:!0,restart:!0}}),c.setState("done"),a.get("assets/fixtures/devices.json").then(function(a){b.addData("devices",a.data)},function(){b.addData("devices",[])}),a.get("assets/fixtures/groups.json").then(function(a){b.addData("groups",a.data)},function(){b.addData("groups",[])}),a.get("assets/fixtures/pages.json").then(function(a){b.addData("pages",a.data)},function(){b.addData("pages",[])}),a.get("assets/fixtures/rules.json").then(function(a){b.addData("rules",a.data)},function(){b.addData("rules",[])}),a.get("assets/fixtures/variables.json").then(function(a){b.addData("variables",a.data)},function(){b.addData("variables",[])})},addData:function(a,b){e[a]=b,this.checkPromises(a)},checkPromises:function(a){a in f&&(f[a].resolve(e[a]),delete f[a])},load:function(a){return a in e?b(function(b){b(e[a])}):(f[a]=b.defer(),f[a].promise)}})}]),angular.module("pimaticApp.adapters").factory("websocketAdapter",["$http","$q","$rootScope","$log","baseAdapter","config","toast",function(a,b,c,d,e,f,g){var h={},i={groups:"group"};return angular.extend({},e,{socket:null,start:function(){h={},this.setupSocket()},apply:function(a){c.$$phase?a():c.$apply(a)},setupSocket:function(){var a=this.store,b=this;null!==this.socket&&this.socket.disconnect(),this.socket=io(f.pimaticHost,{reconnection:!0,reconnectionDelay:1e3,reconnectionDelayMax:3e3,timeout:2e4,forceNew:!0}),this.socket.on("connect",function(){d.debug("websocketApi","connect"),b.socket.emit("call",{id:"errorMessageCount",action:"queryMessagesCount",params:{criteria:{level:"error"}}}),b.socket.emit("call",{id:"guiSettings",action:"getGuiSettings",params:{}}),b.socket.emit("call",{id:"updateProcessStatus",action:"getUpdateProcessStatus",params:{}})}),this.socket.on("error",function(a){d.debug("websocketApi","error",a),b.apply(function(){c.setState("unauthenticated")})}),this.socket.on("disconnect",function(){d.debug("websocketApi","disconnect")}),this.socket.on("hello",function(a){d.debug("websocketApi","hello",a),b.apply(function(){b.store.setUser(a),c.setState("done")})}),this.socket.on("callResult",function(a){switch(d.debug("websocketApi","callResult",a),a.id){case"errorMessageCount":break;case"guiSettings":break;case"updateProcessStatus":}}),this.socket.on("devices",function(a){d.debug("websocketApi","devices",a),b.handleIncomingData("devices",a)}),this.socket.on("rules",function(a){d.debug("websocketApi","rules",a),b.handleIncomingData("rules",a)}),this.socket.on("variables",function(a){d.debug("websocketApi","variables",a),b.handleIncomingData("variables",a)}),this.socket.on("pages",function(a){d.debug("websocketApi","pages",a),b.handleIncomingData("pages",a)}),this.socket.on("groups",function(a){d.debug("websocketApi","groups",a),b.handleIncomingData("groups",a)}),this.socket.on("deviceAttributeChanged",function(c){d.debug("websocketApi","deviceAttributeChanged",c),b.apply(function(){var b=a.get("devices",c.deviceId);null!==b&&angular.forEach(b.attributes,function(a){a.name==c.attributeName&&(a.value=c.value,a.lastUpdate=c.time)})})}),this.socket.on("variableValueChanged",function(c){d.debug("websocketApi","variableValueChanged",c),b.apply(function(){var b=a.get("variables",c.variableName);null!==b&&(b.value=c.variableValue)})}),this.socket.on("deviceChanged",function(c){d.debug("websocketApi","deviceChanged",c),b.apply(function(){a.update("devices",c,!0)})}),this.socket.on("deviceRemoved",function(c){d.debug("websocketApi","deviceRemoved",c),b.apply(function(){a.remove("devices",c,!0)})}),this.socket.on("deviceAdded",function(c){d.debug("websocketApi","deviceAdded",c),b.apply(function(){a.add("devices",c,!0)})}),this.socket.on("deviceOrderChanged",function(a){d.debug("websocketApi","deviceOrderChanged",a)}),this.socket.on("pageChanged",function(c){d.debug("websocketApi","pageChanged",c),b.apply(function(){a.update("pages",c,!0)})}),this.socket.on("pageRemoved",function(c){d.debug("websocketApi","pageRemoved",c),b.apply(function(){a.remove("pages",c,!0)})}),this.socket.on("pageAdded",function(c){d.debug("websocketApi","pageAdded",c),b.apply(function(){a.add("pages",c,!0)})}),this.socket.on("pageOrderChanged",function(a){d.debug("websocketApi","pageOrderChanged",a)}),this.socket.on("groupChanged",function(c){d.debug("websocketApi","groupChanged",c),b.apply(function(){a.update("groups",c,!0)})}),this.socket.on("groupRemoved",function(c){d.debug("websocketApi","groupRemoved",c),b.apply(function(){a.remove("groups",c,!0)})}),this.socket.on("groupAdded",function(c){d.debug("websocketApi","groupAdded",c),b.apply(function(){a.add("groups",c,!0)})}),this.socket.on("groupOrderChanged",function(a){d.debug("websocketApi","groupOrderChanged",a)}),this.socket.on("ruleChanged",function(c){d.debug("websocketApi","ruleChanged",c),b.apply(function(){a.update("rules",c,!0)})}),this.socket.on("ruleAdded",function(c){d.debug("websocketApi","ruleAdded",c),b.apply(function(){a.add("rules",c,!0)})}),this.socket.on("ruleRemoved",function(c){d.debug("websocketApi","ruleRemoved",c),b.apply(function(){a.remove("rules",c,!0)})}),this.socket.on("ruleOrderChanged",function(a){d.debug("websocketApi","ruleOrderChanged",a)}),this.socket.on("variableChanged",function(c){d.debug("websocketApi","variableChanged",c),b.apply(function(){a.update("variables",c,!0)})}),this.socket.on("variableAdded",function(c){d.debug("websocketApi","variableAdded",c),b.apply(function(){a.add("variables",c,!0)})}),this.socket.on("variableRemoved",function(c){d.debug("websocketApi","variableRemoved",c),b.apply(function(){a.remove("variables",c,!0)})}),this.socket.on("variableOrderChanged",function(a){d.debug("websocketApi","variableOrderChanged",a)}),this.socket.on("updateProcessStatus",function(a){d.debug("websocketApi","updateProcessStatus",a)}),this.socket.on("updateProcessMessage",function(a){d.debug("websocketApi","updateProcessMessage",a)}),this.socket.on("messageLogged",function(a){d.debug("websocketApi","messageLogged",a),"debug"!=a.level&&g.show(a.msg)})},login:function(c,d,e){return b(function(b,g){var h={username:c,password:d};e&&(h.rememberMe=!0),a.post(f.pimaticHost+"/login",h).success(function(a){a.success?b({username:a.username,rememberMe:a.rememberMe,role:a.role}):g(a.message)}).error(function(a){g(a.message)})})},logout:function(){return b(function(b){a.get(f.pimaticHost+"/logout").success(function(){b()}).error(function(){b()})})},handleIncomingData:function(a,b){a in h&&"promises"in h[a]?(angular.forEach(h[a].promises,function(a){a.resolve(b)}),delete h[a]):(h[a]={},h[a].data=b)},deviceAction:function(c,d,e){var g=this;return b(function(b,h){var i=f.pimaticHost+"/api/device/"+c+"/"+d;!angular.isUndefined(e)&&angular.isObject(e)&&(i+="?"+g.toQueryString(e)),a.get(i).success(function(a){a.success?b():h()}).error(function(){h()})})},add:function(c,d){return b(function(b,e){var g=i[c],h={};h[g]=d,a.post(f.pimaticHost+"/api/"+c+"/"+d.id,h).then(function(a){b(a[g])},function(a){e(a.message)})})},update:function(c,d){return b(function(b,e){var g=i[c],h={};h[g]=d,a.patch(f.pimaticHost+"/api/"+c+"/"+d.id,h).then(function(a){b(a[g])},function(a){e(a.message)})})},remove:function(c,d){return b(function(b,e){a["delete"](f.pimaticHost+"/api/"+c+"/"+d.id).then(function(a){b(a.removed)},function(a){e(a.message)})})},load:function(a){var c,d;return a in h&&"data"in h[a]?(c=b(function(b){b(h[a].data)}),delete h[a],c):(d=b.defer(),angular.isUndefined(h[a])&&(h[a]={}),angular.isUndefined(h[a].promises)&&(h[a].promises=[]),h[a].promises.push(d),d.promise)}})}]),angular.module("pimaticApp.services").factory("auth",["store","$injector","$location","$q",function(a,b,c,d){var e={store:a,isLoggedIn:function(){return null!==a.getUser()},login:function(b,c,e){var f=this;return d(function(d,g){f.store.adapter.login(b,c,e).then(function(b){a.reload(),a.setUser(b),d(b)},g)})},logout:function(){var b=this;return d(function(c,d){b.store.adapter.logout().then(function(){a.setUser(null),a.reset(),c()},d)})}};return e}]),angular.module("pimaticApp.services").factory("events",["toast",function(a){return{onDeviceActionDone:function(b,c){a.show('Succesfully performed "'+c+'" on '+b.id)},onDeviceActionFail:function(b,c){a.error('Failed to perform "'+c+'" on '+b.id)}}}]),angular.module("pimaticApp.services").provider("store",function(){var a=this;this.$get=["$q","$log","$injector","config",function(b,c,d,e){return a.store.$q=b,a.store.$log=c,a.store.adapter=d.get(e.adapterName),a.store}],this.store={adapter:null,store:{},reset:function(){this.$log.debug("=== STORE RESET ==="),this.store={user:{timestamp:0,loading:!1,data:null},devices:{timestamp:0,loading:!1,data:[]},groups:{timestamp:0,loading:!1,data:[]},pages:{timestamp:0,loading:!1,data:[]},rules:{timestamp:0,loading:!1,data:[]},variables:{timestamp:0,loading:!1,data:[]}},this.adapter.setStore(this)},reload:function(){this.reset(),this.adapter.start()},isLoading:function(a){return this.store[a].loading},getUser:function(){return this.store.user.data},setUser:function(a){this.store.user.data=a},get:function(a,b,c){var d,e,f=this;return a in f.store?(0!==f.store[a].timestamp||f.store[a].loading||(f.store[a].loading=!0,c||f.adapter.load(a).then(function(b){f.store[a].data=b,e=new Date,f.store[a].timestamp=e.getTime(),f.store[a].loading=!1},function(){f.store[a].loading=!1})),angular.isUndefined(b)?f.store[a].data:(d=null,angular.forEach(f.store[a].data,function(a){a.id==b&&(d=a)}),d)):angular.isUndefined(b)?[]:null},add:function(a,b,c){var d,e=this.adapter,f=this;return this.$log.debug("store","add()","type=",a,"object=",b,"skipApi=",c),d=function(){var d=f.get(a,b.id,c);return null===d?f.$q(function(d){f.get(a,void 0,c).push(b),d(b)}):f.update(a,b,c)},f.$q(function(f,g){c?d(b).then(function(a){f(a)}):e.add(a,b).then(function(a){d(a).then(function(a){f(a)})},function(a){g(a)})})},update:function(a,b,c){var d=this.adapter,e=this;return this.$log.debug("store","update()","type=",a,"object=",b,"skipApi=",c),e.$q(function(f,g){var h=e.get(a,b.id);return null===h?void g("Fatal: update called, but object does not exist"):void(c?(angular.merge(h,b),f(h)):d.update(a,b).then(function(a){angular.merge(h,a),f(h)},function(a){g(a)}))})},remove:function(a,b,c){var d,e=this;return this.$log.debug("store","remove()","type=",a,"object=",b,"skipApi=",c),a in e.store?(d=function(){var c=-1;angular.forEach(e.store[a].data,function(a,d){c=a.id==b.id?d:c}),c>=0&&e.store[a].data.splice(c,1)},e.$q(function(f,g){c?(d(b),f(b)):e.adapter.remove(a,b).then(function(a){d(b),f(a)},function(a){g(a)})})):e.$q(function(a,b){b("Type is not valid")})}}}),angular.module("pimaticApp.services").factory("toast",["$mdToast",function(a){return{show:function(b){a.show(a.simple().content(b))},error:function(b){a.show(a.simple().content(b))}}}]),angular.module("pimaticApp.services").factory("utils",["store",function(a){return{getUngroupedDeviceIds:function(){var b=a.get("groups"),c=a.get("devices"),d=[];return angular.forEach(c,function(a){d.push(a.id)}),angular.forEach(b,function(a){angular.forEach(a.devices,function(a){var b=d.indexOf(a);b>=0&&d.splice(b,1)})}),d}}}]),angular.module("pimaticApp").filter("elapsed",function(){return function(a){var b,c,d;return b=Math.floor(a/3600),c=b>9?b:"0"+b,a-=3600*b,d=Math.floor(a/60),c+=":"+(d>9?d:"0"+d),a-=60*d,c+=":"+(a>9?a:"0"+a)}}),angular.module("pimaticApp").filter("extract",function(){return function(a,b){return a.map(function(a){return a[b]})}}),angular.module("pimaticApp").filter("intersect",function(){return function(a,b){return a.filter(function(a){return b.indexOf(a)!=-1})}}),angular.module("pimaticApp").controller("ApplicationController",["$scope","$mdSidenav","$mdMedia","auth","config",function(a,b,c,d,e){a.auth=d,a.config=e,a.$mdMedia=c,a.toggleMenu=function(){b("left").toggle()},a.logout=function(){a.toggleMenu(),d.logout().then(function(){a.setState("unauthenticated")})}}]),angular.module("pimaticApp.devices").controller("ButtonsController",["$scope","store","events",function(a,b,c){a.buttonPressed=function(d){var e="buttonPressed";b.adapter.deviceAction(a.device.id,e,{buttonId:d.id}).then(function(){c.onDeviceActionDone(a.device,e)},function(){c.onDeviceActionFail(a.device,e)})}}]),angular.module("pimaticApp.devices").controller("DimmerController",["$scope","store","events",function(a,b,c){a.updateDimlevel=function(d){var e="changeDimlevelTo";b.adapter.deviceAction(a.device.id,e,{dimlevel:d.value}).then(function(){c.onDeviceActionDone(a.device,e,{dimlevel:d.value})},function(){c.onDeviceActionFail(a.device,e,{dimlevel:d.value}),d.value=!d.value})}}]),angular.module("pimaticApp.devices").controller("ShutterController",["$scope","store","events",function(a,b,c){a.moveUp=function(){var d=a.getAttribute("position"),e="up"==d.value?"stop":"moveUp";b.adapter.deviceAction(a.device.id,e).then(function(){c.onDeviceActionDone(a.device,e)},function(){c.onDeviceActionFail(a.device,e)})},a.moveDown=function(){var d=a.getAttribute("position"),e="down"==d.value?"stop":"moveDown";b.adapter.deviceAction(a.device.id,e).then(function(){c.onDeviceActionDone(a.device,e)},function(){c.onDeviceActionFail(a.device,e)})}}]),angular.module("pimaticApp.devices").controller("SwitchController",["$scope","store","events",function(a,b,c){a.updateValue=function(d){var e=d.value?"turnOn":"turnOff";b.adapter.deviceAction(a.device.id,e).then(function(){c.onDeviceActionDone(a.device,e)},function(){d.value=!d.value,c.onDeviceActionFail(a.device,e)})}}]),angular.module("pimaticApp.devices").controller("ThermostatController",["$scope","store","events","mdThemeColors",function(a,b,c,d){a.themeColors=d,a.up=function(){a.setTemperatureSetpoint(a.getAttribute("temperatureSetpoint").value+.5)},a.down=function(){a.setTemperatureSetpoint(a.getAttribute("temperatureSetpoint").value-.5)},a.setTemperatureSetpoint=function(d){var e="changeTemperatureTo";b.adapter.deviceAction(a.device.id,e,{temperatureSetpoint:d}).then(function(){c.onDeviceActionDone(a.device,e)},function(){c.onDeviceActionFail(a.device,e)})},a.setMode=function(d){var e="changeModeTo";b.adapter.deviceAction(a.device.id,e,{mode:d}).then(function(){c.onDeviceActionDone(a.device,e)},function(){c.onDeviceActionFail(a.device,e)})},a.preset=function(b){var c=a.getConfig(b,!1);angular.isNumber(c)&&a.setTemperatureSetpoint(c)}}]),angular.module("pimaticApp.devices").controller("TimerController",["$scope","store","events",function(a,b,c){a.start=function(){var d="startTimer";b.adapter.deviceAction(a.device.id,d).then(function(){c.onDeviceActionDone(a.device,d)},function(){c.onDeviceActionFail(a.device,d)})},a.stop=function(){var d="stopTimer";b.adapter.deviceAction(a.device.id,d).then(function(){c.onDeviceActionDone(a.device,d)},function(){c.onDeviceActionFail(a.device,d)})},a.reset=function(){var d="resetTimer";b.adapter.deviceAction(a.device.id,d).then(function(){c.onDeviceActionDone(a.device,d)},function(){c.onDeviceActionFail(a.device,d)})}}]),angular.module("pimaticApp").controller("HomeController",["$scope","$filter","utils","store",function(a,b,c,d){a.selectedTab=0,a.getUngroupedDeviceIds=c.getUngroupedDeviceIds,a.getDeviceIds=function(c,d){return angular.isUndefined(d)?b("intersect")(b("extract")(c.devices,"deviceId"),a.getUngroupedDeviceIds()):b("intersect")(b("extract")(c.devices,"deviceId"),d.devices)},a.getPages=function(){return d.get("pages")},a.getGroups=function(){return d.get("groups")},a.getDevice=function(a){return d.get("devices",a)}}]),angular.module("pimaticApp").controller("LoginController",["$scope","auth",function(a,b){null!==b.user&&a.setState("done"),a.form={},a.login=function(){a.form.message=null,a.form.busy=!0,b.login(a.form.username,a.form.password,a.form.rememberMe).then(function(){a.form.busy=!1,a.setState("done")},function(b){a.form.message=b,a.form.busy=!1})}}]),angular.module("pimaticApp.settings").controller("DevicesController",["$scope","utils","store",function(a,b,c){a.getUngroupedDeviceIds=b.getUngroupedDeviceIds,a.getGroups=function(){return c.get("groups")},a.getDevice=function(a){return c.get("devices",a)}}]),angular.module("pimaticApp.settings").controller("GroupsCreateController",["$scope","$location","toast","store",function(a,b,c,d){a.group={},a.cancel=function(a){a.preventDefault(),b.path("settings/groups")},a.save=function(){d.add("groups",a.group).then(function(){b.path("settings/groups")},function(a){c.error("Saving group failed: "+a)})}}]),angular.module("pimaticApp.settings").controller("GroupsEditController",["$scope","$location","$routeParams","$mdDialog","toast","store",function(a,b,c,d,e,f){a.group=angular.copy(f.get("groups",c.id)),null===a.group&&b.path("settings/groups"),a.cancel=function(a){a.preventDefault(),b.path("settings/groups")},a["delete"]=function(c){var g;c.preventDefault(),g=d.confirm().title("Are you sure you want to delete this group?").content(a.group.id).ariaLabel("Delete group").ok("Yes").cancel("No").targetEvent(c),d.show(g).then(function(){f.remove("groups",a.group).then(function(){b.path("settings/groups")},function(a){e.error("Deleting group failed: "+a)})})},a.save=function(){f.update("groups",a.group).then(function(){b.path("settings/groups")},function(a){e.error("Saving group failed: "+a)})}}]),angular.module("pimaticApp.settings").controller("GroupsController",["$scope","$location","store",function(a,b,c){a.edit=function(a){b.path("settings/groups/"+a)},a.getGroups=function(){return c.get("groups")}}]),angular.module("pimaticApp").directive("attributeValue",function(){return{scope:{attribute:"=",useName:"="},template:'<div layout="row"><div flex layout="row" layout-align="start center" class="md-body-1">{{useName ? attribute.name : attribute.label}}</div><div><span>{{attribute.value}} {{attribute.unit}}</span></div></div>'}}),angular.module("pimaticApp").directive("deviceCard",function(){return{scope:{device:"="},template:"<ng-include src=\"'partials/devices/' + device.template + '.html'\"></ng-include>",controller:["$scope",function(a){a.getAttribute=function(b){var c=null;return angular.forEach(a.device.attributes,function(a){a.name==b&&(c=a)}),c},a.getConfig=function(b,c){return b in a.device.config?a.device.config[b]:b in a.device.configDefaults?a.device.configDefaults[b]:c}}]}}),angular.module("pimaticApp").directive("pimaticTouchend",function(){return function(a,b,c){b.on("touchend",function(){a.$apply(function(){a.$eval(c.pimaticTouchend)})})}}),angular.module("pimaticApp").run(["$rootScope","$location","$injector","$log","store","auth",function(a,b,c,d,e,f){a.state="starting",a.redirectedFrom=null,a.setState=function(c){a.state=c,"done"!=c&&"unauthenticated"!=c||(angular.isUndefined(a.redirectedFrom)||null===a.redirectedFrom?(d.debug("New state:",c,"Redirecting to ","unauthenticated"==c?"/login":"/home"),b.path("unauthenticated"==c?"/login":"/home")):(b.path(a.redirectedFrom),d.debug("New state:",c,"Redirecting to ",a.redirectedFrom),a.redirectedFrom=null))},a.$on("$routeChangeStart",function(c,e){"starting"==a.state?"/loading"!=e.originalPath&&(d.debug("App","Application is loading, redirecting to the loading page"),a.redirectedFrom=e.originalPath,b.path("/loading")):f.isLoggedIn()||"/login"!==e.originalPath&&(d.debug("pimaticApp","Redirecting to login..."),a.redirectedFrom=e.originalPath,b.path("/login"))})}]),angular.module("pimaticApp").run(["store",function(a){a.reload()}]);