This repository has been archived by the owner on Nov 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a19c3e
commit 4bc5d73
Showing
9 changed files
with
456 additions
and
516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* ============================================================ | ||
* bootstrapSwitch v1.3 by Larentis Mattia @spiritualGuru | ||
* http://www.larentis.eu/switch/ | ||
* ============================================================ | ||
* Licensed under the Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* ============================================================ */ | ||
.has-switch { | ||
border-radius: 30px; | ||
display: inline-block; | ||
cursor: pointer; | ||
line-height: 1.231; | ||
overflow: hidden; | ||
position: relative; | ||
text-align: left; | ||
width: 80px; | ||
-webkit-mask: url('../images/switch/mask.png') 0 0 no-repeat; | ||
mask: url('../images/switch/mask.png') 0 0 no-repeat; | ||
-webkit-user-select: none; | ||
-moz-user-select: none; | ||
-ms-user-select: none; | ||
-o-user-select: none; | ||
user-select: none; | ||
} | ||
.has-switch.deactivate { | ||
opacity: 0.5; | ||
filter: alpha(opacity=50); | ||
cursor: default !important; | ||
} | ||
.has-switch.deactivate label, | ||
.has-switch.deactivate span { | ||
cursor: default !important; | ||
} | ||
.has-switch > div { | ||
width: 162%; | ||
position: relative; | ||
top: 0; | ||
} | ||
.has-switch > div.switch-animate { | ||
-webkit-transition: left 0.25s ease-out; | ||
-moz-transition: left 0.25s ease-out; | ||
-o-transition: left 0.25s ease-out; | ||
transition: left 0.25s ease-out; | ||
-webkit-backface-visibility: hidden; | ||
} | ||
.has-switch > div.switch-off { | ||
left: -63%; | ||
} | ||
.has-switch > div.switch-off label { | ||
background-color: #7f8c9a; | ||
border-color: #bdc3c7; | ||
-webkit-box-shadow: -1px 0 0 rgba(255, 255, 255, 0.5); | ||
-moz-box-shadow: -1px 0 0 rgba(255, 255, 255, 0.5); | ||
box-shadow: -1px 0 0 rgba(255, 255, 255, 0.5); | ||
} | ||
.has-switch > div.switch-on { | ||
left: 0%; | ||
} | ||
.has-switch > div.switch-on label { | ||
background-color: #1abc9c; | ||
} | ||
.has-switch input[type=checkbox] { | ||
display: none; | ||
} | ||
.has-switch span { | ||
cursor: pointer; | ||
font-size: 14.994px; | ||
font-weight: 700; | ||
float: left; | ||
height: 29px; | ||
line-height: 19px; | ||
margin: 0; | ||
padding-bottom: 6px; | ||
padding-top: 5px; | ||
position: relative; | ||
text-align: center; | ||
width: 50%; | ||
z-index: 1; | ||
-webkit-box-sizing: border-box; | ||
-moz-box-sizing: border-box; | ||
box-sizing: border-box; | ||
-webkit-transition: 0.25s ease-out; | ||
-moz-transition: 0.25s ease-out; | ||
-o-transition: 0.25s ease-out; | ||
transition: 0.25s ease-out; | ||
-webkit-backface-visibility: hidden; | ||
} | ||
.has-switch span.switch-left { | ||
border-radius: 30px 0 0 30px; | ||
background-color: #34495e; | ||
color: #1abc9c; | ||
border-left: 1px solid transparent; | ||
} | ||
.has-switch span.switch-right { | ||
border-radius: 0 30px 30px 0; | ||
background-color: #bdc3c7; | ||
color: #ffffff; | ||
text-indent: 7px; | ||
} | ||
.has-switch span.switch-right [class*="fui-"] { | ||
text-indent: 0; | ||
} | ||
.has-switch label { | ||
border: 4px solid #34495e; | ||
border-radius: 50%; | ||
float: left; | ||
height: 21px; | ||
margin: 0 -15px 0 -14px; | ||
padding: 0; | ||
position: relative; | ||
vertical-align: middle; | ||
width: 21px; | ||
z-index: 100; | ||
-webkit-transition: 0.25s ease-out; | ||
-moz-transition: 0.25s ease-out; | ||
-o-transition: 0.25s ease-out; | ||
transition: 0.25s ease-out; | ||
-webkit-backface-visibility: hidden; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import bottle_helpers as bh | ||
|
||
class API(object): | ||
def __init__(self, app, config): | ||
self.app = app | ||
self.config = config | ||
app.route('/<out_format:re:(?i)(xml|json)>/<ftype:path>/<func:path>', | ||
method = ['GET', 'POST'], | ||
callback = self.route_all) | ||
self.callbacks = {} | ||
def add_route(self, key, callback): | ||
self.callbacks[key] = callback | ||
def route_all(self, out_format, ftype, func): | ||
if ftype in self.callbacks: | ||
func = func.strip().lower() | ||
resp = self.callbacks[ftype](func) | ||
return bh.format_response(resp, out_format, self.config['pretty_print']) | ||
bh.raise404() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import bottle_helpers as bh | ||
|
||
class ConfigAPI(object): | ||
def __init__(self, api, config): | ||
self.config = config | ||
self.api = api | ||
api.add_route('config', self.route) | ||
|
||
def is_section(self, val): | ||
if not isinstance(val, str): | ||
print self.config[val].depth | ||
return False#not isinstance(val, (str, unicode, list, tuple)) | ||
|
||
def route(self, func): | ||
if (func == 'getall'): | ||
return [{k:v} for k, v in self.config.iteritems() | ||
if not self.is_section(k)] | ||
|
||
elif (func == 'get'): | ||
key = bh.get_string('key') | ||
if key in self.config: | ||
return self.config[key] | ||
bh.raise404() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
class TASensor(object): | ||
def __init__(self, config, rawsensor): | ||
super(TASensor, self).__init__() | ||
super(TASensor, self).__setattr__('id', str(rawsensor.id)) | ||
super(TASensor, self).__setattr__('raw', rawsensor) | ||
|
||
# Create a config entry with default values if one doesn't exist | ||
sensor_config = config['sensors'] | ||
if not self.id in sensor_config.keys(): | ||
sensor_config[self.id] = { | ||
'ignore' : 0, | ||
'name' : None | ||
} | ||
|
||
super(TASensor, self).__setattr__('config', config) | ||
super(TASensor, self).__setattr__('snscfg', sensor_config[self.id]) | ||
super(TASensor, self).__setattr__('ignore', sensor_config[self.id]['ignore']) | ||
super(TASensor, self).__setattr__('name', sensor_config[self.id]['name']) | ||
|
||
def __setattr__(self, name, value): | ||
if name == 'name': | ||
self.snscfg['name'] = value | ||
self.config.write() | ||
elif name == 'ignore': | ||
self.snscfg['ignore'] = int(value) | ||
self.config.write() | ||
else: | ||
raise AttributeError(name) | ||
super(TASensor, self).__setattr__(name, value) |
Oops, something went wrong.