Commit 0435bb47 authored by mitselek's avatar mitselek

upgrade dependencies and resolve remote modules

parent 5ce7e060
bin
node_modules
old
Panustaja-*/*
\ No newline at end of file
var app = require('app')
const path = require('path')
const fs = require('fs')
const util = require('util')
// var op = require('object-path')
var path = require('path')
var fs = require('fs')
var ipc = require('ipc')
var clipboard = require('clipboard')
var BrowserWindow = require('browser-window')
// const app = require('electron').app
const { app, BrowserWindow, ipcMain, clipboard } = require('electron')
// var ipcMain = require('electron').ipcMain
// const { clipboard } = require('electron')
var windows = {}
var mainWindow
......@@ -13,7 +16,8 @@ var userUrl = 'https://entu.keeleressursid.ee/api2/user'
var authUrl = userUrl + '/auth'
ISDEV = process.env.DEV ? true : false
ISDEV = true
// ISDEV = process.env.DEV ? true : false
var pjsonPath = path.join(__dirname, '..', 'package.json')
var pjson = require(pjsonPath)
......@@ -23,67 +27,79 @@ if (ISDEV) {
}
console.log('----==== ' + pjson.name + ' v.' + pjson.version + ' (build ' + (pjson.build) + ') ====----')
var webPreferences = {
'partition': 'persist:panustaja (build ' + (pjson.build) + ')',
'page-visibility': true, // Prevent throttling DOM timers (app gets less priority while in background)
const webPreferences = {
partition: 'persist:panustaja (build ' + (pjson.build) + ')',
// Prevent throttling DOM timers (app gets less priority while in background)
pageVisibility: true,
nodeIntegration: true
}
app.on('ready', function() {
windows.authWindow = new BrowserWindow({ width: 900, height: 600, show: true, 'web-preferences': webPreferences })
// windows.authWindow.webContents.openDevTools(true)
const authWin = new BrowserWindow({
width: 600,
height: 900,
webPreferences: webPreferences
})
authWin.loadURL(authUrl, {userAgent: 'Chrome'})
var title = pjson.name + ' v.' + pjson.version + (pjson.version.indexOf('-') > -1 ? pjson.build : '') + ' | Logi sisse'
windows.authWindow.center()
windows.authWindow.setTitle(title)
windows.authWindow.loadUrl(authUrl)
windows.authWindow.webContents.on('did-get-response-details', function(e, s, newUrl) {
windows.authWindow.setTitle(title)
authWin.center()
authWin.setTitle(title)
authWin.webContents.on('did-get-response-details', function(e, s, newUrl) {
authWin.setTitle(title)
if (newUrl === userUrl || newUrl === userUrl + '#') {
windows.authWindow.hide()
authWin.hide()
}
})
windows.authWindow.webContents.on('did-finish-load', function() {
windows.authWindow.setTitle(title)
var newUrl = windows.authWindow.webContents.getUrl()
authWin.webContents.on('did-finish-load', function() {
authWin.setTitle(title)
var newUrl = authWin.webContents.getURL()
if (newUrl === userUrl || newUrl === userUrl + '#') {
clipboard.clear()
windows.authWindow.webContents.selectAll()
windows.authWindow.webContents.copy()
authWin.webContents.selectAll()
authWin.webContents.copy()
setTimeout(function () {
mainWindow = new BrowserWindow({ width: 900, height: 600, show: true, 'web-preferences': webPreferences })
mainWindow = new BrowserWindow({ width: 900, height: 600, show: true, webPreferences: webPreferences })
mainWindow.setTitle('Panustaja')
mainWindow.center()
var viewPath = path.join(app.getAppPath(), 'code', 'panuView.html')
mainWindow.webContents.loadUrl('file://' + viewPath)
mainWindow.webContents.loadURL('file://' + viewPath)
if (ISDEV) {
mainWindow.webContents.openDevTools(true)
}
windows.authWindow.close()
delete windows.authWindow
authWin.close()
delete authWin
}, 1000)
} else {
return
}
})
})
ipc.on('log', function(event, message) {
ipcMain.on('log', function(event, message) {
console.log('message: ', message)
})
ipc.on('data', function(event, message) {
ipcMain.on('data', function(event, message) {
console.log('data: ' + JSON.stringify(message, null, 4))
})
ipc.on('setTitle', function(event, message) {
ipcMain.on('setTitle', function(event, message) {
mainWindow.setTitle(message)
})
var userData = false
// console.log('userData: ' + JSON.stringify(userData, null, 4))
ipc.on('setUser', function(event, data) {
ipcMain.on('setUser', function(event, data) {
userData = data
// console.log('setUser: ' + JSON.stringify(userData, null, 4))
})
ipc.on('getUser', function(event) {
ipcMain.on('getUser', function(event) {
event.returnValue = userData
// console.log('getUser: ' + JSON.stringify(userData, null, 4))
})
......
......@@ -5,21 +5,20 @@ var path = require('path')
var async = require('async')
var mime = require('mime')
var remote = require('remote')
// var app = remote.require('app')
var dialog = remote.require('dialog')
var clipboard = remote.require('clipboard')
const clipboard = require('electron').remote.clipboard
const { ipcRenderer } = require('electron').remote
const { dialog } = require('electron').remote
console.log(dialog)
var pjson = require(path.join(__dirname, '..', 'package.json'))
UPLOADERVERSION = pjson.name + ' v.' + pjson.version + (pjson.version.indexOf('-') > -1 ? pjson.build : '')
var ipc = require('ipc')
var b2s = require(path.join(__dirname, 'bytesToSize.js'))
var uploader = require(path.join(__dirname, 'upload.js'))
var userData = {}
var data = ipc.sendSync('getUser', null)
var data = ipcRenderer.sendSync('getUser', null)
function setFormState(state) {
switch(state) {
......@@ -107,7 +106,7 @@ function resourceLoaded() {
renderResource()
setFormState('loaded')
clearInterval(rendererInterval)
// ipc.send('data', resource)
// ipcRenderer.send('data', resource)
document.getElementById('uploadResourceButton').onclick = function uploadResource() {
uploader.upload()
}
......@@ -190,7 +189,7 @@ document.getElementById('selectLocalButton').onclick = function selectLocal () {
if (!data) {
data = JSON.parse(clipboard.readText())
clipboard.clear()
ipc.send('setUser', data)
ipcRenderer.send('setUser', data)
}
if (op.get(data, 'result.user_id', false)) {
userData.userId = op.get(data, 'result.user_id')
......@@ -198,10 +197,10 @@ if (op.get(data, 'result.user_id', false)) {
userData.name = op.get(data, 'result.name')
document.getElementById('userName').innerHTML = userData.name
var title = UPLOADERVERSION + ' | ' + userData.name
ipc.send('setTitle', title)
ipcRenderer.send('setTitle', title)
setFormState('select')
} else {
ipc.send('log', 'User data incomplete.')
ipc.send('data', data)
ipcRenderer.send('log', 'User data incomplete.')
ipcRenderer.send('data', data)
}
ipc.send('closeAuth')
ipcRenderer.send('closeAuth')
This diff is collapsed.
{
"name": "Panustaja",
"name": "panustaja",
"description": "Ressursikataloogi upitamiseks keeleressurside Entu repositooriumisse.",
"version": "1.0.1-d",
"build": 103,
"version": "2.0.0",
"build": 129,
"main": "./code/app.js",
"license": "CC-SA",
"private": true,
......@@ -10,11 +10,17 @@
"type": "git",
"url": "git@gitlab.keeleressursid.ee:michelek/panustaja.git"
},
"scripts": {
"start": "electron ."
},
"dependencies": {
"async": "^1.5.0",
"mime": "^1.3.4",
"object-path": "^0.9.2",
"request": "^2.65.0"
},
"devDependencies": {}
}
"devDependencies": {
"electron": "^10.1.1",
"electron-packager": "^15.1.0"
}
}
\ No newline at end of file
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