marlin-conf
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -220,4 +220,4 @@ //modules | ||
.then(outFile(file)) | ||
.then(a=>console.log('updated h: ',path.relative(root,file))) | ||
.catch(a=>console.log('fail h: ',file,a)) | ||
.then(a=>(console.log('updated h: ',path.relative(root,file)),a)) | ||
.catch(a=>{ console.log('fail h: ',file,a); throw a;}) | ||
} | ||
@@ -224,0 +224,0 @@ |
{ | ||
"name": "marlin-conf", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "configuration tool for Marlin project", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -57,5 +57,6 @@ var express = require('express'); | ||
ob[0][req.params.prop]=req.params.value; | ||
mctool.updateH(root,path.join(root,'Marlin',req.params.file+'.h'),ob); | ||
return mctool.updateH(root,path.join(root,'Marlin',req.params.file+'.h'),ob); | ||
}) | ||
.then(a=>res.send(req.params)) | ||
.catch(a=>res.status(403).send(a)) | ||
}) | ||
@@ -62,0 +63,0 @@ function main(){ |
@@ -10,5 +10,19 @@ function _add(tmpl){ | ||
} | ||
function getVal(o,name){ | ||
function saveProp(cmd){ | ||
var state=$('.mct-header .mct-status') | ||
state.text('saving...').fadeIn().css({color:'black'}); | ||
return $.post(cmd) | ||
.then(function(a){ state.text('saved').fadeOut(1000); return a}) | ||
.fail(function(a){ state.text(''+a.responseJSON.code).css({color:'red'})}) | ||
} | ||
function applyProp(def,row,prop,val){ | ||
def.changed=def.changed||{} | ||
def.changed[prop]=val | ||
var ch=['disabled','value'].filter(function(i){ return i in def.changed &&def.changed[i]!=def[i]}) | ||
row.toggleClass('bg-info',!!ch.length) | ||
} | ||
function updateChanged(sec){ | ||
var cnt=sec.find('.form-group.bg-info').length; | ||
sec.find('.panel-title span.badge:eq(1)').text(cnt); | ||
} | ||
$(function(){ | ||
@@ -41,28 +55,16 @@ var defs=$.get('/json'); | ||
var val=d.find('input').eq(1).val(dv); | ||
function processProp(name,val){ | ||
saveProp('/set/'+file.file.name+'/'+define+'/'+name+'/'+val) | ||
.then(a=>applyProp(def,d,name,val)) | ||
} | ||
function saveProp(cmd){ | ||
var state=$('.mct-header span').eq(1) | ||
state.text('saving...').fadeIn(); | ||
return $.post(cmd) | ||
.then(a=>(state.text('saved').fadeOut(1000),a)) | ||
.fail(a=>state.text('error')) | ||
} | ||
function applyProp(def,row,prop,val){ | ||
def.changed=def.changed||{} | ||
def.changed[prop]=val | ||
var ch=['disabled','value'].filter(i=>def.changed[i]&&def.changed[i]!=def[i]) | ||
row.toggleClass('bg-info',ch.length) | ||
} | ||
dis.on('change',function(){ | ||
processProp('disabled',!dis.prop('checked')); | ||
}) | ||
val.on('change',function(){ | ||
var dv=$(this).val(); | ||
if (def.type=='string') | ||
dv='"'+dv+'"'; | ||
processProp('value',dv); | ||
}) | ||
function processProp(name,val){ | ||
saveProp('/set/'+file.file.name+'/'+define+'/'+name+'/'+val) | ||
.then(function(){ applyProp(def,d,name,val)}) | ||
.then(function(){ updateChanged(d.parents('.panel'))}) | ||
} | ||
dis.on('change',function(){ | ||
processProp('disabled',!dis.prop('checked')); | ||
}) | ||
val.on('change',function(){ | ||
var dv=$(this).val(); | ||
if (def.type=='string') | ||
dv='"'+dv+'"'; | ||
processProp('value',dv); | ||
}) | ||
var p=d.find('.col-sm-6 p'); | ||
@@ -73,3 +75,3 @@ var b=d.find('button'); | ||
else | ||
b.on('click',a=>loadHint(define)) | ||
b.on('click',function(){loadHint(define)}) | ||
if (def.value == undefined) | ||
@@ -80,4 +82,9 @@ val.remove(),p.remove(); | ||
}) | ||
sec.find('.panel-title span:eq(1)').text(cnt); | ||
sec.find('.panel-title span.badge:eq(0)').text(cnt); | ||
updateChanged(sec); | ||
sec.find('[type=checkbox]').bootstrapToggle() | ||
with(sec.find('.panel-heading button')){ | ||
eq(1).on('click',function(){sec.find('.form-group').not('.bg-info').hide()}) | ||
eq(0).on('click',function(){sec.find('.form-group').show()}) | ||
} | ||
}) | ||
@@ -84,0 +91,0 @@ }) |
Sorry, the diff of this file is not supported yet
169480
875