media Datenbank

This commit is contained in:
Kevin Adametz 2019-11-14 20:29:01 +01:00
parent 70704be1ea
commit c11fc557bf
73 changed files with 2241 additions and 9655 deletions

View file

@ -166,12 +166,16 @@ function toggleActions() {
rename(item);
});
$('a[data-action=item_move]').on('click', function () {
$('a[data-action=item_move]').on('click', function (e) {
var items = [];
items.push(getOneSelectedElement($(this).parents('.file-item').data('id')));
move(items);
});
$('a[data-action=item_color]').on('click', function (e) {
item = getOneSelectedElement($(this).parents('.file-item').data('id'));
colors(item);
});
$('a[data-action=item_trash]').on('click', function () {
var items = [];
@ -236,8 +240,10 @@ function toggleActions() {
function goTo(new_dir) {
$('#working_dir').val(new_dir);
loadItems();
if(!$('.dropdown-menu').hasClass('show')){
$('#working_dir').val(new_dir);
loadItems();
}
}
function getPreviousDir() {
@ -256,7 +262,11 @@ function performLfmRequest(url, parameter, type) {
$.each(parameter, function (key, value) {
data[key] = value;
});
}return $.ajax({
}
// console.log(lfm_route + '/' + url);
// console.log(type);
// console.log(data);
return $.ajax({
type: 'GET',
beforeSend: function(request) {
var token = getUrlParam('token');
@ -269,7 +279,7 @@ function performLfmRequest(url, parameter, type) {
data: data,
cache: false
}).done(function (data) {
console.log(data);
// console.log(data);
/* if(data !== "OK"){
var response = JSON.parse(data);
console.log("done");
@ -289,6 +299,7 @@ function performLfmRequest(url, parameter, type) {
console.log(textStatus);
console.log(errorThrown);
displayErrorResponse(jqXHR);
refreshFoldersAndItems();
});
}
@ -341,7 +352,7 @@ function loadItems() {
loading(true);
performLfmRequest('jsonitems', {show_list: lfm_show_list, sort_type: lfm_sort_type}, 'html')
.done(function (data) {
//console.log(data);
console.log(data);
lfm_selected = [];
var response = JSON.parse(data);
var working_dir = response.working_dir;
@ -364,6 +375,7 @@ function loadItems() {
.attr('data-id', index)
//.click(toggleSelected)
.click(function (e) {
console.log($(e.target));
if(!$(e.target).hasClass('lfm-click-disable') && !$(e.target).hasClass('dropdown-item')){
if (item.is_file) {
if($(e.target).hasClass('file-item-img') || $(e.target).hasClass('file-item-icon')){
@ -395,7 +407,11 @@ function loadItems() {
if (item.thumb_url) {
var image = $('<div>').addClass('file-item-img').css('background-image', 'url("' + item.thumb_url + '?timestamp=' + item.time + '")');
} else {
var image = $('<div>').addClass('file-item-icon text-secondary fa ' + item.icon);
var image = $('<div>').addClass('file-item-icon fa ' + item.icon).css({"color":item.color});
}
if(!item.is_file){
template.find('.link-item-download').remove();
}
template.find('.file-item-name').before(image);
template.find('.file-item-name').text(item.name);
@ -472,6 +488,15 @@ function rename(item) {
});
}
function colors(item) {
colorshue(lang['message-color'], item.color, function (color) {
performLfmRequest('colorshue', {
file: item.name,
new_color: color
}).done(refreshFoldersAndItems);
});
}
function trash(items) {
notify(lang['message-delete'], function () {
var d = performLfmRequest('delete', {
@ -530,7 +555,14 @@ function preview(item) {
var media = $('#previewTemplate').clone().attr('id', 'previewMedia').removeClass('d-none');
media.find('.media-preview').attr('src', item.url + '?timestamp=' + item.time);
if(item.icon == "fa-image" || item.icon == "fa-file-pdf"){
media.find('.media-preview').attr('src', item.url + '?timestamp=' + item.time).removeClass('d-none');
}else{
var icon = $('<div>').addClass('file-item-icon fa ' + item.icon).css('color', item.color);
media.find('.file-manager-col-view').html(icon).removeClass('d-none');
}
media.find('.media-name').html(item.name);
media.find('.media-url').val(item.url);
media.find('.media-download').attr('target', '_blank').attr('href', item.url);
@ -759,8 +791,35 @@ function dialog(title, value, callback) {
$('#dialog').on('shown.bs.modal', function () {
$('#dialog').find('input').focus();
});
$('#dialog').find('.btn-primary').unbind().click(function (e) {
$('#dialog').find('.btn-primary').unbind('click').click(function (e) {
callback($('#dialog').find('input').val());
});
$('#dialog').find('input').unbind('keypress.key13').bind('keypress.key13', function (e) {
if (e.which === 13) {
$('#dialog').find('.btn-primary').click();
}
});
$('#dialog').modal('show').find('.modal-title').text(title);
}
function colorshue(title, color, callback) {
console.log(color);
$('#minicolors-hue').minicolors('value', color);
$('#colorhue').on('shown.bs.modal', function () {
//$('#colorhue').find('input').focus();
});
$('#colorhue').find('.btn-primary').unbind('click').click(function (e) {
callback($('#colorhue').find('input').val());
});
$('#colorhue').find('input').unbind('keypress.key13').bind('keypress.key13', function (e) {
if (e.which === 13) {
$('#colorhue').find('.btn-primary').click();
}
});
$('#colorhue').modal('show').find('.modal-title').text(title);
}
$('#minicolors-hue').minicolors({
control: 'hue',
position: 'bottom ' + 'left',
});