mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-24 03:05:41 +00:00
added ability to rename files
This commit is contained in:
parent
e8de73985e
commit
216b1d38ba
3 changed files with 16 additions and 12 deletions
|
|
@ -184,6 +184,8 @@ generation of json of directory listing.
|
|||
|
||||
* Added to html templating.
|
||||
|
||||
* Added ability to rename files.
|
||||
|
||||
|
||||
2012.12.12, Version 0.1.8
|
||||
|
||||
|
|
|
|||
|
|
@ -1348,18 +1348,19 @@ var CloudCommander, Util,
|
|||
pCurrentFile = null;
|
||||
|
||||
var lCurrent = pCurrentFile || DOM.getCurrentFile(),
|
||||
lName = DOM.getCurrentName(lCurrent),
|
||||
lNewName = prompt("Rename", lName) || lName;
|
||||
|
||||
if( !Util.strCmp(lName, lNewName) ){
|
||||
lFrom = DOM.getCurrentName(lCurrent),
|
||||
lTo = prompt("Rename", lFrom) || lFrom,
|
||||
lDirPath = DOM.getCurrentDirPath();
|
||||
if( !Util.strCmp(lFrom, lTo) ){
|
||||
var lFiles = {
|
||||
from : lName,
|
||||
to : lNewName
|
||||
from : lDirPath + lFrom,
|
||||
to : lDirPath + lTo
|
||||
};
|
||||
|
||||
DOM.Images.showLoad();
|
||||
|
||||
CloudCommander.getConfig(function(pConfig){
|
||||
var lUrl = DOM.getCurrentDirPath();
|
||||
lUrl = pConfig && pConfig.api_url + '/mv';
|
||||
var lUrl = pConfig && pConfig.api_url + '/mv';
|
||||
|
||||
DOM.ajax({
|
||||
method : 'put',
|
||||
|
|
@ -1368,7 +1369,7 @@ var CloudCommander, Util,
|
|||
error : DOM.Images.showError,
|
||||
success : function(pData){
|
||||
DOM.Images.hideLoad();
|
||||
DOM.setCurrentName(lName, lCurrent);
|
||||
DOM.setCurrentName(lTo, lCurrent);
|
||||
Util.log(pData);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@
|
|||
if(lRet){
|
||||
var p = pParams,
|
||||
lCmd = p.command,
|
||||
lFiles = Util.stringifyJSON(p.body);
|
||||
lFiles = Util.parseJSON(p.body);
|
||||
console.log(p.body);
|
||||
switch(lCmd){
|
||||
case 'auth':
|
||||
|
|
@ -234,14 +234,15 @@
|
|||
});
|
||||
break;
|
||||
case 'mv':
|
||||
if(lFiles)
|
||||
Util.log(lFiles);
|
||||
if( Util.checkObjTrue(lFiles, ['from', 'to']) )
|
||||
fs.rename(lFiles.from, lFiles.to, function(pError){
|
||||
if(!pError)
|
||||
main.sendResponse(pParams);
|
||||
else
|
||||
main.sendError(pParams, pError);
|
||||
});
|
||||
else
|
||||
main.sendError(pParams, p.data);
|
||||
break;
|
||||
|
||||
case 'cp':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue