2019-01-20 19:37:45 +01:00
|
|
|
/* This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
|
|
|
|
* Copyright (C) 2018 OzzieIsaacs
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-06-06 21:21:10 +02:00
|
|
|
/* exported TableActions, RestrictionActions, EbookActions*/
|
2019-07-13 20:45:48 +02:00
|
|
|
|
2018-08-28 09:42:19 +02:00
|
|
|
$(function() {
|
|
|
|
|
2020-06-06 21:21:10 +02:00
|
|
|
$("#books-table").bootstrapTable({
|
|
|
|
formatNoMatches: function () {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-12-29 13:54:52 +01:00
|
|
|
$("#domain_allow_submit").click(function(event) {
|
2018-08-28 09:42:19 +02:00
|
|
|
event.preventDefault();
|
2019-12-29 13:54:52 +01:00
|
|
|
$("#domain_add_allow").ajaxForm();
|
2018-08-28 09:42:19 +02:00
|
|
|
$(this).closest("form").submit();
|
2019-07-13 20:45:48 +02:00
|
|
|
$.ajax ({
|
2018-08-28 09:42:19 +02:00
|
|
|
method:"get",
|
2019-12-29 13:54:52 +01:00
|
|
|
url: window.location.pathname + "/../../ajax/domainlist/1",
|
2018-08-28 09:42:19 +02:00
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
2019-07-13 20:45:48 +02:00
|
|
|
success:function(data) {
|
2019-12-29 13:54:52 +01:00
|
|
|
$("#domain-allow-table").bootstrapTable("load", data);
|
2018-08-28 09:42:19 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2019-12-29 13:54:52 +01:00
|
|
|
$("#domain-allow-table").bootstrapTable({
|
|
|
|
formatNoMatches: function () {
|
|
|
|
return "";
|
|
|
|
},
|
|
|
|
striped: false
|
|
|
|
});
|
|
|
|
$("#domain_deny_submit").click(function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
$("#domain_add_deny").ajaxForm();
|
|
|
|
$(this).closest("form").submit();
|
|
|
|
$.ajax ({
|
|
|
|
method:"get",
|
|
|
|
url: window.location.pathname + "/../../ajax/domainlist/0",
|
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
|
|
|
success:function(data) {
|
|
|
|
$("#domain-deny-table").bootstrapTable("load", data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$("#domain-deny-table").bootstrapTable({
|
2019-01-08 07:58:22 +01:00
|
|
|
formatNoMatches: function () {
|
|
|
|
return "";
|
2019-03-05 16:31:09 +01:00
|
|
|
},
|
|
|
|
striped: false
|
2018-08-28 09:42:19 +02:00
|
|
|
});
|
|
|
|
$("#btndeletedomain").click(function() {
|
|
|
|
//get data-id attribute of the clicked element
|
2019-01-08 07:58:22 +01:00
|
|
|
var domainId = $(this).data("domainId");
|
2018-08-28 09:42:19 +02:00
|
|
|
$.ajax({
|
|
|
|
method:"post",
|
|
|
|
url: window.location.pathname + "/../../ajax/deletedomain",
|
|
|
|
data: {"domainid":domainId}
|
|
|
|
});
|
2019-01-08 07:58:22 +01:00
|
|
|
$("#DeleteDomain").modal("hide");
|
2018-08-28 09:42:19 +02:00
|
|
|
$.ajax({
|
|
|
|
method:"get",
|
2019-12-29 13:54:52 +01:00
|
|
|
url: window.location.pathname + "/../../ajax/domainlist/1",
|
2018-08-28 09:42:19 +02:00
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
2019-03-05 16:31:09 +01:00
|
|
|
success:function(data) {
|
2019-12-29 13:54:52 +01:00
|
|
|
$("#domain-allow-table").bootstrapTable("load", data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.ajax({
|
|
|
|
method:"get",
|
|
|
|
url: window.location.pathname + "/../../ajax/domainlist/0",
|
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
|
|
|
success:function(data) {
|
|
|
|
$("#domain-deny-table").bootstrapTable("load", data);
|
2018-08-28 09:42:19 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
//triggered when modal is about to be shown
|
2019-01-15 20:08:47 +01:00
|
|
|
$("#DeleteDomain").on("show.bs.modal", function(e) {
|
2018-08-28 09:42:19 +02:00
|
|
|
//get data-id attribute of the clicked element and store in button
|
2019-01-08 07:58:22 +01:00
|
|
|
var domainId = $(e.relatedTarget).data("domain-id");
|
|
|
|
$(e.currentTarget).find("#btndeletedomain").data("domainId", domainId);
|
2018-08-28 09:42:19 +02:00
|
|
|
});
|
2020-01-01 17:26:47 +01:00
|
|
|
|
2020-06-08 17:34:03 +02:00
|
|
|
$("#delete_confirm").click(function() {
|
|
|
|
//get data-id attribute of the clicked element
|
|
|
|
var deleteId = $(this).data("deleteid");
|
|
|
|
$.ajax({
|
|
|
|
method:"get",
|
|
|
|
url: window.location.pathname + "/../../delete"/+deleteId,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
//triggered when modal is about to be shown
|
|
|
|
$("#deleteModal").on("show.bs.modal", function(e) {
|
|
|
|
//get data-id attribute of the clicked element and store in button
|
|
|
|
var bookId = $(e.relatedTarget).data("delete-id");
|
|
|
|
$(e.currentTarget).find("#delete_confirm").data("deleteid", bookId);
|
|
|
|
});
|
|
|
|
// receive result from request, dismiss modal dialog, show flash message
|
|
|
|
// insert after navbar
|
|
|
|
/*$("#deleteModal").on("hidden.bs.modal", function () {
|
|
|
|
<div class="row-fluid text-center" style="margin-top: -20px;">
|
|
|
|
<div id="flash_success" class="alert alert-success">{{ message[1] }}</div>
|
|
|
|
</div>*/
|
|
|
|
|
|
|
|
// to save current setting
|
|
|
|
// coresponding event: onColumnSwitch
|
|
|
|
//$table.bootstrapTable('getVisibleColumns')
|
|
|
|
//$table.bootstrapTable('getHiddenColumns').
|
|
|
|
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#restrictModal").on("hidden.bs.modal", function () {
|
2020-01-05 16:43:48 +01:00
|
|
|
// Destroy table and remove hooks for buttons
|
|
|
|
$("#restrict-elements-table").unbind();
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#restrict-elements-table").bootstrapTable("destroy");
|
2020-01-05 16:43:48 +01:00
|
|
|
$("[id^=submit_]").unbind();
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#h1").addClass("hidden");
|
|
|
|
$("#h2").addClass("hidden");
|
|
|
|
$("#h3").addClass("hidden");
|
|
|
|
$("#h4").addClass("hidden");
|
2020-01-01 17:26:47 +01:00
|
|
|
});
|
2020-03-29 16:22:11 +02:00
|
|
|
function startTable(type) {
|
|
|
|
var pathname = document.getElementsByTagName("script"), src = pathname[pathname.length - 1].src;
|
|
|
|
var path = src.substring(0, src.lastIndexOf("/"));
|
2020-01-01 17:26:47 +01:00
|
|
|
$("#restrict-elements-table").bootstrapTable({
|
|
|
|
formatNoMatches: function () {
|
|
|
|
return "";
|
|
|
|
},
|
2020-01-05 16:43:48 +01:00
|
|
|
url: path + "/../../ajax/listrestriction/" + type,
|
2020-04-27 20:01:13 +02:00
|
|
|
rowStyle: function(row) {
|
2020-03-29 16:22:11 +02:00
|
|
|
// console.log('Reihe :' + row + " Index :" + index);
|
|
|
|
if (row.id.charAt(0) === "a") {
|
|
|
|
return {classes: "bg-primary"};
|
|
|
|
} else {
|
|
|
|
return {classes: "bg-dark-danger"};
|
2020-01-05 16:43:48 +01:00
|
|
|
}
|
|
|
|
},
|
2020-04-27 20:01:13 +02:00
|
|
|
onClickCell: function (field, value, row) {
|
|
|
|
if (field === 3) {
|
2020-01-01 17:26:47 +01:00
|
|
|
$.ajax ({
|
2020-03-29 16:22:11 +02:00
|
|
|
type: "Post",
|
2020-05-11 18:41:16 +02:00
|
|
|
data: "id=" + row.id + "&type=" + row.type + "&Element=" + encodeURIComponent(row.Element),
|
2020-01-05 16:43:48 +01:00
|
|
|
url: path + "/../../ajax/deleterestriction/" + type,
|
2020-01-01 17:26:47 +01:00
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
2020-04-27 20:01:13 +02:00
|
|
|
success:function() {
|
2020-01-01 17:26:47 +01:00
|
|
|
$.ajax({
|
|
|
|
method:"get",
|
2020-03-29 16:22:11 +02:00
|
|
|
url: path + "/../../ajax/listrestriction/" + type,
|
2020-01-01 17:26:47 +01:00
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
|
|
|
success:function(data) {
|
|
|
|
$("#restrict-elements-table").bootstrapTable("load", data);
|
|
|
|
}
|
|
|
|
});
|
2020-01-05 16:43:48 +01:00
|
|
|
}
|
|
|
|
});
|
2020-01-01 17:26:47 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
striped: false
|
|
|
|
});
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#restrict-elements-table").removeClass("table-hover");
|
2020-04-27 20:01:13 +02:00
|
|
|
$("#restrict-elements-table").on("editable-save.bs.table", function (e, field, row) {
|
2020-01-05 16:43:48 +01:00
|
|
|
$.ajax({
|
2020-03-29 16:22:11 +02:00
|
|
|
url: path + "/../../ajax/editrestriction/" + type,
|
|
|
|
type: "Post",
|
2020-04-24 21:05:56 +02:00
|
|
|
data: row
|
2020-01-05 16:43:48 +01:00
|
|
|
});
|
|
|
|
});
|
2020-04-27 20:01:13 +02:00
|
|
|
$("[id^=submit_]").click(function() {
|
2020-01-05 16:43:48 +01:00
|
|
|
$(this)[0].blur();
|
2020-01-01 17:26:47 +01:00
|
|
|
$.ajax({
|
2020-03-29 16:22:11 +02:00
|
|
|
url: path + "/../../ajax/addrestriction/" + type,
|
|
|
|
type: "Post",
|
2020-01-01 17:26:47 +01:00
|
|
|
data: $(this).closest("form").serialize() + "&" + $(this)[0].name + "=",
|
|
|
|
success: function () {
|
2020-03-29 16:22:11 +02:00
|
|
|
$.ajax ({
|
|
|
|
method:"get",
|
|
|
|
url: path + "/../../ajax/listrestriction/" + type,
|
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
|
|
|
success:function(data) {
|
|
|
|
$("#restrict-elements-table").bootstrapTable("load", data);
|
|
|
|
}
|
2020-01-01 17:26:47 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
});
|
|
|
|
}
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#get_column_values").on("click", function() {
|
2020-01-01 17:26:47 +01:00
|
|
|
startTable(1);
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#h2").removeClass("hidden");
|
2020-01-01 17:26:47 +01:00
|
|
|
});
|
|
|
|
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#get_tags").on("click", function() {
|
2020-01-01 17:26:47 +01:00
|
|
|
startTable(0);
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#h1").removeClass("hidden");
|
2020-01-05 16:43:48 +01:00
|
|
|
});
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#get_user_column_values").on("click", function() {
|
2020-01-05 16:43:48 +01:00
|
|
|
startTable(3);
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#h4").removeClass("hidden");
|
2020-01-01 17:26:47 +01:00
|
|
|
});
|
2020-01-05 16:43:48 +01:00
|
|
|
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#get_user_tags").on("click", function() {
|
2020-01-05 16:43:48 +01:00
|
|
|
startTable(2);
|
|
|
|
$(this)[0].blur();
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#h3").removeClass("hidden");
|
2020-01-05 16:43:48 +01:00
|
|
|
});
|
|
|
|
|
2018-08-28 09:42:19 +02:00
|
|
|
});
|
|
|
|
|
2019-04-14 14:08:49 +02:00
|
|
|
/* Function for deleting domain restrictions */
|
2020-04-27 20:01:13 +02:00
|
|
|
function TableActions (value, row) {
|
2018-08-28 09:42:19 +02:00
|
|
|
return [
|
2019-01-08 07:58:22 +01:00
|
|
|
"<a class=\"danger remove\" data-toggle=\"modal\" data-target=\"#DeleteDomain\" data-domain-id=\"" + row.id
|
|
|
|
+ "\" title=\"Remove\">",
|
|
|
|
"<i class=\"glyphicon glyphicon-trash\"></i>",
|
|
|
|
"</a>"
|
|
|
|
].join("");
|
2019-04-14 14:08:49 +02:00
|
|
|
}
|
2020-01-01 17:26:47 +01:00
|
|
|
|
|
|
|
/* Function for deleting domain restrictions */
|
2020-04-27 20:01:13 +02:00
|
|
|
function RestrictionActions (value, row) {
|
2020-01-01 17:26:47 +01:00
|
|
|
return [
|
|
|
|
"<div class=\"danger remove\" data-restriction-id=\"" + row.id + "\" title=\"Remove\">",
|
|
|
|
"<i class=\"glyphicon glyphicon-trash\"></i>",
|
|
|
|
"</div>"
|
|
|
|
].join("");
|
|
|
|
}
|
2020-06-06 21:21:10 +02:00
|
|
|
|
|
|
|
/* Function for deleting books */
|
|
|
|
function EbookActions (value, row) {
|
|
|
|
return [
|
2020-06-09 20:46:02 +02:00
|
|
|
"<div class=\"danger remove\" data-toggle=\"modal\" data-target=\"#deleteModal\" data-delete-id=\"" + row.id + "\" title=\"Remove\">",
|
2020-06-06 21:21:10 +02:00
|
|
|
"<i class=\"glyphicon glyphicon-trash\"></i>",
|
|
|
|
"</div>"
|
|
|
|
].join("");
|
|
|
|
}
|