Commit 47997b66 authored by Alain Takoudjou's avatar Alain Takoudjou

Fix rename, copy and paster in Editor. Add Upload file in editor

parent 0b55aeef
......@@ -68,4 +68,5 @@
.contextMenu LI.rename A { background-image: url(images/mfile.png); }
.contextMenu LI.md5sum A { background-image: url(images/selection-select.png); }
.contextMenu LI.refresh A { background-image: url(images/refresh.png); }
.contextMenu LI.favorite A { background-image: url(images/knewstuff.png); }
\ No newline at end of file
.contextMenu LI.favorite A { background-image: url(images/knewstuff.png); }
.contextMenu LI.uploadfile A { background-image: url(images/upload_folder.png); }
\ No newline at end of file
......@@ -156,7 +156,7 @@ function updateStatus(elt, val) {
$(src).addClass(value);
switch (val) {
case "waiting":
$(src).children('p').text("Waiting for starting");
$(src).children('p').text("Queue");
break;
case "stopped":
$(src).children('p').text("Stopped by user");
......
......@@ -9,6 +9,8 @@ $(document).ready(function () {
var viewer,
modelist,
config,
files,
working_node = null,
editorlist = Array(),
editorIndex = 0,
saveTimeOut = null,
......@@ -434,6 +436,7 @@ $(document).ready(function () {
var request, cb = clipboardNode.toDict(true, function(dict){
delete dict.key; // Remove key, so a new one will be created
});
cb.data.path = node.data.path + '/' + clipboardNode.title;
if( pasteMode == "cut" ) {
// Cut mode: check for recursion and remove source
dataForSend.opt = 7;
......@@ -449,7 +452,7 @@ $(document).ready(function () {
node.render();
}
else{
node.lazyLoad()
node.load(true);
}
clipboardNode.remove();
}
......@@ -466,7 +469,7 @@ $(document).ready(function () {
request.always(function() {
if (ajaxResult){
if (dataForSend.opt === 14){
node.lazyLoad(true);
node.load(true);
node.toggleExpanded();
}
else if (node.isExpanded()){
......@@ -493,7 +496,7 @@ $(document).ready(function () {
menu.disableContextMenuItems("#edit,#view,#md5sum,#favorite");
}
else{
menu.disableContextMenuItems("#nfile,#nfolder,#refresh,#paste");
menu.disableContextMenuItems("#nfile,#nfolder,#refresh,#paste,#ufile");
}
return true;
}
......@@ -570,7 +573,7 @@ $(document).ready(function () {
getmd5sum(node.data.path);
break;
case "refresh":
node.lazyLoad(true);
node.load(true);
node.toggleExpanded();
break;
case "nfolder":
......@@ -586,7 +589,7 @@ $(document).ready(function () {
request = fileBrowserOp(dataForSend)
request.always(function() {
if (ajaxResult){
node.lazyLoad(true);
node.load(true);
node.toggleExpanded();
}
});
......@@ -604,7 +607,7 @@ $(document).ready(function () {
request = fileBrowserOp(dataForSend)
request.always(function() {
if (ajaxResult){
node.lazyLoad(true);
node.load(true);
node.toggleExpanded();
}
});
......@@ -639,10 +642,18 @@ $(document).ready(function () {
request = fileBrowserOp(dataForSend);
request.always(function() {
if (ajaxResult){
var copy = node.toDict(true, function(dict){
dict.title = newName;
});
node.applyPatch(copy);
if (node.getParent().isRoot()) {
if ($('#fileTreeFull').css('display') === 'none'){
$('#fileTree').fancytree("getTree").reload();
}
else {
$('#fileTreeFull').fancytree("getTree").reload();
}
}
else {
node.getParent().load(true);
node.toggleExpanded();
}
}
});
......@@ -650,6 +661,16 @@ $(document).ready(function () {
case "favorite":
addToFavourite(node.data.path);
break;
case "ufile":
$.colorbox.remove();
$("#uploadForm input[name=dir]").val(node.data.path);
$("#inlineUpload").colorbox({inline:true,
width: "480px", height: "200px", onComplete:function(){
//nothing
}});
$("#inlineUpload").click();
working_node = node;
break;
default:
return;
}
......@@ -683,7 +704,7 @@ $(document).ready(function () {
data:{opt: 20, dir: path, key: key, listfiles: 'yes'},
cache: false
},
lazyload: function(event, data) {
lazyLoad: function(event, data) {
var node = data.node;
data.result = {
url: $SCRIPT_ROOT + "/fileBrowser",
......@@ -980,4 +1001,34 @@ $(document).ready(function () {
return false;
});
$('#choosefiles').on('change', function (event) {
files = event.target.files;
});
$("#submitUpload").click( function (){
jQuery('#uploadForm').submit();
$("#cboxClose").click();
return false;
});
jQuery('#uploadForm').ajaxForm({
beforeSubmit: function () {
$("#error").Popup("We are uploading your file...", {type: 'info', duration: 3000});
},
success: function (data, statusText, xhr, $form) {
if (data.indexOf("{result: '1'}") === -1) {
var msg = (data === "{result: '0'}") ? "ERROR: Please check your file or folder location!" : data;
$("#error").Popup("Error: " + msg, {type: 'error', duration: 5000});
} else {
$("#error").Popup("Your file has been uploaded!", {type: 'confirm', duration: 5000});
working_node.load(true);
}
},
error: function (xhr, ajaxOptions, thrownError) {
alertStatus (xhr);
},
dataType: 'script'
});
});
......@@ -40,6 +40,7 @@
<li class="paste"><a href="#paste">Paste</a></li>
<li class="newfile separator"><a href="#nfile">New File</a></li>
<li class="newdir"><a href="#nfolder">New Folder</a></li>
<li class="uploadfile"><a href="#ufile">Upload File</a></li>
</ul>
<div id="software_folder">
<div class='box_header'>
......@@ -109,4 +110,23 @@
</div>
</div>
<a id='inlineUpload' style='display:none' href="#uploadContent">Inline HTML</a>
<div style='display:none'>
<div id="uploadContent" style="padding:10px; background:#fff;">
<h2 style="color: #4c6172; font: 18px \'Helvetica Neue\', Helvetica, Arial, sans-serif;">
Upload local file to your workspace</h2>
<p id="uploadlog" class="message"><br/></p>
<br/>
<form action="{{ url_for('fileBrowser') }}" id="uploadForm" enctype="multipart/form-data">
<div class="fileinputs">
<input type="file" name="filename" size="30" id="choosefiles" />
<input type="hidden" name="opt" value="11" />
<input type="hidden" name="dir" value="" />
<br/>
<input type=submit value="Upload" id="submitUpload" class="button" />
</div>
</form>
</div>
</div>
{% endblock %}
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