search CRM for username
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 12 Apr 2011 15:44:59 +0000 (15:44 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 12 Apr 2011 15:44:59 +0000 (15:44 +0000)
templates/layouts/angular.html.ep [new file with mode: 0644]
templates/user.html.ep [new file with mode: 0644]
web_ui.pl

diff --git a/templates/layouts/angular.html.ep b/templates/layouts/angular.html.ep
new file mode 100644 (file)
index 0000000..505ca7e
--- /dev/null
@@ -0,0 +1,8 @@
+<!doctype html>
+<html xmlns:ng="http://angularjs.org">
+ <head>
+  <title><%= title %></title>
+  <script src="http://code.angularjs.org/angular-0.9.12.min.js" ng:autobind></script>
+ </head>
+ <body><%= content %></body>
+</html>
diff --git a/templates/user.html.ep b/templates/user.html.ep
new file mode 100644 (file)
index 0000000..614eab3
--- /dev/null
@@ -0,0 +1,61 @@
+% layout 'angular';
+
+  <script>
+    function CRM($xhr) {
+      var self = this;
+   
+      this.fetch = function() {
+        self.clear();
+       self.url = '/g/' + self.function_name + '/' + self.args + '?callback=JSON_CALLBACK';
+        $xhr('JSON', self.url, function(code, response) {
+          self.code = code;
+          self.response = response;
+        });
+      };
+   
+      this.clear = function() {
+        self.url = null;
+        self.code = null;
+        self.response = null;
+      };
+
+    }
+
+    CRM.$inject = ['$xhr'];
+  </script>
+  <div ng:controller="CRM">
+    <input type="hidden" name="function_name" value="CRM_search"      size="20"/>
+    <label for="args">username:
+    <input type="text" name="args"     value="test" size="10"/>
+    </label>
+    <button ng:click="fetch()">fetch</button>
+    <button ng:click="clear()">clear</button>
+    <b ng:show="url && ! code">loading {{url}}</b>
+    <b ng:show="response">{{response.length}} results</b>
+    <table ng:show="response">
+    <tr>
+       <th>USERNAME</th>
+       <th>BROJ</th>
+       <th>USLUGA</th>
+       <th>IP_MANAGEMENT</th>
+       <th>IP_VOICE</th>
+       <th>KOLOKACIJA</th>
+       <th>OPT82</th>
+    </tr>
+    <tr ng:repeat="u in response">
+       <td>{{u.USERNAME}}</td>
+       <td>{{u.BROJ}}</td>
+       <td>{{u.USLUGA}}</td>
+       <td>{{u.IP_MANAGEMENT}}</td>
+       <td>{{u.IP_VOICE}}</td>
+       <td>{{u.KOLOKACIJA}}</td>
+       <td>{{u.OPT82}}</td>
+    </tr>
+    </table>
+    <input type=checkbox name=debug value=1>
+    <pre ng:show=debug>
+url={{url}}
+code={{code}}
+response={{response}}
+    </pre>
+  </div>
index a66b49e..22d4455 100755 (executable)
--- a/web_ui.pl
+++ b/web_ui.pl
@@ -190,4 +190,11 @@ get '/_redis' => sub {
        _render_jsonp( $self, Mojo::JSON->new->encode({ status => $status }) );
 };
 
+get '/user' => sub {
+       my $self = shift;
+
+       $self->render('user');
+};
+
+
 app->start;