-
Notifications
You must be signed in to change notification settings - Fork 0
/
st-entity-location.html
129 lines (124 loc) · 4.57 KB
/
st-entity-location.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="st-repository-location.html">
<dom-module id="st-entity-location">
<template>
<st-repository-location id="locationrepo" baseurl='{{baseurl}}' on-getdone='_locationReceived' ></st-repository-location>
</template>
<script>
Polymer({
is:'st-entity-location',
properties: {
auto: {
type: Boolean,
value: false
},
odata: {
type: Object
},
rawreceived: {
type: Object,
notify: true,
observer: '_rawChanged'
},
gid: {
type: Number,
notify: true
},
selflink: {
type: String,
notify: true
},
name: {
type: String,
notify: true
},
description: {
type: String,
notify: true
},
location: {
type: String,
notify: true
},
encodingtype: {
type: String,
notify: true
},
thingsurl: {
type: String,
notify: true
},
historicallocationsurl: {
type: String,
notify: true
},
baseurl: {
type: String,
notify: true
},
things: {
type: Array,
notify: true
},
historicallocations: {
type: Array,
notify: true
},
deleted: {
type: Boolean,
notify: true,
value: false
}
},
_locationReceived(res){
this.rawreceived = res.detail.response;
},
_deleteDone(res){
this.deleted = true;
},
_rawChanged(){
if(!this.rawreceived){
return;
}
if(this.rawreceived['@iot.id']) { this.gid = this.rawreceived['@iot.id']; }
if(this.rawreceived.name) { this.name = this.rawreceived.name; }
if(this.rawreceived.description) { this.description = this.rawreceived.description; }
if(this.rawreceived.location) { this.location = this.rawreceived.location; }
if(this.rawreceived.encodingType) { this.encodingtype = this.rawreceived.encodingType; }
if(this.rawreceived['@iot.selfLink']) { this.selflink = this.rawreceived['@iot.selfLink']; }
if(this.rawreceived['Things@iot.navigationLink']) { this.thingsurl = this.rawreceived['Things@iot.navigationLink']; }
if(this.rawreceived['HistoricalLocations@iot.navigationLink']) { this.historicallocationsurl = this.rawreceived['HistoricalLocations@iot.navigationLink']; }
if(this.rawreceived.HistoricalLocations){ this.historicallocations = this.rawreceived.HistoricalLocations; }
if(this.rawreceived.Things){ this.things = this.rawreceived.Things; }
},
get(id){
if(id){
this.gid = id;
}
this.$.locationrepo.getByID(this.gid, this.odata);
},
put(){
this.$.locationrepo.put(this.gid, this._createLocationObject());
},
patch(){
this.$.locationrepo.patch(this.gid, this._createLocationObject());
},
delete(){
this.$.locationrepo.delete(this.gid);
},
_createLocationObject(){
return {
name: this.name,
description: this.description,
location: this.location,
encodingType: this.encodingtype
};
},
ready(){
if(this.auto){
this.get();
}
}
});
</script>
</dom-module>