local app
This commit is contained in:
parent
d255ed6a03
commit
a775ed3055
7 changed files with 314 additions and 3 deletions
86
static/js/importDocumentsDialog.amp.js
Normal file
86
static/js/importDocumentsDialog.amp.js
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
'use strict';
|
||||
|
||||
pandora.ui.importDocumentsDialog = function() {
|
||||
|
||||
var dialogHeight = 100,
|
||||
dialogWidth = 512 + 16,
|
||||
formWidth = getFormWidth(),
|
||||
|
||||
$button,
|
||||
$content = Ox.Element(),
|
||||
value,
|
||||
$input = [
|
||||
Ox.TextArea({
|
||||
labelWidth: 96,
|
||||
width: 512
|
||||
}).css({
|
||||
margin: '8px'
|
||||
}).bindEvent({
|
||||
change: function(data) {
|
||||
$button.options({disabled: !data.value});
|
||||
value = data.value
|
||||
}
|
||||
}).appendTo($content),
|
||||
],
|
||||
|
||||
that = Ox.Dialog({
|
||||
buttons: [
|
||||
Ox.Button({
|
||||
id: 'cancel',
|
||||
title: Ox._('Cancel')
|
||||
})
|
||||
.bindEvent({
|
||||
click: function() {
|
||||
that.close();
|
||||
}
|
||||
}),
|
||||
$button = Ox.Button({
|
||||
disabled: true,
|
||||
id: 'import',
|
||||
title: Ox._('Import URLs')
|
||||
})
|
||||
.bindEvent({
|
||||
click: importDocuments
|
||||
})
|
||||
],
|
||||
closeButton: true,
|
||||
content: $content,
|
||||
height: dialogHeight,
|
||||
removeOnClose: true,
|
||||
title: Ox._('Import Documents'),
|
||||
width: dialogWidth
|
||||
})
|
||||
.bindEvent({
|
||||
resize: setSize
|
||||
});
|
||||
|
||||
function getFormWidth() {
|
||||
return dialogWidth - 32 - Ox.UI.SCROLLBAR_SIZE;
|
||||
}
|
||||
|
||||
function setSize(data) {
|
||||
dialogHeight = data.height;
|
||||
dialogWidth = data.width;
|
||||
formWidth = getFormWidth();
|
||||
$input.forEach(function($element) {
|
||||
$element.options({width: formWidth});
|
||||
});
|
||||
}
|
||||
|
||||
function importDocuments() {
|
||||
that.options({content: Ox.LoadingScreen().start()});
|
||||
var urls = value.trim().split('\n');
|
||||
pandora.api.importDocuments({
|
||||
urls: urls
|
||||
}, function(result) {
|
||||
if (result.data.taskId) {
|
||||
pandora.wait(result.data.taskId, function(result) {
|
||||
that.close();
|
||||
}
|
||||
} else {
|
||||
that.options({content: 'Failed'});
|
||||
}
|
||||
})
|
||||
}
|
||||
return that;
|
||||
};
|
||||
53
static/js/localInit.amp.js
Normal file
53
static/js/localInit.amp.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
pandora.localInit = function() {
|
||||
var plugins = [];
|
||||
|
||||
plugins.push(ExtrasMenu());
|
||||
|
||||
plugins.length && load();
|
||||
|
||||
function load() {
|
||||
patchReload();
|
||||
plugins.forEach(function(plugin) { plugin.load() });
|
||||
}
|
||||
|
||||
function patchReload() {
|
||||
var reload = pandora.$ui.appPanel.reload;
|
||||
pandora.$ui.appPanel.reload = function() {
|
||||
reload();
|
||||
load();
|
||||
}
|
||||
}
|
||||
|
||||
function ExtrasMenu() {
|
||||
var that = {};
|
||||
|
||||
var css = {
|
||||
//margin: '2px',
|
||||
},
|
||||
$item = Ox.MenuButton({
|
||||
items: [
|
||||
].concat(pandora.user.level == 'admin' ? [
|
||||
] : [], [
|
||||
{id: 'import_documents', title: 'Import Documents...'},
|
||||
]),
|
||||
style: 'rounded',
|
||||
title: 'set',
|
||||
tooltip: Ox._('Extras'),
|
||||
type: 'image'
|
||||
}).css(css).bindEvent({
|
||||
click: function(data) {
|
||||
if (data.id == 'import_documents') {
|
||||
pandora.ui.importDocumentsDialog().open()
|
||||
}
|
||||
},
|
||||
}),
|
||||
plugins = [];
|
||||
|
||||
that.load = function() {
|
||||
pandora.$ui.mainMenu.find('.OxExtras').prepend($item);
|
||||
pandora.$ui.extraItem = $item;
|
||||
};
|
||||
return that;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue