-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautoGrowV1.js
51 lines (49 loc) · 1.41 KB
/
autoGrowV1.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
(function () {
freeboard.loadDatasourcePlugin({
type_name: "autogrow_plugin",
display_name: "Huxley",
description : "Huxley - Autogrow plugin <strong>by Bug Labs!</strong>",
settings: [
{
name: "uuid",
display_name: "Device UUID",
type: "text",
default_value: "370889dd1590be048e9b99ab620941af",
description : "Autogrow UUID",
},
{
name: "refresh",
display_name: "Refresh Every",
type: "number",
suffix: "seconds",
default_value: 10
}
],
newInstance: function (settings, newInstanceCallback, updateCallback) {
newInstanceCallback(new huxleyAgDatasource(settings, updateCallback));
}
});
var huxleyAgDatasource = function (settings, updateCallback) {
var self = this;
var currentSettings = settings;
var getData = function () {
$.ajax({
type: "GET",
url: "https://api.autogrow.com/multi/v0/" + currentSettings.uuid + "/site",
success: function (payload) {
updateCallback(JSON.parse(payload));
},
error: function (xhr, status, error) {
}
});
}
self.onSettingsChanged = function (newSettings) {
currentSettings = newSettings;
};
self.updateNow = function () {
getData();
};
self.onDispose = function () {
};
};
}());