Ent 5432 libreria de modulos de pandora integrada en consola
|
@ -313,6 +313,8 @@ if (check_acl($config['id_user'], 0, 'PM')) {
|
|||
$sub2['godmode/setup/setup&section=integria']['text'] = __('Integria IMS');
|
||||
$sub2['godmode/setup/setup&section=integria']['refr'] = 0;
|
||||
|
||||
enterprise_hook('module_library_submenu');
|
||||
|
||||
$sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications');
|
||||
$sub2['godmode/setup/setup&section=notifications']['refr'] = 0;
|
||||
|
||||
|
@ -498,6 +500,21 @@ if (check_acl($config['id_user'], 0, 'PM') && $config['enable_update_manager'])
|
|||
$menu_godmode['messages']['sub'] = $sub;
|
||||
}
|
||||
|
||||
// Module library.
|
||||
if (check_acl($config['id_user'], 0, 'AR')) {
|
||||
$menu_godmode['gmodule_library']['text'] = __('Module library');
|
||||
$menu_godmode['gmodule_library']['sec2'] = 'godmode/module_library/module_library_view';
|
||||
$menu_godmode['gmodule_library']['id'] = 'god-module_library';
|
||||
|
||||
$sub = [];
|
||||
$sub['godmode/module_library/module_library_view']['text'] = __('View');
|
||||
$sub['godmode/module_library/module_library_view']['id'] = 'View';
|
||||
|
||||
$sub['godmode/module_library/module_library_view&tab=categories']['text'] = __('Categories');
|
||||
$sub['godmode/module_library/module_library_view&tab=categories']['id'] = 'categories';
|
||||
|
||||
$menu_godmode['gmodule_library']['sub'] = $sub;
|
||||
}
|
||||
|
||||
if (!$config['pure']) {
|
||||
menu_print_menu($menu_godmode);
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
/**
|
||||
* Module library view.
|
||||
*
|
||||
* @category Module library
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2020 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* 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 for version 2.
|
||||
* 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'AR')) {
|
||||
// Doesn't have access to this page.
|
||||
db_pandora_audit('ACL Violation', 'Trying to access Module Library View');
|
||||
include 'general/noaccess.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// Header.
|
||||
if (check_acl($config['id_user'], 0, 'PM') && enterprise_installed()) {
|
||||
$buttons['setup'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=general&sec2=godmode/setup/setup&section=module_library">'.html_print_image('images/gm_setup.png', true, ['title' => __('Setup')]).'</a>',
|
||||
];
|
||||
}
|
||||
|
||||
$buttons['categories'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=categories">'.html_print_image('images/list.png', true, ['title' => __('Categories')]).'</a>',
|
||||
];
|
||||
|
||||
$buttons['view'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view">'.html_print_image('images/operation.png', true, ['title' => __('View')]).'</a>',
|
||||
];
|
||||
|
||||
|
||||
$tab = get_parameter('tab', 'view');
|
||||
if ($tab != 'search_module') {
|
||||
$buttons[$tab]['active'] = true;
|
||||
}
|
||||
|
||||
ui_print_page_header(__('Module Library').' » '.__('View'), '', false, 'module_library', true, $buttons);
|
||||
|
||||
|
||||
// Styles.
|
||||
ui_require_css_file('module_library');
|
||||
|
||||
|
||||
// Get params.
|
||||
$page = get_parameter('page', '1');
|
||||
$search = get_parameter('search', '');
|
||||
$id_cat = get_parameter('id_cat', '');
|
||||
|
||||
// Show error messages.
|
||||
echo '<div id="show_errors_library"></div>';
|
||||
|
||||
echo '<div id="module_library_main">';
|
||||
|
||||
$sidebar_library = '
|
||||
<div class="sidebar_library">
|
||||
<h3>'.__('Search').'</h3>
|
||||
<input id="search_module" name="search_module" placeholder="Search module" type="text" class="search_input"/>
|
||||
<h3>'.__('Categories').'</h3>
|
||||
<div id="categories_sidebar"><ul></ul></div>
|
||||
</div>
|
||||
';
|
||||
|
||||
switch ($tab) {
|
||||
case 'search_module':
|
||||
echo '<div class="content_library">';
|
||||
echo '<div id="search_title_result"><h2>'.__('Search').': </h2></div>';
|
||||
echo '<div id="search_result" class="result_string-'.$search.'"></div>';
|
||||
echo '<div id="pagination_library" class="page-'.$page.'"></div>';
|
||||
echo '<div id="modal_library"></div>';
|
||||
echo '</div>';
|
||||
echo $sidebar_library;
|
||||
break;
|
||||
|
||||
case 'categories':
|
||||
if ($id_cat != '') {
|
||||
echo '<div class="content_library">';
|
||||
echo '<div id="category_title_result"><h2>'.__('Category').': </h2></div>';
|
||||
echo '<div id="category_result" class="result_category-'.$id_cat.'"></div>';
|
||||
echo '<div id="pagination_library" class="page-'.$page.'"></div>';
|
||||
echo '<div id="modal_library"></div>';
|
||||
echo '</div>';
|
||||
echo $sidebar_library;
|
||||
} else {
|
||||
echo '<div id="categories_library">';
|
||||
echo '</div>';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
echo '<div id="library_main">';
|
||||
echo '<span></span>';
|
||||
echo '<p></p>';
|
||||
echo '<div id="library_main_content">';
|
||||
// Show 9 categories.
|
||||
for ($i = 1; $i <= 9; $i++) {
|
||||
echo '<div class="library_main_category"></div>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
echo '<button name="view_all" class="sub next">
|
||||
<a href="index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=categories">'.__('View all categories').'</a>
|
||||
</button>';
|
||||
echo '</div>';
|
||||
echo $sidebar_library;
|
||||
break;
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
?>
|
||||
<script>
|
||||
var more_details = '<?php echo __('More details'); ?>';
|
||||
var total_modules_text = '<?php echo __('Total modules'); ?>';
|
||||
var view_web = '<?php echo __('View in Module Library'); ?>';
|
||||
var empty_result = '<?php echo __('No module found'); ?>';
|
||||
var error_get_token = '<?php echo __('Problem with authentication. Check your internet connection'); ?>';
|
||||
var invalid_user = '<?php echo __('Invalid username or password'); ?>';
|
||||
var error_main = '<?php echo __('Error loading Module Library'); ?>';
|
||||
var error_category = '<?php echo __('Error loading category'); ?>';
|
||||
var error_categories = '<?php echo __('Error loading categories'); ?>';
|
||||
var error_no_category = '<?php echo __('There is no such category'); ?>';
|
||||
var error_search = '<?php echo __('Error loading results'); ?>';
|
||||
var token = null;
|
||||
</script>
|
||||
|
||||
<?php
|
||||
if (check_acl($config['id_user'], 0, 'AW') && enterprise_installed()) {
|
||||
enterprise_include_once('include/functions_module_library.php');
|
||||
}
|
||||
|
||||
ui_require_javascript_file('module_library');
|
||||
|
|
@ -127,6 +127,13 @@ $buttons['ehorus'] = [
|
|||
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup§ion=ehorus').'">'.html_print_image('images/ehorus/ehorus.png', true, ['title' => __('eHorus')]).'</a>',
|
||||
];
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'PM') && enterprise_installed()) {
|
||||
$buttons['module_library'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup§ion=module_library').'">'.html_print_image('images/library.png', true, ['title' => __('Module Library')]).'</a>',
|
||||
];
|
||||
}
|
||||
|
||||
// FIXME: Not definitive icon
|
||||
$buttons['notifications'] = [
|
||||
'active' => false,
|
||||
|
@ -190,6 +197,12 @@ switch ($section) {
|
|||
$help_header = 'setup_integria_tab';
|
||||
break;
|
||||
|
||||
case 'module_library':
|
||||
$buttons['module_library']['active'] = true;
|
||||
$subpage = ' » '.__('Module Library');
|
||||
$help_header = 'setup_module_library_tab';
|
||||
break;
|
||||
|
||||
case 'gis':
|
||||
$buttons['gis']['active'] = true;
|
||||
$subpage = ' » '.__('Map conections GIS');
|
||||
|
|
After Width: | Height: | Size: 362 B |
After Width: | Height: | Size: 337 B |
After Width: | Height: | Size: 349 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 876 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.5 KiB |
|
@ -4999,6 +4999,14 @@ function get_help_info($section_name)
|
|||
}
|
||||
break;
|
||||
|
||||
case 'setup_module_library_tab':
|
||||
if ($es) {
|
||||
$result .= 'Configuracion_Consola&printable=yes#Librer.C3.ADa_de_m.C3.B3dulos';
|
||||
} else {
|
||||
$result .= 'Console_Setup&printable=yes#Module_library';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'diagnostic_tool_tab':
|
||||
if ($es) {
|
||||
$result .= 'Gestion_y_Administracion&printable=yes#Diagnostic_tool';
|
||||
|
@ -5127,6 +5135,14 @@ function get_help_info($section_name)
|
|||
}
|
||||
break;
|
||||
|
||||
case 'module_library':
|
||||
if ($es) {
|
||||
$result .= 'Intro_Monitorizacion&printable=yes#Librer.C3.ADa_de_m.C3.B3dulos';
|
||||
} else {
|
||||
$result .= 'Intro_Monitoring&printable=yes#Module_library';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'agent_snmp_explorer_tab':
|
||||
if ($es) {
|
||||
$result .= 'Monitorizacion_remota&printable=yes#Wizard_SNMP';
|
||||
|
|
|
@ -1587,6 +1587,18 @@ function config_update_config()
|
|||
}
|
||||
break;
|
||||
|
||||
case 'module_library':
|
||||
$module_library_user = get_parameter('module_library_user');
|
||||
if ($module_library_user == '' || !config_update_value('module_library_user', $module_library_user)) {
|
||||
$error_update[] = __('User');
|
||||
}
|
||||
|
||||
$module_library_password = get_parameter('module_library_password');
|
||||
if ($module_library_password == '' || !config_update_value('module_library_password', $module_library_password)) {
|
||||
$error_update[] = __('Password');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
|
@ -3025,6 +3037,15 @@ function config_process_config()
|
|||
config_update_value('integria_hostname', '');
|
||||
}
|
||||
|
||||
// Module Library.
|
||||
if (!isset($config['module_library_user'])) {
|
||||
config_update_value('module_library_user', '');
|
||||
}
|
||||
|
||||
if (!isset($config['module_library_password'])) {
|
||||
config_update_value('module_library_password', '');
|
||||
}
|
||||
|
||||
// Finally, check if any value was overwritten in a form.
|
||||
config_update_config();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,514 @@
|
|||
/*
|
||||
Variables from PHP:
|
||||
- token
|
||||
- more_details
|
||||
- total_modules_text
|
||||
- view_web
|
||||
- empty_result
|
||||
- error_get_token
|
||||
- invalid_user
|
||||
- error_main
|
||||
- error_category
|
||||
- error_categories
|
||||
- error_no_category
|
||||
- error_search
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
// Save categories in sessionStorage to avoid making the request to the API many times.
|
||||
function set_local_categories() {
|
||||
var local_categories_exist = sessionStorage.getItem("categories");
|
||||
|
||||
if (local_categories_exist === null) {
|
||||
get_all_categories();
|
||||
} else {
|
||||
// Categories view.
|
||||
var local_categories = JSON.parse(atob(local_categories_exist));
|
||||
if ($("#categories_library").length) {
|
||||
var local_cat = "";
|
||||
$.each(local_categories, function(index, value) {
|
||||
if (value.count != 0) {
|
||||
local_cat +=
|
||||
'<div class="card card_category"><a href="index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=categories&id_cat=' +
|
||||
value.id +
|
||||
'">' +
|
||||
value.name +
|
||||
" (" +
|
||||
value.count +
|
||||
")</<span></div>";
|
||||
}
|
||||
});
|
||||
$("#categories_library").append(local_cat);
|
||||
}
|
||||
|
||||
// Sidebar.
|
||||
if (
|
||||
$("#categories_sidebar").length &&
|
||||
$("#categories_sidebar ul li").length < 1
|
||||
) {
|
||||
var first_level = "";
|
||||
var second_level = "";
|
||||
var parents = [];
|
||||
var children = [];
|
||||
|
||||
$.each(local_categories, function(index, value) {
|
||||
// First level list - parents.
|
||||
if (value.parent == 0 && value.count != 0) {
|
||||
first_level +=
|
||||
'<li><a href="index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=categories&id_cat=' +
|
||||
value.id +
|
||||
'">' +
|
||||
value.name +
|
||||
" (" +
|
||||
value.count +
|
||||
')</a><span id="parent-' +
|
||||
value.id +
|
||||
'"></span></li>';
|
||||
|
||||
parents.push(value.id);
|
||||
} else {
|
||||
children.push(value);
|
||||
}
|
||||
});
|
||||
$("#categories_sidebar ul").append(first_level);
|
||||
|
||||
// Second level list - children.
|
||||
$.each(parents, function(index, id_parent) {
|
||||
$.each(children, function(i, v) {
|
||||
if (id_parent == v.parent && v.count != 0) {
|
||||
second_level += "<li>"; //'<li id="child-' + v.id + '" class="parent-' + v.parent + '">';
|
||||
second_level +=
|
||||
'<a href="index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=categories&id_cat=' +
|
||||
v.id +
|
||||
'">';
|
||||
second_level += v.name + " (" + v.count + ")";
|
||||
second_level += "</a>";
|
||||
second_level += "</li>";
|
||||
}
|
||||
});
|
||||
$("#categories_sidebar span#parent-" + id_parent).append(
|
||||
'<ul class="categories_sidebar_children">' + second_level + "</ul>"
|
||||
);
|
||||
second_level = "";
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Call first time.
|
||||
set_local_categories();
|
||||
|
||||
// Get all categories from Module library.
|
||||
function get_all_categories() {
|
||||
$.ajax({
|
||||
url:
|
||||
"https://pandorafms.com/library/wp-json/wp/v2/categories?per_page=100",
|
||||
type: "GET",
|
||||
crossDomain: true,
|
||||
contentType: "application/json",
|
||||
success: function(data) {
|
||||
sessionStorage.setItem("categories", btoa(JSON.stringify(data)));
|
||||
set_local_categories();
|
||||
},
|
||||
error: function(error) {
|
||||
if ($("#categories_library").length) {
|
||||
show_error_msg("#categories_library", error_categories);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Posts returned from the search / Get all posts from a category.
|
||||
function get_modules(search_modules, page, selector) {
|
||||
// Pagination.
|
||||
if (!page) {
|
||||
page = 1;
|
||||
}
|
||||
|
||||
var api_url = "";
|
||||
if (selector == "search") {
|
||||
api_url = "https://pandorafms.com/library/wp-json/wp/v2/posts?search=";
|
||||
} else if (selector == "category") {
|
||||
api_url =
|
||||
"https://pandorafms.com/library/wp-json/wp/v2/posts/?categories=";
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url:
|
||||
api_url + search_modules + "&orderby=modified&per_page=9&page=" + page,
|
||||
type: "GET",
|
||||
crossDomain: true,
|
||||
contentType: "application/json",
|
||||
beforeSend: function(xhr) {
|
||||
if (token !== null) {
|
||||
xhr.setRequestHeader("Authorization", "Bearer " + token);
|
||||
}
|
||||
$("#" + selector + "_result").addClass("loading_posts");
|
||||
},
|
||||
success: function(response, textStatus, jqXHR) {
|
||||
var total_pages = parseInt(
|
||||
jqXHR.getResponseHeader("X-WP-TotalPages"),
|
||||
10
|
||||
);
|
||||
var total_posts = parseInt(jqXHR.getResponseHeader("X-WP-Total"), 10);
|
||||
|
||||
if (selector == "search") {
|
||||
$("#search_title_result h2").append(
|
||||
"<span class='pandora_green_text'>" + search_modules + "</span>"
|
||||
);
|
||||
}
|
||||
|
||||
if (total_posts < 1) {
|
||||
$("#" + selector + "_result").css("grid-template-columns", "unset");
|
||||
$("#" + selector + "_result").append(
|
||||
'<div id="empty_result">' + empty_result + "</div>"
|
||||
);
|
||||
} else {
|
||||
var link = "";
|
||||
if (selector == "search") {
|
||||
link =
|
||||
"index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=search_module&search=" +
|
||||
search_modules;
|
||||
} else if (selector == "category") {
|
||||
link =
|
||||
"index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=categories&id_cat=" +
|
||||
search_modules;
|
||||
}
|
||||
|
||||
print_excerpt(selector + "_result", response);
|
||||
pagination_library(link, total_pages, total_posts, page);
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
if (selector == "search") {
|
||||
show_error_msg("#search_result", error_search);
|
||||
}
|
||||
//show_error_msg("#category_result", error_category);
|
||||
},
|
||||
complete: function(data) {
|
||||
$("#" + selector + "_result").removeClass("loading_posts");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Show results.
|
||||
if ($("#category_result").length || $("#search_result").length) {
|
||||
var result = "";
|
||||
if ($("#category_result").length) {
|
||||
result = "category_result";
|
||||
var id_cat = $("#" + result).attr("class");
|
||||
id_cat = id_cat.replace("result_category-", "");
|
||||
} else if ($("#search_result").length) {
|
||||
result = "search_result";
|
||||
var search_string = $("#" + result).attr("class");
|
||||
search_string = search_string.replace("result_string-", "");
|
||||
}
|
||||
|
||||
if ($("#pagination_library").length) {
|
||||
var page = $("#pagination_library").attr("class");
|
||||
page = page.replace("page-", "");
|
||||
}
|
||||
|
||||
if (id_cat != "" && result == "category_result") {
|
||||
get_modules(id_cat, page, "category");
|
||||
if (result == "category_result") {
|
||||
get_category(id_cat);
|
||||
}
|
||||
} else if (search_string != "" && result == "search_result") {
|
||||
get_modules(search_string, page, "search");
|
||||
}
|
||||
} else if ($("#library_main").length) {
|
||||
library_main();
|
||||
}
|
||||
|
||||
// Sidebar search.
|
||||
$("#search_module").keypress(function(event) {
|
||||
var keycode = event.keyCode ? event.keyCode : event.which;
|
||||
if (keycode == "13") {
|
||||
var browse = $("#search_module").val();
|
||||
window.location =
|
||||
"index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=search_module&search=" +
|
||||
browse;
|
||||
}
|
||||
event.stopPropagation();
|
||||
});
|
||||
}); // document ready ends
|
||||
|
||||
/* Print main page */
|
||||
function library_main() {
|
||||
$.ajax({
|
||||
url: "https://pandorafms.com/library/wp-json/wp/v2/pages/121",
|
||||
type: "GET",
|
||||
crossDomain: true,
|
||||
contentType: "application/json",
|
||||
beforeSend: function(xhr) {
|
||||
$("#library_main").addClass("loading_posts");
|
||||
},
|
||||
complete: function(data) {
|
||||
$("#library_main").removeClass("loading_posts");
|
||||
}
|
||||
})
|
||||
.done(function(data) {
|
||||
var array_cat = [
|
||||
"",
|
||||
"Miscelaneus",
|
||||
"Application monitoring",
|
||||
"Network Monitoring",
|
||||
"Operating Systems",
|
||||
"Artwork",
|
||||
"Security monitoring",
|
||||
"Tools",
|
||||
"Inventory",
|
||||
"System Integrations"
|
||||
];
|
||||
|
||||
var array_cat_ids = ["", 4, 5, 7, 6, 9, 8, 11, 12, 13];
|
||||
|
||||
var main_page = data.content.rendered;
|
||||
|
||||
// Remove code from Divi Theme.
|
||||
main_page = main_page.replace(/<p>\[.*?\]<\/p>/g, "");
|
||||
|
||||
var clean_page = main_page.split("\n");
|
||||
clean_page = clean_page.filter(function(element) {
|
||||
return element != "";
|
||||
});
|
||||
|
||||
// Title.
|
||||
$("#library_main>span").append(clean_page[0]);
|
||||
// Description.
|
||||
$("#library_main>span+p").append(clean_page[1]);
|
||||
|
||||
// Remove unused items.
|
||||
// Remove only 1 index because we need the index 1 to exist for the loop. The 0 index in the loop will be ignored.
|
||||
clean_page.splice(0, 1);
|
||||
|
||||
$.each(clean_page, function(i, v) {
|
||||
var main_category = $(
|
||||
"#library_main_content div.library_main_category:nth-child(" + i + ")"
|
||||
);
|
||||
|
||||
if (main_category.length > 0) {
|
||||
main_category.append(
|
||||
"<a href='index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=categories&id_cat=" +
|
||||
array_cat_ids[i] +
|
||||
"'><img src='images/module_library/" +
|
||||
array_cat[i].replace(" ", "-") +
|
||||
".png'/><h4>" +
|
||||
array_cat[i] +
|
||||
"</h4>" +
|
||||
v +
|
||||
"</a>"
|
||||
);
|
||||
}
|
||||
});
|
||||
})
|
||||
.fail(function(jqXHR, textStatus, errorThrown) {
|
||||
$("#library_main_content").empty();
|
||||
show_error_msg("#library_main_content", error_main);
|
||||
});
|
||||
}
|
||||
|
||||
// Get all data from one category. This is necessary to get the category name.
|
||||
function get_category(id) {
|
||||
$.ajax({
|
||||
url: "https://pandorafms.com/library/wp-json/wp/v2/categories/" + id,
|
||||
type: "GET",
|
||||
contentType: "application/json",
|
||||
success: function(response) {
|
||||
$("#category_title_result h2").append(
|
||||
'<span class="pandora_green_text">' + response.name + "</span>"
|
||||
);
|
||||
},
|
||||
error: function(error) {
|
||||
if (error.readyState == 4) {
|
||||
if (error.status == "404") {
|
||||
show_error_msg("#category_result", error_no_category);
|
||||
}
|
||||
} else {
|
||||
show_error_msg("#category_result", error_category);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Print a summary text of the returned posts (by a category or a search).
|
||||
function print_excerpt(id_div, response) {
|
||||
var return_posts = "";
|
||||
|
||||
$.each(response, function(i, elem) {
|
||||
var excerpt = elem.excerpt.rendered;
|
||||
|
||||
if (excerpt.length > 250) {
|
||||
excerpt = excerpt.substr(0, 230) + "[…]</p>";
|
||||
}
|
||||
|
||||
return_posts += "<div class='card'>";
|
||||
return_posts +=
|
||||
"<div class='card_excerpt'><h4>" +
|
||||
elem.title.rendered +
|
||||
"</h4>" +
|
||||
excerpt +
|
||||
"</div>";
|
||||
return_posts +=
|
||||
'<div class="card_link"><div id="card_link-' +
|
||||
elem.id +
|
||||
'" class="card_link_button"><span>' +
|
||||
more_details +
|
||||
"</span></div></div>";
|
||||
|
||||
return_posts += "</div>";
|
||||
});
|
||||
// Append to modal window.
|
||||
$("#" + id_div).append(return_posts);
|
||||
|
||||
var modal_details = $("#modal_library").dialog({
|
||||
resizable: false,
|
||||
autoOpen: false,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
maxHeight: 600,
|
||||
width: 700,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
open: function() {
|
||||
$(".ui-dialog-content").scrollTop(0);
|
||||
},
|
||||
buttons: {
|
||||
Close: function() {
|
||||
modal_details.dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.each(response, function(i, elem) {
|
||||
$("#card_link-" + elem.id).on("click", function() {
|
||||
var id = $(this).attr("id");
|
||||
id = id.replace("card_link-", "");
|
||||
|
||||
var updated = "";
|
||||
var modification_date = new Date(elem.modified).setHours(0, 0, 0, 0);
|
||||
var creation_date = new Date(elem.date).setHours(0, 0, 0, 0);
|
||||
if (modification_date > creation_date) {
|
||||
updated =
|
||||
"<p><span class='bold'>Update in: </span><span class='date'>" +
|
||||
format_date(elem.modified) +
|
||||
"</span></p>";
|
||||
}
|
||||
|
||||
if (elem.id == id) {
|
||||
$("#modal_library").html(
|
||||
'<p><span class="date">' +
|
||||
format_date(elem.date) +
|
||||
"</span> | <span class='bold'>" +
|
||||
category_names(elem.categories) +
|
||||
"</span></p>" +
|
||||
updated +
|
||||
elem.content.rendered +
|
||||
'<div class="view_web"><a href="' +
|
||||
elem.link +
|
||||
'" target="_blank"><button class="sub next">' +
|
||||
view_web +
|
||||
"</button></a></div>"
|
||||
);
|
||||
}
|
||||
var title = elem.title.rendered.replace(/<.*?>/g, "");
|
||||
modal_details.dialog("option", "title", title).dialog("open");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Function to format date from posts. (To show in modal window).
|
||||
function format_date(date_string) {
|
||||
const months = [
|
||||
"Jan",
|
||||
"Feb",
|
||||
"Mar",
|
||||
"Apr",
|
||||
"May",
|
||||
"Jun",
|
||||
"Jul",
|
||||
"Aug",
|
||||
"Sep",
|
||||
"Oct",
|
||||
"Nov",
|
||||
"Dec"
|
||||
];
|
||||
|
||||
var date = new Date(date_string);
|
||||
let formatted_date =
|
||||
months[date.getMonth()] + " " + date.getDate() + ", " + date.getFullYear();
|
||||
|
||||
return formatted_date;
|
||||
}
|
||||
|
||||
// Function to get the names of the categories. (To show in modal window).
|
||||
function category_names(categories) {
|
||||
var local_categories_exist = sessionStorage.getItem("categories");
|
||||
if (local_categories_exist !== null) {
|
||||
var local_categories = JSON.parse(atob(local_categories_exist));
|
||||
var category_names = "";
|
||||
$.each(categories, function(index, value) {
|
||||
$.each(local_categories, function(i, v) {
|
||||
if (value == v.id) {
|
||||
category_names +=
|
||||
"<a href='index.php?sec=gmodule_library&sec2=godmode/module_library/module_library_view&tab=categories&id_cat=" +
|
||||
v.id +
|
||||
"'>" +
|
||||
v.name +
|
||||
"</a>" +
|
||||
", ";
|
||||
}
|
||||
});
|
||||
});
|
||||
category_names = category_names.replace(/,\s*$/, "");
|
||||
return category_names;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to print the pagination.
|
||||
//?per_page=5&page=4 is equivalent to ?per_page=5&offset=15
|
||||
function pagination_library(link, total_pages, total_posts, page) {
|
||||
$("#pagination_library").append(
|
||||
'<div class="pagination_total">' +
|
||||
total_modules_text +
|
||||
": " +
|
||||
total_posts +
|
||||
"</div>"
|
||||
);
|
||||
|
||||
// If only one page, don't show pagination.
|
||||
if (total_pages <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var links_pagination = "";
|
||||
for (var i = 1; i <= total_pages; i++) {
|
||||
if (i == page) {
|
||||
links_pagination +=
|
||||
'<a href="' +
|
||||
link +
|
||||
"&page=" +
|
||||
i +
|
||||
'" class="active_number">' +
|
||||
i +
|
||||
"</a>";
|
||||
} else {
|
||||
links_pagination += '<a href="' + link + "&page=" + i + '">' + i + "</a>";
|
||||
}
|
||||
}
|
||||
$("#pagination_library").append(
|
||||
'<div class="pagination_pages">' + links_pagination + "</div>"
|
||||
);
|
||||
}
|
||||
|
||||
// Show error messsage.
|
||||
function show_error_msg(selector, message_error) {
|
||||
$("#search_result, #category_result").css("grid-template-columns", "unset");
|
||||
if (selector == "#categories_library") {
|
||||
$(selector).append("<div id='empty_result'>" + message_error + "</div>");
|
||||
} else {
|
||||
$(selector).append("<div id='empty_result'>" + message_error + "</div>");
|
||||
}
|
||||
}
|
|
@ -210,6 +210,9 @@ li.sub_subMenu.selected {
|
|||
#icon_god-um_messages {
|
||||
background-image: url(../../images/um_messages.menu_gray.png);
|
||||
}
|
||||
#icon_god-module_library {
|
||||
background-image: url(../../images/gm_library.menu_gray.png);
|
||||
}
|
||||
|
||||
#menu_container {
|
||||
z-index: 3;
|
||||
|
@ -371,6 +374,9 @@ ul li {
|
|||
.selected#icon_god-um_messages {
|
||||
background-image: url(../../images/um_messages.menu_white.png);
|
||||
}
|
||||
.selected#icon_god-module_library {
|
||||
background-image: url(../../images/gm_library.menu_white.png);
|
||||
}
|
||||
|
||||
#menu_full {
|
||||
height: 100%;
|
||||
|
|
|
@ -0,0 +1,265 @@
|
|||
* {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#module_library_main {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr minmax(min-content, max-content);
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.no-enterprise {
|
||||
background-color: #f7f7f7;
|
||||
padding: 20px 20px;
|
||||
padding-right: 50px;
|
||||
margin-bottom: 20px;
|
||||
margin-top: 20px;
|
||||
border: 1px solid #d0d0d0;
|
||||
border-radius: 2px;
|
||||
text-shadow: none;
|
||||
color: #ff5f5f;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: 1px solid #e2e2e2;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
padding: 0;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.card_excerpt {
|
||||
padding: 0px 20px;
|
||||
}
|
||||
|
||||
.card_excerpt p {
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.card_link {
|
||||
border-top: 1px solid #e2e2e2;
|
||||
}
|
||||
|
||||
.card_link_button {
|
||||
cursor: pointer;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
.card_link_button:hover {
|
||||
cursor: pointer;
|
||||
padding: 10px 20px;
|
||||
background-color: #eaeaea;
|
||||
}
|
||||
|
||||
.loading_posts {
|
||||
background: url("../../images/wait.gif") no-repeat center center;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
#show_errors_library {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* --- Main page --- */
|
||||
#library_main {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#library_main h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
#library_main_content {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(300px, 1fr));
|
||||
grid-gap: 20px;
|
||||
gap: 20px;
|
||||
text-align: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
#library_main_content div.library_main_category {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
#library_main_content div.library_main_category h4 {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
#library_main_content div.library_main_category p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#library_main_content div.library_main_category:hover a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#library_main_content div.library_main_category:hover {
|
||||
border: 1px solid #e2e2e2;
|
||||
background-color: #fff;
|
||||
border-radius: 4px;
|
||||
padding: 19px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* --- Sidebar --- */
|
||||
.sidebar_library {
|
||||
min-width: 360px;
|
||||
margin-left: 50px;
|
||||
border-left: 1px solid #d0d0d0;
|
||||
padding: 0px 0px 0px 30px;
|
||||
}
|
||||
|
||||
@media screen and (max-height: 1080px) {
|
||||
#categories_sidebar > ul {
|
||||
max-height: 620px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar_library h3:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.categories_sidebar_children {
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
/* --- Search results --- */
|
||||
#category_title_result,
|
||||
#search_title_result {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#category_title_result h2,
|
||||
#search_title_result h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
#category_title_result span,
|
||||
#search_title_result span {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
#category_result,
|
||||
#search_result {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(300px, 1fr));
|
||||
grid-gap: 20px;
|
||||
}
|
||||
|
||||
#empty_result {
|
||||
padding: 10px;
|
||||
border: 1px solid #f85858;
|
||||
border: 1px solid #e2e2e2;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
color: #f85858;
|
||||
background-color: #fff;
|
||||
text-transform: uppercase;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* --- Categories page --- */
|
||||
#categories_library {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(150px, 1fr));
|
||||
grid-template-rows: repeat(8, 1fr);
|
||||
grid-auto-rows: 1fr;
|
||||
grid-gap: 20px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.card_category {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
#categories_library .card_category a {
|
||||
font-weight: bold;
|
||||
font-size: 11pt;
|
||||
}
|
||||
|
||||
#categories_library .card_category a:hover {
|
||||
color: #82b92e;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* --- Pagination --- */
|
||||
#pagination_library {
|
||||
margin-top: 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#pagination_library .pagination_pages {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#pagination_library .pagination_pages a {
|
||||
border: 1px solid#cacaca;
|
||||
border-right: 0;
|
||||
padding: 5px;
|
||||
min-width: 22px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#pagination_library .pagination_pages a:last-child {
|
||||
border-right: 1px solid#cacaca;
|
||||
}
|
||||
|
||||
#pagination_library .pagination_pages a:hover {
|
||||
background-color: #e2e2e2;
|
||||
}
|
||||
|
||||
#pagination_library .pagination_pages a.active_number {
|
||||
background-color: #82b92e;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Modal */
|
||||
#modal_library {
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
}
|
||||
|
||||
#modal_library h2 {
|
||||
color: #82b92e !important;
|
||||
}
|
||||
|
||||
#modal_library ul {
|
||||
list-style-type: disc;
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
#modal_library a {
|
||||
color: #82b92e;
|
||||
}
|
||||
|
||||
#modal_library pre {
|
||||
border: 1px solid #e2e2e2;
|
||||
background: #f5f5f5;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
padding: 20px 20px;
|
||||
color: #383838;
|
||||
margin-bottom: 10px;
|
||||
font-family: Courier New, monospace;
|
||||
}
|
||||
|
||||
#modal_library div.view_web {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#modal_library .date {
|
||||
color: #8c8c8c;
|
||||
}
|
||||
|
||||
#modal_library .bold {
|
||||
font-weight: bold;
|
||||
}
|