2a2e777171609989f96a3f3f1ae151c6a3356d9c
[src/app-framework-demo.git] / afb-client / app / Frontend / pages / Sample / SampleModule.js
1 (function() {
2 'use strict';
3
4 // list all rependencies within the page + controler if needed
5 angular.module('SampleModule', ['SubmitButton','UploadFile'])
6
7   .controller('SampleController', function ($http) {
8         var self = this; // I hate JavaScript
9         this.status='muted-off';
10
11         console.log ("sample controller");
12
13         this.MuteOn = function() {
14            console.log ("Muted");
15             // send AJAX request to server
16             var handler = $http.post('/api/dbus/ping', {type:'mute', action: "on"});
17             
18             handler.success(function(response, errcode, headers, config) {
19                 self.status = 'muted-on';                
20             });
21
22             handler.error(function(status, errcode, headers) {
23                 console.log ("Oops /api/dbus/pring err=" + errcode);
24                 self.status = 'muted-error';                
25             });
26         };
27         
28         this.MuteOff = function() {
29            console.log ("UnMuted"); 
30             // send AJAX request to server
31             var handler = $http.post('/api/dbus/ping', {type:'mute', action: "off"});
32             
33             handler.success(function(response, errcode, headers, config) {
34                self.status = 'muted-off';                
35             });
36
37             handler.error(function(status, errcode, headers) {
38                 console.log ("Oops /api/dbus/ping err=" + errcode);
39                 self.status = 'muted-error';                
40             });
41             
42         };
43
44  
45    });
46
47 console.log ("SampleControler Loaded");
48 })();