|
|
@ -17,8 +17,10 @@ if (typeof XMLHttpRequest === 'undefined') {
|
|
|
|
rmDialog: null,
|
|
|
|
rmDialog: null,
|
|
|
|
mvDialog: null,
|
|
|
|
mvDialog: null,
|
|
|
|
flist: null,
|
|
|
|
flist: null,
|
|
|
|
|
|
|
|
fmlist: null,
|
|
|
|
selection: [],
|
|
|
|
selection: [],
|
|
|
|
dirBar: null,
|
|
|
|
curDirBar: null,
|
|
|
|
|
|
|
|
subDirsBar: null,
|
|
|
|
destination: null,
|
|
|
|
destination: null,
|
|
|
|
rootDisplay: null,
|
|
|
|
rootDisplay: null,
|
|
|
|
setRoot: function(sub) {
|
|
|
|
setRoot: function(sub) {
|
|
|
@ -35,12 +37,13 @@ if (typeof XMLHttpRequest === 'undefined') {
|
|
|
|
this.setRoot(sub);
|
|
|
|
this.setRoot(sub);
|
|
|
|
var owner = this.element.data('owner');
|
|
|
|
var owner = this.element.data('owner');
|
|
|
|
this.selection = [];
|
|
|
|
this.selection = [];
|
|
|
|
this.dirBar.empty();
|
|
|
|
this.curDirBar.empty();
|
|
|
|
|
|
|
|
this.subDirsBar.empty();
|
|
|
|
$('<button>' + owner + '</button>')
|
|
|
|
$('<button>' + owner + '</button>')
|
|
|
|
.click(function () {
|
|
|
|
.click(function () {
|
|
|
|
_this.openDir(null);
|
|
|
|
_this.openDir(null);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.appendTo(this.dirBar);
|
|
|
|
.appendTo(this.curDirBar);
|
|
|
|
var npath = null
|
|
|
|
var npath = null
|
|
|
|
|
|
|
|
|
|
|
|
if (_this.root) {
|
|
|
|
if (_this.root) {
|
|
|
@ -52,15 +55,39 @@ if (typeof XMLHttpRequest === 'undefined') {
|
|
|
|
$('<button/>')
|
|
|
|
$('<button/>')
|
|
|
|
.append(part)
|
|
|
|
.append(part)
|
|
|
|
.click(function () {
|
|
|
|
.click(function () {
|
|
|
|
_this.OpenDir(npath);
|
|
|
|
_this.openDir(npath);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.appendTo(this.dirBar);
|
|
|
|
.appendTo(_this.curDirBar);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.ftable.find('tr.fileinfo').remove();
|
|
|
|
this.ftable.find('tr.fileinfo').remove();
|
|
|
|
var fsiourl = this.root ? '/api/fs/' + this.root : '/api/fs';
|
|
|
|
var fsiourl = this.root ? '/api/fs/' + this.root : '/api/fs';
|
|
|
|
$.get(fsiourl, function (data) {
|
|
|
|
$.get(fsiourl, function (data) {
|
|
|
|
|
|
|
|
if (data.SubDirectories.length == 0 && data.Files.length == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$('<button class="glyphicon"> remove this empty directory</button>').click(
|
|
|
|
|
|
|
|
function() {
|
|
|
|
|
|
|
|
var xmlhttp = new XMLHttpRequest();
|
|
|
|
|
|
|
|
xmlhttp.open('DELETE', '/api/fs/' + _this.root, true);
|
|
|
|
|
|
|
|
xmlhttp.send();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xmlhttp.onreadystatechange = function(event) {
|
|
|
|
|
|
|
|
// XMLHttpRequest.DONE === 4
|
|
|
|
|
|
|
|
if (this.readyState === XMLHttpRequest.DONE) {
|
|
|
|
|
|
|
|
if (this.status === 200) {
|
|
|
|
|
|
|
|
var dnames = _this.root.split('/');
|
|
|
|
|
|
|
|
var dcnt = dnames.length;
|
|
|
|
|
|
|
|
var nroot = dnames.slice(0,dcnt-1).join('/');
|
|
|
|
|
|
|
|
_this.openDir(nroot);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).appendTo(_this.subDirsBar);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
$.each(data.SubDirectories, function () {
|
|
|
|
$.each(data.SubDirectories, function () {
|
|
|
|
var item = this;
|
|
|
|
var item = this;
|
|
|
|
var spath = _this.root ? _this.root + '/' + item.Name : item.Name;
|
|
|
|
var spath = _this.root ? _this.root + '/' + item.Name : item.Name;
|
|
|
@ -69,7 +96,7 @@ if (typeof XMLHttpRequest === 'undefined') {
|
|
|
|
.click(function () {
|
|
|
|
.click(function () {
|
|
|
|
_this.openDir(spath);
|
|
|
|
_this.openDir(spath);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.appendTo(_this.dirBar);
|
|
|
|
.appendTo(_this.subDirsBar);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$.each(data.Files, function () {
|
|
|
|
$.each(data.Files, function () {
|
|
|
@ -83,18 +110,16 @@ if (typeof XMLHttpRequest === 'undefined') {
|
|
|
|
_this.SetItemSelected(item.Name, this.checked);
|
|
|
|
_this.SetItemSelected(item.Name, this.checked);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.appendTo($td);
|
|
|
|
.appendTo($td);
|
|
|
|
|
|
|
|
var furl = (_this.root) ? '/files/' + owner + '/' + _this.root + '/' + item.Name
|
|
|
|
$('<td></td>')
|
|
|
|
: '/files/' + owner + '/' + item.Name;
|
|
|
|
.append($('<a></a>')
|
|
|
|
$('<td class="filename"></td>')
|
|
|
|
.append(item.Name)
|
|
|
|
.append($('<a></a>').attr('href',furl)
|
|
|
|
.click(function () {
|
|
|
|
.append(item.Name)).appendTo($tr);
|
|
|
|
if (_this.root) document.location = '/' + owner + '/' + _this.root + '/' + item.Name;
|
|
|
|
$('<td class="filesize">' + item.Size + '</td>').appendTo($tr);
|
|
|
|
else document.location = '/files/' + owner + '/' + item.Name;
|
|
|
|
$('<td class="filemdate">' + item.LastModified + '</td>').appendTo($tr);
|
|
|
|
})).appendTo($tr);
|
|
|
|
|
|
|
|
$('<td>' + item.Size + '</td>').appendTo($tr);
|
|
|
|
|
|
|
|
$('<td>' + item.LastModified + '</td>').appendTo($tr);
|
|
|
|
|
|
|
|
$tr.appendTo(_this.ftable);
|
|
|
|
$tr.appendTo(_this.ftable);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
SetItemSelected: function (name, selected) {
|
|
|
|
SetItemSelected: function (name, selected) {
|
|
|
@ -106,26 +131,43 @@ if (typeof XMLHttpRequest === 'undefined') {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
setFileAway: function(fname)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.selection = this.selection.filter(function (ele) {
|
|
|
|
|
|
|
|
return ele !== fname;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
this.ftable.find('tr.fileinfo').filter(function () {
|
|
|
|
|
|
|
|
return $(this).children('td:nth-child(2)').text() == fname;
|
|
|
|
|
|
|
|
}).remove();
|
|
|
|
|
|
|
|
},
|
|
|
|
RemoveSelectedFiles: function () {
|
|
|
|
RemoveSelectedFiles: function () {
|
|
|
|
|
|
|
|
var _this = this;
|
|
|
|
$.each(this.selection, function () {
|
|
|
|
$.each(this.selection, function () {
|
|
|
|
|
|
|
|
var dfile = this;
|
|
|
|
|
|
|
|
var dfilep = _this.root ? _this.root + '/' + this : this;
|
|
|
|
var xmlhttp = new XMLHttpRequest();
|
|
|
|
var xmlhttp = new XMLHttpRequest();
|
|
|
|
xmlhttp.open('DELETE', '/api/fs/' + this, true);
|
|
|
|
xmlhttp.onreadystatechange = function(event) {
|
|
|
|
|
|
|
|
if (this.readyState === XMLHttpRequest.DONE) {
|
|
|
|
|
|
|
|
if (this.status === 200) {
|
|
|
|
|
|
|
|
_this.setFileAway(dfile);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
alert( 'deletion of : ' + dfile + 'failed : '+ this.statusText );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
xmlhttp.open('DELETE', '/api/fs/' + dfilep, true);
|
|
|
|
xmlhttp.send();
|
|
|
|
xmlhttp.send();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.selection = [];
|
|
|
|
|
|
|
|
// FIXME this could fail for a very long list of big files
|
|
|
|
|
|
|
|
setTimeout(500, function () {
|
|
|
|
|
|
|
|
this.openDir(this.root);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
moveSelectedFiles: function () {
|
|
|
|
moveSelectedFiles: function () {
|
|
|
|
var _this = this;
|
|
|
|
var _this = this;
|
|
|
|
var dest = this.destination;
|
|
|
|
var dest = this.destination;
|
|
|
|
$.each(this.selection, function () {
|
|
|
|
$.each(this.selection, function () {
|
|
|
|
|
|
|
|
var mfile = this;
|
|
|
|
var data = {};
|
|
|
|
var data = {};
|
|
|
|
data['id'] = _this.root ? _this.root + '/' + this : this;
|
|
|
|
data['id'] = _this.root ? _this.root + '/' + mfile : mfile;
|
|
|
|
data['to'] = dest;
|
|
|
|
data['to'] = dest;
|
|
|
|
console.log(data);
|
|
|
|
|
|
|
|
var request = $.ajax({
|
|
|
|
var request = $.ajax({
|
|
|
|
url: '/api/fsc/mvftd',
|
|
|
|
url: '/api/fsc/mvftd',
|
|
|
|
type: 'POST',
|
|
|
|
type: 'POST',
|
|
|
@ -133,20 +175,14 @@ if (typeof XMLHttpRequest === 'undefined') {
|
|
|
|
contentType: 'application/json;charset=utf-8'
|
|
|
|
contentType: 'application/json;charset=utf-8'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
request.done(function( msg ) {
|
|
|
|
request.done(function() {
|
|
|
|
$( "#log" ).html( msg );
|
|
|
|
_this.setFileAway(mfile);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
request.fail(function( jqXHR, textStatus, msg ) {
|
|
|
|
request.fail(function( jqXHR, textStatus, msg ) {
|
|
|
|
alert( 'Request failed: ' + textStatus );
|
|
|
|
alert( 'Failed to move : ' + mfile + ' : ' + textStatus );
|
|
|
|
$( '#log' ).html( msg );
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.selection = [];
|
|
|
|
|
|
|
|
// FIXME this could fail for a very long list of big files
|
|
|
|
|
|
|
|
setTimeout(500, function () {
|
|
|
|
|
|
|
|
this.openDir(this.root);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
askForRemoval: function () {
|
|
|
|
askForRemoval: function () {
|
|
|
|
this.flist.empty();
|
|
|
|
this.flist.empty();
|
|
|
@ -157,10 +193,10 @@ if (typeof XMLHttpRequest === 'undefined') {
|
|
|
|
this.rmDialog.modal({ show: true });
|
|
|
|
this.rmDialog.modal({ show: true });
|
|
|
|
},
|
|
|
|
},
|
|
|
|
askForMoving: function () {
|
|
|
|
askForMoving: function () {
|
|
|
|
this.flist.empty();
|
|
|
|
this.fmlist.empty();
|
|
|
|
var _this = this;
|
|
|
|
var _this = this;
|
|
|
|
$.each(this.selection, function () {
|
|
|
|
$.each(this.selection, function () {
|
|
|
|
_this.flist.append('<li>' + this + '</li>');
|
|
|
|
_this.fmlist.append('<li>' + this + '</li>');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.mvDialog.modal({ show: true });
|
|
|
|
this.mvDialog.modal({ show: true });
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -212,8 +248,8 @@ if (typeof XMLHttpRequest === 'undefined') {
|
|
|
|
mdCnt.append(mdHeader);
|
|
|
|
mdCnt.append(mdHeader);
|
|
|
|
var mdBody = $('<div class="modal-body"></div>');
|
|
|
|
var mdBody = $('<div class="modal-body"></div>');
|
|
|
|
mdBody.append('<p>You´re about to move these files :</p>');
|
|
|
|
mdBody.append('<p>You´re about to move these files :</p>');
|
|
|
|
this.flist = $('<ul></ul>');
|
|
|
|
this.fmlist = $('<ul></ul>');
|
|
|
|
mdBody.append(this.flist);
|
|
|
|
mdBody.append(this.fmlist);
|
|
|
|
var inputDest = $('<input type="text" class="form-control" hint="dest/dir">').on('change', function() { _this.onDestinationChanged(this); });
|
|
|
|
var inputDest = $('<input type="text" class="form-control" hint="dest/dir">').on('change', function() { _this.onDestinationChanged(this); });
|
|
|
|
this.rootDisplay = $('<p></p>');
|
|
|
|
this.rootDisplay = $('<p></p>');
|
|
|
|
this.rootDisplay.addClass('hidden');
|
|
|
|
this.rootDisplay.addClass('hidden');
|
|
|
@ -236,9 +272,11 @@ if (typeof XMLHttpRequest === 'undefined') {
|
|
|
|
_create: function () {
|
|
|
|
_create: function () {
|
|
|
|
var $view = this.element;
|
|
|
|
var $view = this.element;
|
|
|
|
var _this = this;
|
|
|
|
var _this = this;
|
|
|
|
this.dirBar = $('<div></div>');
|
|
|
|
this.curDirBar = $('<div class="curdir"></div>');
|
|
|
|
this.dirBar.appendTo($view);
|
|
|
|
this.curDirBar.appendTo($view);
|
|
|
|
this.ftable = $('<table border="1">')
|
|
|
|
this.subDirsBar = $('<div class="subdirs"></div>');
|
|
|
|
|
|
|
|
this.subDirsBar.appendTo($view);
|
|
|
|
|
|
|
|
this.ftable = $('<table>')
|
|
|
|
.css('border-spacing', '6px')
|
|
|
|
.css('border-spacing', '6px')
|
|
|
|
.css('border-collapse', 'separate');
|
|
|
|
.css('border-collapse', 'separate');
|
|
|
|
var btnRm = $('<button class="glyphicon"></button>').click(function () {
|
|
|
|
var btnRm = $('<button class="glyphicon"></button>').click(function () {
|
|
|
@ -251,7 +289,6 @@ if (typeof XMLHttpRequest === 'undefined') {
|
|
|
|
_this.ftable.append(tr);
|
|
|
|
_this.ftable.append(tr);
|
|
|
|
tr.append($('<th></th>').append(btnRm).append(btnMv)).append('<th>Nom</th><th>Taille</th><th>Modification</th>');
|
|
|
|
tr.append($('<th></th>').append(btnRm).append(btnMv)).append('<th>Nom</th><th>Taille</th><th>Modification</th>');
|
|
|
|
_this.ftable.appendTo($view);
|
|
|
|
_this.ftable.appendTo($view);
|
|
|
|
$('<div id="log">Logs<br/></div>').appendTo($view);
|
|
|
|
|
|
|
|
this.createRmDialog();
|
|
|
|
this.createRmDialog();
|
|
|
|
this.createMvDialog();
|
|
|
|
this.createMvDialog();
|
|
|
|
this.openDir($view.data('path'));
|
|
|
|
this.openDir($view.data('path'));
|
|
|
|