Commit e971f7f9 authored by mitselek's avatar mitselek

open uploaded resource in OS browser

parent 7fb603c5
......@@ -18,6 +18,7 @@ var userData = {}
var data = ipcRenderer.sendSync('getUser', null)
function setFormState(state) {
console.log('Entering form state:', state)
switch(state) {
case 'select':
document.getElementById('selectLocal').removeAttribute('hidden')
......@@ -152,33 +153,38 @@ function recurseLocal(parentResource, paths, loadedCB) {
document.getElementById('selectLocalButton').onclick = function selectLocal () {
resource = {name: 'root'}
resourceStats = {files: {count: 0, size: 0}, directories: {count: 0}, mime:{}}
dialog.showOpenDialog({properties:['openFile', 'openDirectory']}, function selectedPath(myPaths) {
if (!myPaths) { return }
rendererInterval = setInterval(function () { renderResource() }, 100)
setFormState('loading')
if (myPaths.length === 1) {
var singleFile = myPaths[0]
op.set(resource, 'name', path.basename(singleFile))
document.getElementById('resourceName').value = resource.name
fs.stat(singleFile, function(err, stats) {
if (err) { throw (err) }
if (stats.isDirectory()) {
fs.readdir(singleFile, function(err, files) {
if (err) { throw (err) }
myPaths = files.map(function(file) {
var fullpath = path.join(singleFile, file)
return fullpath
})
recurseLocal(resource, myPaths, resourceLoaded)
const dialogOptions = {
message: "Vali meelepärane kataloog",
properties: ['openFile', 'openDirectory']
}
let myPaths = dialog.showOpenDialogSync(dialogOptions)
if (!myPaths) { return }
rendererInterval = setInterval(function () { renderResource() }, 100)
setFormState('loading')
if (myPaths.length === 1) {
var singleFile = myPaths[0]
op.set(resource, 'name', path.basename(singleFile))
document.getElementById('resourceName').value = resource.name
fs.stat(singleFile, function(err, stats) {
if (err) { throw (err) }
if (stats.isDirectory()) {
fs.readdir(singleFile, function(err, files) {
if (err) { throw (err) }
myPaths = files.map(function(file) {
var fullpath = path.join(singleFile, file)
return fullpath
})
} else {
recurseLocal(resource, myPaths, resourceLoaded)
}
})
} else {
recurseLocal(resource, myPaths, resourceLoaded)
}
})
})
} else {
recurseLocal(resource, myPaths, resourceLoaded)
}
})
} else {
recurseLocal(resource, myPaths, resourceLoaded)
}
}
......
......@@ -4,6 +4,8 @@ var op = require('object-path')
var path = require('path')
var async = require('async')
const { shell } = require('electron').remote
// var remote = require('remote')
// var dialog = remote.require('dialog')
......@@ -190,7 +192,7 @@ function upload() {
document.getElementById('resourceEntuLink').setAttribute('href', 'https://entu.keeleressursid.ee/entity/resource/' + newEid)
document.getElementById('resourceEntuLink').innerHTML = 'https://entu.keeleressursid.ee/entity/resource/' + newEid
document.getElementById('resourceEntuLink').onclick = function openResourceInBrowser() {
require('shell').openExternal('https://entu.keeleressursid.ee/entity/resource/' + newEid)
shell.openExternal('https://entu.keeleressursid.ee/entity/resource/' + newEid)
return false
}
// ipc.send('data', resource)
......
......@@ -2,7 +2,7 @@
"name": "panustaja",
"description": "Ressursikataloogi upitamiseks keeleressurside Entu repositooriumisse.",
"version": "2.0.0",
"build": 142,
"build": 149,
"main": "./code/app.js",
"license": "CC-SA",
"private": true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment