Commit e4bcc6b8 authored by Gero Müller's avatar Gero Müller
Browse files

use timestamps and remove unneeded info from file_list

parent 73bcb97d
...@@ -6,15 +6,19 @@ var FileBaseActions = Class.extend({ ...@@ -6,15 +6,19 @@ var FileBaseActions = Class.extend({
this.entries = {}; this.entries = {};
}, },
abspath: function(data) {
return this.owner.workflow.path + '/' + data.name;
},
openFolder: function(data) {; openFolder: function(data) {;
this.owner.workflow.path = data.path; this.owner.workflow.path = this.abspath(data);
this.owner.updateView(); this.owner.updateView();
}, },
openFile: function(data) { openFile: function(data) {
var ext = $.Helpers.strExtension(data.name); var ext = $.Helpers.strExtension(data.name);
console.log(ext); console.log(ext);
var path = data.path; var path = this.abspath(data);
var handlers = Vispa.extensionManager.getFileHandlers(ext, true); var handlers = Vispa.extensionManager.getFileHandlers(ext, true);
...@@ -40,7 +44,7 @@ var FileBaseActions = Class.extend({ ...@@ -40,7 +44,7 @@ var FileBaseActions = Class.extend({
type: 'POST', type: 'POST',
data: { data: {
_wid: Vispa.workspaceManager.getWorkspace().id, _wid: Vispa.workspaceManager.getWorkspace().id,
path: data.path, path: this.abspath(data),
name: newName name: newName
}, },
success: function(response) { success: function(response) {
...@@ -57,7 +61,7 @@ var FileBaseActions = Class.extend({ ...@@ -57,7 +61,7 @@ var FileBaseActions = Class.extend({
type: 'POST', type: 'POST',
data: { data: {
_wid: Vispa.workspaceManager.getWorkspace().id, _wid: Vispa.workspaceManager.getWorkspace().id,
path: data.path, path: this.abspath(data),
name: newName name: newName
}, },
success: function(response) { success: function(response) {
...@@ -148,7 +152,7 @@ var FileBaseActions = Class.extend({ ...@@ -148,7 +152,7 @@ var FileBaseActions = Class.extend({
var paths = new Array(); var paths = new Array();
$.each(this.owner.selections.entries, function(i, entry) { $.each(this.owner.selections.entries, function(i, entry) {
paths.push(entry.data.path); paths.push(entry.this.abspath(data));
}); });
$.ajax({ $.ajax({
......
...@@ -16,7 +16,7 @@ var FileBaseEvents = Class.extend({ ...@@ -16,7 +16,7 @@ var FileBaseEvents = Class.extend({
event.preventDefault(); event.preventDefault();
var data = node.data().data; var data = node.data().data;
this.owner.selections.unselectAll(); this.owner.selections.unselectAll();
this.owner.selections.addSelection(data.path, node); this.owner.selections.addSelection(this.abspath(data), node);
var items = [_this.owner.menuitems.openFolder(data), var items = [_this.owner.menuitems.openFolder(data),
_this.owner.menuitems.rename(data), _this.owner.menuitems.rename(data),
_this.owner.menuitems.copy(data), _this.owner.menuitems.copy(data),
...@@ -46,7 +46,7 @@ var FileBaseEvents = Class.extend({ ...@@ -46,7 +46,7 @@ var FileBaseEvents = Class.extend({
event.preventDefault(); event.preventDefault();
var data = node.data().data; var data = node.data().data;
this.owner.selections.unselectAll(); this.owner.selections.unselectAll();
this.owner.selections.addSelection(data.path, node); this.owner.selections.addSelection(this.abspath(data), node);
var items = [_this.owner.menuitems.openFile(data), var items = [_this.owner.menuitems.openFile(data),
_this.owner.menuitems.openWith(data), _this.owner.menuitems.openWith(data),
_this.owner.menuitems.rename(data), _this.owner.menuitems.rename(data),
......
...@@ -47,7 +47,7 @@ var FileBaseMenuItems = Class.extend({ ...@@ -47,7 +47,7 @@ var FileBaseMenuItems = Class.extend({
// This is not following the usual concept // This is not following the usual concept
// But for this single line there is no sense in // But for this single line there is no sense in
// implementing a function actions.js // implementing a function actions.js
handler.callback(data.path); handler.callback(this.abspath(data));
} }
}); });
......
...@@ -50,10 +50,10 @@ var FileBaseView = Class.extend({ ...@@ -50,10 +50,10 @@ var FileBaseView = Class.extend({
// selectbox.change(function(event) { // selectbox.change(function(event) {
// event.stopPropagation(); // event.stopPropagation();
// if (selectbox.is(":checked")) { // if (selectbox.is(":checked")) {
// owner.selections.addSelection(data.path, node); // owner.selections.addSelection(this.abspath(data), node);
// node.data().selected = true; // node.data().selected = true;
// } else { // } else {
// owner.selections.unselect(data.path); // owner.selections.unselect(this.abspath(data));
// }; // };
// }); // });
// }) // })
...@@ -63,11 +63,11 @@ var FileBaseView = Class.extend({ ...@@ -63,11 +63,11 @@ var FileBaseView = Class.extend({
event.stopPropagation(); event.stopPropagation();
if (selectbox.is(":checked")) { if (selectbox.is(":checked")) {
selectbox.removeAttr("checked"); selectbox.removeAttr("checked");
owner.selections.unselect(data.path.toString()); owner.selections.unselect(this.abspath(data).toString());
} else { } else {
node.data().selected = true; node.data().selected = true;
selectbox.attr('checked', true); selectbox.attr('checked', true);
owner.selections.addSelection(data.path.toString(), node); owner.selections.addSelection(this.abspath(data).toString(), node);
}; };
} else { } else {
......
...@@ -32,8 +32,17 @@ var Tableview = Class.extend({ ...@@ -32,8 +32,17 @@ var Tableview = Class.extend({
// Set the right path // Set the right path
this.owner.workflow.parentpath = data.parentpath; this.owner.workflow.parentpath = data.parentpath;
directives = {
mtime : {
text : function() {
var dt = new Date(this.mtime * 1000);
return dt.toLocaleString();
}
}
};
// render the content // render the content
$(".files-table", this.fileContentContainer).render(data.filelist); $(".files-table", this.fileContentContainer).render(data.filelist, directives);
// Get the objects and append the data to them // Get the objects and append the data to them
$(".files-table", this.fileContentContainer).children().each(function(i, child) { $(".files-table", this.fileContentContainer).children().each(function(i, child) {
......
...@@ -6,8 +6,8 @@ var FileBrowserActions = FileBaseActions.extend({ ...@@ -6,8 +6,8 @@ var FileBrowserActions = FileBaseActions.extend({
}, },
openFolder: function(data) { openFolder: function(data) {
this.owner.workflow.path = data.path; this.owner.workflow.path = this.abspath(data);
this.owner.updateView(); this.owner.updateView();
Vispa.pathBar.setValue(data.path); Vispa.pathBar.setValue(this.abspath(data));
} }
}); });
\ No newline at end of file
...@@ -209,7 +209,7 @@ var FileSelectorContent = ExtensionContentFull.extend({ ...@@ -209,7 +209,7 @@ var FileSelectorContent = ExtensionContentFull.extend({
render: function(node) { render: function(node) {
$(node).append(this.selector.getContent()); $(node).append(this.selector.getContent());
// $(node).append(this.workflow.initialData.path); // $(node).append(this.workflow.initialthis.abspath(data));
return this; return this;
}, },
......
...@@ -7,7 +7,7 @@ var FileSelectorActions = FileBaseActions.extend({ ...@@ -7,7 +7,7 @@ var FileSelectorActions = FileBaseActions.extend({
// This is not really an open File method but a select file method // This is not really an open File method but a select file method
openFile: function(data) { openFile: function(data) {
this.owner.workflow.selection.push(data.path) this.owner.workflow.selection.push(this.abspath(data))
if (this.owner.workflow.multimode) { if (this.owner.workflow.multimode) {
this.owner.workflow.callback(this.owner.workflow.selection); this.owner.workflow.callback(this.owner.workflow.selection);
} else { } else {
......
...@@ -89,19 +89,16 @@ class FileSystem(object): ...@@ -89,19 +89,16 @@ class FileSystem(object):
fullpath = os.path.join(path_expand, elem) fullpath = os.path.join(path_expand, elem)
# get locales, mtime, etc
locale.setlocale(locale.LC_ALL, '')
stats = os.stat(fullpath) stats = os.stat(fullpath)
size = locale.format('%d', stats.st_size, grouping=True) size = stats.st_size
mtime = datetime.fromtimestamp(stats.st_mtime).strftime('%Y-%m-%d %H:%M:%S') mtime = stats.st_mtime
if stat.S_ISDIR(stats.st_mode): if stat.S_ISDIR(stats.st_mode):
filelist.append({'name': elem, 'type': 'd', 'parent': path, 'mtime': mtime, 'size': size, 'path': fullpath}) filelist.append({'name': elem, 'type': 'd', 'mtime': mtime, 'size': size})
if deep: if deep:
filelist.extend(self.get_file_list(fullpath, deep, filter, reverse)) filelist.extend(self.get_file_list(fullpath, deep, filter, reverse))
else: else:
extension = elem.split('.')[-1] filelist.append({'name': elem, 'type': 'f', 'mtime': mtime, 'size': size})
filelist.append({'name': elem, 'type': 'f', 'parent': path, 'mtime': mtime, 'size': size, 'path': fullpath})
except Exception, e: except Exception, e:
filelist.append({'warning': str(e)}) filelist.append({'warning': str(e)})
...@@ -111,6 +108,7 @@ class FileSystem(object): ...@@ -111,6 +108,7 @@ class FileSystem(object):
data = {'filelist': filelist, 'parentpath': parentpath} data = {'filelist': filelist, 'parentpath': parentpath}
if encode_json: if encode_json:
return json.dumps(data) return json.dumps(data)
else:
return data return data
......
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