-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
66 lines (52 loc) · 2.4 KB
/
app.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
(function () {
var app = angular.module('ESC_WebApp', []);
app.controller('PublicSensorController', ['$http', '$log', '$window', function ($http, $log, $window) {
var pub_con = this;
this.sensors = [];
this.loadSensors = function () {
$http.get('http://147.32.107.139:8081/registered_sensors')
.then(function (response) {
pub_con.sensors = response.data._public;
});
};
this.loadSensors();
this.showData = function (index) {
$log.log("Index: " + index);
//$window.alert("Index: " + index);
$http.get('http://147.32.107.139:8081/registered_sensors/' + pub_con.sensors[index].uuid)
.then(function (response) {
var text = "Data:";
response.data.measured.forEach(function (entry) {
text += "\n" + entry.name + ": " + entry.value;
});
$window.alert(text);
}, function (response) {
$log.warn("ERROR");
});
};
}]);
app.controller('PrivateSensorController', ['$http', '$log', '$window', function ($http, $log, $window) {
this.alertLoggedPerson = function () {
var auth2 = gapi.auth2.getAuthInstance();
var profile = auth2.currentUser.get().getBasicProfile();
console.log(profile);
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail());
console.log('ID_token: '+ gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse().id_token);
};
}]);
app.controller('RegistrationController', ['$http', '$log', function ($http, $log) {
var reg_con = this;
this.registration = {};
this.register = function () {
$log.log('START');
$log.log(reg_con.registration);
$http.post('http://147.32.107.139:8081/sensor_registration?access_token=ya29.1wFuoBApLzhK0zgFi4C9Mu3lbqxA10AdZ2b1ihQLctssG8YgZ0ghyOymdZ3I9QIktWvu', reg_con.registration)
.then(function () {
$log.log('END');
});
};
}]);
})();