-
Notifications
You must be signed in to change notification settings - Fork 0
/
st-entity-observedproperties.html
67 lines (64 loc) · 2.22 KB
/
st-entity-observedproperties.html
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
67
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="st-repository-observedproperty.html">
<link rel="import" href="st-utils.html">
<dom-module id="st-entity-observedproperties" odata="{{odata}}">
<template>
<st-repository-observedproperty id="observedpropertyrepo" baseurl='{{baseurl}}' on-getdone='_observedPropertiesReceived'></st-repository-observedproperty>
<st-utils id="utils" baseurl='{{baseurl}}'></st-utils>
</template>
<script>
Polymer({
is:'st-entity-observedproperties',
properties: {
auto: {
type: Boolean,
value: false
},
baseurl: {
type: String,
notify: true
},
odata: {
type: Object
},
collection: {
type: Array,
notify: true
},
count: {
type: Number,
notify: true
},
nextlink: {
type: String,
notify: true
}
},
_observedPropertiesReceived(res){
var data = res.detail.response;
if(data['@iot.count']) { this.count = data['@iot.count']; }
if(data.value) { this.collection = data.value; }
this.nextlink = data['@iot.nextLink'] ? data['@iot.nextLink'] : "";
},
get(){
this.$.observedpropertyrepo.get(this.odata);
},
getNextPage(){
if(this.nextlink) {
this.$.utils.updateOdataForNextLink(this.odata, this.nextlink);
this.get();
} else {
throw "No nextlink available";
}
},
post(data){
this.$.observedpropertyrepo.post(data);
},
ready(){
if(this.auto){
this.get();
}
}
});
</script>
</dom-module>