remote-file: add locales & confirmation prompts
This commit is contained in:
parent
79a0bde0c5
commit
bdeb53280c
4 changed files with 22 additions and 4 deletions
|
|
@ -46,6 +46,7 @@ module.exports = {
|
|||
session_uploaderror: 'Failed to upload session file.',
|
||||
session_savesuccess: 'Session saved successfully',
|
||||
session_saveerror: 'The session file can\'t be saved remotely, use "export" instead',
|
||||
session_unsaved: 'Your changes will be lost if you close this session without saving, continue ?',
|
||||
|
||||
// sidepanel
|
||||
sidepanel_fs: 'Fullscreen',
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ module.exports = {
|
|||
session_uploaderror: 'Échec à l\'envoi du fichier de session.',
|
||||
session_savesuccess: 'Session enregistrée avec succès',
|
||||
session_saveerror: 'La session ne peut pas être enregistrée sur le serveur, utilisez la fonction "exporter"',
|
||||
session_unsaved: 'Vos modifications seront perdues si vous fermez la session actuelle sans sauvegarder, continuer ?',
|
||||
|
||||
// sidepanel
|
||||
sidepanel_fs: 'Plein Écran',
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ module.exports = { // @https://github.com/suhr
|
|||
editor_load: 'Загрузить',
|
||||
editor_save: 'Сохранить',
|
||||
editor_save_as: 'Экспорт',
|
||||
editor_import: 'Import',
|
||||
editor_export: 'Export',
|
||||
|
||||
// editor context-menu
|
||||
editor_editparent: 'К родителю',
|
||||
|
|
@ -34,7 +36,7 @@ module.exports = { // @https://github.com/suhr
|
|||
// server
|
||||
server_disconnected: 'The connection to the server has been interrupted',
|
||||
server_connected: 'The connection to the server has been restored',
|
||||
|
||||
|
||||
// session
|
||||
session_browse: 'Обзор...',
|
||||
session_new: 'Новая сессия',
|
||||
|
|
@ -43,6 +45,7 @@ module.exports = { // @https://github.com/suhr
|
|||
session_uploaderror: 'Не удалось загрузить файл сессии.',
|
||||
session_savesuccess: 'Session saved successfully',
|
||||
session_saveerror: 'The session file can\'t be saved remotely, use "export" instead',
|
||||
session_unsaved: 'Your changes will be lost if you close this session without saving, continue ?',
|
||||
|
||||
// sidepanel
|
||||
sidepanel_fs: 'Полный экран',
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ var SessionManager = class SessionManager {
|
|||
|
||||
this.windowTitle = document.title
|
||||
|
||||
this.allowRemoteSave = false
|
||||
|
||||
ipc.on('connect', ()=>{
|
||||
ipc.send('sessionSetPath', {path: this.sessionPath})
|
||||
})
|
||||
|
|
@ -133,6 +131,8 @@ var SessionManager = class SessionManager {
|
|||
|
||||
saveAs(blob, new Date().toJSON().slice(0,10)+'_'+new Date().toJSON().slice(11,16) + '.json')
|
||||
|
||||
edior.unsavedSession = false
|
||||
|
||||
}
|
||||
|
||||
list(data) {
|
||||
|
|
@ -172,12 +172,17 @@ var SessionManager = class SessionManager {
|
|||
if (!READ_ONLY) {
|
||||
|
||||
var brw = lobby.footer.appendChild(html`<a href="#" tabindex="0" class="btn browse">${raw(icon('folder-open'))} ${locales('session_browse')}</a>`)
|
||||
var imp = lobby.footer.appendChild(html`<a href="#" tabindex="0" class="btn import">${raw(icon('upload'))} ${locales('editor_import')}</a>`)
|
||||
var nws = lobby.footer.appendChild(html`<a href="#" tabindex="0" class="btn new">${raw(icon('file'))} ${locales('session_new')}</a>`)
|
||||
|
||||
brw.addEventListener('click', (e)=>{
|
||||
this.browse()
|
||||
})
|
||||
|
||||
imp.addEventListener('click', (e)=>{
|
||||
this.import()
|
||||
})
|
||||
|
||||
nws.addEventListener('click', (e)=>{
|
||||
this.create()
|
||||
})
|
||||
|
|
@ -205,6 +210,7 @@ var SessionManager = class SessionManager {
|
|||
browse() {
|
||||
|
||||
remoteBrowse({extension: 'json'}, (path)=>{
|
||||
if (editor.unsavedSession && !confirm(locales('session_unsaved'))) return
|
||||
ipc.send('sessionOpen',{path:path})
|
||||
})
|
||||
|
||||
|
|
@ -213,7 +219,14 @@ var SessionManager = class SessionManager {
|
|||
import() {
|
||||
|
||||
upload('.json', (path, result)=>{
|
||||
ipc.send('sessionOpen',{file:result, path:path})
|
||||
var session
|
||||
try {
|
||||
session = JSON.parse(result)
|
||||
} catch (err) {
|
||||
new Popup({title: raw(icon('exclamation-triangle')) + ' ' + locales('session_parsingerror'), content: err, closable:true})
|
||||
}
|
||||
if (editor.unsavedSession && !confirm(locales('session_unsaved'))) return
|
||||
if (session) sessionManager.load(session)
|
||||
}, ()=>{
|
||||
new Popup({title: raw(icon('exclamation-triangle')) + ' ' + locales('error'), content: locales('session_uploaderror'), closable:true})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue