Commit 9ba26304 authored by Mihkel Putrinš's avatar Mihkel Putrinš

refactor

parent c9fe9c65
......@@ -27,9 +27,9 @@ app.on('ready', function() {
// USER_PATH = path.join(app.getPath('temp'), 'user.json')
var web_preferences = {
"partition": "persist:panustaja (build " + (pjson.build) + ")",
'partition': 'persist:panustaja (build ' + (pjson.build) + ')',
}
windows['authWindow'] = new BrowserWindow({ width: 900, height: 600, show: true, "web-preferences": web_preferences })
windows['authWindow'] = new BrowserWindow({ width: 900, height: 600, show: true, 'web-preferences': web_preferences })
// windows['authWindow'].webContents.openDevTools(true)
var title = pjson.name + ' v.' + pjson.version + (pjson.version.indexOf('-') > -1 ? pjson.build : '') + ' | Logi sisse'
windows['authWindow'].center()
......@@ -50,11 +50,11 @@ app.on('ready', function() {
windows['authWindow'].webContents.copy()
var web_preferences = {
"partition": "persist:panustaja (build " + (pjson.build) + ")",
"page-visibility": true, // Prevent throttling DOM timers (app gets less priority while in background)
'partition': 'persist:panustaja (build ' + (pjson.build) + ')',
'page-visibility': true, // Prevent throttling DOM timers (app gets less priority while in background)
}
setTimeout(function () {
mainWindow = new BrowserWindow({ width: 900, height: 600, show: true, "web-preferences": web_preferences })
mainWindow = new BrowserWindow({ width: 900, height: 600, show: true, 'web-preferences': web_preferences })
mainWindow.setTitle('Panustaja')
mainWindow.center()
var view_path = path.join(app.getAppPath(), 'code', 'panu_view.html')
......
......@@ -6,7 +6,7 @@ var async = require('async')
var mime = require('mime')
var remote = require('remote')
var app = remote.require('app')
// var app = remote.require('app')
var dialog = remote.require('dialog')
var clipboard = remote.require('clipboard')
......
......@@ -52,18 +52,18 @@ function addEntuFile(eid, file_path, callback) {
var options = {
url: ENTU_API_FILE,
headers: {
'X-Auth-UserId': user_data['user_id'],
'X-Auth-Token': user_data['session_key'],
'X-Auth-UserId': user_data.user_id,
'X-Auth-Token': user_data.session_key,
'User-Agent': UPLOADER_VERSION
}
}
var req = request.post(options, function (err, resp, body) {
// var req = request.post(options, function (err, resp, body) {
var req = request.post(options, function (err) {
// console.log(err, resp, JSON.parse(body))
if (err) {
callback(err)
// } else if (resp.status.statusCode !== 200) {
// callback(body)
// } else if (resp.status.statusCode !== 200) { callback(body) }
} else {
// console.log('URL: ' + body)
callback()
......@@ -79,7 +79,7 @@ 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: " + uploaded_files_progress + '(+' + chunk.length + ')')
console.log('Uploaded: ' + uploaded_files_progress + '(+' + chunk.length + ')')
})
}
......@@ -88,8 +88,8 @@ function addEntuProperties(eid, data, callback) {
// console.log(url_data)
var xhr = new window.XMLHttpRequest()
xhr.open('PUT', ENTU_API_ENTITY + '-' + eid + '?' + url_data, true)
xhr.setRequestHeader('X-Auth-UserId', user_data['user_id'])
xhr.setRequestHeader('X-Auth-Token', user_data['session_key'])
xhr.setRequestHeader('X-Auth-UserId', user_data.user_id)
xhr.setRequestHeader('X-Auth-Token', user_data.session_key)
xhr.onload = function () {
var response = JSON.parse(this.responseText)
// console.log(JSON.stringify({sent:data, got:response}, null, 4))
......@@ -105,9 +105,9 @@ function createEntuResource(parent_eid, resource, callback) {
console.log('create under EID:', parent_eid)
var xhr = new window.XMLHttpRequest()
xhr.open('POST', ENTU_API_ENTITY + '-' + parent_eid, true)
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
xhr.setRequestHeader('X-Auth-UserId', user_data['user_id'])
xhr.setRequestHeader('X-Auth-Token', user_data['session_key'])
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded')
xhr.setRequestHeader('X-Auth-UserId', user_data.user_id)
xhr.setRequestHeader('X-Auth-Token', user_data.session_key)
xhr.onload = function () {
// if (err) {
// console.log(err)
......@@ -119,8 +119,8 @@ function createEntuResource(parent_eid, resource, callback) {
console.log('onload new EID:', new_eid)
op.set(resource, ['eid'], new_eid)
addEntuProperties(new_eid, {
"resource-name": path.basename(op.get(resource, ['name'], 'nameless resource')),
"resource-uploader-version": UPLOADER_VERSION
'resource-name': path.basename(op.get(resource, ['name'], 'nameless resource')),
'resource-uploader-version': UPLOADER_VERSION
}, function(err) {
if (err) { return callback(err) }
uploaded_resources_progress++
......
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