Procházet zdrojové kódy

Action Button for Sensors added

tags/3.1_alpha
Manuel83 před 8 roky
rodič
revize
3af76d0a1e
3 změnil soubory, kde provedl 42 přidání a 28 odebrání
  1. +10
    -1
      modules/core/core.py
  2. +5
    -0
      modules/sensors/__init__.py
  3. +27
    -27
      modules/ui/static/bundle.js

+ 10
- 1
modules/core/core.py Zobrazit soubor

@@ -267,7 +267,7 @@ class CraftBeerPi(ActorAPI, SensorAPI):
# helper method for parsing props
def __parseProps(self, key, cls):
name = cls.__name__
self.cache[key][name] = {"name": name, "class": cls, "properties": []}
self.cache[key][name] = {"name": name, "class": cls, "properties": [], "actions": []}
tmpObj = cls()
members = [attr for attr in dir(tmpObj) if not callable(getattr(tmpObj, attr)) and not attr.startswith("__")]
for m in members:
@@ -283,6 +283,13 @@ class CraftBeerPi(ActorAPI, SensorAPI):
t = tmpObj.__getattribute__(m)
self.cache[key][name]["properties"].append(
{"name": m, "label": t.label, "type": "select", "configurable": True, "options": t.options})

for name, method in cls.__dict__.iteritems():
if hasattr(method, "action"):
label = method.__getattribute__("label")
self.cache[key][cls.__name__]["actions"].append({"method": name, "label": label})


return cls


@@ -315,6 +322,8 @@ class CraftBeerPi(ActorAPI, SensorAPI):

def get_fermentation_controller(self, name):
return self.cache["fermentation_controller_types"].get(name)


# Step action
def action(self,label):
def real_decorator(func):


+ 5
- 0
modules/sensors/__init__.py Zobrazit soubor

@@ -12,6 +12,11 @@ class SensorView(BaseView):
model = Sensor
cache_key = "sensors"

@route('<int:id>/action/<method>', methods=["POST"])
def action(self, id, method):

cbpi.cache.get("sensors").get(id).instance.__getattribute__(method)()
return ('', 204)

def _post_post_callback(self, m):
cbpi.init_sensor(m.id)


+ 27
- 27
modules/ui/static/bundle.js
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


Načítá se…
Zrušit
Uložit