Commit be23deb3 authored by murban's avatar murban
Browse files

Working implementation of different actions: CreateFile, CreateFolder, Copy,...

Working implementation of different actions: CreateFile, CreateFolder, Copy, Cut, Paste, Remove, Rename, Compress, Open.
Missing actions are: Upload, Download, Info, OpenWith
parent 60f3283e
......@@ -147,28 +147,30 @@ class FSAjaxController(AbstractController):
return self.fail(msg='Couldn\'t remove the file(s): %s' % str(e))
@cherrypy.expose
@cherrypy.tools.allow(methods=['POST'])
@cherrypy.tools.allow(methods=['POST', 'GET'])
@cherrypy.tools.json_out()
def compress(self, path, paths, name):
try:
fs = self.get('fs')
# 'paths' can be a unicode/string or list of unicodes/strings
# so convert it with the convert function
fs.compress(str(path), self.convert(path, 'string'), str(name))
paths = json.loads(paths)
fs.compress(str(path), paths, str(name))
return self.success()
except Exception, e:
return self.fail(msg='Couldn\'t compress the file(s): %s' % str(e))
@cherrypy.expose
@cherrypy.tools.allow(methods=['POST'])
@cherrypy.tools.allow(methods=['POST', 'GET'])
@cherrypy.tools.json_out()
@cherrypy.tools.json_in()
def paste(self, path, paths, cut):
try:
fs = self.get('fs')
paths = json.loads(paths)
# 'paths' can be a unicode/string or list of unicodes/strings
# so convert it with the convert function
fs.paste(str(path), self.convert(
path, 'string'), self.convert(cut, 'boolean'))
fs.paste(path, paths, self.convert(cut, 'boolean'))
return self.success()
except Exception, e:
action = 'cut' if self.convert(cut, 'boolean') else 'copy'
......
......@@ -245,7 +245,7 @@ class FileSystem(object):
paths.append(fullp)
else:
ap = fullp[len(path):] if fullp.startswith(path) else fullp
archive.write(fullpp, ap)
archive.write(fullp, ap)
ap = p[len(path):] if p.startswith(path) else p
archive.write(p, ap)
......
......@@ -2,6 +2,7 @@ var FileBaseActions = Class.extend({
init: function(owner) {
this.owner = owner;
this.pastebool = false;
this.cutbool = false;
this.pasteentries = {};
},
......@@ -15,39 +16,101 @@ var FileBaseActions = Class.extend({
},
rename: function(data) {
console.log("rename");
var type = data.type
var _this = this;
var type = data.type;
var name = data.name;
var newName = prompt("Enter a new name", name)
if (newName == name || newName == null || newName == "") {
return
};
if (type == "d") {
$.getJSON(
this.urlFormatter('ajax/fs/rename_folder' + "?path=" + this.workflow.path + "?name=" + "test2"),
function(data) {
_this.workflow.data = data;
_this.currentView.setContent(data);
console.log(data);
$.ajax({
url: this.owner.urlFormatter('ajax/fs/renamefolder'),
type: 'POST',
data: {
path: data.path,
name: newName
},
success: function(response) {
if (response.success) {
_this.owner.updateView();
} else {
$.Topic('msg.error').publish(response.msg);
}
}
});
} else {
$.ajax({
url: this.owner.urlFormatter('ajax/fs/renamefile'),
type: 'POST',
data: {
path: data.path,
name: newName
},
success: function(response) {
if (response.success) {
_this.owner.updateView();
} else {
$.Topic('msg.error').publish(response.msg);
}
}
});
} else{};
};
},
copy: function(data) {
this.pastebool = true;
this.pasteentries = this.owner.selections.entries;
console.log("copy");
console.log(this.pasteentries);
},
cut: function(data) {
this.pastebool = true;
this.pasteentries = this.owner.selections.entries;
console.log("cut");
console.log(this.pasteentries);
this.cutbool = true;
},
paste: function(data) {
console.log("paste");
var _this = this;
var paths = new Array();
$.each(this.pasteentries, function(i, entry) {
paths.push(entry.data.path);
});
$.ajax({
url: this.owner.urlFormatter('ajax/fs/paste'),
type: 'GET',
data: {
'path': this.owner.workflow.path,
'paths': JSON.stringify(paths),
'cut': this.cutbool
},
success: function(response) {
if (response.success) {
_this.owner.updateView();
} else {
$.Topic('msg.error').publish(response.msg);
}
}
});
},
remove: function(data) {
console.log("remove");
var _this = this;
$.ajax({
url: this.owner.urlFormatter('ajax/fs/remove'),
type: 'POST',
data: {
path: data.path,
},
success: function(response) {
if (response.success) {
_this.owner.updateView();
} else {
$.Topic('msg.error').publish(response.msg);
}
}
});
},
download: function(data) {
......@@ -55,7 +118,34 @@ var FileBaseActions = Class.extend({
},
compress: function(data) {
console.log("compress");
var _this = this;
var newName = prompt("Enter a name for the zip-file", name)
if (newName == name || newName == null || newName == "") {
return
};
var paths = new Array();
$.each(this.owner.selections.entries, function(i, entry) {
paths.push(entry.data.path);
});
$.ajax({
url: this.owner.urlFormatter('ajax/fs/compress'),
type: 'GET',
data: {
'path': this.owner.workflow.path,
'paths': JSON.stringify(paths),
'name': newName
},
success: function(response) {
if (response.success) {
_this.owner.updateView();
} else {
$.Topic('msg.error').publish(response.msg);
}
}
});
},
info: function(data) {
......@@ -63,10 +153,48 @@ var FileBaseActions = Class.extend({
},
createFile: function(data) {
console.log("createFile");
var _this = this;
var newName = prompt("Enter name for new file:", name)
if (newName == null || newName == "") {
return
};
$.ajax({
url: this.owner.urlFormatter('ajax/fs/createfile'),
type: 'POST',
data: {
path: _this.owner.workflow.path,
name: newName
},
success: function(response) {
if (response.success) {
_this.owner.updateView();
} else {
$.Topic('msg.error').publish(response.msg);
}
}
});
},
createFolder: function(data) {
console.log("createFolder");
var _this = this;
var newName = prompt("Enter name for new directory:", name)
if (newName == null || newName == "") {
return
};
$.ajax({
url: this.owner.urlFormatter('ajax/fs/createfolder'),
type: 'POST',
data: {
path: this.owner.workflow.path,
name: newName
},
success: function(response) {
if (response.success) {
_this.owner.updateView();
} else {
$.Topic('msg.error').publish(response.msg);
}
}
});
}
});
\ No newline at end of file
......@@ -71,7 +71,6 @@ var FileBaseEvents = Class.extend({
event.preventDefault();
var eventtype = event.which
console.log(eventtype);
if (eventtype == 1) {
_this.leftClickBkg(event, data);
} else {
......@@ -84,8 +83,6 @@ var FileBaseEvents = Class.extend({
event.stopPropagation();
event.preventDefault();
this.owner.selections.unselectAll();
console.log(event);
console.log("test left");
},
rightClickBkg: function(event, data) {
......
......@@ -11,12 +11,10 @@ var FileBaseSelections = Class.extend({
unselect: function (path, node) {
delete this.entries[path];
console.log(this.entries);
},
addSelection: function(path, node)
{
this.entries[path] = node;
console.log(this.entries);
}
});
\ No newline at end of file
......@@ -3,32 +3,11 @@ var Symbolview = Class.extend({
this.owner = owner;
this.mainContainer = null;
this.menu = null;
// console.log(this.owner);
// console.log(this.owner.view.mainContainer);
},
render: function() {
// var maindiv = $('<div />')
// .addClass("file-maindiv");
// // .isotope({
// // // options
// // itemSelector: '.file-item',
// // layoutMode: 'fitRows'
// // });
// this.mainContainer = maindiv;
// this.menu = $('<div/>');
// this.menu.appendTo(maindiv);
// this.menu.css('background-color', '#FFFFFF')
// // .css('display', 'none')
// .css('width', '220px')
// .css('height', '220px')
// .css('margin', '5px')
// .css('float', 'left')
// .css('position', 'relative');
// return maindiv;
},
setContent: function(data) {
var _this = this
//empty the existing container
......@@ -107,7 +86,9 @@ var Symbolview = Class.extend({
var lastchanged = $("<p/>", {
text: $.Helpers.strFormat('Last Changed: {0} b', data.mtime)
text: $.Helpers.strFormat('Last Changed: {0} b', data.mtime),
title: data.name,
alt: data.name
}).appendTo(icon);
// var extension = $("<p/>",{
......@@ -115,7 +96,9 @@ var Symbolview = Class.extend({
// }).appendTo(icon);
var size = $("<p/>", {
text: $.Helpers.strFormat('Size: {0} b', data.size)
text: $.Helpers.strFormat('Size: {0} b', data.size),
title: data.name,
alt: data.name
}).appendTo(icon);
// var name = $("<a/>", {
......@@ -129,6 +112,7 @@ var Symbolview = Class.extend({
},
title: data.name,
alt: data.name
});
// css
......
......@@ -548,8 +548,6 @@ var View = VispaModule.extend({
setupMenus: function() {
var mainItems = Vispa.menuItems('main');
console.log("tesdt");
console.log(mainItems);
var mainPosition = {
at: 'right bottom',
my: 'right top'
......
Supports Markdown
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