From 2743b5f9709396e69c1ed3265c7be5b32c356b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Mon, 21 Oct 2013 00:04:58 +0200 Subject: [PATCH] added angularJS Framework --- node/ip-poll.js | 27 ++- node/package.json | 3 +- node/public/css/style.css | 17 ++ node/public/js/app.js | 37 ++++ node/public/js/controllers.js | 24 +++ node/public/js/vendor/angular.min.js | 163 ++++++++++++++++++ node/public/js/{ => vendor}/autoload.js | 0 node/public/js/{ => vendor}/html5shiv.js | 0 node/public/js/{ => vendor}/ink-all.min.js | 0 node/public/js/{ => vendor}/ink-ui.min.js | 0 .../js/{ => vendor}/ink.formvalidator.js | 0 node/public/js/{ => vendor}/ink.min.js | 0 node/public/js/{ => vendor}/modernizr.js | 0 node/public/js/{ => vendor}/prettify.js | 0 node/public/style.css | 5 - node/routes/index.js | 43 +++++ node/snmp-mac.js | 1 + node/statusbot.js | 86 ++++----- node/views/index.jade | 13 +- node/views/layout.jade | 25 ++- 20 files changed, 365 insertions(+), 79 deletions(-) create mode 100644 node/public/css/style.css create mode 100644 node/public/js/app.js create mode 100644 node/public/js/controllers.js create mode 100644 node/public/js/vendor/angular.min.js rename node/public/js/{ => vendor}/autoload.js (100%) rename node/public/js/{ => vendor}/html5shiv.js (100%) rename node/public/js/{ => vendor}/ink-all.min.js (100%) rename node/public/js/{ => vendor}/ink-ui.min.js (100%) rename node/public/js/{ => vendor}/ink.formvalidator.js (100%) rename node/public/js/{ => vendor}/ink.min.js (100%) rename node/public/js/{ => vendor}/modernizr.js (100%) rename node/public/js/{ => vendor}/prettify.js (100%) delete mode 100644 node/public/style.css create mode 100644 node/routes/index.js diff --git a/node/ip-poll.js b/node/ip-poll.js index 5fee0bf..99c50d4 100644 --- a/node/ip-poll.js +++ b/node/ip-poll.js @@ -1,23 +1,40 @@ +var redis = require("redis"); var util = require('util'); var EventEmitter = require('events').EventEmitter; -var exec = require('child_process').exec +var exec = require('child_process').exec; + +var redisprefix = "ippoll:"; var IpPoll = function(switchaddr, hostsaddr) { var self = this; + var redisClient = redis.createClient(); + var regexp = /\(([0-9]+) hosts* up\)/; var nmap = "nmap -n -sP -T5 --host-timeout 10ms "; + + + redisClient.on("connect", function () { + //redisClient.set(redisprefix + "24:77:03:a9:f3:f4","lucas"); + + console.log("connected to redis"); + self.emit('ready'); + }); this.pollCount = function() { exec(nmap + "--min-hostgroup 10 " + hostsaddr, function (error, stdout, stderr) { if(error == null) { var matches = regexp.exec(stdout); if(matches != null && matches.length == 2) { - self.emit('doneCount', parseInt(matches[1])); + var num = parseInt(matches[1]); + + redisClient.zadd('onlinecount', Date.now(), num, function() { + self.emit('doneCount', num); + }); } } }); - } + }; this.pollState = function() { exec(nmap + switchaddr, function (error, stdout, stderr) { @@ -30,8 +47,8 @@ var IpPoll = function(switchaddr, hostsaddr) { self.emit('doneState', "unknown"); } }); - } -} + }; +}; util.inherits(IpPoll, EventEmitter); diff --git a/node/package.json b/node/package.json index 7db90b0..d6a337d 100644 --- a/node/package.json +++ b/node/package.json @@ -9,7 +9,8 @@ "net-snmp": "*", "redis": "*", "underscore": "*", - "jade": "*" + "jade": "*", + "socket.io": "*" }, "main": "index" } diff --git a/node/public/css/style.css b/node/public/css/style.css new file mode 100644 index 0000000..19948bc --- /dev/null +++ b/node/public/css/style.css @@ -0,0 +1,17 @@ +.status-icon { + width: 128px; + height: 128px; + display: block; +} + +.status-icon-false { + background-image: url("/img/red.png"); +} + +.status-icon-true { + background-image: url("/img/green.png"); +} + +.status-icon-unknown { + background-image: url("/img/yellow.png"); +} \ No newline at end of file diff --git a/node/public/js/app.js b/node/public/js/app.js new file mode 100644 index 0000000..e363263 --- /dev/null +++ b/node/public/js/app.js @@ -0,0 +1,37 @@ +'use strict'; + +angular.module('Services', []). + factory('Socket', function ($rootScope) { + var socket = io.connect(); + + return { + on: function(eventName, callback) { + socket.on(eventName, function() { + var args = arguments; + $rootScope.$apply(function() { + callback.apply(socket, args); + }); + }); + }, + emit: function(eventName, data, callback) { + if(typeof data == 'function') { + callback = data; + data = {}; + } + socket.emit(eventName, data, function() { + var args = arguments; + $rootScope.$apply(function() { + if(callback) { + callback.apply(socket, args); + } + }); + }); + }, + emitAndListen: function(eventName, data, callback) { + this.emit(eventName, data, callback); + this.on(eventName, callback); + } + }; + }); + +angular.module('roomstateapp', ['roomstateapp.controllers', 'Services']); \ No newline at end of file diff --git a/node/public/js/controllers.js b/node/public/js/controllers.js new file mode 100644 index 0000000..dd65a0f --- /dev/null +++ b/node/public/js/controllers.js @@ -0,0 +1,24 @@ +'use strict'; + + +angular.module('roomstateapp.controllers', []). + controller('StatusCtrl', function ($scope, $http, Socket) { + + $http({ + method: 'GET', + url: '/api/simple/v2' + }). + success(function (data, status, headers, config) { + $scope.simple = data; + }). + error(function (data, status, headers, config) { + //$scope.name = 'Error!' + console.log("error getting data"); + }); + + Socket.on('sdata', function(message) { + console.log("received data from server: " + message.data.names); + $scope.simple = message.data; + }); + + }); diff --git a/node/public/js/vendor/angular.min.js b/node/public/js/vendor/angular.min.js new file mode 100644 index 0000000..4ae11c8 --- /dev/null +++ b/node/public/js/vendor/angular.min.js @@ -0,0 +1,163 @@ +/* + AngularJS v1.0.8 + (c) 2010-2012 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(P,T,q){'use strict';function m(b,a,c){var d;if(b)if(H(b))for(d in b)d!="prototype"&&d!="length"&&d!="name"&&b.hasOwnProperty(d)&&a.call(c,b[d],d);else if(b.forEach&&b.forEach!==m)b.forEach(a,c);else if(!b||typeof b.length!=="number"?0:typeof b.hasOwnProperty!="function"&&typeof b.constructor!="function"||b instanceof L||aa&&b instanceof aa||ma.call(b)!=="[object Object]"||typeof b.callee==="function")for(d=0;d=0&&b.splice(c,1);return a}function U(b,a){if(pa(b)||b&&b.$evalAsync&&b.$watch)throw Error("Can't copy Window or Scope");if(a){if(b===a)throw Error("Can't copy equivalent objects or arrays");if(E(b))for(var c=a.length=0;c2?ha.call(arguments,2):[];return H(a)&&!(a instanceof RegExp)?c.length?function(){return arguments.length?a.apply(b,c.concat(ha.call(arguments,0))):a.apply(b,c)}:function(){return arguments.length?a.apply(b,arguments):a.call(b)}:a}function kc(b,a){var c=a;/^\$+/.test(b)?c=q:pa(a)?c="$WINDOW":a&&T===a?c="$DOCUMENT":a&&a.$evalAsync&& +a.$watch&&(c="$SCOPE");return c}function ba(b,a){return typeof b==="undefined"?q:JSON.stringify(b,kc,a?" ":null)}function qb(b){return B(b)?JSON.parse(b):b}function Wa(b){b&&b.length!==0?(b=y(""+b),b=!(b=="f"||b=="0"||b=="false"||b=="no"||b=="n"||b=="[]")):b=!1;return b}function qa(b){b=w(b).clone();try{b.html("")}catch(a){}var c=w("
").append(b).html();try{return b[0].nodeType===3?y(c):c.match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/,function(a,b){return"<"+y(b)})}catch(d){return y(c)}}function rb(b){try{return decodeURIComponent(b)}catch(a){}} +function Xa(b){var a={},c,d;m((b||"").split("&"),function(b){b&&(c=b.split("="),d=rb(c[0]),v(d)&&(a[d]=v(c[1])?rb(c[1]):!0))});return a}function sb(b){var a=[];m(b,function(b,d){a.push(Ya(d,!0)+(b===!0?"":"="+Ya(b,!0)))});return a.length?a.join("&"):""}function Za(b){return Ya(b,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function Ya(b,a){return encodeURIComponent(b).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,a?"%20":"+")} +function lc(b,a){function c(a){a&&d.push(a)}var d=[b],e,g,h=["ng:app","ng-app","x-ng-app","data-ng-app"],f=/\sng[:\-]app(:\s*([\w\d_]+);?)?\s/;m(h,function(a){h[a]=!0;c(T.getElementById(a));a=a.replace(":","\\:");b.querySelectorAll&&(m(b.querySelectorAll("."+a),c),m(b.querySelectorAll("."+a+"\\:"),c),m(b.querySelectorAll("["+a+"]"),c))});m(d,function(a){if(!e){var b=f.exec(" "+a.className+" ");b?(e=a,g=(b[2]||"").replace(/\s+/g,",")):m(a.attributes,function(b){if(!e&&h[b.name])e=a,g=b.value})}}); +e&&a(e,g?[g]:[])}function tb(b,a){var c=function(){b=w(b);a=a||[];a.unshift(["$provide",function(a){a.value("$rootElement",b)}]);a.unshift("ng");var c=ub(a);c.invoke(["$rootScope","$rootElement","$compile","$injector",function(a,b,c,d){a.$apply(function(){b.data("$injector",d);c(b)(a)})}]);return c},d=/^NG_DEFER_BOOTSTRAP!/;if(P&&!d.test(P.name))return c();P.name=P.name.replace(d,"");$a.resumeBootstrap=function(b){m(b,function(b){a.push(b)});c()}}function ab(b,a){a=a||"_";return b.replace(mc,function(b, +d){return(d?a:"")+b.toLowerCase()})}function bb(b,a,c){if(!b)throw Error("Argument '"+(a||"?")+"' is "+(c||"required"));return b}function ra(b,a,c){c&&E(b)&&(b=b[b.length-1]);bb(H(b),a,"not a function, got "+(b&&typeof b=="object"?b.constructor.name||"Object":typeof b));return b}function cb(b,a,c){if(!a)return b;for(var a=a.split("."),d,e=b,g=a.length,h=0;h 
"+b;a.removeChild(a.firstChild);eb(this,a.childNodes);this.remove()}else eb(this,b)}function fb(b){return b.cloneNode(!0)}function sa(b){wb(b);for(var a=0,b=b.childNodes|| +[];a-1}function zb(b,a){a&&m(a.split(" "),function(a){b.className=S((" "+b.className+" ").replace(/[\n\t]/g," ").replace(" "+S(a)+" "," "))})}function Ab(b,a){a&&m(a.split(" "),function(a){if(!Ca(b,a))b.className=S(b.className+" "+S(a))})}function eb(b,a){if(a)for(var a=!a.nodeName&&v(a.length)&&!pa(a)?a:[a],c=0;c4096&&c.warn("Cookie '"+ +a+"' possibly not set or overflowed because it was too large ("+d+" > 4096 bytes)!")}else{if(i.cookie!==Q){Q=i.cookie;d=Q.split("; ");ga={};for(f=0;f0&&(a=unescape(e.substring(0,j)),ga[a]===q&&(ga[a]=unescape(e.substring(j+1))))}return ga}};f.defer=function(a,b){var c;p++;c=l(function(){delete o[c];e(a)},b||0);o[c]=!0;return c};f.defer.cancel=function(a){return o[a]?(delete o[a],n(a),e(s),!0):!1}}function zc(){this.$get=["$window","$log","$sniffer","$document", +function(b,a,c,d){return new xc(b,d,a,c)}]}function Ac(){this.$get=function(){function b(b,d){function e(a){if(a!=l){if(n){if(n==a)n=a.n}else n=a;g(a.n,a.p);g(a,l);l=a;l.n=null}}function g(a,b){if(a!=b){if(a)a.p=b;if(b)b.n=a}}if(b in a)throw Error("cacheId "+b+" taken");var h=0,f=D({},d,{id:b}),i={},j=d&&d.capacity||Number.MAX_VALUE,k={},l=null,n=null;return a[b]={put:function(a,b){var c=k[a]||(k[a]={key:a});e(c);u(b)||(a in i||h++,i[a]=b,h>j&&this.remove(n.key))},get:function(a){var b=k[a];if(b)return e(b), +i[a]},remove:function(a){var b=k[a];if(b){if(b==l)l=b.p;if(b==n)n=b.n;g(b.n,b.p);delete k[a];delete i[a];h--}},removeAll:function(){i={};h=0;k={};l=n=null},destroy:function(){k=f=i=null;delete a[b]},info:function(){return D({},f,{size:h})}}}var a={};b.info=function(){var b={};m(a,function(a,e){b[e]=a.info()});return b};b.get=function(b){return a[b]};return b}}function Bc(){this.$get=["$cacheFactory",function(b){return b("templates")}]}function Fb(b){var a={},c="Directive",d=/^\s*directive\:\s*([\d\w\-_]+)\s+(.*)$/, +e=/(([\d\w\-_]+)(?:\:([^;]+))?;?)/,g="Template must have exactly one root element. was: ",h=/^\s*(https?|ftp|mailto|file):/;this.directive=function i(d,e){B(d)?(bb(e,"directive"),a.hasOwnProperty(d)||(a[d]=[],b.factory(d+c,["$injector","$exceptionHandler",function(b,c){var e=[];m(a[d],function(a){try{var g=b.invoke(a);if(H(g))g={compile:I(g)};else if(!g.compile&&g.link)g.compile=I(g.link);g.priority=g.priority||0;g.name=g.name||d;g.require=g.require||g.controller&&g.name;g.restrict=g.restrict||"A"; +e.push(g)}catch(h){c(h)}});return e}])),a[d].push(e)):m(d,ob(i));return this};this.urlSanitizationWhitelist=function(a){return v(a)?(h=a,this):h};this.$get=["$injector","$interpolate","$exceptionHandler","$http","$templateCache","$parse","$controller","$rootScope","$document",function(b,j,k,l,n,o,p,z,r){function x(a,b,c){a instanceof w||(a=w(a));m(a,function(b,c){b.nodeType==3&&b.nodeValue.match(/\S+/)&&(a[c]=w(b).wrap("").parent()[0])});var d=A(a,b,a,c);return function(b,c){bb(b,"scope"); +for(var e=c?va.clone.call(a):a,g=0,j=e.length;g=8||i.specified)k=i.name,o=ca(k.toLowerCase()),j[o]=k,c[o]=i=S(V&&k=="href"?decodeURIComponent(a.getAttribute(k,2)):i.value),Cb(a,o)&&(c[o]=!0),R(a,b,i,o),C(b,o,"A",g);a=a.className;if(B(a)&&a!=="")for(;h=e.exec(a);)o=ca(h[2]),C(b,o,"C",g)&&(c[o]=S(h[3])),a=a.substr(h.index+h[0].length);break;case 3:Y(b,a.nodeValue);break;case 8:try{if(h=d.exec(a.nodeValue))o=ca(h[1]),C(b,o,"M",g)&&(c[o]=S(h[2]))}catch(n){}}b.sort(t);return b}function K(a,b,c,d,e){function j(a, +b){if(a)a.require=t.require,n.push(a);if(b)b.require=t.require,r.push(b)}function h(a,b){var c,d="data",e=!1;if(B(a)){for(;(c=a.charAt(0))=="^"||c=="?";)a=a.substr(1),c=="^"&&(d="inheritedData"),e=e||c=="?";c=b[d]("$"+a+"Controller");if(!c&&!e)throw Error("No controller: "+a);}else E(a)&&(c=[],m(a,function(a){c.push(h(a,b))}));return c}function i(a,d,e,g,j){var l,z,t,F,N;l=b===e?c:jc(c,new ia(w(e),c.$attr));z=l.$$element;if(K){var Cc=/^\s*([@=&])\s*(\w*)\s*$/,x=d.$parent||d;m(K.scope,function(a,b){var c= +a.match(Cc)||[],e=c[2]||b,c=c[1],g,j,h;d.$$isolateBindings[b]=c+e;switch(c){case "@":l.$observe(e,function(a){d[b]=a});l.$$observers[e].$$scope=x;break;case "=":j=o(l[e]);h=j.assign||function(){g=d[b]=j(x);throw Error(Gb+l[e]+" (directive: "+K.name+")");};g=d[b]=j(x);d.$watch(function(){var a=j(x);a!==d[b]&&(a!==g?g=d[b]=a:h(x,a=g=d[b]));return a});break;case "&":j=o(l[e]);d[b]=function(a){return j(x,a)};break;default:throw Error("Invalid isolate scope definition for directive "+K.name+": "+a);}})}Y&& +m(Y,function(a){var b={$scope:d,$element:z,$attrs:l,$transclude:j};N=a.controller;N=="@"&&(N=l[a.name]);z.data("$"+a.name+"Controller",p(N,b))});g=0;for(t=n.length;gt.priority)break; +if(u=t.scope)ua("isolated scope",K,t,F),M(u)&&(N(F,"ng-isolate-scope"),K=t),N(F,"ng-scope"),z=z||t;C=t.name;if(u=t.controller)Y=Y||{},ua("'"+C+"' controller",Y[C],t,F),Y[C]=t;if(u=t.transclude)ua("transclusion",ja,t,F),ja=t,l=t.priority,u=="element"?(R=w(b),F=c.$$element=w(T.createComment(" "+C+": "+c[C]+" ")),b=F[0],v(e,w(R[0]),b),da=x(R,d,l)):(R=w(fb(b)).contents(),F.html(""),da=x(R,d));if(u=t.template)if(ua("template",A,t,F),A=t,u=Hb(u),t.replace){R=w("
"+S(u)+"
").contents();b=R[0];if(R.length!= +1||b.nodeType!==1)throw Error(g+u);v(e,F,b);C={$attr:{}};a=a.concat(J(b,a.splice(D+1,a.length-(D+1)),C));ga(c,C);y=a.length}else F.html(u);if(t.templateUrl)ua("template",A,t,F),A=t,i=Q(a.splice(D,a.length-D),i,F,c,e,t.replace,da),y=a.length;else if(t.compile)try{s=t.compile(F,c,da),H(s)?j(null,s):s&&j(s.pre,s.post)}catch(G){k(G,qa(F))}if(t.terminal)i.terminal=!0,l=Math.max(l,t.priority)}i.scope=z&&z.scope;i.transclude=ja&&da;return i}function C(d,e,g,j){var h=!1;if(a.hasOwnProperty(e))for(var o,e= +b.get(e+c),l=0,p=e.length;lo.priority)&&o.restrict.indexOf(g)!=-1)d.push(o),h=!0}catch(n){k(n)}return h}function ga(a,b){var c=b.$attr,d=a.$attr,e=a.$$element;m(a,function(d,e){e.charAt(0)!="$"&&(b[e]&&(d+=(e==="style"?";":" ")+b[e]),a.$set(e,d,!0,c[e]))});m(b,function(b,g){g=="class"?(N(e,b),a["class"]=(a["class"]?a["class"]+" ":"")+b):g=="style"?e.attr("style",e.attr("style")+";"+b):g.charAt(0)!="$"&&!a.hasOwnProperty(g)&&(a[g]=b,d[g]=c[g])})}function Q(a,b,c,d,e, +j,h){var i=[],k,o,p=c[0],r=a.shift(),z=D({},r,{controller:null,templateUrl:null,transclude:null,scope:null});c.html("");l.get(r.templateUrl,{cache:n}).success(function(l){var n,r,l=Hb(l);if(j){r=w("
"+S(l)+"
").contents();n=r[0];if(r.length!=1||n.nodeType!==1)throw Error(g+l);l={$attr:{}};v(e,c,n);J(n,a,l);ga(d,l)}else n=p,c.html(l);a.unshift(z);k=K(a,n,d,h);for(o=A(c[0].childNodes,h);i.length;){var ia=i.pop(),l=i.pop();r=i.pop();var F=i.pop(),t=n;r!==p&&(t=fb(n),v(l,w(r),t));k(function(){b(o, +F,t,e,ia)},F,t,e,ia)}i=null}).error(function(a,b,c,d){throw Error("Failed to load template: "+d.url);});return function(a,c,d,e,g){i?(i.push(c),i.push(d),i.push(e),i.push(g)):k(function(){b(o,c,d,e,g)},c,d,e,g)}}function t(a,b){return b.priority-a.priority}function ua(a,b,c,d){if(b)throw Error("Multiple directives ["+b.name+", "+c.name+"] asking for "+a+" on: "+qa(d));}function Y(a,b){var c=j(b,!0);c&&a.push({priority:0,compile:I(function(a,b){var d=b.parent(),e=d.data("$binding")||[];e.push(c);N(d.data("$binding", +e),"ng-binding");a.$watch(c,function(a){b[0].nodeValue=a})})})}function R(a,b,c,d){var e=j(c,!0);e&&b.push({priority:100,compile:I(function(a,b,c){b=c.$$observers||(c.$$observers={});d==="class"&&(e=j(c[d],!0));c[d]=q;(b[d]||(b[d]=[])).$$inter=!0;(c.$$observers&&c.$$observers[d].$$scope||a).$watch(e,function(a){c.$set(d,a)})})})}function v(a,b,c){var d=b[0],e=d.parentNode,g,j;if(a){g=0;for(j=a.length;g0){var e=Q[0],f=e.text;if(f==a||f==b||f==c||f==d||!a&&!b&&!c&&!d)return e}return!1}function f(b,c,d,f){return(b=h(b,c,d,f))?(a&&!b.json&&e("is not valid json",b),Q.shift(),b):!1}function i(a){f(a)||e("is unexpected, expecting ["+ +a+"]",h())}function j(a,b){return function(c,d){return a(c,d,b)}}function k(a,b,c){return function(d,e){return b(d,e,a,c)}}function l(){for(var a=[];;)if(Q.length>0&&!h("}",")",";","]")&&a.push(v()),!f(";"))return a.length==1?a[0]:function(b,c){for(var d,e=0;e","<=",">="))a=k(a,b.fn,r());return a}function x(){for(var a=m(),b;b=f("*","/","%");)a=k(a,b.fn,m());return a}function m(){var a;return f("+")?A():(a=f("-"))?k(C,a.fn,m()):(a=f("!"))?j(a.fn,m()):A()}function A(){var a; +if(f("("))a=v(),i(")");else if(f("["))a=J();else if(f("{"))a=K();else{var b=f();(a=b.fn)||e("not a primary expression",b)}for(var c;b=f("(","[",".");)b.text==="("?(a=w(a,c),c=null):b.text==="["?(c=a,a=R(a)):b.text==="."?(c=a,a=Y(a)):e("IMPOSSIBLE");return a}function J(){var a=[];if(g().text!="]"){do a.push(t());while(f(","))}i("]");return function(b,c){for(var d=[],e=0;e1;d++){var e=a.shift(),g=b[e];g||(g={},b[e]=g);b=g}return b[a.shift()]=c}function Pb(b,a,c,d,e){return function(g,h){var f=h&&h.hasOwnProperty(b)?h:g,i;if(f===null||f===q)return f;if((f=f[b])&&f.then){if(!("$$v"in f))i=f,i.$$v=q,i.then(function(a){i.$$v=a});f=f.$$v}if(!a||f===null||f=== +q)return f;if((f=f[a])&&f.then){if(!("$$v"in f))i=f,i.$$v=q,i.then(function(a){i.$$v=a});f=f.$$v}if(!c||f===null||f===q)return f;if((f=f[c])&&f.then){if(!("$$v"in f))i=f,i.$$v=q,i.then(function(a){i.$$v=a});f=f.$$v}if(!d||f===null||f===q)return f;if((f=f[d])&&f.then){if(!("$$v"in f))i=f,i.$$v=q,i.then(function(a){i.$$v=a});f=f.$$v}if(!e||f===null||f===q)return f;if((f=f[e])&&f.then){if(!("$$v"in f))i=f,i.$$v=q,i.then(function(a){i.$$v=a});f=f.$$v}return f}}function Nb(b,a){if(jb.hasOwnProperty(b))return jb[b]; +var c=b.split("."),d=c.length,e;if(a)e=d<6?Pb(c[0],c[1],c[2],c[3],c[4]):function(a,b){var e=0,g;do g=Pb(c[e++],c[e++],c[e++],c[e++],c[e++])(a,b),b=q,a=g;while(e7),hasEvent:function(c){if(c=="input"&&V==9)return!1;if(u(a[c])){var e= +b.document.createElement("div");a[c]="on"+c in e}return a[c]},csp:!1}}]}function Yc(){this.$get=I(P)}function Qb(b){var a={},c,d,e;if(!b)return a;m(b.split("\n"),function(b){e=b.indexOf(":");c=y(S(b.substr(0,e)));d=S(b.substr(e+1));c&&(a[c]?a[c]+=", "+d:a[c]=d)});return a}function Rb(b){var a=M(b)?b:q;return function(c){a||(a=Qb(b));return c?a[y(c)]||null:a}}function Sb(b,a,c){if(H(c))return c(b,a);m(c,function(c){b=c(b,a)});return b}function Zc(){var b=/^\s*(\[|\{[^\{])/,a=/[\}\]]\s*$/,c=/^\)\]\}',?\n/, +d=this.defaults={transformResponse:[function(d){B(d)&&(d=d.replace(c,""),b.test(d)&&a.test(d)&&(d=qb(d,!0)));return d}],transformRequest:[function(a){return M(a)&&ma.apply(a)!=="[object File]"?ba(a):a}],headers:{common:{Accept:"application/json, text/plain, */*","X-Requested-With":"XMLHttpRequest"},post:{"Content-Type":"application/json;charset=utf-8"},put:{"Content-Type":"application/json;charset=utf-8"}}},e=this.responseInterceptors=[];this.$get=["$httpBackend","$browser","$cacheFactory","$rootScope", +"$q","$injector",function(a,b,c,i,j,k){function l(a){function c(a){var b=D({},a,{data:Sb(a.data,a.headers,f)});return 200<=a.status&&a.status<300?b:j.reject(b)}a.method=la(a.method);var e=a.transformRequest||d.transformRequest,f=a.transformResponse||d.transformResponse,g=D({},a.headers),i=D({"X-XSRF-TOKEN":b.cookies()["XSRF-TOKEN"]},d.headers.common,d.headers[y(a.method)]),k,l,o,p;a:for(k in i){l=y(k);for(o in a.headers)if(y(o)===l)continue a;g[k]=i[k]}if(u(a.data))for(var q in g)if(y(q)==="content-type"){delete g[q]; +break}e=Sb(a.data,Rb(g),e);p=n(a,e,g);p=p.then(c,c);m(z,function(a){p=a(p)});p.success=function(b){p.then(function(c){b(c.data,c.status,c.headers,a)});return p};p.error=function(b){p.then(null,function(c){b(c.data,c.status,c.headers,a)});return p};return p}function n(b,c,d){function e(a,b,c){m&&(200<=a&&a<300?m.put(q,[a,b,Qb(c)]):m.remove(q));f(b,a,c);i.$apply()}function f(a,c,d){c=Math.max(c,0);(200<=c&&c<300?k.resolve:k.reject)({data:a,status:c,headers:Rb(d),config:b})}function h(){var a=za(l.pendingRequests, +b);a!==-1&&l.pendingRequests.splice(a,1)}var k=j.defer(),n=k.promise,m,t,q=o(b.url,b.params);l.pendingRequests.push(b);n.then(h,h);b.cache&&b.method=="GET"&&(m=M(b.cache)?b.cache:p);if(m)if(t=m.get(q))if(t.then)return t.then(h,h),t;else E(t)?f(t[1],t[0],U(t[2])):f(t,200,{});else m.put(q,n);t||a(b.method,q,c,e,d,b.timeout,b.withCredentials);return n}function o(a,b){if(!b)return a;var c=[];hc(b,function(a,b){a==null||a==q||(M(a)&&(a=ba(a)),c.push(encodeURIComponent(b)+"="+encodeURIComponent(a)))}); +return a+(a.indexOf("?")==-1?"?":"&")+c.join("&")}var p=c("$http"),z=[];m(e,function(a){z.push(B(a)?k.get(a):k.invoke(a))});l.pendingRequests=[];(function(a){m(arguments,function(a){l[a]=function(b,c){return l(D(c||{},{method:a,url:b}))}})})("get","delete","head","jsonp");(function(a){m(arguments,function(a){l[a]=function(b,c,d){return l(D(d||{},{method:a,url:b,data:c}))}})})("post","put");l.defaults=d;return l}]}function $c(){this.$get=["$browser","$window","$document",function(b,a,c){return ad(b, +bd,b.defer,a.angular.callbacks,c[0],a.location.protocol.replace(":",""))}]}function ad(b,a,c,d,e,g){function h(a,b){var c=e.createElement("script"),d=function(){e.body.removeChild(c);b&&b()};c.type="text/javascript";c.src=a;V?c.onreadystatechange=function(){/loaded|complete/.test(c.readyState)&&d()}:c.onload=c.onerror=d;e.body.appendChild(c)}return function(e,i,j,k,l,n,o){function p(a,c,d,e){c=(i.match(Jb)||["",g])[1]=="file"?d?200:404:c;a(c==1223?204:c,d,e);b.$$completeOutstandingRequest(s)}b.$$incOutstandingRequestCount(); +i=i||b.url();if(y(e)=="jsonp"){var q="_"+(d.counter++).toString(36);d[q]=function(a){d[q].data=a};h(i.replace("JSON_CALLBACK","angular.callbacks."+q),function(){d[q].data?p(k,200,d[q].data):p(k,-2);delete d[q]})}else{var r=new a;r.open(e,i,!0);m(l,function(a,b){a&&r.setRequestHeader(b,a)});var x;r.onreadystatechange=function(){if(r.readyState==4){var a=r.getAllResponseHeaders(),b=["Cache-Control","Content-Language","Content-Type","Expires","Last-Modified","Pragma"];a||(a="",m(b,function(b){var c= +r.getResponseHeader(b);c&&(a+=b+": "+c+"\n")}));p(k,x||r.status,r.responseText,a)}};if(o)r.withCredentials=!0;r.send(j||"");n>0&&c(function(){x=-1;r.abort()},n)}}}function cd(){this.$get=function(){return{id:"en-us",NUMBER_FORMATS:{DECIMAL_SEP:".",GROUP_SEP:",",PATTERNS:[{minInt:1,minFrac:0,maxFrac:3,posPre:"",posSuf:"",negPre:"-",negSuf:"",gSize:3,lgSize:3},{minInt:1,minFrac:2,maxFrac:2,posPre:"\u00a4",posSuf:"",negPre:"(\u00a4",negSuf:")",gSize:3,lgSize:3}],CURRENCY_SYM:"$"},DATETIME_FORMATS:{MONTH:"January,February,March,April,May,June,July,August,September,October,November,December".split(","), +SHORTMONTH:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),DAY:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),SHORTDAY:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(","),AMPMS:["AM","PM"],medium:"MMM d, y h:mm:ss a","short":"M/d/yy h:mm a",fullDate:"EEEE, MMMM d, y",longDate:"MMMM d, y",mediumDate:"MMM d, y",shortDate:"M/d/yy",mediumTime:"h:mm:ss a",shortTime:"h:mm a"},pluralCat:function(b){return b===1?"one":"other"}}}}function dd(){this.$get=["$rootScope","$browser","$q", +"$exceptionHandler",function(b,a,c,d){function e(e,f,i){var j=c.defer(),k=j.promise,l=v(i)&&!i,f=a.defer(function(){try{j.resolve(e())}catch(a){j.reject(a),d(a)}finally{delete g[k.$$timeoutId]}l||b.$apply()},f);k.$$timeoutId=f;g[f]=j;return k}var g={};e.cancel=function(b){return b&&b.$$timeoutId in g?(g[b.$$timeoutId].reject("canceled"),delete g[b.$$timeoutId],a.defer.cancel(b.$$timeoutId)):!1};return e}]}function Tb(b){function a(a,e){return b.factory(a+c,e)}var c="Filter";this.register=a;this.$get= +["$injector",function(a){return function(b){return a.get(b+c)}}];a("currency",Ub);a("date",Vb);a("filter",ed);a("json",fd);a("limitTo",gd);a("lowercase",hd);a("number",Wb);a("orderBy",Xb);a("uppercase",id)}function ed(){return function(b,a){if(!E(b))return b;var c=[];c.check=function(a){for(var b=0;b +-1;case "object":for(var c in a)if(c.charAt(0)!=="$"&&d(a[c],b))return!0;return!1;case "array":for(c=0;ce+1?h="0":(f=h,j=!0)}if(j)e>0&&b>-1&&b<1&&(f=b.toFixed(e));else{h=(h.split(Zb)[1]||"").length;u(e)&&(e=Math.min(Math.max(a.minFrac,h),a.maxFrac));var h=Math.pow(10,e),b=Math.round(b*h)/h,b=(""+b).split(Zb),h=b[0],b=b[1]||"",j=0,k=a.lgSize,l=a.gSize;if(h.length>=k+l)for(var j=h.length-k,n=0;n0||e>-c)e+=c;e===0&&c==-12&&(e=12);return kb(e,a,d)}}function Ka(b,a){return function(c,d){var e=c["get"+b](),g=la(a?"SHORT"+b:b);return d[g][e]}}function Vb(b){function a(a){var b;if(b=a.match(c)){var a=new Date(0),g=0,h=0;b[9]&&(g=G(b[9]+b[10]),h=G(b[9]+ +b[11]));a.setUTCFullYear(G(b[1]),G(b[2])-1,G(b[3]));a.setUTCHours(G(b[4]||0)-g,G(b[5]||0)-h,G(b[6]||0),G(b[7]||0))}return a}var c=/^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;return function(c,e){var g="",h=[],f,i,e=e||"mediumDate",e=b.DATETIME_FORMATS[e]||e;B(c)&&(c=jd.test(c)?G(c):a(c));Ra(c)&&(c=new Date(c));if(!oa(c))return c;for(;e;)(i=kd.exec(e))?(h=h.concat(ha.call(i,1)),e=h.pop()):(h.push(e),e=null);m(h,function(a){f=ld[a];g+=f?f(c, +b.DATETIME_FORMATS):a.replace(/(^'|'$)/g,"").replace(/''/g,"'")});return g}}function fd(){return function(b){return ba(b,!0)}}function gd(){return function(b,a){if(!(b instanceof Array))return b;var a=G(a),c=[],d,e;if(!b||!(b instanceof Array))return c;a>b.length?a=b.length:a<-b.length&&(a=-b.length);a>0?(d=0,e=a):(d=b.length+a,e=b.length);for(;dn?(d.$setValidity("maxlength", +!1),q):(d.$setValidity("maxlength",!0),a)};d.$parsers.push(c);d.$formatters.push(c)}}function lb(b,a){b="ngClass"+b;return W(function(c,d,e){function g(b){if(a===!0||c.$index%2===a)i&&!ea(b,i)&&h(i),f(b);i=U(b)}function h(a){M(a)&&!E(a)&&(a=Ta(a,function(a,b){if(a)return b}));d.removeClass(E(a)?a.join(" "):a)}function f(a){M(a)&&!E(a)&&(a=Ta(a,function(a,b){if(a)return b}));a&&d.addClass(E(a)?a.join(" "):a)}var i=q;c.$watch(e[b],g,!0);e.$observe("class",function(){var a=c.$eval(e[b]);g(a,a)});b!== +"ngClass"&&c.$watch("$index",function(d,g){var i=d&1;i!==g&1&&(i===a?f(c.$eval(e[b])):h(c.$eval(e[b])))})})}var y=function(b){return B(b)?b.toLowerCase():b},la=function(b){return B(b)?b.toUpperCase():b},V=G((/msie (\d+)/.exec(y(navigator.userAgent))||[])[1]),w,aa,ha=[].slice,Qa=[].push,ma=Object.prototype.toString,$a=P.angular||(P.angular={}),ta,Ga,Z=["0","0","0"];s.$inject=[];na.$inject=[];var S=function(){return!String.prototype.trim?function(b){return B(b)?b.replace(/^\s*/,"").replace(/\s*$/,""): +b}:function(b){return B(b)?b.trim():b}}();Ga=V<9?function(b){b=b.nodeName?b:b[0];return b.scopeName&&b.scopeName!="HTML"?la(b.scopeName+":"+b.nodeName):b.nodeName}:function(b){return b.nodeName?b.nodeName:b[0].nodeName};var mc=/[A-Z]/g,md={full:"1.0.8",major:1,minor:0,dot:8,codeName:"bubble-burst"},Ba=L.cache={},Aa=L.expando="ng-"+(new Date).getTime(),qc=1,bc=P.document.addEventListener?function(b,a,c){b.addEventListener(a,c,!1)}:function(b,a,c){b.attachEvent("on"+a,c)},gb=P.document.removeEventListener? +function(b,a,c){b.removeEventListener(a,c,!1)}:function(b,a,c){b.detachEvent("on"+a,c)},oc=/([\:\-\_]+(.))/g,pc=/^moz([A-Z])/,va=L.prototype={ready:function(b){function a(){c||(c=!0,b())}var c=!1;this.bind("DOMContentLoaded",a);L(P).bind("load",a)},toString:function(){var b=[];m(this,function(a){b.push(""+a)});return"["+b.join(", ")+"]"},eq:function(b){return b>=0?w(this[b]):w(this[this.length+b])},length:0,push:Qa,sort:[].sort,splice:[].splice},Ea={};m("multiple,selected,checked,disabled,readOnly,required".split(","), +function(b){Ea[y(b)]=b});var Db={};m("input,select,option,textarea,button,form".split(","),function(b){Db[la(b)]=!0});m({data:yb,inheritedData:Da,scope:function(b){return Da(b,"$scope")},controller:Bb,injector:function(b){return Da(b,"$injector")},removeAttr:function(b,a){b.removeAttribute(a)},hasClass:Ca,css:function(b,a,c){a=vb(a);if(v(c))b.style[a]=c;else{var d;V<=8&&(d=b.currentStyle&&b.currentStyle[a],d===""&&(d="auto"));d=d||b.style[a];V<=8&&(d=d===""?q:d);return d}},attr:function(b,a,c){var d= +y(a);if(Ea[d])if(v(c))c?(b[a]=!0,b.setAttribute(a,d)):(b[a]=!1,b.removeAttribute(d));else return b[a]||(b.attributes.getNamedItem(a)||s).specified?d:q;else if(v(c))b.setAttribute(a,c);else if(b.getAttribute)return b=b.getAttribute(a,2),b===null?q:b},prop:function(b,a,c){if(v(c))b[a]=c;else return b[a]},text:D(V<9?function(b,a){if(b.nodeType==1){if(u(a))return b.innerText;b.innerText=a}else{if(u(a))return b.nodeValue;b.nodeValue=a}}:function(b,a){if(u(a))return b.textContent;b.textContent=a},{$dv:""}), +val:function(b,a){if(u(a)){if(Ga(b)==="SELECT"&&b.multiple){var c=[];m(b.options,function(a){a.selected&&c.push(a.value||a.text)});return c.length===0?null:c}return b.value}b.value=a},html:function(b,a){if(u(a))return b.innerHTML;for(var c=0,d=b.childNodes;c":function(a,c,d,e){return d(a,c)>e(a,c)},"<=":function(a,c,d,e){return d(a,c)<=e(a,c)},">=":function(a,c,d,e){return d(a,c)>=e(a,c)},"&&":function(a,c,d,e){return d(a,c)&&e(a,c)},"||":function(a,c,d,e){return d(a,c)||e(a,c)},"&":function(a,c,d,e){return d(a,c)&e(a,c)},"|":function(a,c,d,e){return e(a,c)(a,c,d(a,c))},"!":function(a,c,d){return!d(a,c)}},Pc={n:"\n",f:"\u000c",r:"\r",t:"\t",v:"\u000b","'":"'",'"':'"'},jb={},bd=P.XMLHttpRequest||function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(c){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(d){}throw Error("This browser does not support XMLHttpRequest."); +};Tb.$inject=["$provide"];Ub.$inject=["$locale"];Wb.$inject=["$locale"];var Zb=".",ld={yyyy:O("FullYear",4),yy:O("FullYear",2,0,!0),y:O("FullYear",1),MMMM:Ka("Month"),MMM:Ka("Month",!0),MM:O("Month",2,1),M:O("Month",1,1),dd:O("Date",2),d:O("Date",1),HH:O("Hours",2),H:O("Hours",1),hh:O("Hours",2,-12),h:O("Hours",1,-12),mm:O("Minutes",2),m:O("Minutes",1),ss:O("Seconds",2),s:O("Seconds",1),EEEE:Ka("Day"),EEE:Ka("Day",!0),a:function(a,c){return a.getHours()<12?c.AMPMS[0]:c.AMPMS[1]},Z:function(a){var a= +-1*a.getTimezoneOffset(),c=a>=0?"+":"";c+=kb(Math[a>0?"floor":"ceil"](a/60),2)+kb(Math.abs(a%60),2);return c}},kd=/((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,jd=/^\d+$/;Vb.$inject=["$locale"];var hd=I(y),id=I(la);Xb.$inject=["$parse"];var nd=I({restrict:"E",compile:function(a,c){V<=8&&(!c.href&&!c.name&&c.$set("href",""),a.append(T.createComment("IE fix")));return function(a,c){c.bind("click",function(a){c.attr("href")||a.preventDefault()})}}}),mb={};m(Ea,function(a, +c){var d=ca("ng-"+c);mb[d]=function(){return{priority:100,compile:function(){return function(a,g,h){a.$watch(h[d],function(a){h.$set(c,!!a)})}}}}});m(["src","href"],function(a){var c=ca("ng-"+a);mb[c]=function(){return{priority:99,link:function(d,e,g){g.$observe(c,function(c){c&&(g.$set(a,c),V&&e.prop(a,g[a]))})}}}});var Na={$addControl:s,$removeControl:s,$setValidity:s,$setDirty:s};$b.$inject=["$element","$attrs","$scope"];var Qa=function(a){return["$timeout",function(c){var d={name:"form",restrict:"E", +controller:$b,compile:function(){return{pre:function(a,d,h,f){if(!h.action){var i=function(a){a.preventDefault?a.preventDefault():a.returnValue=!1};bc(d[0],"submit",i);d.bind("$destroy",function(){c(function(){gb(d[0],"submit",i)},0,!1)})}var j=d.parent().controller("form"),k=h.name||h.ngForm;k&&(a[k]=f);j&&d.bind("$destroy",function(){j.$removeControl(f);k&&(a[k]=q);D(f,Na)})}}}};return a?D(U(d),{restrict:"EAC"}):d}]},od=Qa(),pd=Qa(!0),qd=/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/, +rd=/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}$/,sd=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/,dc={text:Pa,number:function(a,c,d,e,g,h){Pa(a,c,d,e,g,h);e.$parsers.push(function(a){var c=X(a);return c||sd.test(a)?(e.$setValidity("number",!0),a===""?null:c?a:parseFloat(a)):(e.$setValidity("number",!1),q)});e.$formatters.push(function(a){return X(a)?"":""+a});if(d.min){var f=parseFloat(d.min),a=function(a){return!X(a)&&ai?(e.$setValidity("max",!1),q):(e.$setValidity("max",!0),a)};e.$parsers.push(d);e.$formatters.push(d)}e.$formatters.push(function(a){return X(a)||Ra(a)?(e.$setValidity("number",!0),a):(e.$setValidity("number",!1),q)})},url:function(a,c,d,e,g,h){Pa(a,c,d,e,g,h);a=function(a){return X(a)||qd.test(a)?(e.$setValidity("url",!0),a):(e.$setValidity("url",!1),q)};e.$formatters.push(a);e.$parsers.push(a)},email:function(a, +c,d,e,g,h){Pa(a,c,d,e,g,h);a=function(a){return X(a)||rd.test(a)?(e.$setValidity("email",!0),a):(e.$setValidity("email",!1),q)};e.$formatters.push(a);e.$parsers.push(a)},radio:function(a,c,d,e){u(d.name)&&c.attr("name",xa());c.bind("click",function(){c[0].checked&&a.$apply(function(){e.$setViewValue(d.value)})});e.$render=function(){c[0].checked=d.value==e.$viewValue};d.$observe("value",e.$render)},checkbox:function(a,c,d,e){var g=d.ngTrueValue,h=d.ngFalseValue;B(g)||(g=!0);B(h)||(h=!1);c.bind("click", +function(){a.$apply(function(){e.$setViewValue(c[0].checked)})});e.$render=function(){c[0].checked=e.$viewValue};e.$formatters.push(function(a){return a===g});e.$parsers.push(function(a){return a?g:h})},hidden:s,button:s,submit:s,reset:s},ec=["$browser","$sniffer",function(a,c){return{restrict:"E",require:"?ngModel",link:function(d,e,g,h){h&&(dc[y(g.type)]||dc.text)(d,e,g,h,c,a)}}}],Ma="ng-valid",La="ng-invalid",Oa="ng-pristine",ac="ng-dirty",td=["$scope","$exceptionHandler","$attrs","$element","$parse", +function(a,c,d,e,g){function h(a,c){c=c?"-"+ab(c,"-"):"";e.removeClass((a?La:Ma)+c).addClass((a?Ma:La)+c)}this.$modelValue=this.$viewValue=Number.NaN;this.$parsers=[];this.$formatters=[];this.$viewChangeListeners=[];this.$pristine=!0;this.$dirty=!1;this.$valid=!0;this.$invalid=!1;this.$name=d.name;var f=g(d.ngModel),i=f.assign;if(!i)throw Error(Gb+d.ngModel+" ("+qa(e)+")");this.$render=s;var j=e.inheritedData("$formController")||Na,k=0,l=this.$error={};e.addClass(Oa);h(!0);this.$setValidity=function(a, +c){if(l[a]!==!c){if(c){if(l[a]&&k--,!k)h(!0),this.$valid=!0,this.$invalid=!1}else h(!1),this.$invalid=!0,this.$valid=!1,k++;l[a]=!c;h(c,a);j.$setValidity(a,c,this)}};this.$setViewValue=function(d){this.$viewValue=d;if(this.$pristine)this.$dirty=!0,this.$pristine=!1,e.removeClass(Oa).addClass(ac),j.$setDirty();m(this.$parsers,function(a){d=a(d)});if(this.$modelValue!==d)this.$modelValue=d,i(a,d),m(this.$viewChangeListeners,function(a){try{a()}catch(d){c(d)}})};var n=this;a.$watch(function(){var c= +f(a);if(n.$modelValue!==c){var d=n.$formatters,e=d.length;for(n.$modelValue=c;e--;)c=d[e](c);if(n.$viewValue!==c)n.$viewValue=c,n.$render()}})}],ud=function(){return{require:["ngModel","^?form"],controller:td,link:function(a,c,d,e){var g=e[0],h=e[1]||Na;h.$addControl(g);c.bind("$destroy",function(){h.$removeControl(g)})}}},vd=I({require:"ngModel",link:function(a,c,d,e){e.$viewChangeListeners.push(function(){a.$eval(d.ngChange)})}}),fc=function(){return{require:"?ngModel",link:function(a,c,d,e){if(e){d.required= +!0;var g=function(a){if(d.required&&(X(a)||a===!1))e.$setValidity("required",!1);else return e.$setValidity("required",!0),a};e.$formatters.push(g);e.$parsers.unshift(g);d.$observe("required",function(){g(e.$viewValue)})}}}},wd=function(){return{require:"ngModel",link:function(a,c,d,e){var g=(a=/\/(.*)\//.exec(d.ngList))&&RegExp(a[1])||d.ngList||",";e.$parsers.push(function(a){var c=[];a&&m(a.split(g),function(a){a&&c.push(S(a))});return c});e.$formatters.push(function(a){return E(a)?a.join(", "): +q})}}},xd=/^(true|false|\d+)$/,yd=function(){return{priority:100,compile:function(a,c){return xd.test(c.ngValue)?function(a,c,g){g.$set("value",a.$eval(g.ngValue))}:function(a,c,g){a.$watch(g.ngValue,function(a){g.$set("value",a)})}}}},zd=W(function(a,c,d){c.addClass("ng-binding").data("$binding",d.ngBind);a.$watch(d.ngBind,function(a){c.text(a==q?"":a)})}),Ad=["$interpolate",function(a){return function(c,d,e){c=a(d.attr(e.$attr.ngBindTemplate));d.addClass("ng-binding").data("$binding",c);e.$observe("ngBindTemplate", +function(a){d.text(a)})}}],Bd=[function(){return function(a,c,d){c.addClass("ng-binding").data("$binding",d.ngBindHtmlUnsafe);a.$watch(d.ngBindHtmlUnsafe,function(a){c.html(a||"")})}}],Cd=lb("",!0),Dd=lb("Odd",0),Ed=lb("Even",1),Fd=W({compile:function(a,c){c.$set("ngCloak",q);a.removeClass("ng-cloak")}}),Gd=[function(){return{scope:!0,controller:"@"}}],Hd=["$sniffer",function(a){return{priority:1E3,compile:function(){a.csp=!0}}}],gc={};m("click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave submit".split(" "), +function(a){var c=ca("ng-"+a);gc[c]=["$parse",function(d){return function(e,g,h){var f=d(h[c]);g.bind(y(a),function(a){e.$apply(function(){f(e,{$event:a})})})}}]});var Id=["$http","$templateCache","$anchorScroll","$compile",function(a,c,d,e){return{restrict:"ECA",terminal:!0,compile:function(g,h){var f=h.ngInclude||h.src,i=h.onload||"",j=h.autoscroll;return function(g,h){var n=0,o,p=function(){o&&(o.$destroy(),o=null);h.html("")};g.$watch(f,function(f){var m=++n;f?a.get(f,{cache:c}).success(function(a){m=== +n&&(o&&o.$destroy(),o=g.$new(),h.html(a),e(h.contents())(o),v(j)&&(!j||g.$eval(j))&&d(),o.$emit("$includeContentLoaded"),g.$eval(i))}).error(function(){m===n&&p()}):p()})}}}}],Jd=W({compile:function(){return{pre:function(a,c,d){a.$eval(d.ngInit)}}}}),Kd=W({terminal:!0,priority:1E3}),Ld=["$locale","$interpolate",function(a,c){var d=/{}/g;return{restrict:"EA",link:function(e,g,h){var f=h.count,i=g.attr(h.$attr.when),j=h.offset||0,k=e.$eval(i),l={},n=c.startSymbol(),o=c.endSymbol();m(k,function(a,e){l[e]= +c(a.replace(d,n+f+"-"+j+o))});e.$watch(function(){var c=parseFloat(e.$eval(f));return isNaN(c)?"":(c in k||(c=a.pluralCat(c-j)),l[c](e,g,!0))},function(a){g.text(a)})}}}],Md=W({transclude:"element",priority:1E3,terminal:!0,compile:function(a,c,d){return function(a,c,h){var f=h.ngRepeat,h=f.match(/^\s*(.+)\s+in\s+(.*)\s*$/),i,j,k;if(!h)throw Error("Expected ngRepeat in form of '_item_ in _collection_' but got '"+f+"'.");f=h[1];i=h[2];h=f.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);if(!h)throw Error("'item' in 'item in collection' should be identifier or (key, value) but got '"+ +f+"'.");j=h[3]||h[1];k=h[2];var l=new hb;a.$watch(function(a){var e,f,h=a.$eval(i),m=c,q=new hb,u,A,w,v,C,s;if(E(h))C=h||[];else{C=[];for(w in h)h.hasOwnProperty(w)&&w.charAt(0)!="$"&&C.push(w);C.sort()}u=C.length-1;e=0;for(f=C.length;ez;)v.pop().element.remove()}for(;w.length>y;)w.pop()[0].element.remove()}var i;if(!(i=s.match(d)))throw Error("Expected ngOptions in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got '"+s+"'.");var j=c(i[2]||i[1]),k=i[4]|| +i[6],l=i[5],m=c(i[3]||""),n=c(i[2]?i[1]:k),o=c(i[7]),w=[[{element:f,label:""}]];r&&(a(r)(e),r.removeClass("ng-scope"),r.remove());f.html("");f.bind("change",function(){e.$apply(function(){var a,c=o(e)||[],d={},h,i,j,m,r,s;if(p){i=[];m=0;for(s=w.length;m@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak{display:none !important;}ng\\:form{display:block;}'); diff --git a/node/public/js/autoload.js b/node/public/js/vendor/autoload.js similarity index 100% rename from node/public/js/autoload.js rename to node/public/js/vendor/autoload.js diff --git a/node/public/js/html5shiv.js b/node/public/js/vendor/html5shiv.js similarity index 100% rename from node/public/js/html5shiv.js rename to node/public/js/vendor/html5shiv.js diff --git a/node/public/js/ink-all.min.js b/node/public/js/vendor/ink-all.min.js similarity index 100% rename from node/public/js/ink-all.min.js rename to node/public/js/vendor/ink-all.min.js diff --git a/node/public/js/ink-ui.min.js b/node/public/js/vendor/ink-ui.min.js similarity index 100% rename from node/public/js/ink-ui.min.js rename to node/public/js/vendor/ink-ui.min.js diff --git a/node/public/js/ink.formvalidator.js b/node/public/js/vendor/ink.formvalidator.js similarity index 100% rename from node/public/js/ink.formvalidator.js rename to node/public/js/vendor/ink.formvalidator.js diff --git a/node/public/js/ink.min.js b/node/public/js/vendor/ink.min.js similarity index 100% rename from node/public/js/ink.min.js rename to node/public/js/vendor/ink.min.js diff --git a/node/public/js/modernizr.js b/node/public/js/vendor/modernizr.js similarity index 100% rename from node/public/js/modernizr.js rename to node/public/js/vendor/modernizr.js diff --git a/node/public/js/prettify.js b/node/public/js/vendor/prettify.js similarity index 100% rename from node/public/js/prettify.js rename to node/public/js/vendor/prettify.js diff --git a/node/public/style.css b/node/public/style.css deleted file mode 100644 index 0c50eb0..0000000 --- a/node/public/style.css +++ /dev/null @@ -1,5 +0,0 @@ -body { - - - -} \ No newline at end of file diff --git a/node/routes/index.js b/node/routes/index.js new file mode 100644 index 0000000..0cb4e53 --- /dev/null +++ b/node/routes/index.js @@ -0,0 +1,43 @@ + +exports.index = function (req, res) { + res.render('index', { title: 'Home', status: req.flash('status') }) +}; + +exports.db = function (req, res) { + res.render('database', { title: 'Manage MAC', status: req.flash('status') }) +}; + +exports.form = function (req, res) { + var snmpMac = req.app.get('snmpMac'); //TODO: wie kann man das schoener machen? + var mac = req.body.mac, + label = req.body.label, + action = req.body.action; + var status = ""; + mac = mac.toLowerCase(); + + if (/^([0-9a-f]{2}[:-]){5}([0-9a-f]{2})$/.exec(mac)) { + if (action == "add") { + if (/^[0-9a-zA-Z]+$/.exec(label)) { + snmpMac.add(mac, label, function (err) { + console.log("add mac result: " + err); + req.flash('status', err == null ? "" : "database error: " + err); + res.redirect("/db"); + }); + } else { + req.flash('status', 'label is invalid ("^[0-9a-zA-Z]+$")'); + res.redirect("/db"); + } + } else if (action == "remove") { + snmpMac.delete(mac, function (err) { + console.log("delete mac result: " + err); + req.flash('status', err == null ? "" : "database error: " + err); + res.redirect("/db"); + }); + } else { + res.redirect("/db"); + } + } else { + req.flash('status', 'mac address is invalid'); + res.redirect("/db"); + } +}; \ No newline at end of file diff --git a/node/snmp-mac.js b/node/snmp-mac.js index 5d01544..dba1c00 100644 --- a/node/snmp-mac.js +++ b/node/snmp-mac.js @@ -66,6 +66,7 @@ var SnmpMac = function(hostname, community) { } else { if(varbinds[i].value == "3") { // only valid arp entries getMacFromOID(varbinds[i].oid, function(mac) { +// console.log(mac); redisClient.get(redisprefix + mac, function(err, reply) { if(reply != null) { names.push(reply); diff --git a/node/statusbot.js b/node/statusbot.js index 4e06544..4bbf1d4 100644 --- a/node/statusbot.js +++ b/node/statusbot.js @@ -1,9 +1,12 @@ var _u = require("underscore"); var express = require('express'), - app = express(); + app = express(), + server = require('http').createServer(app), + io = require('socket.io').listen(server); var flash = require('connect-flash'); var SnmpMac = require("./snmp-mac"); var IpPoll = require("./ip-poll"); +var routes = require("./routes"); var spaceanswer = { "api": "0.13", @@ -35,7 +38,6 @@ var simpleanswer = { "state": "unknown", "lastchange": 0 }; - var snmpMac = new SnmpMac("juni.ctdo.de", "ctdo23"); var ippoll = new IpPoll("switch2.raum.ctdo.de", "195.160.169.20-62 195.160.169.70-126"); @@ -49,6 +51,8 @@ ippoll.on('doneCount', function (num) { console.log("there are " + num + " hosts up"); simpleanswer.count = num; simpleanswer.lastchange = parseInt((new Date().getTime()) / 1000); + + io.sockets.emit('sdata', { "data": simpleanswer }); }); ippoll.on('doneState', function (state) { @@ -58,28 +62,42 @@ ippoll.on('doneState', function (state) { spaceanswer.state.lastchange = parseInt((new Date().getTime()) / 1000); simpleanswer.lastchange = spaceanswer.state.lastchange; + + io.sockets.emit('sdata', { "data": simpleanswer }); }); +io.configure(function () { + io.set('log level', 0); +}); +io.sockets.on('connection', function (socket) { +// socket.emit('news', { hello: 'world' }); +}); + + + function work() { snmpMac.poll(); ippoll.pollCount(); ippoll.pollState(); } -work(); -setInterval(work, 60000); +setInterval(work, 10000); +app.set('snmpMac', snmpMac); //TODO: wie kann man das schoener machen? (Modul in die Routes reintun) app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); +app.disable('x-powered-by'); +app.configure('development', function () { + app.use(express.errorHandler()); + app.locals.pretty = true; +}); + app.use(express.static(__dirname + '/public')); app.use(express.bodyParser()); app.use(express.cookieParser('chaostreff')); app.use(express.session({ cookie: { maxAge: 60000 }})); app.use(flash()); -app.configure('development', function () { - app.use(express.errorHandler()); - app.locals.pretty = true; -}); + app.get('/api/spaceapi/v13', function (req, res) { res.send(spaceanswer); @@ -88,54 +106,14 @@ app.get('/api/simple/v2', function (req, res) { res.send(simpleanswer); }); -app.get('/db', function (req, res) { - res.render('database', { title: 'Manage MAC', status: req.flash('status') }) -}); +app.get('/db', routes.db); +app.post('/form', routes.form); -app.post('/form', function (req, res) { - var mac = req.body.mac, - label = req.body.label, - action = req.body.action; - var status = ""; - mac = mac.toLowerCase(); - - if (/^([0-9a-f]{2}[:-]){5}([0-9a-f]{2})$/.exec(mac)) { - if (action == "add") { - if (/^[0-9a-zA-Z]+$/.exec(label)) { - snmpMac.add(mac, label, function (err) { - console.log("add mac result: " + err); - req.flash('status', err == null ? "" : "database error: " + err); - res.redirect("/db"); - }); - } else { - req.flash('status', 'label is invalid ("^[0-9a-zA-Z]+$")'); - res.redirect("/db"); - } - } else if (action == "remove") { - snmpMac.delete(mac, function (err) { - console.log("delete mac result: " + err); - req.flash('status', err == null ? "" : "database error: " + err); - res.redirect("/db"); - }); - } else { - res.redirect("/db"); - } - } else { - req.flash('status', 'mac address is invalid'); - res.redirect("/db"); - } -}); - -app.get('/', function (req, res) { - res.render('index', { title: 'Home', status: req.flash('status') }) -}); +app.get('/', routes.index); + + +server.listen(3000); -app.disable('x-powered-by'); -app.listen(3000); - -snmpMac.poll(); -ippoll.pollCount(); -ippoll.pollState(); diff --git a/node/views/index.jade b/node/views/index.jade index 3b80a86..b3077c8 100644 --- a/node/views/index.jade +++ b/node/views/index.jade @@ -2,24 +2,27 @@ extend layout block content - .ink-grid + .ink-grid(ng-controller='StatusCtrl') .column-group.gutters .large-20.small-100 - img(src="img/yellow.png") + div(class="status-icon status-icon-{{simple.state}}") dl dt aktueller Status: - dd#stnow Unbekannt + dd#stnow {{simple.state}} dt letzte Abfrage: - dd#sttime niemals + dd#sttime {{simple.lastchange}} .large-80.small-100 - p baz bam + p Personen Anwensend: + ul + li(ng-repeat="name in simple.names") + {{name}} diff --git a/node/views/layout.jade b/node/views/layout.jade index 1de7ccf..f7e2fc7 100644 --- a/node/views/layout.jade +++ b/node/views/layout.jade @@ -1,5 +1,5 @@ !!!5 -html +html(ng-app="roomstateapp") head title #{title} - CTDO Raumstatus @@ -7,14 +7,7 @@ html link(rel="stylesheet",href="/css/ink-ie7-min.css",type="text/css",media="screen") link(rel='stylesheet', href='/css/ink-min.css') - link(rel='stylesheet', href='/style.css') - - script(type="text/javascript",src="/js/ink.min.js") - script(type="text/javascript",src="/js/ink.formvalidator.js") - script(type="text/javascript",src="/js/ink-ui.min.js") - script(type="text/javascript",src="/js/autoload.js") - script(type="text/javascript",src="/js/html5shiv.js") - + link(rel='stylesheet', href='/css/style.css') body .ink-grid @@ -33,3 +26,17 @@ html li: a(href='/db') Manage MAC Addresses li: a(href="//www.chaostreff-dortmund.de/") CTDO Webseite li: a(href="//wiki.ctdo.de/") CTDO Wiki + + + + script(type="text/javascript",src="/js/vendor/angular.min.js") + script(type="text/javascript",src="/js/vendor/ink.min.js") + script(type="text/javascript",src="/js/vendor/autoload.js") + script(type="text/javascript",src="/js/vendor/html5shiv.js") + script(type="text/javascript",src="/js/vendor/ink.formvalidator.js") + script(type="text/javascript",src="/js/vendor/ink-ui.min.js") + //script(type="text/javascript",src="/js/vendor/prettify.js") + //script(type="text/javascript",src="/js/vendor/modernizr.js") + script(type="text/javascript",src="/js/app.js") + script(type="text/javascript",src="/js/controllers.js") + script(type="text/javascript",src="/socket.io/socket.io.js") \ No newline at end of file