Commit 22caca01 authored by Mihkel Putrinš's avatar Mihkel Putrinš
Browse files

bump version

parent b3d9ce33
bin
node_modules
{ {
"name": "Panustaja", "name": "Panustaja",
"description": "Ressursikataloogi upitamiseks keeleressurside Entu repositooriumisse.", "description": "Ressursikataloogi upitamiseks keeleressurside Entu repositooriumisse.",
"version": "1.0.0", "version": "1.0.1",
"main": "./source/index.html", "main": "./source/index.html",
"license": "CC-SA", "license": "CC-SA",
"private": true, "private": true,
......
// 1. core modules // 1. core modules
var util = require('util') var util = require('util')
var fs = require('fs') var fs = require('fs')
var path = require('path') var path = require('path')
var gui = global.window.nwDispatcher.requireNwGui() var gui = global.window.nwDispatcher.requireNwGui()
// 2. public modules from npm // 2. public modules from npm
var moment = require('moment') var moment = require('moment')
// 3. Own modules // 3. Own modules
...@@ -19,256 +19,257 @@ var translate = require('./translations/estonian.js') ...@@ -19,256 +19,257 @@ var translate = require('./translations/estonian.js')
var loadDirs = function loadDirs() { var loadDirs = function loadDirs() {
var my_nodes = {} var my_nodes = {}
var root_node = {} var root_node = {}
var rec_counter = 1 var rec_counter = 1
var files_total = 0 var files_total = 0
var dirs_total = 0 var dirs_total = 0
var bytes_total = 0 var bytes_total = 0
var overquota_total = 0 var overquota_total = 0
var overquota_files_total = 0 var overquota_files_total = 0
var decreaseCounter = function decreaseCounter(finalCallback) { var decreaseCounter = function decreaseCounter(finalCallback) {
if (rec_counter === 1) { if (rec_counter === 1) {
finalCallback() finalCallback()
} else { } else {
rec_counter -- rec_counter --
} }
}
// Decrease this, if statusline doesnot refresh often enough
var load_factor = 4.1
var ticker = Math.round((new Date()).getTime() / 1000)
var nodes_per_sec = 0
var loadRec = function(parent_node, full_path, finalCallback) {
if (ticker === Math.round((new Date()).getTime() / 1000)) {
nodes_per_sec ++
} else {
// console.log(ticker + ':' + nodes_per_sec + ' nodes. Active threads: ' + rec_counter)
$('[progress]').text(nodes_per_sec + '/sec;' + displayNodePath(path.dirname(full_path), path.basename(full_path)))
ticker = Math.round((new Date()).getTime() / 1000)
nodes_per_sec = 0
} }
var wait_ms = Math.round(rec_counter/load_factor)
setTimeout(function() { // Decrease this, if statusline doesnot refresh often enough
fs.stat(full_path, function(err, stats) { var load_factor = 4.1
if(stats === undefined) { var ticker = Math.round((new Date()).getTime() / 1000)
decreaseCounter(finalCallback) var nodes_per_sec = 0
return var loadRec = function(parent_node, full_path, finalCallback) {
} if (ticker === Math.round((new Date()).getTime() / 1000)) {
// console.log('Loading', full_path, finalCallback) nodes_per_sec ++
if (my_nodes[stats.ino] !== undefined) { } else {
decreaseCounter(finalCallback) // console.log(ticker + ':' + nodes_per_sec + ' nodes. Active threads: ' + rec_counter)
return $('[progress]').text(nodes_per_sec + '/sec;' + displayNodePath(path.dirname(full_path), path.basename(full_path)))
ticker = Math.round((new Date()).getTime() / 1000)
nodes_per_sec = 0
} }
var wait_ms = Math.round(rec_counter/load_factor)
var new_node = my_nodes[stats.ino] = { setTimeout(function() {
ino: stats.ino, fs.stat(full_path, function(err, stats) {
full_path: full_path, if(stats === undefined) {
dirname: path.dirname(full_path), decreaseCounter(finalCallback)
basename: path.basename(full_path), return
entuname: path.basename(full_path), }
size: stats.isDirectory() ? 0 : stats.size, // console.log('Loading', full_path, finalCallback)
overquota: (stats.size > configuration.__MAX_FILESIZE_2G ? true : false), if (my_nodes[stats.ino] !== undefined) {
parent: parent_node, decreaseCounter(finalCallback)
is_dir: stats.isDirectory(), return
file_count: 0, }
dir_count: 0,
nodes: {}
}
if (parent_node === null) { var new_node = my_nodes[stats.ino] = {
root_node = new_node ino: stats.ino,
} full_path: full_path,
dirname: path.dirname(full_path),
basename: path.basename(full_path),
entuname: path.basename(full_path),
size: stats.isDirectory() ? 0 : stats.size,
overquota: (stats.size > configuration.__MAX_FILESIZE_2G ? true : false),
parent: parent_node,
is_dir: stats.isDirectory(),
file_count: 0,
dir_count: 0,
nodes: {}
}
if (parent_node !== null) { if (parent_node === null) {
parent_node.nodes[stats.ino] = new_node root_node = new_node
} }
// console.log('New node ', Object.keys(my_nodes).length, JSON.stringify({count:rec_counter, path:full_path})) if (parent_node !== null) {
parent_node.nodes[stats.ino] = new_node
if (stats.isDirectory()) {
if (parent_node !== null) {
parent_node.dir_count ++
}
dirs_total ++
fs.readdir(full_path, function(err, files) {
if (files !== undefined) {
files.forEach(function(childname) {
if (configuration.__EXCLUDE_FILENAMES.indexOf(childname) === -1) {
rec_counter ++
loadRec(my_nodes[stats.ino], path.join(full_path, childname), finalCallback)
} }
})
// console.log('New node ', Object.keys(my_nodes).length, JSON.stringify({count:rec_counter, path:full_path}))
if (stats.isDirectory()) {
if (parent_node !== null) {
parent_node.dir_count ++
}
dirs_total ++
fs.readdir(full_path, function(err, files) {
if (files !== undefined) {
files.forEach(function(childname) {
if (configuration.__EXCLUDE_FILENAMES.indexOf(childname) === -1) {
rec_counter ++
loadRec(my_nodes[stats.ino], path.join(full_path, childname), finalCallback)
}
})
}
decreaseCounter(finalCallback)
})
} else if (stats.isFile()) {
if (parent_node !== null) {
parent_node.file_count ++
}
files_total ++
bytes_total += stats.size
decreaseCounter(finalCallback)
} else {
decreaseCounter(finalCallback)
}
})
}, wait_ms)
}
var displayNodePath = function displayNodePath(dirname_in, basename_in) {
var dirname = dirname_in
var basename = basename_in
var max_length = 40
var node_path = path.resolve(dirname, basename)
var diff = node_path.length - max_length
var half_len = Math.round(max_length / 2)
// console.log(node_path, node_path.length, diff)
if (diff > 0) {
diff += 1
var basename_intact = false
var basename_diff = basename.length - half_len
if (basename_diff > 0) {
var crop_size = Math.min(diff, basename_diff)
basename = basename.slice(crop_size)
diff = diff - crop_size
} else {
basename_intact = true
} }
decreaseCounter(finalCallback) var dirname_diff = dirname.length - half_len + 1
}) if (dirname_diff > 0) {
} else if (stats.isFile()) { var crop_size = Math.min(diff, dirname_diff)
if (parent_node !== null) { dirname = dirname.slice(0, dirname.length - crop_size)
parent_node.file_count ++ }
} var ret_value = dirname + '' + basename
files_total ++ if (basename_intact)
bytes_total += stats.size ret_value = path.resolve(dirname + '', basename)
decreaseCounter(finalCallback)
} else { if (ret_value === undefined)
decreaseCounter(finalCallback) // console.log(dirname, basename, dirname_in, basename_in)
$('[progress]').text(ret_value)
return ret_value
} }
})
}, wait_ms)
}
var displayNodePath = function displayNodePath(dirname_in, basename_in) {
var dirname = dirname_in
var basename = basename_in
var max_length = 40
var node_path = path.resolve(dirname, basename)
var diff = node_path.length - max_length
var half_len = Math.round(max_length / 2)
// console.log(node_path, node_path.length, diff)
if (diff > 0) {
diff += 1
var basename_intact = false
var basename_diff = basename.length - half_len
if (basename_diff > 0) {
var crop_size = Math.min(diff, basename_diff)
basename = basename.slice(crop_size)
diff = diff - crop_size
} else {
basename_intact = true
}
var dirname_diff = dirname.length - half_len + 1
if (dirname_diff > 0) {
var crop_size = Math.min(diff, dirname_diff)
dirname = dirname.slice(0, dirname.length - crop_size)
}
var ret_value = dirname + '' + basename
if (basename_intact)
ret_value = path.resolve(dirname + '', basename)
if (ret_value === undefined)
// console.log(dirname, basename, dirname_in, basename_in)
$('[progress]').text(ret_value)
return ret_value
} }
}
return {
return { bytes_total: function () {
bytes_total: function () { return bytes_total
return bytes_total },
}, root_node: function () {
root_node: function () { return root_node
return root_node },
}, nodes: function () {
nodes: function () { return my_nodes
return my_nodes },
}, load: function (full_path, finalCallback) {
load: function (full_path, finalCallback) { // console.log(my_nodes, 'Loading', full_path)
// console.log(my_nodes, 'Loading', full_path) loadRec(null, full_path, finalCallback)
loadRec(null, full_path, finalCallback) },
}, reset: function () {
reset: function () { my_nodes = {}
my_nodes = {} rec_counter = 1
rec_counter = 1 output_counter = 0
output_counter = 0
files_total = 0
files_total = 0 dirs_total = 0
dirs_total = 0 bytes_total = 0
bytes_total = 0 overquota_total = 0
overquota_total = 0 overquota_files_total = 0
overquota_files_total = 0
// console.log(my_nodes, 'Resetting')
// console.log(my_nodes, 'Resetting') $('#upload_stats').empty()
$('#upload_stats').empty() $('#overquota_total').empty()
$('#overquota_total').empty() $('#overquota_files').empty()
$('#overquota_files').empty() $('[progress]').text('...')
$('[progress]').text('...') },
}, displayNodes: function (ms_so_far) {
displayNodes: function (ms_so_far) { var now_ms = (new Date()).getTime()
var now_ms = (new Date()).getTime() if (files_total + dirs_total !== Object.keys(my_nodes).length) {
if (files_total + dirs_total !== Object.keys(my_nodes).length) { // console.log('Warning: ' + files_total + ' + ' + dirs_total + ' !== ' + Object.keys(my_nodes).length + '!')
// console.log('Warning: ' + files_total + ' + ' + dirs_total + ' !== ' + Object.keys(my_nodes).length + '!') }
} $('#upload_stats')
$('#upload_stats') .append($('<div>')
.append($('<div>') .append('<label>' + translate('dirs_total') + '</label>')
.append('<label>' + translate('dirs_total') + '</label>') .append('<span id="dirs_total">' + dirs_total + '</span>')
.append('<span id="dirs_total">' + dirs_total + '</span>') )
) .append($('<div>')
.append($('<div>') .append('<label>' + translate('files_total') + '</label>')
.append('<label>' + translate('files_total') + '</label>') .append('<span id="files_total">' + files_total + '</span>')
.append('<span id="files_total">' + files_total + '</span>') )
) .append($('<div>')
.append($('<div>') .append('<label>' + translate('bytes_total') + '</label>')
.append('<label>' + translate('bytes_total') + '</label>') .append('<span id=bytes_total>' + bytesToSize(bytes_total) + '</span>')
.append('<span id=bytes_total>' + bytesToSize(bytes_total) + '</span>') )
)
var node_keys = Object.keys(my_nodes)
var node_keys = Object.keys(my_nodes) for (var i = 0; i < node_keys.length; i++) {
for (var i = 0; i < node_keys.length; i++) { var ino = node_keys[i]
var ino = node_keys[i] var current_node = my_nodes[ino]
var current_node = my_nodes[ino] // console.log(i, ino)
// console.log(i, ino) if (current_node.overquota) {
if (current_node.overquota) { // console.log(current_node.size + ' > ' + configuration.__MAX_FILESIZE_2G)
// console.log(current_node.size + ' > ' + configuration.__MAX_FILESIZE_2G)
bytes_total = bytes_total - current_node.size
bytes_total = bytes_total - current_node.size overquota_total = overquota_total + current_node.size
overquota_total = overquota_total + current_node.size files_total = files_total - 1
files_total = files_total - 1 overquota_files_total = overquota_files_total + 1
overquota_files_total = overquota_files_total + 1
var cn_path = displayNodePath(current_node.dirname, current_node.basename)
var cn_path = displayNodePath(current_node.dirname, current_node.basename) $('#overquota_files')
$('#overquota_files').append( .append($('<li class="hoverlink"><a>' + cn_path + '<span class="right">' + bytesToSize(current_node.size) + '</span></a></li>')
$('<li class="hoverlink"><a>' + cn_path + '<span class="right">' + bytesToSize(current_node.size) + '</span></a></li>') .prop('path', path.resolve(current_node.dirname, current_node.basename))
.prop('path', path.resolve(current_node.dirname, current_node.basename)) .click(function(event) {
.click(function(event) { gui.Shell.showItemInFolder($(this).prop('path'))
gui.Shell.showItemInFolder($(this).prop('path')) })
}) .mouseenter(function(event) {
.mouseenter(function(event) { $('[progress]').text($(this).prop('path'))
$('[progress]').text($(this).prop('path')) })
}) .mouseleave(function(event) {
.mouseleave(function(event) { $('[progress]').text(
$('[progress]').text( (dirs_total + files_total + overquota_files_total)
+ ' faili ja kataloogi lugemiseks kulus '
+ msToTime($('#upload_stats').prop('load_time_total')) + '.'
)
})
)
}
}
$('#bytes_total').text(bytesToSize(bytes_total))
$('#files_total').text(files_total)
if ($('#overquota_files').children().size() > 0) {
$('#overquota_files').show()
$('#overquota_files').before('<h3>' + overquota_files_total + ' fail' + (overquota_files_total ? 'i' : '') + ' (' + bytesToSize(overquota_total) + ') jääb praegu upitamata</h3>')
$('#overquota_files').before('<p>' + (overquota_files_total ? 'Nende' : 'Selle') + ' repositooriumisse lisamiseks helista või kirjuta meile.</p>')
} else {
$('#overquota_files').hide()
}
if (bytes_total > configuration.__UPLOAD_QUOTA_20G) {
$('#upload_button').hide()
$('#overquota_total').show()
} else {
$('#overquota_total').hide()
$('#upload_button').show()
}
$('#upload_stats')
.prop('load_time_total', (new Date()).getTime() - now_ms + ms_so_far)
// .append($('<div>')
// .append('<label>' + translate('load_time_total') + '</label>')
// .append('<span>' + msToTime((new Date()).getTime() - now_ms + ms_so_far) + '</span>')
// )
$('[progress]').text(
(dirs_total + files_total + overquota_files_total) (dirs_total + files_total + overquota_files_total)
+ ' faili ja kataloogi lugemiseks kulus ' + ' faili ja kataloogi lugemiseks kulus '
+ msToTime($('#upload_stats').prop('load_time_total')) + '.' ) + msToTime($('#upload_stats').prop('load_time_total')) + '.' )
})
)
} }
}
$('#bytes_total').text(bytesToSize(bytes_total))
$('#files_total').text(files_total)
if ($('#overquota_files').children().size() > 0) {
$('#overquota_files').show()
$('#overquota_files').before('<h3>' + overquota_files_total + ' fail' + (overquota_files_total ? 'i' : '') + ' (' + bytesToSize(overquota_total) + ') jääb praegu upitamata</h3>')
$('#overquota_files').before('<p>' + (overquota_files_total ? 'Nende' : 'Selle') + ' repositooriumisse lisamiseks helista või kirjuta meile.</p>')
} else {
$('#overquota_files').hide()
}
if (bytes_total > configuration.__UPLOAD_QUOTA_20G) {
$('#upload_button').hide()
$('#overquota_total').show()
} else {
$('#overquota_total').hide()
$('#upload_button').show()
}
$('#upload_stats')
.prop('load_time_total', (new Date()).getTime() - now_ms + ms_so_far)
// .append($('<div>')
// .append('<label>' + translate('load_time_total') + '</label>')
// .append('<span>' + msToTime((new Date()).getTime() - now_ms + ms_so_far) + '</span>')
// )
$('[progress]').text(
(dirs_total + files_total + overquota_files_total)
+ ' faili ja kataloogi lugemiseks kulus '
+ msToTime($('#upload_stats').prop('load_time_total')) + '.' )
} }
}
} }
......
...@@ -63,7 +63,7 @@ var progressDoneCB = function progressDoneCB(metrics) { ...@@ -63,7 +63,7 @@ var progressDoneCB = function progressDoneCB(metrics) {
// $('#upload_progress').children().empty() // $('#upload_progress').children().empty()
$('#upload_back').width('0%') $('#upload_back').width('0%')
$('#upload_front').width('0%') $('#upload_front').width('0%')
console.log('progress done', metrics) // console.log('progress done', metrics)
} }
progress.register_callbacks( progress.register_callbacks(
progressStartedCB, progressStartedCB,
...@@ -94,7 +94,7 @@ ENTU_API_AUTH = ENTU_API + 'user/auth' ...@@ -94,7 +94,7 @@ ENTU_API_AUTH = ENTU_API + 'user/auth'
ENTU_API_USER = ENTU_API + 'user' ENTU_API_USER = ENTU_API + 'user'
console.log ( '= ' + gui.App.manifest.name + ' v.' + __VERSION + ' ==================================') // console.log ( '= ' + gui.App.manifest.name + ' v.' + __VERSION + ' ==================================')
gui.Window.get().focus() gui.Window.get().focus()
...@@ -117,7 +117,7 @@ $( document ).ready(function() { ...@@ -117,7 +117,7 @@ $( document ).ready(function() {
require('dns').resolve('www.google.com', function(err) { require('dns').resolve('www.google.com', function(err) {
if (err) { if (err) {
window.alert ('Netti pole') window.alert ('Netti pole')
console.log(err) // console.log(err)
process.exit(1) process.exit(1)
} }
}) })
...@@ -125,7 +125,7 @@ $( document ).ready(function() { ...@@ -125,7 +125,7 @@ $( document ).ready(function() {
require('dns').resolve(ENTU_DNS, function(err) { require('dns').resolve(ENTU_DNS, function(err) {
if (err) if (err)
{ {
console.log(err) // console.log(err)
window.alert ('Entu pole saadaval') window.alert ('Entu pole saadaval')
process.exit(1) process.exit(1)
} }
...@@ -178,7 +178,7 @@ $( document ).ready(function() { ...@@ -178,7 +178,7 @@ $( document ).ready(function() {
+ ' faili ja kataloogi lugemiseks kulus ' + ' faili ja kataloogi lugemiseks kulus '
+ msToTime((new Date()).getTime() - now_ms) + '.' + msToTime((new Date()).getTime() - now_ms) + '.'
$('[progress]').text(status_message) $('[progress]').text(status_message)
console.log(status_message) // console.log(status_message)
advanceToNextCard() advanceToNextCard()
loadDirs.displayNodes((new Date()).getTime() - now_ms) loadDirs.displayNodes((new Date()).getTime() - now_ms)
} }
...@@ -216,7 +216,7 @@ $( document ).ready(function() { ...@@ -216,7 +216,7 @@ $( document ).ready(function() {
$('#back_button').hide() $('#back_button').hide()
$('#upload_button').hide() $('#upload_button').hide()
uploader.createResources(configuration.__ROOT_EID, function uploadCallback(data) { uploader.createResources(configuration.__ROOT_EID, function uploadCallback(data) {
console.log('Uploaded OK') // , data) // console.log('Uploaded OK') // , data)
advanceToNextCard() advanceToNextCard()
$('[progress]').text('Valmis.') $('[progress]').text('Valmis.')
$('#waitspinner').hide('slow') $('#waitspinner').hide('slow')
...@@ -292,7 +292,7 @@ var execPath = function execPath() { ...@@ -292,7 +292,7 @@ var execPath = function execPath() {
} }