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 @@ ...@@ -68,4 +68,5 @@
.contextMenu LI.rename A { background-image: url(images/mfile.png); } .contextMenu LI.rename A { background-image: url(images/mfile.png); }
.contextMenu LI.md5sum A { background-image: url(images/selection-select.png); } .contextMenu LI.md5sum A { background-image: url(images/selection-select.png); }
.contextMenu LI.refresh A { background-image: url(images/refresh.png); } .contextMenu LI.refresh A { background-image: url(images/refresh.png); }
.contextMenu LI.favorite A { background-image: url(images/knewstuff.png); } .contextMenu LI.favorite A { background-image: url(images/knewstuff.png); }
\ No newline at end of file .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) { ...@@ -156,7 +156,7 @@ function updateStatus(elt, val) {
$(src).addClass(value); $(src).addClass(value);
switch (val) { switch (val) {
case "waiting": case "waiting":
$(src).children('p').text("Waiting for starting"); $(src).children('p').text("Queue");
break; break;
case "stopped": case "stopped":
$(src).children('p').text("Stopped by user"); $(src).children('p').text("Stopped by user");
......
...@@ -9,6 +9,8 @@ $(document).ready(function () { ...@@ -9,6 +9,8 @@ $(document).ready(function () {
var viewer, var viewer,
modelist, modelist,
config, config,
files,
working_node = null,
editorlist = Array(), editorlist = Array(),
editorIndex = 0, editorIndex = 0,
saveTimeOut = null, saveTimeOut = null,
...@@ -434,6 +436,7 @@ $(document).ready(function () { ...@@ -434,6 +436,7 @@ $(document).ready(function () {
var request, cb = clipboardNode.toDict(true, function(dict){ var request, cb = clipboardNode.toDict(true, function(dict){
delete dict.key; // Remove key, so a new one will be created delete dict.key; // Remove key, so a new one will be created
}); });
cb.data.path = node.data.path + '/' + clipboardNode.title;
if( pasteMode == "cut" ) { if( pasteMode == "cut" ) {
// Cut mode: check for recursion and remove source // Cut mode: check for recursion and remove source
dataForSend.opt = 7; dataForSend.opt = 7;
...@@ -449,7 +452,7 @@ $(document).ready(function () { ...@@ -449,7 +452,7 @@ $(document).ready(function () {
node.render(); node.render();
} }
else{ else{
node.lazyLoad() node.load(true);
} }
clipboardNode.remove(); clipboardNode.remove();
} }
...@@ -466,7 +469,7 @@ $(document).ready(function () { ...@@ -466,7 +469,7 @@ $(document).ready(function () {
request.always(function() { request.always(function() {
if (ajaxResult){ if (ajaxResult){
if (dataForSend.opt === 14){ if (dataForSend.opt === 14){
node.lazyLoad(true); node.load(true);
node.toggleExpanded(); node.toggleExpanded();
} }
else if (node.isExpanded()){ else if (node.isExpanded()){
...@@ -493,7 +496,7 @@ $(document).ready(function () { ...@@ -493,7 +496,7 @@ $(document).ready(function () {
menu.disableContextMenuItems("#edit,#view,#md5sum,#favorite"); menu.disableContextMenuItems("#edit,#view,#md5sum,#favorite");
} }
else{ else{
menu.disableContextMenuItems("#nfile,#nfolder,#refresh,#paste"); menu.disableContextMenuItems("#nfile,#nfolder,#refresh,#paste,#ufile");
} }
return true; return true;
} }
...@@ -570,7 +573,7 @@ $(document).ready(function () { ...@@ -570,7 +573,7 @@ $(document).ready(function () {
getmd5sum(node.data.path); getmd5sum(node.data.path);
break; break;
case "refresh": case "refresh":
node.lazyLoad(true); node.load(true);
node.toggleExpanded(); node.toggleExpanded();
break; break;
case "nfolder": case "nfolder":
...@@ -586,7 +589,7 @@ $(document).ready(function () { ...@@ -586,7 +589,7 @@ $(document).ready(function () {
request = fileBrowserOp(dataForSend) request = fileBrowserOp(dataForSend)
request.always(function() { request.always(function() {
if (ajaxResult){ if (ajaxResult){
node.lazyLoad(true); node.load(true);
node.toggleExpanded(); node.toggleExpanded();
} }
}); });
...@@ -604,7 +607,7 @@ $(document).ready(function () { ...@@ -604,7 +607,7 @@ $(document).ready(function () {
request = fileBrowserOp(dataForSend) request = fileBrowserOp(dataForSend)
request.always(function() { request.always(function() {
if (ajaxResult){ if (ajaxResult){
node.lazyLoad(true); node.load(true);
node.toggleExpanded(); node.toggleExpanded();
} }
}); });
...@@ -639,10 +642,18 @@ $(document).ready(function () { ...@@ -639,10 +642,18 @@ $(document).ready(function () {
request = fileBrowserOp(dataForSend); request = fileBrowserOp(dataForSend);
request.always(function() { request.always(function() {
if (ajaxResult){ if (ajaxResult){
var copy = node.toDict(true, function(dict){ if (node.getParent().isRoot()) {
dict.title = newName; if ($('#fileTreeFull').css('display') === 'none'){
}); $('#fileTree').fancytree("getTree").reload();
node.applyPatch(copy); }
else {
$('#fileTreeFull').fancytree("getTree").reload();
}
}
else {
node.getParent().load(true);
node.toggleExpanded();
}
} }
}); });
...@@ -650,6 +661,16 @@ $(document).ready(function () { ...@@ -650,6 +661,16 @@ $(document).ready(function () {
case "favorite": case "favorite":
addToFavourite(node.data.path); addToFavourite(node.data.path);
break; 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: default:
return; return;
} }
...@@ -683,7 +704,7 @@ $(document).ready(function () { ...@@ -683,7 +704,7 @@ $(document).ready(function () {
data:{opt: 20, dir: path, key: key, listfiles: 'yes'}, data:{opt: 20, dir: path, key: key, listfiles: 'yes'},
cache: false cache: false
}, },
lazyload: function(event, data) { lazyLoad: function(event, data) {
var node = data.node; var node = data.node;
data.result = { data.result = {
url: $SCRIPT_ROOT + "/fileBrowser", url: $SCRIPT_ROOT + "/fileBrowser",
...@@ -980,4 +1001,34 @@ $(document).ready(function () { ...@@ -980,4 +1001,34 @@ $(document).ready(function () {
return false; 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 @@ ...@@ -40,6 +40,7 @@
<li class="paste"><a href="#paste">Paste</a></li> <li class="paste"><a href="#paste">Paste</a></li>
<li class="newfile separator"><a href="#nfile">New File</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="newdir"><a href="#nfolder">New Folder</a></li>
<li class="uploadfile"><a href="#ufile">Upload File</a></li>
</ul> </ul>
<div id="software_folder"> <div id="software_folder">
<div class='box_header'> <div class='box_header'>
...@@ -109,4 +110,23 @@ ...@@ -109,4 +110,23 @@
</div> </div>
</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 %} {% 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