Commit b02d83d1 authored by Mihkel Putrinš's avatar Mihkel Putrinš

d96. varia

parent 3aa7e582
......@@ -60,8 +60,9 @@ app.on('ready', function() {
if (IS_DEV) {
mainWindow.webContents.openDevTools(true)
}
windows['authWindow'].close()
delete windows['authWindow']
}, 1000)
windows['authWindow'].hide()
} else {
return
}
......@@ -79,11 +80,15 @@ ipc.on('setTitle', function(event, message) {
mainWindow.setTitle(message)
})
ipc.on('closeAuth', function(event) {
if (windows['authWindow']) {
windows['authWindow'].close()
delete windows['authWindow']
}
var user_data = false
console.log('user_data: ' + JSON.stringify(user_data, null, 4))
ipc.on('setUser', function(event, data) {
user_data = data
console.log('setUser: ' + JSON.stringify(user_data, null, 4))
})
ipc.on('getUser', function(event, msg) {
event.returnValue = user_data
console.log('getUser: ' + JSON.stringify(user_data, null, 4))
})
app.on('window-all-closed', function() {
......
......@@ -13,7 +13,6 @@ var app = remote.require('app')
var dialog = remote.require('dialog')
var clipboard = remote.require('clipboard')
// console.log(path.join(__dirname)) ==> panustaja/code/views
var pjson = require(path.join(__dirname, '..', 'package.json'))
UPLOADER_VERSION = pjson.name + ' v.' + pjson.version + (pjson.version.indexOf('-') > -1 ? pjson.build : '')
......@@ -23,18 +22,22 @@ var b2s = require(path.join(__dirname, 'bytesToSize.js'))
var uploader = require(path.join(__dirname, 'upload.js'))
var user_data = {}
var resource = {}
var resource_stats = {}
var renderer_interval
var data = ipc.sendSync('getUser', null)
var initialize = function initialize() {
var data = JSON.parse(clipboard.readText())
console.log('user_data: ' + data)
if (!data) {
data = JSON.parse(clipboard.readText())
clipboard.clear()
ipc.send('setUser', data)
}
console.log('user_data: ' + JSON.stringify(data, null, 4))
if (op.get(data, 'result.user_id', false)) {
user_data['user_id'] = op.get(data, 'result.user_id')
user_data['session_key'] = op.get(data, 'result.session_key')
user_data['name'] = op.get(data, 'result.name')
document.getElementById('userName').innerHTML = user_data.name
var title = UPLOADER_VERSION + ' | ' + user_data['name']
var title = UPLOADER_VERSION + ' | ' + user_data.name
ipc.send('setTitle', title)
setFormState('select')
} else {
......@@ -44,6 +47,10 @@ var initialize = function initialize() {
ipc.send('closeAuth')
}
var resource = {}
var resource_stats = {}
var renderer_interval
function selectLocal () {
resource = {name: 'root'}
resource_stats = {files: {count: 0, size: 0}, directories: {count: 0}, mime:{}}
......
......@@ -4,8 +4,8 @@ var op = require('object-path')
var path = require('path')
var async = require('async')
var remote = require('remote')
var dialog = remote.require('dialog')
// var remote = require('remote')
// var dialog = remote.require('dialog')
var b2s = require(path.join(__dirname, '..', 'code', 'bytesToSize.js'))
......@@ -21,7 +21,6 @@ var upload = function upload() {
uploaded_resources_progress = 0
uploaded_files_progress = 0
// setFormState('uploading')
console.log(JSON.stringify(resource, null, 4))
document.getElementById('uploadTotalResources').innerHTML = (resource_stats.directories.count + 1)
document.getElementById('uploadTotalSize').innerHTML = b2s(resource_stats.files.size)
......@@ -120,6 +119,7 @@ var createEntuResource = function createEntuResource(parent_eid, resource, callb
xhr.send('definition=resource')
}
var addEntuFile = function addEntuFile(eid, file_path, callback) {
var options = {
......@@ -142,6 +142,8 @@ var addEntuFile = function addEntuFile(eid, file_path, callback) {
callback()
}
})
var form = req.form()
var read_stream = fs.createReadStream(file_path)
form.append('file', read_stream)
......@@ -150,10 +152,8 @@ var addEntuFile = function addEntuFile(eid, file_path, callback) {
form.append('filename', path.basename(file_path))
read_stream.on('data', function(chunk) {
uploaded_files_progress += chunk.length
// console.log("Uploaded: " + chunk.length)
console.log("Uploaded: " + uploaded_files_progress + '(+' + chunk.length + ')')
})
// setInterval(function () {
// }, 10)
}
var addEntuProperties = function addEntuProperties(eid, data, callback) {
......
{
"name": "Panustaja",
"description": "Ressursikataloogi upitamiseks keeleressurside Entu repositooriumisse.",
"version": "1.0.1-d",
"build": 95,
"main": "./code/app.js",
"license": "CC-SA",
"private": true,
"repository": {
"type": "git",
"url": "git@gitlab.keeleressursid.ee:michelek/panustaja.git"
},
"dependencies": {
"async": "^1.5.0",
"electron-jade": "^1.3.0",
"marked": "^0.3.5",
"mmmagic": "^0.4.1",
"moment": "^2.10.6",
"object-path": "^0.9.2",
"request": "^2.65.0"
},
"devDependencies": {
"electron-packager": "^5.1.1"
}
}
\ No newline at end of file
"name": "Panustaja",
"description": "Ressursikataloogi upitamiseks keeleressurside Entu repositooriumisse.",
"version": "1.0.1-d",
"build": 96,
"main": "./code/app.js",
"license": "CC-SA",
"private": true,
"repository": {
"type": "git",
"url": "git@gitlab.keeleressursid.ee:michelek/panustaja.git"
},
"dependencies": {
"async": "^1.5.0",
"electron-jade": "^1.3.0",
"mmmagic": "^0.4.1",
"object-path": "^0.9.2",
"request": "^2.65.0"
},
"devDependencies": {
"electron-packager": "^5.1.1"
}
}
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