Skip to content

Commit

Permalink
followers 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
flatsiedatsie authored Jul 31, 2020
1 parent 3eae41a commit 20d39c4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
8 changes: 7 additions & 1 deletion js/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

this.item_elements = ['limit1','limit2','thing1','property1','limit3','limit4','thing2','property2'];
this.all_things;
this.items_list = [];

this.item_number = 0;

Expand Down Expand Up @@ -40,6 +41,7 @@
//console.log("clicked on add follower button");
//console.log(this);

/*
var clone = document.getElementById('extension-followers-original-item').cloneNode(true);
clone.removeAttribute('id');
clone.classList.add("new");
Expand All @@ -62,6 +64,9 @@
});
document.getElementById('extension-followers-list').append(clone);
*/
this.items_list.push({'enabled': false});
this.regenerate_items(this.items_list);
});


Expand Down Expand Up @@ -119,10 +124,11 @@
`/extensions/${this.id}/api/init`

).then((body) => {
//console.log("Python API result:");
//console.log("Python API result:");
//console.log(body);
//console.log(body['items']);
if(body['state'] == 'ok'){
this.items_list = body['items']
this.regenerate_items(body['items']);
}
else{
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}
},
"short_name": "Followers",
"version": "0.1.5",
"version": "0.2.0",
"web_accessible_resources": [
"css/*.css",
"images/*.svg",
Expand Down
13 changes: 6 additions & 7 deletions pkg/followers.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def handle_request(self, request):
self.persistent_data['items'] = request.body['items']


print("")
#print("")
# Get all the things via the API.
try:
self.things = self.api_get("/things")
Expand All @@ -345,7 +345,7 @@ def handle_request(self, request):
# try to get the correct property type (integer/float)
try:
for item in self.persistent_data['items']:
print("_item: " + str(item))
#print("_item: " + str(item))
if 'thing2' in item and 'property2' in item:
for thing in self.things:
thing_id = str(thing['id'].rsplit('/', 1)[-1])
Expand All @@ -358,8 +358,8 @@ def handle_request(self, request):
property_id = thing['properties'][thing_property_key]['links'][0]['href'].rsplit('/', 1)[-1]
#print("property_id = " + str(property_id))
if str(item['property2']) == property_id:
print("bingo for property: " + str(property_id))
print("___type: " + str(thing['properties'][thing_property_key]['type']))
#print("bingo for property: " + str(property_id))
#print("___type: " + str(thing['properties'][thing_property_key]['type']))

#self.persistent_data['items'][item]['property2_type'] = str(thing['properties'][thing_property_key]['type'])
item['property2_type'] = str(thing['properties'][thing_property_key]['type'])
Expand Down Expand Up @@ -423,7 +423,7 @@ def unload(self):

def cancel_pairing(self):
"""Cancel the pairing process."""
print("END OF PAIRING -----------------------------")
#print("END OF PAIRING -----------------------------")

# Get all the things via the API.
try:
Expand All @@ -446,7 +446,6 @@ def api_get(self, api_path):
#print("GET TOKEN = " + str(self.token))
if self.token == None:
print("PLEASE ENTER YOUR AUTHORIZATION CODE IN THE SETTINGS PAGE")
self.set_status_on_thing("Authorization code missing, check settings")
return []

try:
Expand Down Expand Up @@ -522,7 +521,7 @@ def api_put(self, api_path, json_dict):

def save_persistent_data(self):
#if self.DEBUG:
print("Saving to persistence data store at path: " + str(self.persistence_file_path))
#print("Saving to persistence data store at path: " + str(self.persistence_file_path))

try:
if not os.path.isfile(self.persistence_file_path):
Expand Down

0 comments on commit 20d39c4

Please sign in to comment.