main: read-only mode (disables, editor and session history)

This commit is contained in:
jean-emmanuel 2017-03-21 08:19:21 +01:00
parent f8b8a566c5
commit 0899f5bc5e
9 changed files with 73 additions and 23 deletions

View file

@ -4,7 +4,8 @@
- bug fixes
- `editor`: correctly remove editing state when disabling the editor right after going to another tab
- main
- **new** `--read-only` switch for disabling the editor and preventing change to the session history
- widgets
- `panel/modal`: add `layout` option ([Visual Format Language](https://github.com/IjzerenHein/autolayout.js))
- `css` option now interprets `&` as a selector for the widget's element itself (useful for targetting pseudo-elements such as `&:after`)

View file

@ -16,6 +16,10 @@ module.exports = {
if (settings.read('theme')) ipc.send('applyStyle',settings.read('theme'),clientId)
if (settings.read('readOnly')) {
ipc.send('editorDisable',{permanent:true})
}
if (settings.read('newSession')) {
ipc.send('sessionNew')
return
@ -85,7 +89,7 @@ module.exports = {
if (data.path) {
this.sessionAddToHistory(data.path)
if (!settings.read('readOnly')) this.sessionAddToHistory(data.path)
fs.lstat(data.path, (err, stats)=>{

View file

@ -61,7 +61,7 @@ if (cli) {
launcher
app.on('ready',function(){
launcher = require('./electron-window')({address:address, shortcuts:false, width:600, height:510})
launcher = require('./electron-window')({address:address, shortcuts:false, width:600, height:540})
})
ipcMain.on('start',function(e, options){

View file

@ -50,7 +50,13 @@ var options = {
true : 'examples can\'t be listed if --load is set'
}
},
'disable-vsync':{type:'boolean',describe:'disable gui\'s vertical synchronization', restart: true}
'disable-vsync':{type:'boolean',describe:'disable gui\'s vertical synchronization', restart: true},
'read-only':{type:'boolean',describe:'disable session editing',
check: (r, argv)=>{
return (!argv.b) ?
true : 'blank session can\'t be started in read-only mode'
}
},
}
@ -95,6 +101,7 @@ var makeDefaultConfig = function(argv){
noGui: argv.n || false,
guiOnly: typeof argv.g == 'string' ? argv.g.length ? argv.g : true : false,
noVsync: argv['disable-vsync'] || false,
readOnly: argv['read-only'] || false,
midi: argv.m,
appAddresses:function(){
var appAddresses = []

View file

@ -1,6 +1,5 @@
var {widgetManager} = require('./managers'),
ipc = require('./ipc'),
{Fader} = require('./widgets/sliders/fader')
ipc = require('./ipc')
module.exports = {
@ -146,7 +145,7 @@ module.exports = {
})
$('.editor').append(f)
},
editorDisable: function(){
editorDisable: function(permanent){
$('.widget.ui-resizable').resizable('destroy')
$('.widget.ui-draggable').draggable('destroy').find('.ui-draggable-handle').remove()
$('.editing').removeClass('editing')
@ -157,6 +156,13 @@ module.exports = {
$('body').removeClass('editor-enabled')
$('#grid-width-input').remove()
EDITING = false
if (permanent) {
$('.editor .btn').remove()
$('.editor .title').html($('.editor .title').html() + ' (disabled)').addClass('disabled')
module.exports.editorEnable = ()=>{}
READ_ONLY = true
}
},
traversingDisable: function(){
$('.traversingEnable, .traversingDisable').toggleClass('on')

View file

@ -35,36 +35,54 @@ var callbacks = module.exports = {
footer = lobby.find('.footer')
for (i in data) {
var max = 50
var path = data[i],
file = path.split('\\').pop().split('/').pop(),
length = data[i].length
path = path.replace(file,'')
if (length > max - 3) {
path = path.substr(0,Math.floor((path.length)/2)-(length-max)/2) + '...' + path.substr(Math.ceil((path.length)/2)+(length-max)/2, path.length)
}
list.append('<a class="btn load" data-session="'+data[i]+'">'+file+' <em style="opacity:0.45">('+path+')</em><span>'+icon('remove')+'</span></a>')
if (!READ_ONLY) {
}
list.append(`
<a class="btn load" data-session="${data[i]}">
${file}<em style="opacity:0.45">(${path})</em>
${READ_ONLY? '' : '<span>'+icon('remove')+'</span>'}
</a>
`)
}
footer.append('<a class="btn browse">'+icon('folder-open')+' Browse</a>')
footer.append('<a class="btn new">'+icon('file-o')+' New</a>')
lobby.find('.load').click(function(e){
e.stopPropagation()
ipc.send('sessionOpen',{path:$(this).data('session')})
})
lobby.find('a span').click(function(e){
e.stopPropagation()
ipc.send('sessionRemoveFromHistory',$(this).parent().data('session'))
$(this).parents('a').remove()
})
lobby.find('.browse').click(function(e){
e.stopPropagation()
actions.sessionBrowse()
})
lobby.find('.new').click(function(e){
e.stopPropagation()
module.exports.sessionNew()
})
if (!READ_ONLY) {
lobby.find('a span').click(function(e){
e.stopPropagation()
ipc.send('sessionRemoveFromHistory',$(this).parent().data('session'))
$(this).parents('a').remove()
})
footer.append('<a class="btn browse">'+icon('folder-open')+' Browse</a>')
footer.append('<a class="btn new">'+icon('file-o')+' New</a>')
lobby.find('.browse').click(function(e){
e.stopPropagation()
actions.sessionBrowse()
})
lobby.find('.new').click(function(e){
e.stopPropagation()
module.exports.sessionNew()
})
}
$('#lobby').append(lobby)
setTimeout(()=>{
lobby.addClass('loaded')
@ -99,6 +117,10 @@ var callbacks = module.exports = {
},150)
},
editorDisable: function(data){
actions.editorDisable(data.permanent)
},
error: function(data){
utils.createPopup(icon('warning')+'&nbsp;'+data.title,data.text,true)
},

View file

@ -9,6 +9,9 @@ var callbacks = {
if (name == 'edit_soft') return callbacks['/EDIT_SOFT'](args)
},
'/EDIT': function(args) {
if (READ_ONLY) return
var [id, json] = args,
newdata = JSON.parse(json),
containers = widgetManager.getWidgetById(id)
@ -25,6 +28,9 @@ var callbacks = {
}
},
'/EDIT_SOFT': function(args) {
if (READ_ONLY) return
var [id, json] = args,
newdata = JSON.parse(json),
containers = widgetManager.getWidgetById(id)

View file

@ -5,6 +5,7 @@ STATE = []
CLIPBOARD = null
EDITING = false
READ_ONLY = false
TABS = {}

View file

@ -83,6 +83,9 @@
flex-grow: 2;
padding: 10rem;
position: relative;
&.disabled {
color:var(--color-text-fade);
}
&:before {
content:"";
position: absolute;