mirror of
https://github.com/myvesta/vesta
synced 2025-07-11 07:36:47 -07:00
File Manager stuff
This commit is contained in:
parent
cad14057cc
commit
55eb1ec16a
5 changed files with 131 additions and 12 deletions
40
bin/v-get-fs-file-type
Executable file
40
bin/v-get-fs-file-type
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
# info: get file type
|
||||
# options: USER FILE
|
||||
#
|
||||
# The function shows file type
|
||||
|
||||
user=$1
|
||||
path=$2
|
||||
|
||||
# Checking arguments
|
||||
if [ -z "$path" ]; then
|
||||
echo "Usage: USER FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking vesta user
|
||||
if [ ! -e "$VESTA/data/users/$user" ]; then
|
||||
echo "Error: vesta user $user doesn't exist"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Checking user homedir
|
||||
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
|
||||
if [ -z $homedir ]; then
|
||||
echo "Error: user home directory doesn't exist"
|
||||
exit 12
|
||||
fi
|
||||
|
||||
# Checking path
|
||||
rpath=$(readlink -f "$path")
|
||||
if [ -z "$(echo $rpath |grep $homedir)" ]; then
|
||||
echo "Error: invalid path $path"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Listing file type
|
||||
sudo -u $user file -i -b $path 2>/dev/null
|
||||
|
||||
# Exiting
|
||||
exit $?
|
|
@ -31,6 +31,11 @@ switch ($_REQUEST['action']) {
|
|||
$dir = $_REQUEST['dir'];
|
||||
print json_encode($fm->ls($dir));
|
||||
break;
|
||||
case 'check_file_type':
|
||||
$dir = $_REQUEST['dir'];
|
||||
|
||||
print json_encode($fm->checkFileType($dir));
|
||||
break;
|
||||
case 'rename_file':
|
||||
$dir = $_REQUEST['dir'];
|
||||
$item = $_REQUEST['item'];
|
||||
|
|
|
@ -42,6 +42,26 @@ class FileManager {
|
|||
);
|
||||
}*/
|
||||
|
||||
public function checkFileType($dir) {
|
||||
$dir = $this->formatFullPath($dir);
|
||||
|
||||
exec(VESTA_CMD . "v-delete-fs-file {$this->user} {$dir}", $output, $return_var);
|
||||
|
||||
$error = self::check_return_code($return_var, $output);
|
||||
|
||||
if (empty($error)) {
|
||||
return array(
|
||||
'result' => true
|
||||
);
|
||||
}
|
||||
else {
|
||||
return array(
|
||||
'result' => false,
|
||||
'message' => $error
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function formatFullPath($path_part = '') {
|
||||
if (substr($path_part, 0, strlen($this->ROOT_DIR)) === $this->ROOT_DIR) {
|
||||
$path = $path_part;
|
||||
|
|
|
@ -164,12 +164,26 @@ FM.setSecondInactive = function(index, box) {
|
|||
FM.BG_TAB = box;
|
||||
}
|
||||
|
||||
FM.goToTop = function() {
|
||||
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
||||
var index = 0;
|
||||
|
||||
FM.setActive(index, FM.CURRENT_TAB);
|
||||
}
|
||||
|
||||
FM.goToBottom = function() {
|
||||
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
||||
var index = $(FM.CURRENT_TAB).find('.dir').length - 1;
|
||||
|
||||
FM.setActive(index, FM.CURRENT_TAB);
|
||||
}
|
||||
|
||||
FM.goUp = function() {
|
||||
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
||||
var index = FM['CURRENT_' + tab + '_LINE'];
|
||||
index -= 1;
|
||||
if (index < 0) {
|
||||
index = $(FM.CURRENT_TAB).find('li').length - 1;
|
||||
index = $(FM.CURRENT_TAB).find('li.dir').length - 1;
|
||||
}
|
||||
|
||||
FM.setActive(index, FM.CURRENT_TAB);
|
||||
|
@ -179,7 +193,7 @@ FM.goDown = function() {
|
|||
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
||||
var index = FM['CURRENT_' + tab + '_LINE'];
|
||||
index += 1;
|
||||
if (index > ($(FM.CURRENT_TAB).find('li').length - 1)) {
|
||||
if (index > ($(FM.CURRENT_TAB).find('li.dir').length - 1)) {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
|
@ -196,6 +210,7 @@ FM.open = function(dir, box, callback) {
|
|||
'dir': dir
|
||||
};
|
||||
App.Ajax.request('cd', params, function(reply) {
|
||||
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
||||
FM.preselectedItems[tab] = [];
|
||||
if (reply.result == true) {
|
||||
var html = FM.generate_listing(reply.listing, box);
|
||||
|
@ -216,6 +231,9 @@ FM.open = function(dir, box, callback) {
|
|||
var url = '/list/directory/?dir_a='+path_a+'&dir_b='+path_b;
|
||||
history.pushState({}, null, url);
|
||||
|
||||
if (FM['CURRENT_' + tab + '_LINE'] == -1) {
|
||||
FM.setActive(0, FM.CURRENT_TAB);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -401,7 +419,7 @@ FM.openFile = function(dir, box, elm) {
|
|||
|
||||
var elm = $(elm).hasClass('dir') ? $(elm) : $(elm).closest('.dir');
|
||||
var src = $.parseJSON($(elm).find('.source').val());
|
||||
console.log(elm);
|
||||
|
||||
if (FM.isItemPseudo(src)) {
|
||||
FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], FM['TAB_' + tab]);
|
||||
}
|
||||
|
@ -587,7 +605,7 @@ FM.checkBulkStatus = function(bulkStatuses, acc) {
|
|||
}
|
||||
|
||||
if (status == true) {
|
||||
$('#popup .results').html(msg);
|
||||
$('#popup .results').html('Done');
|
||||
$('.controls p').replaceWith('<p class="ok" onClick="FM.bulkPopupClose();">close</p>');
|
||||
}
|
||||
else {
|
||||
|
@ -637,7 +655,7 @@ FM.bulkCopy = function() {
|
|||
var cfr_html = '';
|
||||
|
||||
$.each(acc, function(i, o) {
|
||||
var ref = $(o).parents('.dir');
|
||||
var ref = $(o);
|
||||
var src = $(ref).find('.source').val();
|
||||
src = $.parseJSON(src);
|
||||
|
||||
|
@ -654,7 +672,7 @@ FM.bulkCopy = function() {
|
|||
|
||||
var bulkStatuses = [];
|
||||
$.each(acc, function(i, o) {
|
||||
var ref = $(o).parents('.dir');
|
||||
var ref = $(o);
|
||||
var src = $(ref).find('.source').val();
|
||||
src = $.parseJSON(src);
|
||||
|
||||
|
@ -712,7 +730,7 @@ FM.bulkRemove = function() {
|
|||
var cfr_html = '';
|
||||
|
||||
$.each(acc, function(i, o) {
|
||||
var ref = $(o).parents('.dir');
|
||||
var ref = $(o);
|
||||
var src = $(ref).find('.source').val();
|
||||
src = $.parseJSON(src);
|
||||
|
||||
|
@ -729,7 +747,7 @@ FM.bulkRemove = function() {
|
|||
|
||||
var bulkStatuses = [];
|
||||
$.each(acc, function(i, o) {
|
||||
var ref = $(o).parents('.dir');
|
||||
var ref = $(o);
|
||||
var src = $(ref).find('.source').val();
|
||||
src = $.parseJSON(src);
|
||||
|
||||
|
@ -784,6 +802,10 @@ FM.toggleAllItemsSelected = function() {
|
|||
$(box).find('.dir').removeClass('selected');
|
||||
var index = FM['CURRENT_' + tab + '_LINE'];
|
||||
$(box).find('.dir:eq(' + index + ')').addClass('selected');
|
||||
|
||||
$(FM.preselectedItems[tab]).each(function(i, index) {
|
||||
$(box).find('.dir:eq(' + index + ')').addClass('selected');
|
||||
});
|
||||
}
|
||||
else {
|
||||
$(box).find('.dir').addClass('selected');
|
||||
|
@ -1010,6 +1032,10 @@ FM.setTabActive = function(box, action) {
|
|||
if (FM.CURRENT_TAB == FM.TAB_A) {
|
||||
$(FM.TAB_B).find('.selected').addClass('selected-inactive').removeClass('selected');
|
||||
$(FM.TAB_A).find('.selected-inactive').addClass('selected').removeClass('selected-inactive');
|
||||
|
||||
if ($(FM.TAB_A).find('.selected-inactive').length == 0 && $(FM.TAB_A).find('.selected').length == 0) {
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(FM.TAB_A).find('.selected').addClass('selected-inactive').removeClass('selected');
|
||||
|
@ -1277,7 +1303,7 @@ FM.confirmCopyItems = function () {
|
|||
App.Ajax.request(action, params, function(reply) {
|
||||
if (reply.result == true) {
|
||||
FM.popupClose();
|
||||
FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], FM['TAB_' + tab]);
|
||||
// FM.open(FM['TAB_' + tab + '_CURRENT_PATH'], FM['TAB_' + tab]);
|
||||
FM.open(FM['TAB_' + opposite_tab + '_CURRENT_PATH'], FM['TAB_' + opposite_tab]);
|
||||
}
|
||||
else {
|
||||
|
@ -1638,6 +1664,11 @@ $(document).ready(function() {
|
|||
|
||||
shortcut.add("Left",function() {
|
||||
FM.setTabActive(FM.TAB_A);
|
||||
|
||||
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
||||
if (FM['CURRENT_' + tab + '_LINE'] == -1) {
|
||||
FM.setActive(0, FM.CURRENT_TAB);
|
||||
}
|
||||
},{
|
||||
'type': 'keydown',
|
||||
'propagate': false,
|
||||
|
@ -1647,6 +1678,29 @@ $(document).ready(function() {
|
|||
|
||||
shortcut.add("Right",function() {
|
||||
FM.setTabActive(FM.TAB_B);
|
||||
|
||||
var tab = FM.getTabLetter(FM.CURRENT_TAB);
|
||||
if (FM['CURRENT_' + tab + '_LINE'] == -1) {
|
||||
FM.setActive(0, FM.CURRENT_TAB);
|
||||
}
|
||||
},{
|
||||
'type': 'keydown',
|
||||
'propagate': false,
|
||||
'disable_in_input': false,
|
||||
'target': document
|
||||
});
|
||||
|
||||
shortcut.add("Home",function() {
|
||||
FM.goToTop();
|
||||
},{
|
||||
'type': 'keydown',
|
||||
'propagate': false,
|
||||
'disable_in_input': false,
|
||||
'target': document
|
||||
});
|
||||
|
||||
shortcut.add("End",function() {
|
||||
FM.goToBottom();
|
||||
},{
|
||||
'type': 'keydown',
|
||||
'propagate': false,
|
||||
|
|
|
@ -24,9 +24,9 @@ App.Templates.html = {
|
|||
<span class="size-value">~!:SIZE_VALUE~!</span>\
|
||||
<span class="date">~!:DATE~!</span>\
|
||||
<span class="time">~!:TIME~!</span>\
|
||||
<span class="subcontext-control ~!:SUBMENU_CLASS~!" onClick="FM.toggleSubContextMenu(this)">••• \
|
||||
<!-- span class="subcontext-control ~!:SUBMENU_CLASS~!" onClick="FM.toggleSubContextMenu(this)">••• \
|
||||
<ul class="subcontext-menu subcontext-menu-hidden"><li onClick="FM.downloadFileFromSubcontext(this);">Download</li><li onClick="FM.editFileFromSubcontext(this);">Edit</li></ul>\
|
||||
</span>\
|
||||
</span -->\
|
||||
</li>'],
|
||||
popup_alert: ['<div class="confirm-box alarm popup-box">\
|
||||
<div class="message">~!:TEXT~!</div>\
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue