Add status progress for batch tool operations
This commit is contained in:
@@ -134,11 +134,11 @@ async function handleUpload(panel: vscode.WebviewPanel, filePaths: string[]) {
|
||||
if (!/\.html?$/i.test(filePath)) { reportError('Must be .html'); continue; }
|
||||
|
||||
if (i > 0 && delayMs > 0) {
|
||||
panel.webview.postMessage({ type: 'status', message: `[${idx}/${paths.length}] Waiting ${delayMs}ms before ${fileName}...` });
|
||||
panel.webview.postMessage({ type: 'status', message: `Waiting ${idx}/${paths.length} ${fileName}` });
|
||||
await sleep(delayMs);
|
||||
}
|
||||
|
||||
panel.webview.postMessage({ type: 'status', message: `[${idx}/${paths.length}] Validating ${fileName}...` });
|
||||
panel.webview.postMessage({ type: 'status', message: `Validating ${idx}/${paths.length} ${fileName}` });
|
||||
|
||||
let res: Response;
|
||||
try {
|
||||
@@ -154,7 +154,7 @@ async function handleUpload(panel: vscode.WebviewPanel, filePaths: string[]) {
|
||||
reportError(`Validation failed: ${validateText.slice(0, 300)}`); continue;
|
||||
}
|
||||
|
||||
panel.webview.postMessage({ type: 'status', message: `[${idx}/${paths.length}] Uploading ${fileName}...` });
|
||||
panel.webview.postMessage({ type: 'status', message: `Uploading ${idx}/${paths.length} ${fileName}` });
|
||||
|
||||
try {
|
||||
res = await fetch('https://p.applov.in/getCachedAdURL', {
|
||||
|
||||
@@ -58,7 +58,9 @@ export function openBase64Scanner(_context: vscode.ExtensionContext) {
|
||||
return;
|
||||
}
|
||||
const results: { file: string; ok: boolean; assets: string[] }[] = [];
|
||||
for (const file of targets) {
|
||||
for (let i = 0; i < targets.length; i++) {
|
||||
const file = targets[i];
|
||||
panel.webview.postMessage({ type: 'status', message: `Scanning ${i + 1}/${targets.length} ${path.basename(file)}` });
|
||||
try {
|
||||
const content = fs.readFileSync(file, 'utf8');
|
||||
const offenders = findNonBase64Assets(content);
|
||||
@@ -312,6 +314,9 @@ ${getToolWebviewStyles()}
|
||||
pickedFolder = '';
|
||||
selectedPage = Math.max(0, Math.ceil(pickedFiles.length / PAGE_SIZE) - 1);
|
||||
renderSelection();
|
||||
} else if (msg.type === 'status') {
|
||||
statusEl.textContent = msg.message;
|
||||
statusEl.className = 'status-panel is-busy';
|
||||
} else if (msg.type === 'results') {
|
||||
if (msg.error) {
|
||||
statusEl.classList.remove('is-busy');
|
||||
|
||||
@@ -116,7 +116,9 @@ export function openMraidChecker(_context: vscode.ExtensionContext) {
|
||||
}
|
||||
|
||||
const results: MraidResult[] = [];
|
||||
for (const file of targets) {
|
||||
for (let i = 0; i < targets.length; i++) {
|
||||
const file = targets[i];
|
||||
panel.webview.postMessage({ type: 'status', message: `Scanning ${i + 1}/${targets.length} ${path.basename(file)}` });
|
||||
try {
|
||||
const content = fs.readFileSync(file, 'utf8');
|
||||
const issues = checkMraid(content, file);
|
||||
@@ -829,6 +831,9 @@ ${getToolWebviewStyles()}
|
||||
pickedFolder = '';
|
||||
selectedPage = Math.max(0, Math.ceil(pickedFiles.length / PAGE_SIZE) - 1);
|
||||
renderSelection();
|
||||
} else if (msg.type === 'status') {
|
||||
statusEl.textContent = msg.message;
|
||||
statusEl.className = 'status-panel is-busy';
|
||||
} else if (msg.type === 'results') {
|
||||
if (msg.error) {
|
||||
statusEl.classList.remove('is-busy');
|
||||
|
||||
@@ -68,6 +68,7 @@ export function openPlayworksConverter(_context: vscode.ExtensionContext) {
|
||||
|
||||
let html: string;
|
||||
try {
|
||||
panel.webview.postMessage({ type: 'status', message: 'Reading source HTML...' });
|
||||
html = fs.readFileSync(opts.sourcePath, 'utf8');
|
||||
} catch (e: any) {
|
||||
panel.webview.postMessage({ type: 'convertDone', results: [], error: `Could not read source: ${e.message}` });
|
||||
@@ -76,11 +77,14 @@ export function openPlayworksConverter(_context: vscode.ExtensionContext) {
|
||||
|
||||
const results: NetworkResult[] = [];
|
||||
try {
|
||||
panel.webview.postMessage({ type: 'status', message: 'Converting Unity...' });
|
||||
results.push({ network: 'un', file: copyUnityInput(opts), ok: true });
|
||||
} catch (e: any) {
|
||||
results.push({ network: 'un', file: '', ok: false, error: e.message });
|
||||
}
|
||||
for (const network of opts.networks) {
|
||||
for (let i = 0; i < opts.networks.length; i++) {
|
||||
const network = opts.networks[i];
|
||||
panel.webview.postMessage({ type: 'status', message: `Converting ${i + 1}/${opts.networks.length} ${network}` });
|
||||
try {
|
||||
const filePath = await convertNetwork(html, opts, network);
|
||||
results.push({ network, file: filePath, ok: true });
|
||||
@@ -600,6 +604,9 @@ ${getToolWebviewStyles()}
|
||||
outEl.value = msg.path;
|
||||
outputDir = msg.path;
|
||||
updateConvertBtn();
|
||||
} else if (msg.type === 'status') {
|
||||
statusEl.textContent = msg.message;
|
||||
statusEl.className = 'status-panel is-busy';
|
||||
} else if (msg.type === 'convertDone') {
|
||||
convertBtn.disabled = false;
|
||||
updateConvertBtn();
|
||||
|
||||
@@ -101,11 +101,13 @@ async function handleUpload(panel: vscode.WebviewPanel, rows: UploadRow[]) {
|
||||
for (let i = 0; i < valid.length; i++) {
|
||||
const r = valid[i];
|
||||
const idx = i + 1;
|
||||
panel.webview.postMessage({ type: 'status', message: `Preparing ${idx}/${valid.length} ${path.basename(r.path)}` });
|
||||
const buf = fs.readFileSync(r.path);
|
||||
const file = new File([buf], stampedNames[i], { type: 'text/html' });
|
||||
form.append(`fileUpload_${idx}`, file as any);
|
||||
form.append(`iterationNameUpload_${idx}`, encodeURI(r.iteration.replace(/\s+/g, '')));
|
||||
}
|
||||
panel.webview.postMessage({ type: 'status', message: `Uploading ${valid.length} file${valid.length === 1 ? '' : 's'}...` });
|
||||
|
||||
let res: Response;
|
||||
try {
|
||||
|
||||
@@ -103,13 +103,16 @@ export function openSendToMobile(context: vscode.ExtensionContext) {
|
||||
return;
|
||||
}
|
||||
const files: SharedFile[] = [];
|
||||
for (const filePath of filePaths) {
|
||||
for (let i = 0; i < filePaths.length; i++) {
|
||||
const filePath = filePaths[i];
|
||||
if (!filePath || !fs.existsSync(filePath)) {
|
||||
panel.webview.postMessage({ type: 'error', message: 'File missing.' });
|
||||
return;
|
||||
}
|
||||
panel.webview.postMessage({ type: 'status', message: `Loading ${i + 1}/${filePaths.length} ${path.basename(filePath)}` });
|
||||
files.push({ buf: fs.readFileSync(filePath), filename: path.basename(filePath) });
|
||||
}
|
||||
panel.webview.postMessage({ type: 'status', message: 'Starting server...' });
|
||||
const token = crypto.randomBytes(6).toString('base64url');
|
||||
|
||||
const cfg = vscode.workspace.getConfiguration('hplToolbox.sendToMobile');
|
||||
@@ -549,6 +552,9 @@ ${getToolWebviewStyles()}
|
||||
selectedPaths = selectedFiles.map(f => f.path);
|
||||
selectedPage = 0;
|
||||
renderSelection();
|
||||
} else if (m.type === 'status') {
|
||||
statusEl.textContent = m.message;
|
||||
statusEl.className = 'status-panel is-busy';
|
||||
} else if (m.type === 'sharing') {
|
||||
statusEl.classList.remove('is-busy');
|
||||
currentUrls = m.urls;
|
||||
|
||||
Reference in New Issue
Block a user