Skip to content

Commit 515f23f

Browse files
committed
electron git clone status, #28, set values fixed, tabs moved, reset value added, config version issue
1 parent 063ad70 commit 515f23f

File tree

10 files changed

+60
-36
lines changed

10 files changed

+60
-36
lines changed

HACKS

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
nat-upnp/lib/nat-upnp/client.js
2-
@@ -106,2 +106,3 @@
3-
});
4-
if (!key) return callback(Error('Incorrect response'));
5-
data = data[key];
2+
@@ -119,3 +119,3 @@
3+
- protocol: data.NewProtocol.toLowerCase(),
4+
+ protocol: (data.NewProtocol || '').toLowerCase(),

app/git-tool.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ exports.Show = (branch, file) => promisify('show', git(root))([branch + ':' + fi
4242
exports.git=git;
4343
exports.root = dir => dir || !root ? gitRoot(dir) : Promise.resolve(root);
4444

45-
exports.clone=name=>new Promise((done,fail)=>{
45+
exports.clone = (name, cb) => new Promise((done, fail) => {
4646
name = name && ('"' + name + '"') || '';
47-
var cmd = exec('git clone https://github.com/MarlinFirmware/Marlin.git ' + name);
47+
var cmd = exec('git clone --progress https://github.com/MarlinFirmware/Marlin.git ' + name);
4848
var timer = setInterval(a=>process.stdout.write("."), 500)
4949
cmd.stdout.on('data', (data) => {
50-
console.log(data.toString());
50+
//console.log(data.toString());
5151
});
5252
cmd.stderr.on('data', (data) => {
53-
console.log(data.toString());
53+
//console.error(data.toString());
54+
cb && cb(data.toString());
5455
});
5556
cmd.on('close', (code) => {
5657
clearInterval(timer);

app/mc-tool.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ var addNumber=a=>{
3232
var killComments=a=>a.map(i=>(i.comment=null,i))
3333
var killDublicated=a=>a.filter(i=>i.number==undefined||!i.disabled).map(i=>(i.number=undefined,i))
3434

35+
const skips = ['CONFIGURATION_H_VERSION'];
36+
3537
var setConfig=(target,file,root)=>a=>{
3638
var map=remap(a);
3739
return Promise.resolve(target).then(t=>{
3840
var undef=[];
39-
var res=t.map(i=>{
41+
var res=t.filter(i => skips.indexOf(i.name) < 0).map(i => {
4042
var o=map[i.name];
4143
if (!o){
4244
undef.push(i.line);

app/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ app.post('/set/:file/:name/:prop/:value', function (req, res) {
700700
var ob = {name: name[0]};
701701
var set = (prop, val) => ob[prop] = (prop == 'disabled' ? val == 'true' : val);
702702
name.length > 1 && set('number', parseInt(name[1]));
703-
set(req.params.prop, req.params.value);
703+
set(req.params.prop, atob(decodeURI(req.params.value)).toString());
704704
return git.root()
705705
.then(root => mctool.updateH(root, path.join(root, 'Marlin', req.params.file + '.h'), [ob]))
706706
.then(a => Object.assign(req.params, {ip: ip}))

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ ipcMain.on('starter-pio', function(ev) {
5252
app.on('ready', function() {
5353
var status = new BrowserWindow({width: 400, height: 400, maximizable: false})
5454
status.setMenu(null);
55+
const update = val => status.webContents.send('starter-git', val);
5556
var folders = store.get('folders') || [];
5657
var opts = {'-G': 0};
5758
Object.keys(opts).reduce((v, key) => (v.i = v.p.indexOf(key), v.i >= 0 && (opts[key] = v.p[v.i + 1]), v), {p: process.argv});
@@ -92,7 +93,7 @@ app.on('ready', function() {
9293
console.log('no repository found in this folder');
9394
showNotify('Wait while Marlin Firmware repo cloning');
9495
dir = path.join(dir, 'Marlin')
95-
return git.clone(dir)
96+
return git.clone(dir, update)
9697
.then(git.root)
9798
.then(a => showNotify('Well done!'))
9899
.catch(e => git.root(dir));

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "marlin-conf",
3-
"version": "2.9.0",
3+
"version": "2.9.1",
44
"description": "configuration tool for Marlin project",
55
"main": "./index.js",
66
"scripts": {
@@ -92,9 +92,9 @@
9292
"yauzl": "^2.9.1",
9393
"yazl": "^2.4.3"
9494
},
95-
"devDependencies": {
95+
"devDependenciesOff": {
9696
"devtron": "^1.4.0",
97-
"electron": "1.7.x",
97+
"electron": "=1.7.10",
9898
"electron-builder": "^20.2.0",
9999
"electron-debug": "^1.5.0",
100100
"eslint": "^4.18.1",

start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function marlin(){
4949
else
5050
if ( is.git ) {
5151
['Marlin/Configuration_adv','Marlin/Configuration'].forEach(f=>{
52-
var base=Promise.all([git.root(),git.Show(is.git,f)]);
52+
var base = Promise.all([git.root(), git.Show(is.git, f + '.h')]);
5353
if ( is.json )
5454
base
5555
.then(a=>mctool.makeJson(a[0],a[1])(path.join(a[0],f+'.h')))

static/index.html

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
background: white;
6363
top: 70%;
6464
height: 30%;
65+
z-index: 5;
6566
}
6667
@media (min-width: 992px){
6768
.mct-hint{
@@ -94,6 +95,7 @@
9495
z-index: 1030;
9596
transition: right 1s;
9697
right:-200px;
98+
max-width: 200px;
9799
}
98100
.navbar-side-right.toggled,
99101
.navbar-side-right:hover{
@@ -474,7 +476,15 @@ <h5 class="modal-title" id="mct-restoreModalLabel">Choose desired configuration
474476
</div>
475477
</div>
476478
</nav>
477-
479+
<nav class="navbar navbar-toggleable-md navbar-light bg-faded config-files">
480+
<ul class="nav nav-tabs" role="tablist">
481+
<template class="_tab_item">
482+
<li class="nav-item">
483+
<a href="#" class="nav-link" role="tab" data-toggle="tab"></a>
484+
</li>
485+
</template>
486+
</ul>
487+
</nav>
478488
<div class="upload-drop-zone" id="mct-dragzone" style="display:none">
479489
Just drag and drop files here
480490
</div>
@@ -525,16 +535,9 @@ <h4 class="alert-heading">Information</h4>
525535
</nav>
526536
</div>
527537
<!-- content -->
528-
<div class="row" style="margin-bottom: 300px;margin-top:100px;">
538+
<div class="row" style="margin-bottom: 300px;margin-top:150px;">
529539
<div class="col-12 col-md-12 col-lg-7">
530-
<div class="tabbable config-files">
531-
<ul class="nav nav-tabs" role="tablist">
532-
<template class="_tab_item">
533-
<li class="nav-item">
534-
<a href="#" class="nav-link" role="tab" data-toggle="tab"></a>
535-
</li>
536-
</template>
537-
</ul>
540+
<div class="tabbable">
538541
<div class="tab-content">
539542
<template class="_tab_content">
540543
<div class="tab-pane fade" id="panel-ID" role="tabpanel">
@@ -561,7 +564,12 @@ <h4 class="alert-heading">Information</h4>
561564
</label>
562565
</div>
563566
<div class="mb-1 mct-splitter"></div>
567+
<div class="input-group">
564568
<input type="text" class="form-control form-control-sm">
569+
<div class="input-group-btn">
570+
<button class="btn btn-secondary btn-sm" type="button"><i class="fa fa-times"></i></button>
571+
</div>
572+
</div>
565573
<select class="custom-select form-control-sm">
566574
<option value="true">True</option>
567575
<option value="false">False</option>

static/main.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ $(function(){
328328
d.find('label').eq(0).text(define.split('.')[0]).attr('title',def.line.trim())//.tooltip(def.line.length>24&&tooltip_large); //take 200ms
329329
var dis=d.find('.onoffswitch')
330330
var p=d.find('.mct-splitter');
331-
var val=d.find('input[type=text]');
331+
var val=d.find('.input-group');
332332
var sel=d.find('select');
333333
if (def.value == undefined)
334334
val.remove(),p.remove(),sel.remove();
@@ -348,7 +348,7 @@ $(function(){
348348
def.type='numeric';
349349
}
350350
}
351-
var inp=val;
351+
var inp=val.find('input');
352352
if (['boolean','select'].indexOf(def.type)>=0){
353353
inp=sel;
354354
val.remove();
@@ -366,10 +366,9 @@ $(function(){
366366
}else{
367367
if (def.type=='string')
368368
dv=dv.slice(1,-1)
369-
val.val(dv);
369+
inp.val(dv);
370370
sel.remove();
371371
}
372-
inp.attr('dtype', def.type)
373372
}
374373

375374
if ( !( def.changed && def.changed.disabled ) && !def.disabled && def.value != undefined)
@@ -400,18 +399,26 @@ $(function(){
400399
loadHint(define);
401400
if (btn.hasClass('fa-github'))
402401
window.opener("https://github.com/MarlinFirmware/Marlin/search?q=" + define + "&type=Issues&utf8=%E2%9C%93", "_blank");
402+
if (btn.find('.fa-times').length) {
403+
var inp = $(this).parent().siblings('input');
404+
var val = opts[define].value;
405+
if (opts[define].type == 'string')
406+
val = val.slice(1, -1);
407+
inp.val(val);
408+
processProp(define, 'value', opts[define].value)
409+
}
403410
})
404411
function processProp(define, name, val) {
405412
lastChanged = define + name;
406-
saveProp('/set/' + file.file.name + '/' + define + '/' + name + '/' + val)
413+
saveProp('/set/' + file.file.name + '/' + define + '/' + name + '/' + encodeURI(btoa(val)))
407414
.then(function() {
408415
setProp(define, name, val);
409416
});
410417
}
411418
tab.tab.on('change', '.card-block select,.card-block input[type=text]', function() {
412419
var btn = $(this), define = btn.parents('.form-group').attr('define');
413420
var val = btn.val();
414-
if (btn.attr('dtype') == 'string')
421+
if (opts[define].type == 'string')
415422
val = '"' + val + '"';
416423
processProp(define, 'value', val);
417424
})
@@ -441,6 +448,7 @@ $(function(){
441448
setTimeout(function(){location.hash=href+' ';},500);
442449
}
443450
});
451+
return;
444452
var sideCountdown = 3;
445453
$(window).scroll($.debounce( 250, true, function(){
446454
sideCountdown && $('.navbar-side-right').toggleClass('toggled', true);
@@ -715,7 +723,7 @@ $(function(){
715723
source.addEventListener('set', function(event) {
716724
var data= JSON.parse(event.data);
717725
if (lastChanged!==data.name+data.prop){
718-
var def=opts[data.name],val=data.value,ui=uiDefs[data.name];
726+
var def=opts[data.name],val=atob(decodeURI(data.value)).toString(),ui=uiDefs[data.name];
719727
if (data.prop=='disabled'){
720728
val=val=='true';
721729
ui.find('.onoffswitch input').prop('checked',!val)
@@ -757,7 +765,7 @@ $(function(){
757765
proc.init=function(){ p.text(''); r.modal();}
758766
proc.info=function(){
759767
_add($('template._alert'))
760-
.find('p').html(`to install PlatformIO use guide from
768+
.find('p').html(`to install PlatformIO use guide from
761769
<strong><a target="_blank" href="http://docs.platformio.org/en/latest/installation.html">Official site</a></strong>
762770
<br>Linux/Mac hint: <code>sudo apt install python-pip</code> <code>sudo pip install -U platformio</code>`)
763771
}

views/start.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
margin: 5px;
7272
padding:0;
7373
}
74-
li {
74+
.trim-left {
7575
white-space: nowrap;
7676
overflow: hidden;
7777
text-overflow: ellipsis;
@@ -115,6 +115,11 @@
115115
$('.component.pio .state').text(data ? 'instaled' : 'error');
116116
data && $('.component.pio').addClass('installed');
117117
});
118+
ipc.on('starter-git', function(ev, data) {
119+
var a = data.split(' ');
120+
var i = a.findIndex(function(i) { return i.indexOf('%') >= 0;})
121+
i >= 0 && $('.folder span').text(a[i] + ' ' + a[i + 1]);
122+
});
118123
ipc.on('starter-init', function(ev, data) {
119124
['git','pio'].map(function(i) {
120125
var c = $('.component.' + i)
@@ -123,7 +128,7 @@
123128
});
124129
data.pio && $('.component.pio button').text('reinstall')
125130
+(data.folders || []).slice(0,4).map(function(f, n) {
126-
$('ul').append($('<li>').text(f).attr('n', n).attr('title', f))
131+
$('ul').append($('<li>').addClass('trim-left').text(f).attr('n', n).attr('title', f))
127132
});
128133
})
129134
})
@@ -152,7 +157,7 @@
152157
</div></div>
153158

154159
<div class="component folder">
155-
<br>
160+
<span>&nbsp;</span>
156161
<button>open folder</button>
157162
<ul>
158163
<li n="new" class="active">new</li>

0 commit comments

Comments
 (0)