Skip to content
Snippets Groups Projects
Commit 6ebbe7b6 authored by jkerdreu's avatar jkerdreu
Browse files

Added fonts, move to /api/ for cleaner url



git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2682 b32b6428-25c9-4566-ad07-03861ab6144f
parent a4bf57ea
Branches
No related tags found
No related merge requests found
......@@ -28,9 +28,10 @@ def setup_xaal():
engine = Engine()
cfg = tools.load_cfg(PACKAGE_NAME)
if not cfg:
logger.info("No config file found, building a new one")
cfg = tools.new_cfg(PACKAGE_NAME)
logger.info(f"No config file found, building a new one {cfg.filename}")
cfg['config']['port'] = DEFAULT_PORT
cfg['devices'] = random_devices()
cfg.write()
dev = Device("hmi.basic")
dev.address = tools.get_uuid(cfg['config']['addr'])
......@@ -51,6 +52,14 @@ def xaal_loop(engine):
while 1:
engine.loop()
def random_devices():
tmp = {}
for k in ['button','contact','switch']:
uid = str(tools.get_random_uuid())
tmp[uid] = {'name':'fake %s' % k,'type':k}
return tmp
def load_config(engine):
global fake_devices
cfg_devices = cfg.get('devices',[])
......@@ -86,19 +95,19 @@ def static(filename):
def index():
return template('index.tpl',request=request,devices = fake_devices)
@get('/click/<addr>/<click_type:int>')
@get('/api/click/<addr>/<click_type:int>')
def click(addr,click_type):
dev = search_device(addr)
if dev and isinstance(dev,devices.Button):
dev.click(click_type)
@get('/set_on/<addr>')
@get('/api/set_on/<addr>')
def set_on(addr):
dev = search_device(addr)
if dev and not isinstance(dev,devices.Button):
dev.set_on()
@get('/set_off/<addr>')
@get('/api/set_off/<addr>')
def set_off(addr):
dev = search_device(addr)
if dev and not isinstance(dev,devices.Button):
......
File added
......@@ -2,7 +2,7 @@ function on_click(btn) {
if (btn.attributes['xaal-addr']) {
addr = btn.attributes['xaal-addr'].value;
console.log('click:' + addr);
url = '/click/'+addr+'/0';
url = '/api/click/'+addr+'/0';
fetch(url);
}
}
......@@ -11,7 +11,7 @@ function on_dclick(btn) {
if (btn.attributes['xaal-addr']) {
addr = btn.attributes['xaal-addr'].value;
console.log('dclick:' + addr);
url = '/click/'+addr+'/1';
url = '/api/click/'+addr+'/1';
fetch(url);
}
}
......@@ -19,10 +19,10 @@ function on_dclick(btn) {
function on_toggle(btn) {
addr = btn.attributes['xaal-addr'].value;
if (btn.checked == true) {
url = '/set_on/'+addr
url = '/api/set_on/'+addr
}
else {
url = '/set_off/'+addr
url = '/api/set_off/'+addr
}
console.log(url);
fetch(url);
......
:root {
--color1: #10778a;
--color1: #105d8a;
--color2: #777;
--color3: #ff005f;
}
@font-face {
font-family: "play";
src: url('Play-Regular.ttf') format('truetype');
}
body {
margin:10px;
font: 13px "play";
}
h1,h2 {
color: var(--color1);
......@@ -120,6 +129,7 @@ li {
border-radius: 2px;
display: inline-block;
padding: 0.5em 1.5em;
font: inherit;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment