--- /dev/null
+import Worker from "../Worker";
+import * as Language from "../../../Language";
+
+const workers = new Map<HTMLElement, number>();
+
+export function register(button: HTMLElement): void {
+ if (!button.dataset.className) {
+ throw new Error(`Missing 'data-class-name' attribute.`);
+ }
+
+ workers.set(button, parseInt(button.dataset.nicevalue!, 10));
+
+ button.addEventListener("click", function (event) {
+ event.preventDefault();
+
+ void runWorker(button);
+ });
+}
+
+export async function runAllWorkers(): Promise<void> {
+ const sorted = Array.from(workers)
+ .sort(([, a], [, b]) => {
+ return a - b;
+ })
+ .map(([el]) => el);
+
+ let i = 1;
+ for (const worker of sorted) {
+ await runWorker(worker, `${worker.textContent!} (${i++} / ${sorted.length})`);
+ }
+}
+
+async function runWorker(button: HTMLElement, dialogTitle: string = button.textContent!): Promise<void> {
+ return new Promise<void>((resolve, reject) => {
+ new Worker({
+ dialogId: "cache",
+ dialogTitle,
+ className: button.dataset.className,
+ callbackAbort() {
+ reject();
+ },
+ callbackSuccess() {
+ let span = button.nextElementSibling;
+ if (span && span.nodeName === "SPAN") {
+ span.remove();
+ }
+
+ span = document.createElement("span");
+ span.innerHTML = `<span class="icon icon16 fa-check green"></span> ${Language.get("wcf.acp.worker.success")}`;
+ button.parentNode!.insertBefore(span, button.nextElementSibling);
+ resolve();
+ },
+ });
+ });
+}
{include file='header' pageTitle='wcf.acp.rebuildData'}
<script data-relocate="true">
- require(['Language', 'WoltLabSuite/Core/Acp/Ui/Worker'], function (Language, AcpUiWorker) {
- Language.add('wcf.acp.worker.abort.confirmMessage', '{jslang}wcf.acp.worker.abort.confirmMessage{/jslang}');
+ require(['Language', 'WoltLabSuite/Core/Acp/Ui/Maintenance/RebuildData'], (Language, RebuildData) => {
+ Language.addObject({
+ 'wcf.acp.worker.abort.confirmMessage': '{jslang}wcf.acp.worker.abort.confirmMessage{/jslang}',
+ 'wcf.acp.worker.success': '{jslang}wcf.acp.worker.success{/jslang}',
+ });
- elBySelAll('.jsRebuildDataWorker', undefined, function (button) {
- if (button.classList.contains('disabled')) return;
-
- button.addEventListener('click', function (event) {
- event.preventDefault();
-
- new AcpUiWorker({
- // dialog
- dialogId: 'cache',
- dialogTitle: button.textContent,
-
- // ajax
- className: elData(button, 'class-name'),
-
- // callbacks
- callbackAbort: null,
- callbackSuccess: () => {
- var span = button.nextElementSibling;
- if (span && span.nodeName === 'SPAN') elRemove(span);
-
- span = elCreate('span');
- span.innerHTML = ' <span class="icon icon16 fa-check green"></span> {lang}wcf.acp.worker.success{/lang}';
- button.parentNode.insertBefore(span, button.nextElementSibling);
- }
- });
+ document.querySelectorAll('.jsRebuildDataWorker').forEach((button) => {
+ RebuildData.register(button);
+ });
+ document.querySelectorAll('.jsRebuildAll').forEach((button) => {
+ button.addEventListener('click', (ev) => {
+ ev.preventDefault();
+ void RebuildData.runAllWorkers();
});
});
});
<h1 class="contentTitle">{lang}wcf.acp.rebuildData{/lang}</h1>
</div>
- {hascontent}
- <nav class="contentHeaderNavigation">
- <ul>
- {content}{event name='contentHeaderNavigation'}{/content}
- </ul>
- </nav>
- {/hascontent}
+ <nav class="contentHeaderNavigation">
+ <ul>
+ <li><a href="#" class="button jsRebuildAll"><span class="icon icon16 fa-long-arrow-down"></span> <span>{lang}wcf.acp.rebuildData.rebuildAll{/lang}</span></a></li>
+ {event name='contentHeaderNavigation'}
+ </ul>
+ </nav>
</header>
{event name='afterContentHeader'}
<dd>
<a href="#"
class="button small jsRebuildDataWorker"
- data-class-name="{$objectType->className}" data-object-type="{$objectType->objectType}"
+ data-class-name="{$objectType->className}"
+ data-object-type="{$objectType->objectType}"
+ data-nicevalue="{if $objectType->nicevalue}{$objectType->nicevalue}{else}0{/if}"
>{lang}wcf.acp.rebuildData.{@$objectType->objectType}{/lang}</a>
<small>{lang}wcf.acp.rebuildData.{@$objectType->objectType}.description{/lang}</small>
</dd>
--- /dev/null
+define(["require", "exports", "tslib", "../Worker", "../../../Language"], function (require, exports, tslib_1, Worker_1, Language) {
+ "use strict";
+ Object.defineProperty(exports, "__esModule", { value: true });
+ exports.runAllWorkers = exports.register = void 0;
+ Worker_1 = tslib_1.__importDefault(Worker_1);
+ Language = tslib_1.__importStar(Language);
+ const workers = new Map();
+ function register(button) {
+ if (!button.dataset.className) {
+ throw new Error(`Missing 'data-class-name' attribute.`);
+ }
+ workers.set(button, parseInt(button.dataset.nicevalue, 10));
+ button.addEventListener("click", function (event) {
+ event.preventDefault();
+ void runWorker(button);
+ });
+ }
+ exports.register = register;
+ async function runAllWorkers() {
+ const sorted = Array.from(workers)
+ .sort(([, a], [, b]) => {
+ return a - b;
+ })
+ .map(([el]) => el);
+ let i = 1;
+ for (const worker of sorted) {
+ await runWorker(worker, `${worker.textContent} (${i++} / ${sorted.length})`);
+ }
+ }
+ exports.runAllWorkers = runAllWorkers;
+ async function runWorker(button, dialogTitle = button.textContent) {
+ return new Promise((resolve, reject) => {
+ new Worker_1.default({
+ dialogId: "cache",
+ dialogTitle,
+ className: button.dataset.className,
+ callbackAbort() {
+ reject();
+ },
+ callbackSuccess() {
+ let span = button.nextElementSibling;
+ if (span && span.nodeName === "SPAN") {
+ span.remove();
+ }
+ span = document.createElement("span");
+ span.innerHTML = `<span class="icon icon16 fa-check green"></span> ${Language.get("wcf.acp.worker.success")}`;
+ button.parentNode.insertBefore(span, button.nextElementSibling);
+ resolve();
+ },
+ });
+ });
+ }
+});
<item name="wcf.acp.rebuildData.com.woltlab.wcf.activityPointItems.description"><![CDATA[Berechnet Anzahl an Aktivitäten neu, für die Benutzer Punkte erhalten; aktualisiert Benutzerränge]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.searchEngineConvertInnoDb.description"><![CDATA[Stellt die Tabellen des Suchindex auf die InnoDB-Engine um.]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.searchEngineConvertInnoDb"><![CDATA[Suchindex auf InnoDB umstellen]]></item>
+ <item name="wcf.acp.rebuildData.rebuildAll"><![CDATA[Alle aktualisieren]]></item>
</category>
<category name="wcf.acp.rescueMode">
<item name="wcf.acp.rescueMode"><![CDATA[Systemwiederherstellung]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.activityPointItems.description"><![CDATA[Recalculates the number of activities for which users get points and rebuilds user ranks.]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.searchEngineConvertInnoDb.description"><![CDATA[Migrates the search engine tables to the InnoDB storage engine.]]></item>
<item name="wcf.acp.rebuildData.com.woltlab.wcf.searchEngineConvertInnoDb"><![CDATA[Migrate Search Index to InnoDB]]></item>
+ <item name="wcf.acp.rebuildData.rebuildAll"><![CDATA[Rebuild All]]></item>
</category>
<category name="wcf.acp.rescueMode">
<item name="wcf.acp.rescueMode"><![CDATA[Rescue Mode]]></item>