- config panel regexp validation on values

- restart application function added
This commit is contained in:
jean-emmanuel 2015-09-09 19:18:10 +02:00 • committed by bordun
parent 91b487312a
commit 2fb5012aad
5 changed files with 123 additions and 38 deletions

View file

@ -117,13 +117,13 @@ body {
a.btn {
.btn {
background: $bg-button;
display: block;border:1px solid $color-border;
padding:10px;
&:hover {
background: $bg-button-hover;
}
padding:15px;
}
a.btn:hover {
background: $bg-button-hover;
}
#lobby {
@ -134,14 +134,20 @@ a.btn {
display: flex;
align-items: center;
justify-content: center;
overflow-y: auto;
padding:20px;
.main {
width:600px;
max-height:100%;
}
.header {
background: $bg-button;
padding:20px;
font-weight:bold;
box-shadow: 0 0 0 1px $color-border inset;
white-space: nowrap;
text-overflow: ellipsis;
}
a {
padding-right:35px;
@ -152,10 +158,9 @@ a.btn {
text-overflow: ellipsis;
span {
position: absolute;
right:1px;
top:1px;
bottom:1px;
padding:9px;
right:0px;
top:0px;
padding:15px;
color:$color-text-fade;
&:hover {
color:$color-text
@ -223,7 +228,7 @@ a.btn {
li {
display:block;
margin-bottom:15px;
margin-bottom:5px;
background:$bg-button;
}
@ -465,13 +470,13 @@ a {
z-index:1000000;
.popup-title {
position: relative;
padding:10px;
padding:15px;
background:$bg-button;
.closer {
position:absolute;
right:0px;
top:0;
padding:10px;
padding:15px;
color:$color-text-fade;
cursor: pointer;
&:hover {
@ -485,6 +490,7 @@ a {
width:100%;
position: relative;
overflow: hidden;
border:1px solid $color-border;
.popup-content {
height:100%;
width:100%;
@ -514,6 +520,9 @@ form {
border:1px solid $color-border;
width:100%;
padding:10px;
&.invalid {
box-shadow: 0 0 0 1px rgba(red,.3)!important;
}
&:focus {
box-shadow: 0 0 0 1px $color-accent;
}

View file

@ -125,21 +125,42 @@ createPopup = function(title,content) {
var remote = require('remote');
configPanel = function(){
var readConfig = remote.getGlobal('readConfig')
var readEditableConfig = remote.getGlobal('readEditableConfig')
var writeConfig = remote.getGlobal('writeConfig')
var config = readConfig()
var config = readEditableConfig()
var form = $('<form></form>')
for (i in config) {
var html = $('\
$.each(config,function(i) {
var item = $('<div>\
<label for="'+i+'">'+i+'</label>\
<p class="info">'+config[i].info+'</p>\
<input name="'+i+'" value="'+config[i].value+'"/>')
form.append(html)
}
</div>')
var input = $('<input name="'+i+'" value="'+config[i].value+'"/>')
input.change(function(){
var v = input.val().trim().replace(/[\s]+/,' ')
input.val(v)
console.log([v,v.match(config[i].match)])
if (v.match(config[i].match)==null) {
input.addClass('invalid')
} else {
input.removeClass('invalid')
};
})
item.append(input)
form.append(item)
})
var submit = $('<a class="btn submit">'+icon('save')+'&nbsp;Save configuration</a>')
@ -149,6 +170,11 @@ configPanel = function(){
submit.click(function(e){
e.preventDefault()
if ($('input.invalid').length>0) {
return
}
var data = form.serializeArray(),
newconfig = {}

View file

@ -2,9 +2,9 @@
"presetPath": "/home/bordun/oscwork/oschtmlgui/presets/",
"sessionPath": "/home/bordun/oscwork/oschtmlgui/sessions/",
"recentSessions": [
"/home/bordun/oscwork/oschtmlgui/sessions/knob.js",
"/home/bordun/oscwork/oschtmlgui/sessions/demo-full.js",
"/home/bordun/oscwork/oschtmlgui/sessions/demo.js",
"/home/bordun/oscwork/oschtmlgui/sessions/demo-full.js",
"/home/bordun/oscwork/oschtmlgui/sessions/knob.js",
"/home/bordun/oscwork/oschtmlgui/sessions/xy.js",
"/home/bordun/oscwork/oschtmlgui/sessions/fadertest.js"
],

View file

@ -12,7 +12,7 @@ var app = require('app')
, ipc = require('ipc')
, configPath = __dirname + '/config.json'
, config = require(configPath)
, args = process.argv.slice(1);
, args = process.argv.slice(0);
dialog.showErrorBox = function(title,err) {
console.log(title + ': ' + err)
@ -27,9 +27,14 @@ var defaultConfig = {
oscInPort:5555
}
var editableConfig = {
syncTargets: "List of target hosts (ip:port pairs), separeted by spaces. Every OSC message sent by the app will be sent to these hosts too.",
oscInPort: "Port on which the app listens to synchronise with other apps. You'll need to restart the app for this change to take effect."
}
syncTargets: {
info:"List of target hosts (ip:port pairs), separated by spaces. Every OSC message sent by the app will be sent to these hosts too.",
match:'^([^:\s]*:[0-9]*[\s]*)*$'
},
oscInPort: {
info:"Port on which the app listens to synchronise with other apps. <i class='fa fa-warning fa-fw'></i>&nbsp;You'll need to restart the app for this change to take effect.",
match:'^([0-9]+){0,1}$'
}}
@ -45,21 +50,25 @@ writeConfig = function(newconfig) {
}
readConfig = function(key) {
if (key!=undefined) {
return config[key] || defaultConfig[key]
} else {
var ret = {}
for (i in editableConfig) {
ret[i] = {
value:readConfig(i),
info:editableConfig[i]
}
return config[key] || defaultConfig[key]
}
readEditableConfig = function(){
var ret = {}
for (i in editableConfig) {
ret[i] = {
value:readConfig(i),
info:editableConfig[i].info,
match:editableConfig[i].match,
}
return ret
}
return ret
}
restartApp = function(){
var exec = require('child_process').exec;
exec(args.join(' '));
app.quit();
}
@ -127,6 +136,10 @@ app.on('ready', function() {
accelerator: 'F11',
click: function() { window.setFullScreen(!window.isFullScreen()); }
},
{
label:'Restart App',
click:restartApp
}
]
},
]

View file

@ -22,7 +22,7 @@ TABS = {
type:'knob',
target:'localhost:6666',
path:'/osc/path/',
color:'#555522',
color:'cyan',
range:{min:-70,max:6}
},
stacktest: {
@ -233,7 +233,44 @@ TABS = {
target:nmPorts['Drums'],
path:'/strip/Toms/Gain/Gain%20(dB)/unscaled',
color:'#777'
}
},
stacktest: {
type:'stack',
widgets:{
BassesXXX: {
type:'switch',
target:'localhost:6666',
path:'/osc/path/',
color:'#555522',
values:[1,2,3,4,5]
},
BassesXXX: {
title:'BassesXXX',
range:'db',
target:nmPorts['MainMix']+' 127.0.0.1:125',
path:'/test2',
},
xypad_test2: {
title:'XY Pad',
type:'xy',
target:nmPorts['MainMix'],
path:'/pad'
},
xGuitars: {
title:'Guitars',
range:'db',
target:nmPorts['MainMix'],
path:'/strip/Guitars/Gain/Gain%20(dB)/unscaled'
},
button1: {
type:'toggle',
target:'localhost:6666',
path:'/osc/path/',
color:'#555522'
}
}
},
}
}
}