craftbeerpi4-pione/cbpi/controller/dashboard_controller.py

34 lines
1,000 B
Python
Raw Normal View History

2019-01-02 21:20:44 +01:00
import logging
from voluptuous import Schema, MultipleInvalid
2019-01-05 20:43:48 +01:00
from cbpi.controller.crud_controller import CRUDController
from cbpi.database.model import DashboardModel, DashboardContentModel
2019-01-02 21:20:44 +01:00
class DashboardController(CRUDController):
model = DashboardModel
name = "Dashboard"
def __init__(self, cbpi):
super(DashboardController, self).__init__(cbpi)
self.cbpi = cbpi
self.logger = logging.getLogger(__name__)
self.cbpi.register(self)
2019-01-07 22:05:52 +01:00
def get_state(self):
return dict(items=self.cache)
2019-01-02 21:20:44 +01:00
async def get_content(self, dashboard_id):
return await DashboardContentModel.get_by_dashboard_id(dashboard_id)
async def add_content(self, data):
return await DashboardContentModel.insert(**data)
async def delete_content(self, content_id):
await DashboardContentModel.delete(content_id)
async def move_content(self,content_id, x, y):
await DashboardContentModel.update_coordinates(content_id, x, y)