| 9168 | title: 'Select destination folder for extraction' |
| 9169 | }); |
| 9170 | |
| 9171 | if (!result.canceled && result.filePaths.length > 0) { |
| 9172 | const destPath = await extractModelFromZip(pathInfo.zipPath, pathInfo.entryPath, result.filePaths[0]); |
| 9173 | dialog.showMessageBox(BrowserWindow.fromWebContents(event.sender), { |
| 9174 | type: 'info', |
| 9175 | title: 'Extraction Complete', |
| 9176 | message: 'Archive extracted successfully', |
| 9177 | detail: `Extracted to: ${destPath}` |
| 9178 | }); |
| 9179 | } |
| 9180 | } catch (error) { |
| 9181 | console.error('Error extracting archive:', error); |
| 9182 | dialog.showMessageBox(BrowserWindow.fromWebContents(event.sender), { |
| 9183 | type: 'error', |
| 9184 | title: 'Error', |
| 9185 | message: 'Could not extract archive', |
| 9186 | detail: error.message |
| 9187 | }); |
| 9188 | } |
| 9189 | } |
| 9190 | } |
| 9191 | ); |
| 9192 | } |
| 9193 | |
| 9194 | // Get all configured slicers from the database |
| 9195 | let slicers = []; |
| 9196 | try { |
| 9197 | // Ensure the slicers table exists before querying it |
| 9198 | const tableExists = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='slicers'`).get(); |
| 9199 | if (tableExists) { |
| 9200 | slicers = db.prepare('SELECT * FROM slicers').all(); |
| 9201 | } else { |
| 9202 | // Create the table if it doesn't exist |
| 9203 | ensureSlicersTableExists(); |
| 9204 | } |
| 9205 | } catch (error) { |
| 9206 | console.error('Error getting slicers:', error); |
| 9207 | } |
| 9208 | |
| 9209 | // Server mode hands the files to the local helper via printventory://. |
| 9210 | // Desktop mode launches the slicer here, and only for a single selection. |
| 9211 | if (slicers.length > 0 && filePaths.length >= 1 && (isServerMode || filePaths.length === 1)) { |
| 9212 | const slicerSubmenu = { |
| 9213 | label: 'Open in Slicer', |
| 9214 | submenu: slicers.map(slicer => ({ |
| 9215 | label: slicer.name, |
| 9216 | slicerName: slicer.name, |
| 9217 | slicerPath: slicer.path, |
| 9218 | click: async () => { |
| 9219 | try { |
| 9220 | // Browser clients launch the helper. Do not start a slicer inside Docker. |
| 9221 | if (isServerMode) { |
| 9222 | const commandPayload = { |
| 9223 | type: 'open-in-slicer', |
| 9224 | filePaths: filePaths.slice(), |
| 9225 | filePath: filePaths[0], |
| 9226 | slicerName: slicer.name, |
| 9227 | slicerPath: slicer.path, |