Exemplo n.º 1
0
 def save(self, slug):
     """Save configuration."""
     sensor_name = slug
     min_value = self.get_argument('min_value')
     max_value = self.get_argument('max_value')
     suffix = self.get_argument('suffix')
     reverse = True if 'reverse' in self.request.arguments else False
     sensor = Sensor(sensor_name, min_value, max_value, reverse, suffix)
     sensor.save()
     slug = url_escape(slug)
     redirect_url = self.redirect_url
     if slug not in redirect_url:
         redirect_url += '/' + slug
     self.redirect(redirect_url, permanent=True)
Exemplo n.º 2
0
 def edit(self, slug):
     """Show configuration form for device."""
     sensor = Sensor.get(slug)
     settings = dict()
     settings['sensor'] = sensor
     settings['method'] = 'put'
     self.render('sensor/config.html', **settings)
Exemplo n.º 3
0
 def show(self, slug):
     """Show device."""
     sensor = Sensor.get(slug)
     if sensor is not None:
         self.render('sensor/show.html', sensor=sensor, slug=slug)
     else:
         self.redirect('/sensor', permanent=False)
Exemplo n.º 4
0
 def get_port_list(self):
     """Get port list from config."""
     self.ports = Manager().dict()
     self.value = Manager().dict()
     self.sensors = dict()
     for p in self.device.ports['input']:
         if p.enabled:
             self.ports[p.number] = p
             self.value[p.number] = 'Connexion à la carte'
             self.sensors[p.number] = Sensor.get(p._type)
Exemplo n.º 5
0
    def edit(self, slug):
        """Show configuration form for device."""
        device = Device.get(Device.get_identifier_from_serial(slug))
        cards = Card.get_all()
        sensors = Sensor.get_all()
        if device is None:
            device = Device.get_config(slug)
            if device is None:
                self.redirect(self.redirect_url + '/create', permanent=False)

        settings = dict()
        settings['method'] = 'put'
        settings['cards'] = cards
        settings['card'] = device.card
        settings['sensors'] = sensors
        settings['device'] = device
        settings['method'] = 'put'
        self.render('device/config.html', **settings)
Exemplo n.º 6
0
 def create(self, slug):
     """Show configuration form for device."""
     cards = Card.get_all()
     sensors = Sensor.get_all()
     device = Device.get(slug)
     if 'card' in self.request.arguments:
         card = Card.get(self.get_argument('card'))
     else:
         card = None
     settings = dict()
     settings['method'] = 'post'
     settings['cards'] = cards
     settings['card'] = card
     settings['sensors'] = sensors
     settings['device'] = device
     settings['slug'] = slug
     settings['method'] = 'post'
     self.render('device/config.html', **settings)
Exemplo n.º 7
0
 def list(self):
     """List configurations."""
     sensors = Sensor.get_all()
     self.render('sensor/list.html', sensors=sensors)
Exemplo n.º 8
0
 def destroy(self, slug):
     """Destroy configuration."""
     sensor = Sensor.get(slug)
     sensor.delete()
     self.redirect(self.redirect_url, permanent=False)