| 1 |
var ola=angular.module("olaApp",["ngRoute"]);ola.config(["$locationProvider",function(a){"use strict";a.hashPrefix("")}]),ola.config(["$routeProvider",function(a){"use strict";a.when("/",{templateUrl:"/new/views/overview.html",controller:"overviewCtrl"}).when("/universes/",{templateUrl:"/new/views/universes.html",controller:"overviewCtrl"}).when("/universe/add",{templateUrl:"/new/views/universe-add.html",controller:"addUniverseCtrl"}).when("/universe/:id",{templateUrl:"/new/views/universe-overview.html",controller:"universeCtrl"}).when("/universe/:id/keypad",{templateUrl:"/new/views/universe-keypad.html",controller:"keypadUniverseCtrl"}).when("/universe/:id/faders",{templateUrl:"/new/views/universe-faders.html",controller:"faderUniverseCtrl"}).when("/universe/:id/rdm",{templateUrl:"/new/views/universe-rdm.html",controller:"rdmUniverseCtrl"}).when("/universe/:id/patch",{templateUrl:"/new/views/universe-patch.html",controller:"patchUniverseCtrl"}).when("/universe/:id/settings",{templateUrl:"/new/views/universe-settings.html",controller:"settingUniverseCtrl"}).when("/plugins",{templateUrl:"/new/views/plugins.html",controller:"pluginsCtrl"}).when("/plugin/:id",{templateUrl:"/new/views/plugin-info.html",controller:"pluginInfoCtrl"}).otherwise({redirectTo:"/"})}]),ola.controller("menuCtrl",["$scope","$ola","$interval","$location",function(a,b,c,d){"use strict";a.Items={},a.Info={},a.goTo=function(a){d.path(a)};var e=function(){b.get.ItemList().then(function(b){a.Items=b}),b.get.ServerInfo().then(function(b){a.Info=b,document.title=b.instance_name+" - "+b.ip})};e(),c(e,1e4)}]),ola.controller("patchUniverseCtrl",["$scope","$ola","$routeParams",function(a,b,c){"use strict";a.Universe=c.id}]),ola.controller("rdmUniverseCtrl",["$scope","$ola","$routeParams",function(a,b,c){"use strict";a.Universe=c.id}]),ola.controller("universeCtrl",["$scope","$ola","$routeParams","$interval","OLA",function(a,b,c,d,e){"use strict";a.dmx=[],a.Universe=c.id;var f=d(function(){b.get.Dmx(a.Universe).then(function(b){for(var c=0;c<e.MAX_CHANNEL_NUMBER;c++)a.dmx[c]="number"==typeof b.dmx[c]?b.dmx[c]:e.MIN_CHANNEL_VALUE})},100);a.$on("$destroy",function(){d.cancel(f)}),a.getColor=function(a){return a>140?"black":"white"}}]),ola.controller("faderUniverseCtrl",["$scope","$ola","$routeParams","$window","$interval","OLA",function(a,b,c,d,e,f){"use strict";a.get=[],a.list=[],a.last=0,a.offset=0,a.send=!1,a.OLA=f,a.Universe=c.id;for(var g=0;g<f.MAX_CHANNEL_NUMBER;g++)a.list[g]=g,a.get[g]=f.MIN_CHANNEL_VALUE;a.light=function(b){for(var c=0;c<f.MAX_CHANNEL_NUMBER;c++)a.get[c]=b;a.change()};var h=e(function(){b.get.Dmx(a.Universe).then(function(b){for(var c=0;c<f.MAX_CHANNEL_NUMBER;c++)c<b.dmx.length?a.get[c]=b.dmx[c]:a.get[c]=f.MIN_CHANNEL_VALUE;a.send=!0})},1e3);a.getColor=function(a){return a>140?"black":"white"},a.ceil=function(a){return d.Math.ceil(a)},a.change=function(){b.post.Dmx(a.Universe,a.get)},a.page=function(b){if(1===b){var c=d.Math.ceil(f.MAX_CHANNEL_NUMBER/a.limit);a.offset+1!==c&&a.offset++}else b===f.MIN_CHANNEL_VALUE&&a.offset!==f.MIN_CHANNEL_VALUE&&a.offset--},a.getWidth=function(){return d.Math.floor(.99*d.innerWidth/a.limit)-52/a.limit+"px"},a.getLimit=function(){var a=.99*d.innerWidth/66;return d.Math.floor(a)},a.limit=a.getLimit(),a.width={width:a.getWidth()},d.$(d).resize(function(){a.$apply(function(){a.limit=a.getLimit(),a.width={width:a.getWidth()}})}),a.$on("$destroy",function(){e.cancel(h)})}]),ola.controller("keypadUniverseCtrl",["$scope","$ola","$routeParams","OLA",function(a,b,c,d){"use strict";a.Universe=c.id;var e;e=/^(?:([0-9]{1,3})(?:\s(THRU)\s(?:([0-9]{1,3}))?)?(?:\s(@)\s(?:([0-9]{1,3}|FULL))?)?)/;var f={channelValue:function(a){return d.MIN_CHANNEL_VALUE<=a&&a<=d.MAX_CHANNEL_VALUE},channelNumber:function(a){return d.MIN_CHANNEL_NUMBER<=a&&a<=d.MAX_CHANNEL_NUMBER},regexGroups:function(a){if(void 0!==a[1]){if(!this.channelNumber(parseInt(a[1],10)))return!1}if(void 0!==a[3]){if(!this.channelNumber(parseInt(a[3],10)))return!1}if(void 0!==a[5]&&"FULL"!==a[5]){if(!this.channelValue(parseInt(a[5],10)))return!1}return!0}};a.field="",a.input=function(b){var c;c="backspace"===b?a.field.substr(0,a.field.length-1):a.field+b;var d=e.exec(c);null===d?a.field="":f.regexGroups(d)&&(a.field=d[0])},a.submit=function(){var c=[],g=a.field,h=e.exec(g);if(null!==h&&f.regexGroups(h)){var i=parseInt(h[1],10),j=h[3]?parseInt(h[3],10):parseInt(h[1],10),k="FULL"===h[5]?d.MAX_CHANNEL_VALUE:parseInt(h[5],10);return!!(i<=j&&f.channelValue(k))&&(b.get.Dmx(a.Universe).then(function(e){for(var f=0;f<d.MAX_CHANNEL_NUMBER;f++)f<e.dmx.length?c[f]=e.dmx[f]:c[f]=d.MIN_CHANNEL_VALUE;for(var g=i;g<=j;g++)c[g-1]=k;b.post.Dmx(a.Universe,c),a.field=""}),!0)}return!1}}]),ola.controller("pluginsCtrl",["$scope","$ola","$location",function(a,b,c){"use strict";a.Items={},a.active=[],a.enabled=[],a.getInfo=function(){b.get.ItemList().then(function(b){a.Items=b})},a.getInfo(),a.Reload=function(){b.action.Reload(),a.getInfo()},a.go=function(a){c.path("/plugin/"+a)},a.changeStatus=function(c,d){b.post.PluginState(c,d),a.getInfo()},a.getStyle=function(a){return a?{"background-color":"green"}:{"background-color":"red"}}}]),ola.controller("addUniverseCtrl",["$scope","$ola","$window","$location",function(a,b,c,d){"use strict";a.Ports={},a.addPorts=[],a.Universes=[],a.Class="",a.Data={id:0,name:"",add_ports:""},b.get.ItemList().then(function(b){for(var c in b.universes)b.universes.hasOwnProperty(c)&&(a.Data.id===parseInt(b.universes[c].id,10)&&a.Data.id++,a.Universes.push(parseInt(b.universes[c].id,10)))}),a.Submit=function(){"number"==typeof a.Data.id&&""!==a.Data.add_ports&&-1===a.Universes.indexOf(a.Data.id)?(void 0!==a.Data.name&&""!==a.Data.name||(a.Data.name="Universe "+a.Data.id),b.post.AddUniverse(a.Data),d.path("/universe/"+a.Data.id)):-1!==a.Universes.indexOf(a.Data.id)?b.error.modal("Universe ID already exists."):void 0!==a.Data.add_ports&&""!==a.Data.add_ports||b.error.modal("There are no ports selected for the universe. This is required.")},b.get.Ports().then(function(b){a.Ports=b}),a.getDirection=function(a){return a?"Output":"Input"},a.updateId=function(){-1!==a.Universes.indexOf(a.Data.id)?a.Class="has-error":a.Class=""},a.TogglePort=function(){a.Data.add_ports=c.$.grep(a.addPorts,Boolean).join(",")}}]),ola.controller("pluginInfoCtrl",["$scope","$routeParams","$ola",function(a,b,c){"use strict";c.get.InfoPlugin(b.id).then(function(b){a.active=b.active,a.enabled=b.enabled,a.name=b.name;var c=document.getElementById("description");c.textContent=b.description,c.innerHTML=c.innerHTML.replace(/\\n/g,"<br />")}),a.stateColor=function(a){return a?{"background-color":"green"}:{"background-color":"red"}}}]),ola.controller("settingUniverseCtrl",["$scope","$ola","$routeParams",function(a,b,c){"use strict";a.loadData=function(){a.Data={old:{},model:{},Remove:[],Add:[]},a.Data.old.id=a.Data.model.id=c.id,b.get.PortsId(c.id).then(function(b){a.DeactivePorts=b}),b.get.UniverseInfo(c.id).then(function(b){a.Data.old.name=a.Data.model.name=b.name,a.Data.old.merge_mode=b.merge_mode,a.Data.model.merge_mode=b.merge_mode,a.ActivePorts=b.output_ports.concat(b.input_ports),a.Data.old.ActivePorts=b.output_ports.concat(b.input_ports);for(var c=0;c<a.ActivePorts.length;++c)a.Data.Remove[c]=""})},a.loadData(),a.Save=function(){var c={};c.id=a.Data.model.id,c.name=a.Data.model.name,c.merge_mode=a.Data.model.merge_mode,c.add_ports=$.grep(a.Data.Add,Boolean).join(","),c.remove_ports=$.grep(a.Data.Remove,Boolean).join(",");var d=[];a.ActivePorts.forEach(function(b,e){if(-1===a.Data.Remove.indexOf(a.ActivePorts[e].id)){var f=a.ActivePorts[e],g=a.Data.old.ActivePorts[e];"static"===f.priority.current_mode&&0<f.priority.value<100&&(c[f.id+"_priority_value"]=f.priority.value,-1===d.indexOf(f.id)&&d.push(f.id)),g.priority.current_mode!==f.priority.current_mode&&(c[f.id+"_priority_mode"]=f.priority.current_mode,-1===d.indexOf(f.id)&&d.push(f.id))}}),c.modify_ports=$.grep(d,Boolean).join(","),b.post.ModifyUniverse(c),a.loadData()}}]),ola.controller("headerControl",["$scope","$ola","$routeParams","$window",function(a,b,c,d){"use strict";a.header={tab:"",id:c.id,name:""},b.get.UniverseInfo(c.id).then(function(b){a.header.name=b.name});var e=d.location.hash;a.header.tab=e.replace(/#\/universe\/[0-9]+\/?/,"")}]),ola.controller("overviewCtrl",["$scope","$ola","$location",function(a,b,c){"use strict";a.Info={},a.Universes={},b.get.ItemList().then(function(b){a.Universes=b.universes}),b.get.ServerInfo().then(function(b){a.Info=b}),a.Shutdown=function(){b.action.Shutdown().then()},a.goUniverse=function(a){c.path("/universe/"+a)}}]),ola.constant("OLA",{MIN_CHANNEL_NUMBER:1,MAX_CHANNEL_NUMBER:512,MIN_CHANNEL_VALUE:0,MAX_CHANNEL_VALUE:255}),ola.factory("$ola",["$http","$window","OLA",function(a,b,c){"use strict";var d=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&("d"===c||"remove_ports"===c||"modify_ports"===c||"add_ports"===c?b.push(c+"="+a[c]):b.push(c+"="+encodeURIComponent(a[c])));return b.join("&")},e=function(a){return a=parseInt(a,10),a<c.MIN_CHANNEL_VALUE?a=c.MIN_CHANNEL_VALUE:a>c.MAX_CHANNEL_VALUE&&(a=c.MAX_CHANNEL_VALUE),a},f=function(a){for(var b=!0,d=[],f=c.MAX_CHANNEL_NUMBER;f>=c.MIN_CHANNEL_NUMBER;f--){var g=e(a[f-1]);(g>c.MIN_CHANNEL_VALUE||!b||f===c.MIN_CHANNEL_NUMBER)&&(d[f-1]=g,b=!1)}return d.join(",")};return{get:{ItemList:function(){return a.get("/json/universe_plugin_list").then(function(a){return a.data})},ServerInfo:function(){return a.get("/json/server_stats").then(function(a){return a.data})},Ports:function(){return a.get("/json/get_ports").then(function(a){return a.data})},PortsId:function(b){return a({method:"GET",url:"/json/get_ports",params:{id:b}}).then(function(a){return a.data})},InfoPlugin:function(b){return a({method:"GET",url:"/json/plugin_info",params:{id:b}}).then(function(a){return a.data})},Dmx:function(b){return a({method:"GET",url:"/get_dmx",params:{u:b}}).then(function(a){return a.data})},UniverseInfo:function(b){return a({method:"GET",url:"/json/universe_info",params:{id:b}}).then(function(a){return a.data})}},post:{ModifyUniverse:function(b){return a({method:"POST",url:"/modify_universe",data:d(b),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(a){return a.data})},AddUniverse:function(b){return a({method:"POST",url:"/new_universe",data:d(b),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(a){return a.data})},Dmx:function(b,c){var e={u:b,d:f(c)};return a({method:"POST",url:"/set_dmx",data:d(e),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(a){return a.data})},PluginState:function(b,c){return a({method:"POST",url:"/set_plugin_state",data:d({state:c,plugin_id:b}),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(a){return a.data})}},action:{Shutdown:function(){return a.get("/quit").then(function(a){return a.data})},Reload:function(){return a.get("/reload").then(function(a){return a.data})},ReloadPids:function(){return a.get("/reload_pids").then(function(a){return a.data})}},rdm:{GetSectionInfo:function(b,c,d){return a({method:"GET",url:"/json/rdm/section_info",params:{id:b,uid:c,section:d}}).then(function(a){return a.data})},SetSection:function(b,c,d,e,f){return a({method:"GET",url:"/json/rdm/set_section_info",params:{id:b,uid:c,section:d,hint:e,int:f}}).then(function(a){return a.data})},GetSupportedPids:function(b,c){return a({method:"GET",url:"/json/rdm/supported_pids",params:{id:b,uid:c}}).then(function(a){return a.data})},GetSupportedSections:function(b,c){return a({method:"GET",url:"/json/rdm/supported_sections",params:{id:b,uid:c}}).then(function(a){return a.data})},UidIdentifyDevice:function(b,c){return a({method:"GET",url:"/json/rdm/uid_identify_device",params:{id:b,uid:c}}).then(function(a){return a.data})},UidInfo:function(b,c){return a({method:"GET",url:"/json/rdm/uid_info",params:{id:b,uid:c}}).then(function(a){return a.data})},UidPersonalities:function(b,c){return a({method:"GET",url:"/json/rdm/uid_personalities",params:{id:b,uid:c}}).then(function(a){return a.data})},Uids:function(b){return a({method:"GET",url:"/json/rdm/uids",params:{id:b}}).then(function(a){return a.data})},RunDiscovery:function(b,c){return a({method:"GET",url:"/rdm/run_discovery",params:{id:b,incremental:c}}).then(function(a){return a.data})}},error:{modal:function(a,b){void 0!==a?$("#errorModalBody").text(a):$("#errorModalBody").text("There has been an error"),void 0!==b?$("#errorModalLabel").text(b):$("#errorModalLabel").text("Error"),$("#errorModal").modal("show")}}}}]),ola.filter("startFrom",function(){"use strict";return function(a,b){return b=parseInt(b,10),a.slice(b)}}); |