diff options
| -rw-r--r-- | htroot/IndexPackManager_p.html | 52 | ||||
| -rw-r--r-- | htroot/env/templates/submenuIndexImport.template | 1 | ||||
| -rw-r--r-- | source/net/yacy/htroot/IndexPackManager_p.java | 119 |
3 files changed, 172 insertions, 0 deletions
diff --git a/htroot/IndexPackManager_p.html b/htroot/IndexPackManager_p.html new file mode 100644 index 000000000..4be78fb4e --- /dev/null +++ b/htroot/IndexPackManager_p.html @@ -0,0 +1,52 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> +<!-- This page is only XHTML 1.0 Transitional because target is being used in a links --> +<html xmlns="http://www.w3.org/1999/xhtml"> +#(reload)#::<meta http-equiv="REFRESH" content="5; url=/IndexPackManager_p.html">#(/reload)# + <head> + <title>YaCy '#[clientname]#': URL Database Administration</title> + #%env/templates/metas.template%# + </head> + <body id="IndexControl"> + #%env/templates/header.template%# + #%env/templates/submenuIndexImport.template%# + + <h2>Index Pack Manager</h2> + + + <fieldset><legend>Pack Folders</legend> + <table class="table table-striped" summary="Packs: Hold List"> + <thead class="thead-dark"> + <tr class="TableHeader"><th width="720">Packs: Hold List</th><th width="180">Size (KB)</th><th>Process</th></tr> + </thead> + <tbody> + #{packs-hold}# + <tr class="TableCell#(dark)#Light::Dark#(/dark)#"><td>#[file]#</td><td class="text-end">#[size]#</td><td>#[process]#</td></tr> + #{/packs-hold}# + </tbody> + </table> + + <table class="table table-striped" summary="Packs: Load List"> + <thead class="thead-dark"> + <tr class="TableHeader"><th width="720">Packs: Load List</th><th width="180">Size (KB)</th><th>Process</th></tr> + </thead> + <tbody> + #{packs-load}# + <tr class="TableCell#(dark)#Light::Dark#(/dark)#"><td>#[file]#</td><td class="text-end">#[size]#</td><td>#[process]#</td></tr> + #{/packs-load}# + </tbody> + + <table class="table table-striped" summary="Packs: Loaded List"> + <thead class="thead-dark"> + <tr class="TableHeader"><th width="720">Packs: Loaded List</th><th width="180">Size (KB)</th><th>Process</th></tr> + </thead> + <tbody> + #{packs-loaded}# + <tr class="TableCell#(dark)#Light::Dark#(/dark)#"><td>#[file]#</td><td class="text-end">#[size]#</td><td>#[process]#</td></tr> + #{/packs-loaded}# + </tbody> + </table> + </fieldset> + + #%env/templates/footer.template%# + </body> +</html> diff --git a/htroot/env/templates/submenuIndexImport.template b/htroot/env/templates/submenuIndexImport.template index 8df07e446..5ff6a80f1 100644 --- a/htroot/env/templates/submenuIndexImport.template +++ b/htroot/env/templates/submenuIndexImport.template @@ -6,6 +6,7 @@ <h3>Index Packs</h3> <ul class="SubMenu"> <li><a href="IndexPackGenerator_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Index Pack Generator</a></li> + <li><a href="IndexPackManager_p.html" class="MenuItemLink #(authorized)#lock::unlock#(/authorized)#">Index Pack Manager</a></li> </ul> </div> <div class="SubMenugroup"> diff --git a/source/net/yacy/htroot/IndexPackManager_p.java b/source/net/yacy/htroot/IndexPackManager_p.java new file mode 100644 index 000000000..ec527f774 --- /dev/null +++ b/source/net/yacy/htroot/IndexPackManager_p.java @@ -0,0 +1,119 @@ +// IndexPackManager_p.java +// ----------------------- +// (C) 2025 by Michael Peter Christen; mc@yacy.net, Frankfurt a. M., Germany +// +// This is a part of YaCy, a peer-to-peer based web search engine +// +// LICENSE +// +// 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 2 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, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +package net.yacy.htroot; + +import java.io.File; + +import net.yacy.cora.protocol.RequestHeader; +import net.yacy.search.Switchboard; +import net.yacy.server.serverObjects; +import net.yacy.server.serverSwitch; + +public class IndexPackManager_p { + + public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) { + // return variable that accumulates replacements + final Switchboard sb = (Switchboard) env; + final serverObjects prop = new serverObjects(); + + if (post != null) { + final String mvfrom = post.get("mvfrom", ""); + final String mvto = post.get("mvto", ""); + final String file = post.get("file", ""); + + if (!mvfrom.isEmpty() && !mvto.isEmpty() && !file.isEmpty()) { + // move as requested + if ("loaded".equals(mvfrom) && "hold".equals(mvto)) { + new File(sb.packsLoadedPath, file).renameTo(new File(sb.packsHoldPath, file)); + } + if ("hold".equals(mvfrom) && "load".equals(mvto)) { + new File(sb.packsHoldPath, file).renameTo(new File(sb.packsLoadPath, file)); + } + } + } + + // set default values + prop.put("reload", 0); + + + // show Pack folder contents + int i = 0; boolean dark = true; + for (final String file: sb.packsInHold()) { + prop.put("packs-hold_" + i + "_file", file); + prop.put("packs-hold_" + i + "_size", new File(sb.packsHoldPath, file).length() / 1024); + prop.put("packs-hold_" + i + "_process", "<a class=\"btn btn-primary\" href=\"IndexPackManager_p.html?mvfrom=hold&mvto=load&file=" + file + "\" role=\"button\">load</a>"); + prop.put("packs_hold" + i + "_dark", dark ? "1" : "0"); + i++; + dark = !dark; + } + if (i == 0) { + prop.put("packs-hold_0_file", "<no packs in hold>"); + prop.put("packs-hold_0_size", ""); + prop.put("packs-hold_" + i + "_process", ""); + prop.put("packs-hold_0_dark", true); + i = 1; + } + prop.put("packs-hold", i); + i = 0; dark = true; + for (final String file: sb.packsInLoad()) { + prop.put("packs-load_" + i + "_file", file); + prop.put("packs-load_" + i + "_size", new File(sb.packsLoadPath, file).length() / 1024); + prop.put("packs-load_" + i + "_process", ""); + prop.put("packs-load_" + i + "_dark", dark ? "1" : "0"); + i++; + dark = !dark; + } + if (i == 0) { + prop.put("packs-load_0_file", "<no packs in load>"); + prop.put("packs-load_0_size", ""); + prop.put("packs-load_0_process", ""); + prop.put("packs-load_0_dark", true); + i = 1; + } else { + // while packs are loaded, we reload the interface to refresh the pack list constantly + prop.put("reload", 1); + } + prop.put("packs-load", i); + i = 0; dark = true; + for (final String file: sb.packsInLoaded()) { + prop.put("packs-loaded_" + i + "_file", file); + prop.put("packs-loaded_" + i + "_size", new File(sb.packsLoadedPath, file).length() / 1024); + prop.put("packs-loaded_" + i + "_process", "<a class=\"btn btn-primary\" href=\"IndexPackManager_p.html?mvfrom=loaded&mvto=hold&file=" + file + "\" role=\"button\">to: hold</a>"); + prop.put("packs-loaded_" + i + "_dark", dark ? "1" : "0"); + i++; + dark = !dark; + } + if (i == 0) { + prop.put("packs-loaded_0_file", "<no packs in loaded>"); + prop.put("packs-loaded_0_size", ""); + prop.put("packs-loaded_0_process", ""); + prop.put("packs-loaded_0_dark", true); + i = 1; + } + prop.put("packs-loaded", i); + + // return rewrite properties + return prop; + } + +}
\ No newline at end of file |
