This repository was archived by the owner on Sep 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
44 lines (41 loc) · 1.31 KB
/
app.js
File metadata and controls
44 lines (41 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(function() {
angular.module('app', ['ngRoute'])
.controller('mainCtrl', ['$http', function($http) {
vm = this;
vm.hosts = [];
vm.sendWake = function(host) {
_.forEach(vm.hosts, function(h) {
if (host == h) {
$http.post('wol_action.php', h)
.then(function(resp) {
//console.log(resp);
h.alert = true;
h.alertSuccess = true;
h.alertMessage = "Wake request sent.";
}, function(error) {
//console.log(error);
h.alert = true;
h.alertFailure = true;
h.alertMessage = error.data.error;
})
}
})
}
$http.get('hosts.json').then(
function(resp) {
vm.hosts = resp.data.hosts;
},
function(error) {
console.log('Error fetching hosts');
}
);
}])
.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when("/", {
templateUrl: "hostList.html",
controller: "mainCtrl",
controllerAs: "vm"
})
}])
})();