-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathphoneDatasource.js
More file actions
65 lines (55 loc) · 1.67 KB
/
phoneDatasource.js
File metadata and controls
65 lines (55 loc) · 1.67 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
For version 1 of OpenXC Social Template, we use this datasource simply to store the
master's phone number, to which alerts are sent. For future versions, we will
uncomment the commented lines to enable communication TO the dashboard from the
master's phone.
*/
(function () {
var phoneDatasource = function (settings, updateCallback) {
var self = this;
var currentSettings = settings;
function onNewDweet(dweet) {
updateCallback(dweet);
}
this.updateNow = function () {
// dweetio.get_latest_dweet_for(currentSettings.thing_id, function (err, dweet) {
// if (err) {
// onNewDweet({});
// }
// else {
// onNewDweet(dweet[0].content);
// }
// });
}
this.onDispose = function () {
}
this.onSettingsChanged = function (newSettings) {
// dweetio.stop_listening();
currentSettings = newSettings;
if (currentSettings.phone_numer && currentSettings.phone_number !== "") {
// dweetio.listen_for(currentSettings.phone_number, function (dweet) {
// onNewDweet(dweet.content);
// });
}
}
self.onSettingsChanged(settings);
};
freeboard.loadDatasourcePlugin({
"type_name": "phone",
"display_name": "Phone Datasource",
"external_scripts": [
//"https://dweet.io/client/dweet.io.min.js"
],
"settings": [
{
name: "phone_number",
display_name: "Phone Number",
"description": "please include country code and remove all symbols e.g. 12223334444",
type: "text"
}
],
newInstance: function (settings, newInstanceCallback, updateCallback) {
newInstanceCallback(new phoneDatasource(settings, updateCallback));
}
});
}());