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