From 42d16ba699e29a4aa00d244b09f7646436bb1acb Mon Sep 17 00:00:00 2001 From: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> Date: Thu, 3 Aug 2023 19:43:40 +0530 Subject: [PATCH 01/22] feat(gsoc): refactor CustomShortcut.vue, remove jQuery add typescript,i18n & reduce dom manipulation (#172) * fix(refactor): refactor CustomShortcut.vue, add typescript, i18n and reduce dom access by js Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(key-binding): fix keybinding not working on the vue simulator Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): move keyBinder() to customShortcut.vue and fix warning message Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * chore(lint): fix linting Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(errorMessage): fix wrong error message display when system default key are entered Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * chore(cleanup): remove unnecessary import Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): fix window width Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): initial fix for esc issue Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): add close button to edit keybinging dialog Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> --------- Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> --- src/components/DialogBox/CustomShortcut.vue | 210 ++++++++++++------ src/locales/en.json | 8 + src/locales/hi.json | 8 + src/simulator/src/data.js | 2 +- src/simulator/src/hotkey_binder/keyBinder.js | 10 +- .../src/hotkey_binder/model/actions.js | 9 +- src/simulator/src/setup.js | 2 +- 7 files changed, 174 insertions(+), 75 deletions(-) diff --git a/src/components/DialogBox/CustomShortcut.vue b/src/components/DialogBox/CustomShortcut.vue index 75cb2bbb..8888f9df 100644 --- a/src/components/DialogBox/CustomShortcut.vue +++ b/src/components/DialogBox/CustomShortcut.vue @@ -2,15 +2,18 @@ - + -

Keybinding Preference

+

+ {{ $t('simulator.panel_header.keybinding_preference') }} +

mdi-close @@ -18,16 +21,33 @@
- Press Desire Key Combination & press Enter or press - ESC to cancel. + {{ + $t( + 'simulator.panel_body.custom_shortcut.esc_cancel' + ) + }} -
-
+ + mdi-close + +
{{ pressedKeys }}
+
{{ warning }}
- Command - Keymapping + {{ + $t('simulator.panel_body.custom_shortcut.command') + }} + {{ + $t( + 'simulator.panel_body.custom_shortcut.keymapping' + ) + }}
- Reset To Default + {{ + $t( + 'simulator.panel_body.custom_shortcut.reset_to_default' + ) + }} - Save + {{ $t('simulator.panel_body.custom_shortcut.save') }} - + + + + diff --git a/src/locales/en.json b/src/locales/en.json index 56d3fd53..4c18c1e5 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -62,6 +62,7 @@ "verilog_module": "Verilog Module", "properties": "Properties", "layout": "Layout", + "keybinding_preference": "Keybinding Preference", "render_image": "Render Image", "select_theme": "Select Theme", "boolean_logic_table": "BooleanLogicTable", @@ -119,6 +120,13 @@ "octal_value": "Octal value", "hexadecimal_value": "Hexadecimal value" }, + "custom_shortcut": { + "esc_cancel": "Press Desire Key Combination & press Enter", + "command": "Command", + "keymapping": "Keymapping", + "reset_to_default": "Reset to Default", + "save": "Save" + }, "report_issue": { "describe_issue": "Describe your issue:", "email_html": "Email [Optional]:", diff --git a/src/locales/hi.json b/src/locales/hi.json index 3793c79f..402cf3b2 100644 --- a/src/locales/hi.json +++ b/src/locales/hi.json @@ -62,6 +62,7 @@ "verilog_module": "वेरिलोग मॉड्यूल", "properties": "प्रॉपर्टीज", "layout": "लेआउट", + "keybinding_preference": "कीबाइंडिंग परेफरेंस", "render_image": "छवि प्रस्तुत करें", "select_theme": "थीम चुनें", "boolean_logic_table": "बूलियन लॉजिक टेबल", @@ -119,6 +120,13 @@ "octal_value": "ऑक्टल वैल्यू", "hexadecimal_value": "हेक्साडेसिमल वैल्यू" }, + "custom_shortcut": { + "esc_cancel": "वांछित कुंजी संयोजन दबाएं और स्टोर करने के लिए enter दबाएं", + "command": "कमांड", + "keymapping": "कीमैपिंग", + "reset_to_default": "डिफ़ॉल्ट पर रीसेट करें", + "save": "सेव करें" + }, "report_issue": { "describe_issue": "अपनी समस्या का वर्णन करें:", "email_html": "ईमेल [वैकल्पिक]:", diff --git a/src/simulator/src/data.js b/src/simulator/src/data.js index a3774562..9e7fb773 100644 --- a/src/simulator/src/data.js +++ b/src/simulator/src/data.js @@ -21,7 +21,7 @@ import { } from './Verilog2CV' import { generateVerilog } from './verilog' import { bitConverterDialog } from './utils' -import { keyBinder } from './hotkey_binder/keyBinder' +import { keyBinder } from '#/components/DialogBox/CustomShortcut.vue' import { ExportProject } from '#/components/DialogBox/ExportProject.vue' import { ImportProject } from '#/components/DialogBox/ImportProject.vue' diff --git a/src/simulator/src/hotkey_binder/keyBinder.js b/src/simulator/src/hotkey_binder/keyBinder.js index 4223bbb6..939c32f8 100644 --- a/src/simulator/src/hotkey_binder/keyBinder.js +++ b/src/simulator/src/hotkey_binder/keyBinder.js @@ -10,12 +10,12 @@ // import { setDefault, checkUpdate, addKeys, warnOverride } from './model/actions' // import { KeyCode } from './model/normalize/normalizer.plugin.js' // import { checkRestricted } from './model/utils.js' -import { SimulatorStore } from '#/store/SimulatorStore/SimulatorStore' +// import { SimulatorStore } from '#/store/SimulatorStore/SimulatorStore' //** keyBinder dialog */ -export function keyBinder() { - const simulatorStore = SimulatorStore() - simulatorStore.dialogBox.customshortcut_dialog = true +// export function keyBinder() { + // const simulatorStore = SimulatorStore() + // simulatorStore.dialogBox.customshortcut_dialog = true // console.log(simulatorStore.dialogBox.customshortcut_dialog) // $('#customShortcutDialog').append(editPanel) // $('#customShortcutDialog').append(heading) @@ -149,4 +149,4 @@ export function keyBinder() { // checkUpdate() // addKeys('user') // } else setDefault() -} +// } diff --git a/src/simulator/src/hotkey_binder/model/actions.js b/src/simulator/src/hotkey_binder/model/actions.js index 14a1b2d1..102209ee 100644 --- a/src/simulator/src/hotkey_binder/model/actions.js +++ b/src/simulator/src/hotkey_binder/model/actions.js @@ -107,7 +107,7 @@ export const setDefault = () => { * @param {string} combo the key combo * @param {string} target the target option of the panel */ -export const warnOverride = (combo, target) => { +export const warnOverride = (combo, target, warning) => { let x = 0 while ($('#preference').children()[x]) { if ( @@ -118,9 +118,10 @@ export const warnOverride = (combo, target) => { ) { const assignee = $('#preference').children()[x].children[1].children[0].innerText - $('#warning').text( - `This key(s) is already assigned to: ${assignee}, press Enter to override.` - ) + // $('#warning').text( + // `This key(s) is already assigned to: ${assignee}, press Enter to override.` + // ) + warning.value = `This key(s) is already assigned to: ${assignee}, press Enter to override.` $('#edit').css('border', '1.5px solid #dc5656') return } else { diff --git a/src/simulator/src/setup.js b/src/simulator/src/setup.js index 60ddd14d..e3645d4c 100644 --- a/src/simulator/src/setup.js +++ b/src/simulator/src/setup.js @@ -26,7 +26,7 @@ import 'codemirror/addon/edit/closebrackets' import 'codemirror/addon/hint/anyword-hint' import 'codemirror/addon/hint/show-hint' import { setupCodeMirrorEnvironment } from './Verilog2CV' -import { keyBinder } from './hotkey_binder/keyBinder' +// import { keyBinder } from '#/components/DialogBox/CustomShortcut.vue' import '../vendor/jquery-ui.min.css' import '../vendor/jquery-ui.min' import { confirmSingleOption } from '#/components/helpers/confirmComponent/ConfirmComponent.vue' From 929b0951a24e0773f04266c8095a802c7cf61c59 Mon Sep 17 00:00:00 2001 From: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> Date: Thu, 3 Aug 2023 19:56:58 +0530 Subject: [PATCH 02/22] feat(gsoc): implement Verilog Editor for the vue simulator (#173) * fix: initial convertion of verilogEditorPanel to vue component & add i18n and typescript support * feat(gsoc): fix tabbar issue, project loading, updating, circuit delete, circuit name change, circuit switching, etc issues Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(netlify-build): add / to check netlify build fixes Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(netlify): add _redirects to fix routing issues with netlify deployment Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(netlify): update netlify.toml to get _redirects to correct directory after build Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(netlify): move redirects to neltify.toml Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): update types for store and naming error fixes Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(gsoc): quit saving on clicking cancle while entering new proejct name from simualtor Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): update prompt component structure to make it a common helper component Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): fix cancle on save unify circuit creation and deletion with seperate helper vue components and remove watch and setInterval to improve performance Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): add new project creation, project details update on create from simulator, confirm component to replace confirm() and alert() Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * update(gsoc): convert alert() and confirm() to use vue component Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): add import & export as .cv file with independent vue components Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): update updateProjectDetails.vue to show tags as chips while entering in the update project form Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): update setup fucntion and fix linting issues, remove setTimeout of 1 second for testing Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(gsoc): recover project not saving to localStorage due to generateSaveData being async function Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(lint): fix linting issues in save.js & remove var from setup.js for const Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(jwt): add jwt in Authorization header Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(linting): data.spec.js remove unused parameter "text" from line 26 Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(lint): fix codeclimate linting issues Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(lint): fix linting issues Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): impliment functionlity of verilog editor as a seperate comopnent Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): add code-window inside verilogEditorPanel.vue Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * chore(lint): fix linting issues Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(ux): fix quickmenu options breaking into seperate blocks Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> --------- Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> --- .../Panels/VerilogEditorPanel/THEMES.json | 24 ++++ src/components/Extra.vue | 67 +----------- .../VerilogEditorPanel/VerilogEditorPanel.vue | 103 ++++++++++++++++++ src/locales/en.json | 4 +- src/locales/hi.json | 4 +- src/simulator/src/Verilog2CV.js | 82 ++++++++------ src/simulator/src/circuit.js | 17 ++- src/simulator/src/data.js | 10 +- src/simulator/src/file/Open.js | 96 ++++++++++++++++ src/simulator/src/file/SaveAs.js | 54 +++++++++ src/simulator/src/ux.js | 4 - src/styles/css/main.stylesheet.css | 2 +- 12 files changed, 353 insertions(+), 114 deletions(-) create mode 100644 src/assets/constants/Panels/VerilogEditorPanel/THEMES.json create mode 100644 src/components/Panels/VerilogEditorPanel/VerilogEditorPanel.vue create mode 100644 src/simulator/src/file/Open.js create mode 100644 src/simulator/src/file/SaveAs.js diff --git a/src/assets/constants/Panels/VerilogEditorPanel/THEMES.json b/src/assets/constants/Panels/VerilogEditorPanel/THEMES.json new file mode 100644 index 00000000..4319f822 --- /dev/null +++ b/src/assets/constants/Panels/VerilogEditorPanel/THEMES.json @@ -0,0 +1,24 @@ +[ + { + "label": "Light Themes", + "options": [ + { "value": "default" }, + { "value": "solarized" }, + { "value": "elegant" }, + { "value": "neat" }, + { "value": "idea" }, + { "value": "neo" } + ] + }, + { + "label": "Dark Themes", + "options": [ + { "value": "blackboard" }, + { "value": "cobalt" }, + { "value": "night" }, + { "value": "the-matrix" }, + { "value": "midnight" }, + { "value": "monokai" } + ] + } +] diff --git a/src/components/Extra.vue b/src/components/Extra.vue index cc31a8c5..526ffdcc 100644 --- a/src/components/Extra.vue +++ b/src/components/Extra.vue @@ -7,9 +7,6 @@ -
- -
@@ -278,68 +275,7 @@ -
-
- Verilog Module - - -
- -
-
- - -
- This is an experimental module. The code is not saved unless - the "Save Code" button is clicked. -
-
-
- -
Apply Themes
-
-
-
-

Select a theme:

- -
-
-
-
+ @@ -551,6 +487,7 @@ + + diff --git a/src/locales/en.json b/src/locales/en.json index 4c18c1e5..0a59ac5c 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -89,7 +89,9 @@ "verilog_module": { "reset_code": "Reset Code", "save_code": "Save Code", - "module_in_experiment_notice": "This is an experimental module. The code is not saved unless the \"Save Code\" button is clicked." + "module_in_experiment_notice": "This is an experimental module. The code is not saved unless the \"Save Code\" button is clicked.", + "apply_themes": "Apply Themes", + "select_theme": "Select a theme:" }, "layout": { "width": "Width", diff --git a/src/locales/hi.json b/src/locales/hi.json index 402cf3b2..23f5739b 100644 --- a/src/locales/hi.json +++ b/src/locales/hi.json @@ -89,7 +89,9 @@ "verilog_module": { "reset_code": "कोड रिसेट करें", "save_code": "कोड सेव करें", - "module_in_experiment_notice": "यह एक प्रायोगिक मॉड्यूल है। कोड तब तक सेव नहीं होगा जब तक \"कोड सेव करें\" बटन क्लिक नहीं किया जाता।" + "module_in_experiment_notice": "यह एक प्रायोगिक मॉड्यूल है। कोड तब तक सेव नहीं होगा जब तक \"कोड सेव करें\" बटन क्लिक नहीं किया जाता।", + "apply_themes": "थीम लागू करें", + "select_theme": "थीम चुनें:" }, "layout": { "width": "चौड़ाई", diff --git a/src/simulator/src/Verilog2CV.js b/src/simulator/src/Verilog2CV.js index ebe6fa51..46892199 100644 --- a/src/simulator/src/Verilog2CV.js +++ b/src/simulator/src/Verilog2CV.js @@ -1,4 +1,8 @@ -import { newCircuit, switchCircuit, changeCircuitName } from './circuit' +import { + createNewCircuitScope, + switchCircuit, + changeCircuitName, +} from './circuit' import SubCircuit from './subcircuit' import simulationArea from './simulationArea' import CodeMirror from 'codemirror/lib/codemirror.js' @@ -31,9 +35,14 @@ import { showProperties } from './ux' var editor var verilogMode = false -export function createVerilogCircuit() { - newCircuit(undefined, undefined, true, true) - verilogModeSet(true) +export async function createVerilogCircuit() { + const returned = await createNewCircuitScope( + undefined, + undefined, + true, + true + ) + if (returned) verilogModeSet(true) } export function saveVerilogCode() { @@ -42,9 +51,7 @@ export function saveVerilogCode() { generateVerilogCircuit(code) } -export function applyVerilogTheme() { - var dropdown = document.getElementById('selectVerilogTheme') - var theme = dropdown.options[dropdown.selectedIndex].innerHTML +export function applyVerilogTheme(theme) { localStorage.setItem('verilog-theme', theme) editor.setOption('theme', theme) } @@ -65,11 +72,11 @@ export function verilogModeSet(mode) { if (mode == verilogMode) return verilogMode = mode if (mode) { - document.getElementById('code-window').style.display = 'block'; - document.querySelector('.elementPanel').style.display = 'none'; - document.querySelector('.timing-diagram-panel').style.display = 'none'; - document.querySelector('.quick-btn').style.display = 'none'; - document.getElementById('verilogEditorPanel').style.display = 'block'; + document.getElementById('code-window').style.display = 'block' + document.querySelector('.elementPanel').style.display = 'none' + document.querySelector('.timing-diagram-panel').style.display = 'none' + document.querySelector('.quick-btn').style.display = 'none' + document.getElementById('verilogEditorPanel').style.display = 'block' if (!embed) { simulationArea.lastSelected = globalScope.root showProperties(undefined) @@ -77,11 +84,11 @@ export function verilogModeSet(mode) { } resetVerilogCode() } else { - document.getElementById('code-window').style.display = 'none'; - document.querySelector('.elementPanel').style.display = 'block'; - document.querySelector('.timing-diagram-panel').style.display = 'block'; - document.querySelector('.quick-btn').style.display = 'block'; - document.getElementById('verilogEditorPanel').style.display = 'none'; + document.getElementById('code-window').style.display = 'none' + document.querySelector('.elementPanel').style.display = '' + document.querySelector('.timing-diagram-panel').style.display = '' + document.querySelector('.quick-btn').style.display = '' + document.getElementById('verilogEditorPanel').style.display = 'none' } } @@ -180,20 +187,21 @@ export default function generateVerilogCircuit( verilogCode, scope = globalScope ) { - const url = '/simulator/verilogcv' var params = { code: verilogCode } - fetch(url, { + fetch('/simulator/verilogcv', { method: 'POST', headers: { - 'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').getAttribute('content'), + 'Content-Type': 'application/json', }, - body: params - }).then((response) => { - var errorCode = response.status - if (errorCode == 500) { - showError('Could not connect to Yosys'); - } else { - var circuitData = response + body: JSON.stringify(params), + }) + .then((response) => { + if (!response.ok) { + throw response + } + return response.json() + }) + .then((circuitData) => { scope.initialize() for (var id in scope.verilogMetadata.subCircuitScopeIds) delete scopeList[id] @@ -209,13 +217,19 @@ export default function generateVerilogCircuit( ) changeCircuitName(circuitData.name) showMessage('Verilog Circuit Successfully Created') - document.getElementById('verilogOutput').innerHTML = ""; - } - }).catch((error) => { - showError('There is some issue with the code'); - var errorMessage = error - document.getElementById('verilogOutput').innerHTML = errorMessage - }) + document.getElementById('verilogOutput').innerHTML = '' + }) + .catch((error) => { + if (error.status == 500) { + showError('Could not connect to Yosys') + } else { + showError('There is some issue with the code') + error.json().then((errorMessage) => { + document.getElementById('verilogOutput').innerHTML = + errorMessage.message + }) + } + }) } export function setupCodeMirrorEnvironment() { diff --git a/src/simulator/src/circuit.js b/src/simulator/src/circuit.js index f1f53d90..42c5c3ff 100644 --- a/src/simulator/src/circuit.js +++ b/src/simulator/src/circuit.js @@ -77,7 +77,7 @@ export function switchCircuit(id) { if (layoutModeGet()) { toggleLayoutMode() } - if (verilogModeGet()) { + if (!scopeList[id].verilogMetadata.isVerilogCircuit) { verilogModeSet(false) } @@ -170,19 +170,25 @@ export function getDependenciesList(scopeId) { /** * Wrapper function around newCircuit to be called from + button on UI */ -export async function createNewCircuitScope(name) { +export async function createNewCircuitScope( + name, + id = undefined, + isVerilog = false, + isVerilogMain = false +) { name = name ?? (await provideCircuitName()) - if (name instanceof Error) return + if (name instanceof Error) return // if user cancels the prompt if (name.trim() == '') { name = 'Untitled-Circuit' } simulationArea.lastSelected = undefined - const scope = newCircuit(name) + newCircuit(name, id, isVerilog, isVerilogMain) if (!embed) { showProperties(simulationArea.lastSelected) updateTestbenchUI() plotArea.reset() } + return true } /** @@ -216,6 +222,9 @@ export function newCircuit(name, id, isVerilog = false, isVerilogMain = false) { circuit_list.value.push(currCircuit) if (isVerilog) { scope.verilogMetadata.isVerilogCircuit = true + // TODO: remove later if not required after fixing verilog code loading from saved file + circuit_list.value.forEach((circuit) => (circuit.isVerilog = false)) + circuit_list.value[circuit_list.value.length - 1].isVerilog = true scope.verilogMetadata.isMainCircuit = isVerilogMain } globalScope = scope diff --git a/src/simulator/src/data.js b/src/simulator/src/data.js index 9e7fb773..cbdb1ac6 100644 --- a/src/simulator/src/data.js +++ b/src/simulator/src/data.js @@ -16,8 +16,9 @@ import { colorThemes } from './themer/themer' import { showTourGuide } from './tutorials' import { createVerilogCircuit, - saveVerilogCode, - resetVerilogCode, + // saveVerilogCode, + // resetVerilogCode, + // applyVerilogTheme, } from './Verilog2CV' import { generateVerilog } from './verilog' import { bitConverterDialog } from './utils' @@ -43,9 +44,10 @@ logixFunction.colorThemes = colorThemes logixFunction.showTourGuide = showTourGuideHelper logixFunction.deleteSelected = deleteSelected logixFunction.newVerilogModule = createVerilogCircuit -logixFunction.saveVerilogCode = saveVerilogCode -logixFunction.resetVerilogCode = resetVerilogCode +// logixFunction.saveVerilogCode = saveVerilogCode +// logixFunction.resetVerilogCode = resetVerilogCode logixFunction.generateVerilog = generateVerilog +// logixFunction.applyVerilogTheme = applyVerilogTheme logixFunction.bitconverter = bitConverterDialog logixFunction.createNewCircuitScope = createNewCircuitScope logixFunction.customShortcut = keyBinder diff --git a/src/simulator/src/file/Open.js b/src/simulator/src/file/Open.js new file mode 100644 index 00000000..c371be16 --- /dev/null +++ b/src/simulator/src/file/Open.js @@ -0,0 +1,96 @@ +/* **************************************************************************************************** */ +/* Implemented in ImportProject.vue Kept for reference in case any bugs occur */ +/* TODO: Remove this file after testing */ +/* **************************************************************************************************** */ + +// import load from '../data/load' +// import { generateSaveData } from '../data/save' +// import { escapeHtml } from '../ux' + +// const scopeSchema = [ +// 'layout', +// 'verilogMetadata', +// 'allNodes', +// 'id', +// 'name', +// 'restrictedCircuitElementsUsed', +// 'nodes', +// ] +// const JSONSchema = [ +// 'name', +// 'timePeriod', +// 'clockEnabled', +// 'projectId', +// 'focussedCircuit', +// 'orderedTabs', +// 'scopes', +// ] + +// var circuitData = null +// const GetDialogData = () => +// '

Browse files or Drag & Drop files here
No file chosen!!
' + +// const ImportCircuitFiles = () => { +// $('#ImportCircuitFilesDialog').empty() +// $('#ImportCircuitFilesDialog').append(GetDialogData()) +// $('#ImportCircuitFilesDialog').dialog({ +// resizable: false, +// close() { +// if (circuitData) load(circuitData) +// }, +// buttons: [ +// { +// text: 'Close', +// click() { +// $(this).dialog('close') +// }, +// }, +// ], +// }) +// $('#ImportCircuitFilesDialog').focus() + +// function ValidateData(fileData) { +// try { +// const parsedFileDate = JSON.parse(fileData) +// if ( +// JSON.stringify(Object.keys(parsedFileDate)) !== +// JSON.stringify(JSONSchema) +// ) +// throw new Error('Invalid JSON data') +// parsedFileDate.scopes.forEach((scope) => { +// const keys = Object.keys(scope) // get scope keys +// scopeSchema.forEach((key) => { +// if (!keys.includes(key)) +// throw new Error('Invalid Scope data') +// }) +// }) +// load(parsedFileDate) +// return true +// } catch (error) { +// $('#message').text('Invalid file format') +// return false +// } +// } + +// function receivedText(e) { +// // backUp data +// const backUp = JSON.parse( +// generateSaveData(escapeHtml($('#projectName').text()).trim(), false) +// ) +// const valid = ValidateData(e.target.result) // validate data +// if (!valid) { +// // fallback +// load(backUp) +// } else { +// $('#ImportCircuitFilesDialog').dialog('close') +// } +// } +// $('#CircuitDataFile').on('change', (event) => { +// var File = event.target.files[0] +// var fr = new FileReader() +// fr.onload = receivedText +// fr.readAsText(File) +// }) +// } + +// export default ImportCircuitFiles diff --git a/src/simulator/src/file/SaveAs.js b/src/simulator/src/file/SaveAs.js new file mode 100644 index 00000000..d94696a7 --- /dev/null +++ b/src/simulator/src/file/SaveAs.js @@ -0,0 +1,54 @@ +/* **************************************************************************************************** */ +/* Implemented in ExportProject.vue Kept for reference in case any bugs occur */ +/* TODO: Remove this file after testing */ +/* **************************************************************************************************** */ + +// import { download, generateSaveData } from '../data/save' +// import { escapeHtml } from '../ux' + +// const GetDialogData = () => { +// const fileName = `${$('#projectName').text().trim()}.cv` +// const Input = document.createElement('input') +// Input.type = 'text' +// Input.name = 'fileName' +// Input.setAttribute('placeholder', fileName) +// Input.id = 'filename' +// Input.defaultValue = fileName +// const Label = document.createElement('label') +// Label.setAttribute('for', 'filename') +// Label.textContent = 'File Name' +// const container = document.createElement('div') +// container.appendChild(Label) +// container.appendChild(Input) +// return container +// } + +// /** +// * To Export Circuit Files +// */ +// const ExportCircuitFiles = () => { +// $('#ExportCircuitFilesDialog').empty() +// $('#ExportCircuitFilesDialog').append(GetDialogData()) +// $('#ExportCircuitFilesDialog').dialog({ +// resizable: false, +// buttons: [ +// { +// text: 'Save', +// click() { +// var fileName = +// escapeHtml($('#filename').val()) || 'untitled' +// const circuitData = generateSaveData( +// fileName.split('.')[0], +// false +// ) +// fileName = `${fileName.split('.')[0]}.cv` +// download(fileName, circuitData) +// $(this).dialog('close') +// }, +// }, +// ], +// }) +// $('#ExportCircuitFilesDialog').focus() +// } + +// export default ExportCircuitFiles diff --git a/src/simulator/src/ux.js b/src/simulator/src/ux.js index cc86c98f..0208e64a 100644 --- a/src/simulator/src/ux.js +++ b/src/simulator/src/ux.js @@ -24,7 +24,6 @@ import { generateImage, generateSaveData } from './data/save' import { setupVerilogExportCodeWindow } from './verilog' import { setupBitConvertor } from './utils' import { updateTestbenchUI, setupTestbenchUI } from './testbench' -import { applyVerilogTheme } from './Verilog2CV' export const uxvar = { smartDropXX: 50, @@ -173,9 +172,6 @@ export function setupUI() { // var dummyCounter=0; // calling apply on select theme in dropdown - $('.applyTheme').on('change', function () { - applyVerilogTheme() - }) $('#report').on('click', function () { var message = $('#issuetext').val() diff --git a/src/styles/css/main.stylesheet.css b/src/styles/css/main.stylesheet.css index b246e156..4ee10246 100644 --- a/src/styles/css/main.stylesheet.css +++ b/src/styles/css/main.stylesheet.css @@ -1881,7 +1881,7 @@ canvas { /*! Custom Color theme dialog styles ends here*/ .code-window .CodeMirror { - height: calc(100% - 78px); + height: calc(100vh - 78px); overflow: scroll; } From ed8af92a218c9bbb0a53b148539ed6a54afdb8a4 Mon Sep 17 00:00:00 2001 From: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> Date: Wed, 6 Sep 2023 00:39:57 +0530 Subject: [PATCH 03/22] feat(gsoc): convert report issue to vue component (#174) * convert issue report form to Vue component in composition api + typescript & i18n support Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(report-issue): convert report Issue to vue component with typescript and i18n support Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): fix tabbar issue, project loading, updating, circuit delete, circuit name change, circuit switching, etc issues Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(netlify-build): add / to check netlify build fixes Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(netlify): add _redirects to fix routing issues with netlify deployment Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(netlify): update netlify.toml to get _redirects to correct directory after build Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(netlify): move redirects to neltify.toml Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): update types for store and naming error fixes Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(gsoc): quit saving on clicking cancle while entering new proejct name from simualtor Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): update prompt component structure to make it a common helper component Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): fix cancle on save unify circuit creation and deletion with seperate helper vue components and remove watch and setInterval to improve performance Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): add new project creation, project details update on create from simulator, confirm component to replace confirm() and alert() Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * update(gsoc): convert alert() and confirm() to use vue component Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): add import & export as .cv file with independent vue components Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): update updateProjectDetails.vue to show tags as chips while entering in the update project form Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): update setup fucntion and fix linting issues, remove setTimeout of 1 second for testing Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(gsoc): recover project not saving to localStorage due to generateSaveData being async function Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(lint): fix linting issues in save.js & remove var from setup.js for const Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(jwt): add jwt in Authorization header Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(linting): data.spec.js remove unused parameter "text" from line 26 Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(lint): fix codeclimate linting issues Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(lint): fix linting issues Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): convert report issue to vue component * chore(gsoc): store client_ID in a variable Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(ReportIssue): remove from global state as not necessary atm Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * chore(codeql): remove hardcoded values Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * fix(lint): add client ID back in Authorization Header Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): update buttons to be flexed Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> --------- Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> --- src/components/Extra.vue | 78 +---- src/components/ReportIssue/ReportIssue.vue | 274 ++++++++++++++++++ .../ReportIssue/ReportIssueButton.vue | 25 ++ src/locales/en.json | 7 +- src/locales/hi.json | 7 +- src/simulator/src/ux.js | 86 ------ 6 files changed, 311 insertions(+), 166 deletions(-) create mode 100644 src/components/ReportIssue/ReportIssue.vue create mode 100644 src/components/ReportIssue/ReportIssueButton.vue diff --git a/src/components/Extra.vue b/src/components/Extra.vue index 526ffdcc..f66eb872 100644 --- a/src/components/Extra.vue +++ b/src/components/Extra.vue @@ -407,82 +407,7 @@ - - - - - - + @@ -499,4 +424,5 @@ import ExportVerilog from './DialogBox/ExportVerilog.vue' import CustomShortcut from './DialogBox/CustomShortcut.vue' import InsertSubcircuit from './DialogBox/InsertSubcircuit.vue' import OpenOffline from './DialogBox/OpenOffline.vue' +import ReportIssue from './ReportIssue/ReportIssue.vue' diff --git a/src/components/ReportIssue/ReportIssue.vue b/src/components/ReportIssue/ReportIssue.vue new file mode 100644 index 00000000..14a9c288 --- /dev/null +++ b/src/components/ReportIssue/ReportIssue.vue @@ -0,0 +1,274 @@ + + + + + diff --git a/src/components/ReportIssue/ReportIssueButton.vue b/src/components/ReportIssue/ReportIssueButton.vue new file mode 100644 index 00000000..f67be3e3 --- /dev/null +++ b/src/components/ReportIssue/ReportIssueButton.vue @@ -0,0 +1,25 @@ + + + diff --git a/src/locales/en.json b/src/locales/en.json index 0a59ac5c..8850887e 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -131,8 +131,11 @@ }, "report_issue": { "describe_issue": "Describe your issue:", - "email_html": "Email [Optional]:", - "report_btn": "Report" + "email": "Email", + "optional": " [Optional]", + "report_btn": "Report", + "cancel_btn": "Cancel", + "close_btn": "Close" } }, "tooltip": { diff --git a/src/locales/hi.json b/src/locales/hi.json index 23f5739b..b91c00d5 100644 --- a/src/locales/hi.json +++ b/src/locales/hi.json @@ -131,8 +131,11 @@ }, "report_issue": { "describe_issue": "अपनी समस्या का वर्णन करें:", - "email_html": "ईमेल [वैकल्पिक]:", - "report_btn": "रिपोर्ट करें" + "email": "ईमेल", + "optional": " [वैकल्पिक]", + "report_btn": "रिपोर्ट करें", + "cancel_btn": "रद्द करें", + "close_btn": "बंद करें" } }, "tooltip": { diff --git a/src/simulator/src/ux.js b/src/simulator/src/ux.js index 0208e64a..f40fb857 100644 --- a/src/simulator/src/ux.js +++ b/src/simulator/src/ux.js @@ -173,34 +173,6 @@ export function setupUI() { // calling apply on select theme in dropdown - $('#report').on('click', function () { - var message = $('#issuetext').val() - var email = $('#emailtext').val() - message += '\nEmail:' + email - message += '\nURL: ' + window.location.href - message += `\nUser Id: ${window.user_id}` - postUserIssue(message) - $('#issuetext').hide() - $('#emailtext').hide() - $('#report').hide() - $('#report-label').hide() - $('#email-label').hide() - }) - $('.issue').on('hide.bs.modal', function (e) { - listenToSimulator = true - $('#result').html('') - $('#issuetext').show() - $('#emailtext').show() - $('#issuetext').val('') - $('#emailtext').val('') - $('#report').show() - $('#report-label').show() - $('#email-label').show() - }) - $('#reportIssue').on('click', function () { - listenToSimulator = false - }) - // $('#saveAsImg').on('click',function(){ // saveAsImg(); // }); @@ -867,61 +839,3 @@ export function fillSubcircuitElements() { this.parentElement.removeChild(this) }) } - -async function postUserIssue(message) { - var img = generateImage('jpeg', 'full', false, 1, false).split(',')[1] - - let result - try { - result = await $.ajax({ - url: 'https://api.imgur.com/3/image', - type: 'POST', - data: { - image: img, - }, - dataType: 'json', - headers: { - Authorization: 'Client-ID 9a33b3b370f1054', - }, - }) - } catch (err) { - console.error('Could not generate image, reporting anyway') - } - - if (result) message += '\n' + result.data.link - - // Generate circuit data for reporting - let circuitData - try { - // Writing default project name to prevent unnecessary prompt in case the - // project is unnamed - circuitData = generateSaveData('Untitled') - } catch (err) { - circuitData = `Circuit data generation failed: ${err}` - } - - $.ajax({ - url: '/simulator/post_issue', - type: 'POST', - beforeSend: function (xhr) { - xhr.setRequestHeader( - 'X-CSRF-Token', - $('meta[name="csrf-token"]').attr('content') - ) - }, - data: { - text: message, - circuit_data: circuitData, - }, - success: function (response) { - $('#result').html( - " You've successfully submitted the issue. Thanks for improving our platform." - ) - }, - failure: function (err) { - $('#result').html( - " There seems to be a network issue. Please reach out to us at support@ciruitverse.org" - ) - }, - }) -} From 328e27e4e0a4e9b1f9fa8ada62090e3f405d484c Mon Sep 17 00:00:00 2001 From: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> Date: Wed, 6 Sep 2023 00:45:33 +0530 Subject: [PATCH 04/22] feat(gsoc): convert QuickMenu to vue component (#175) * fix(QuickButton): convert QucikButtonPanel to vue component Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> * feat(gsoc): convert drag dots to .svg file Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> --------- Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> --- .../Navbar/QuickButton/QuickButton.vue | 329 ++++++++++++------ src/simulator/src/data.js | 3 +- src/simulator/src/listeners.js | 80 +++-- src/simulator/src/ux.js | 47 ++- src/styles/color_theme.scss | 8 - src/styles/css/assets/shorcuts/dragDots.svg | 86 +++++ src/styles/css/main.stylesheet.css | 133 ------- 7 files changed, 379 insertions(+), 307 deletions(-) create mode 100644 src/styles/css/assets/shorcuts/dragDots.svg diff --git a/src/components/Navbar/QuickButton/QuickButton.vue b/src/components/Navbar/QuickButton/QuickButton.vue index 35a6e221..aad07b93 100644 --- a/src/components/Navbar/QuickButton/QuickButton.vue +++ b/src/components/Navbar/QuickButton/QuickButton.vue @@ -1,131 +1,39 @@ - + diff --git a/src/simulator/src/data.js b/src/simulator/src/data.js index cbdb1ac6..4e573c21 100644 --- a/src/simulator/src/data.js +++ b/src/simulator/src/data.js @@ -1,4 +1,4 @@ -import { fullView, deleteSelected } from './ux' +import { fullView } from './ux' import { createSubCircuitPrompt } from './subcircuit' import save from './data/save' import load from './data/load' @@ -42,7 +42,6 @@ logixFunction.createCombinationalAnalysisPrompt = logixFunction.fullViewOption = fullView logixFunction.colorThemes = colorThemes logixFunction.showTourGuide = showTourGuideHelper -logixFunction.deleteSelected = deleteSelected logixFunction.newVerilogModule = createVerilogCircuit // logixFunction.saveVerilogCode = saveVerilogCode // logixFunction.resetVerilogCode = resetVerilogCode diff --git a/src/simulator/src/listeners.js b/src/simulator/src/listeners.js index 99a4b9c5..2730767c 100644 --- a/src/simulator/src/listeners.js +++ b/src/simulator/src/listeners.js @@ -44,27 +44,29 @@ var unit = 10 var listenToSimulator = true export default function startListeners() { - $('#deleteSelected').on('click', () => { - deleteSelected() - }) - - $('#zoomIn').on('click', () => { - changeScale(0.2, 'zoomButton', 'zoomButton', 2) - }) - - $('#zoomOut').on('click', () => { - changeScale(-0.2, 'zoomButton', 'zoomButton', 2) - }) - - $('#undoButton').on('click', () => { - undo() - }) - $('#redoButton').on('click', () => { - redo() - }) - $('#viewButton').on('click', () => { - fullView() - }) + // added the below functionalities in QuickButton.vue component local script tag part + + // $('#deleteSelected').on('click', () => { + // deleteSelected() + // }) + + // $('#zoomIn').on('click', () => { + // changeScale(0.2, 'zoomButton', 'zoomButton', 2) + // }) + + // $('#zoomOut').on('click', () => { + // changeScale(-0.2, 'zoomButton', 'zoomButton', 2) + // }) + + // $('#undoButton').on('click', () => { + // undo() + // }) + // $('#redoButton').on('click', () => { + // redo() + // }) + // $('#viewButton').on('click', () => { + // fullView() + // }) $(document).on('keyup', (e) => { if (e.key === 'Escape') exitFullView() @@ -735,21 +737,25 @@ function zoomSliderListeners() { curLevel = zoomLevel } } - function sliderZoomButton(direction) { - var zoomSlider = $('#customRange1') - var currentSliderValue = parseInt(zoomSlider.val(), 10) - if (direction === -1) { - currentSliderValue-- - } else { - currentSliderValue++ - } - zoomSlider.val(currentSliderValue).change() - } - $('#decrement').click(() => { - sliderZoomButton(-1) - }) - $('#increment').click(() => { - sliderZoomButton(1) - }) + // previously used for the + and - zoom buttons in quickButtons + + // function sliderZoomButton(direction) { + // var zoomSlider = $('#customRange1') + // var currentSliderValue = parseInt(zoomSlider.val(), 10) + // if (direction === -1) { + // currentSliderValue-- + // } else { + // currentSliderValue++ + // } + // zoomSlider.val(currentSliderValue).change() + // } + + // $('#decrement').click(() => { + // sliderZoomButton(-1) + // }) + + // $('#increment').click(() => { + // sliderZoomButton(1) + // }) } diff --git a/src/simulator/src/ux.js b/src/simulator/src/ux.js index f40fb857..361c6855 100644 --- a/src/simulator/src/ux.js +++ b/src/simulator/src/ux.js @@ -763,28 +763,39 @@ function setupPanelListeners(panelSelector) { } export function exitFullView() { - $('.navbar').show() - $('.modules').show() - $('.report-sidebar').show() - $('#tabsBar').show() - $('#exitViewBtn').remove() - $('#moduleProperty').show() - $('.timing-diagram-panel').show() - $('.testbench-manual-panel').show() + const exitViewBtn = document.querySelector('#exitViewBtn') + if (exitViewBtn) exitViewBtn.remove() + + const elements = document.querySelectorAll( + '.navbar, .modules, .report-sidebar, #tabsBar, #moduleProperty, .timing-diagram-panel, .testbench-manual-panel, .quick-btn' + ) + elements.forEach((element) => { + if (element instanceof HTMLElement) { + element.style.display = '' + } + }) } export function fullView() { - const markUp = `` - $('.navbar').hide() - $('.modules').hide() - $('.report-sidebar').hide() - $('#tabsBar').hide() - $('#moduleProperty').hide() - $('.timing-diagram-panel').hide() - $('.testbench-manual-panel').hide() - $('#exitView').append(markUp) - $('#exitViewBtn').on('click', exitFullView) + const app = document.querySelector('#app') + + const exitViewEl = document.createElement('button') + exitViewEl.id = 'exitViewBtn' + exitViewEl.textContent = 'Exit Full Preview' + + const elements = document.querySelectorAll( + '.navbar, .modules, .report-sidebar, #tabsBar, #moduleProperty, .timing-diagram-panel, .testbench-manual-panel, .quick-btn' + ) + elements.forEach((element) => { + if (element instanceof HTMLElement) { + element.style.display = 'none' + } + }) + + app.appendChild(exitViewEl) + exitViewEl.addEventListener('click', exitFullView) } + /** Fills the elements that can be displayed in the subcircuit, in the subcircuit menu **/ diff --git a/src/styles/color_theme.scss b/src/styles/color_theme.scss index 0b067258..85a9b0ad 100644 --- a/src/styles/color_theme.scss +++ b/src/styles/color_theme.scss @@ -145,14 +145,6 @@ $output-rect: blue; background: var(--bg-navbar); } -.quick-btn { - background: var(--bg-navbar); - border-top: 1.5px solid var(--qp-br-tl); - border-left: 1.5px solid var(--qp-br-tl); - border-right: 1.5px solid var(--qp-br-rd); - border-bottom: 1.5px solid var(--qp-br-rd); -} - .dropdown > ul { background-color: var(--bg-primary-moz); border: 0.5px solid var(--bg-tabs); diff --git a/src/styles/css/assets/shorcuts/dragDots.svg b/src/styles/css/assets/shorcuts/dragDots.svg new file mode 100644 index 00000000..dacde439 --- /dev/null +++ b/src/styles/css/assets/shorcuts/dragDots.svg @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/styles/css/main.stylesheet.css b/src/styles/css/main.stylesheet.css index 4ee10246..27a59afd 100644 --- a/src/styles/css/main.stylesheet.css +++ b/src/styles/css/main.stylesheet.css @@ -240,78 +240,6 @@ input[type='text']:focus { margin-right: 36px; } -.quick-btn { - display: flex; - position: absolute; - width: 400px; - height: 33px; - top: 90px; - right: 280px; - border-radius: 7px; - z-index: 100; -} - -.quick-btn > div { - margin: auto; -} - -.quick-btn > div > button { - margin: auto; - border: none; -} - -.quick-btn-save-online { - background: url(./assets/shorcuts/save-online.svg) center/cover; - width: 21.43px; - height: 15.2px; - display: block; -} - -.quick-btn-save { - background: url(./assets/shorcuts/save.svg) center/cover; - width: 15.2px; - height: 15.2px; - display: block; -} - -.quick-btn-delete { - background: url(./assets/shorcuts/delete.svg) center/cover; - width: 20px; - height: 15.2px; - display: block; -} - -.quick-btn-download { - background: url(./assets/shorcuts/download.svg) center/cover; - width: 15.2px; - height: 15.2px; - display: block; -} - -.quick-btn-zoom-fit { - background: url(./assets/shorcuts/fit.svg) center/cover; - width: 15.2px; - height: 15.2px; - display: block; -} - -.quick-btn-undo { - background: url(./assets/shorcuts/undo.svg) center/cover; - width: 15.2px; - height: 16.2px; - display: block; -} - -.quick-btn-redo { - background: url(./assets/shorcuts/redo.svg) center/cover; - width: 15.2px; - height: 16.2px; - display: block; -} - -.quick-btn-view { - color: white; -} /* dropdown-menu styles */ .dropdown > ul { @@ -1670,57 +1598,6 @@ input:checked + .slider:before { border-radius: 3px; } -.zoom-slider { - color: white; - font-size: 20px; -} - -.zoom-slider-increment { - position: relative; - bottom: 0.3rem; -} -.zoom-slider-decrement { - position: relative; - bottom: 0.4rem; -} - -.custom-range { - width: 80px !important; -} -.custom-range::-moz-range-track { - height: 1px; -} - -.custom-range::-moz-range-thumb { - width: 10px; - height: 10px; - background-color: white; - border: 0; - border-radius: 50%; - cursor: pointer; -} -.custom-range:focus::-moz-range-thumb { - box-shadow: 0 0 0 1px #fff, 0 0 0 0.2rem rgba(75, 86, 99, 0.25); -} - -input[type='range'] { - -webkit-appearance: none; -} - -input[type='range']::-webkit-slider-runnable-track { - height: 1px; -} - -input[type='range']::-webkit-slider-thumb { - -webkit-appearance: none; - width: 10px; - height: 10px; - background-color: white; - border: 0; - border-radius: 50%; - cursor: pointer; -} - .draggable-panel-css .minimize { position: absolute; right: 15px; @@ -1772,16 +1649,6 @@ input[type='range']::-webkit-slider-thumb { border-radius: 5px; } -.panel-drag { - cursor: move; - opacity: 0.6; - /* display: grid; - grid-template-columns: 1fr 1fr; - grid-template-rows: 1fr 1fr 1fr 1fr 1fr 1fr; - padding: 6px 0; - width: 1px; */ -} - .ce-hidden, .prop-hidden { cursor: move; From 2d26319d162e5ccc670c2856584cbcab46e09d55 Mon Sep 17 00:00:00 2001 From: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> Date: Wed, 6 Sep 2023 00:50:01 +0530 Subject: [PATCH 05/22] feat(gsoc): fix insert subcircuit logic & error (#180) Signed-off-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> --- src/components/DialogBox/InsertSubcircuit.vue | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/components/DialogBox/InsertSubcircuit.vue b/src/components/DialogBox/InsertSubcircuit.vue index 3500640b..f2c1b1a6 100644 --- a/src/components/DialogBox/InsertSubcircuit.vue +++ b/src/components/DialogBox/InsertSubcircuit.vue @@ -26,10 +26,7 @@ :key="scopeId" >
@@ -23,6 +25,7 @@ title="Decrease Height" variant="text" icon="mdi-minus" + @click.prevent="layoutFunction('decreaseLayoutHeight')" /> Height
Reset all nodes: - +
Title @@ -45,42 +54,55 @@ active-class="no-active" variant="outlined" icon="mdi-chevron-up" + @click.prevent="layoutFunction('layoutTitleUp')" />
Title Enabled:
- @@ -90,13 +112,24 @@ diff --git a/src/router/index.ts b/src/router/index.ts index 6659082b..730aea09 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,6 +1,6 @@ import { createRouter, createWebHistory } from 'vue-router' -// import simulator from '../pages/simulator.vue' import simulatorHandler from '../pages/simulatorHandler.vue' +import Embed from '../pages/embed.vue' const routes = [ { @@ -10,18 +10,28 @@ const routes = [ { path: '/simulatorvue', // @TODO: update later back to /simulator name: 'simulator', - // component: simulator, component: simulatorHandler, children: [ { path: 'edit/:projectId', name: 'simulator-edit', - // component: simulator, component: simulatorHandler, props: true, }, ], }, + { + path: '/simulatorvue/:projectId', + name: 'simulator-view', + component: Embed, + props: true, + }, + { + path: '/simulatorvue/embed/:projectId', + name: 'simulator-embed', + component: Embed, + props: true, + }, ] const router = createRouter({ history: createWebHistory(), diff --git a/src/simulator/src/circuit.js b/src/simulator/src/circuit.js index 42c5c3ff..f86429e3 100644 --- a/src/simulator/src/circuit.js +++ b/src/simulator/src/circuit.js @@ -256,14 +256,15 @@ export function newCircuit(name, id, isVerilog = false, isVerilogMain = false) { // switch circuit function moved inside vue component - $('.circuitName').on('click', (e) => { - simulationArea.lastSelected = globalScope.root - setTimeout(() => { - // here link with the properties panel - document.getElementById('circname').select() - }, 100) - }) - + if (!embed) { + $('.circuitName').on('click', () => { + simulationArea.lastSelected = globalScope.root + setTimeout(() => { + // here link with the properties panel + document.getElementById('circname').select() + }, 100) + }) + } // moved inside vue - component // $('.tabsCloseButton').on('click', function (e) { // e.stopPropagation() diff --git a/src/simulator/src/embed.js b/src/simulator/src/embed.js index fb89b247..b17e82ba 100644 --- a/src/simulator/src/embed.js +++ b/src/simulator/src/embed.js @@ -1,132 +1,132 @@ -/* eslint-disable import/no-cycle */ -// Helper functions for when circuit is embedded -import { scopeList, circuitProperty } from './circuit' -import simulationArea from './simulationArea' -import { - scheduleUpdate, - wireToBeCheckedSet, - updateCanvasSet, - gridUpdateSet, -} from './engine' -import { prevPropertyObjGet, prevPropertyObjSet } from './ux' -import { ZoomIn, ZoomOut } from './listeners' +// /* eslint-disable import/no-cycle */ +// // Helper functions for when circuit is embedded +// import { scopeList, circuitProperty } from './circuit' +// import simulationArea from './simulationArea' +// import { +// scheduleUpdate, +// wireToBeCheckedSet, +// updateCanvasSet, +// gridUpdateSet, +// } from './engine' +// import { prevPropertyObjGet, prevPropertyObjSet } from './ux' +// import { ZoomIn, ZoomOut } from './listeners' -// circuitProperty.toggleFullScreen = toggleFullScreen; -$(document).ready(() => { - // Clock features - $('#clockProperty').append( - " " - ) - $('#clockProperty').append( - `
Time:
` - ) - $('#clockProperty').append( - `
Clock:
` - ) +// // circuitProperty.toggleFullScreen = toggleFullScreen; +// $(document).ready(() => { +// // Clock features +// $('#clockProperty').append( +// " " +// ) +// $('#clockProperty').append( +// `
Time:
` +// ) +// $('#clockProperty').append( +// `
Clock:
` +// ) - // Following codes need to be removed - $('.objectPropertyAttributeEmbed').on( - 'change keyup paste click', - function () { - scheduleUpdate() - updateCanvasSet(true) - wireToBeCheckedSet(1) - if ( - simulationArea.lastSelected && - simulationArea.lastSelected[this.name] - ) { - prevPropertyObjSet( - simulationArea.lastSelected[this.name](this.value) - ) || prevPropertyObjGet() - } else { - circuitProperty[this.name](this.value) - } - } - ) +// // Following codes need to be removed +// $('.objectPropertyAttributeEmbed').on( +// 'change keyup paste click', +// function () { +// scheduleUpdate() +// updateCanvasSet(true) +// wireToBeCheckedSet(1) +// if ( +// simulationArea.lastSelected && +// simulationArea.lastSelected[this.name] +// ) { +// prevPropertyObjSet( +// simulationArea.lastSelected[this.name](this.value) +// ) || prevPropertyObjGet() +// } else { +// circuitProperty[this.name](this.value) +// } +// } +// ) - // Following codes need to be removed - $('.objectPropertyAttributeEmbedChecked').on( - 'change keyup paste click', - function () { - scheduleUpdate() - updateCanvasSet(true) - wireToBeCheckedSet(1) - if ( - simulationArea.lastSelected && - simulationArea.lastSelected[this.name] - ) { - prevPropertyObjSet( - simulationArea.lastSelected[this.name](this.value) - ) || prevPropertyObjGet() - } else { - circuitProperty[this.name](this.checked) - } - } - ) +// // Following codes need to be removed +// $('.objectPropertyAttributeEmbedChecked').on( +// 'change keyup paste click', +// function () { +// scheduleUpdate() +// updateCanvasSet(true) +// wireToBeCheckedSet(1) +// if ( +// simulationArea.lastSelected && +// simulationArea.lastSelected[this.name] +// ) { +// prevPropertyObjSet( +// simulationArea.lastSelected[this.name](this.value) +// ) || prevPropertyObjGet() +// } else { +// circuitProperty[this.name](this.checked) +// } +// } +// ) - $('#zoom-in-embed').on('click', () => ZoomIn()) +// $('#zoom-in-embed').on('click', () => ZoomIn()) - $('#zoom-out-embed').on('click', () => ZoomOut()) -}) +// $('#zoom-out-embed').on('click', () => ZoomOut()) +// }) -// Full screen toggle helper function -function toggleFullScreen(value) { - if (!getfullscreenelement()) { - GoInFullscreen(document.documentElement) - } else { - GoOutFullscreen() - } -} -// Center focus accordingly -function exitHandler() { - setTimeout(() => { - Object.keys(scopeList).forEach((id) => { - scopeList[id].centerFocus(true) - }) - gridUpdateSet(true) - scheduleUpdate() - }, 100) -} +// // Full screen toggle helper function +// function toggleFullScreen(value) { +// if (!getfullscreenelement()) { +// GoInFullscreen(document.documentElement) +// } else { +// GoOutFullscreen() +// } +// } +// // Center focus accordingly +// function exitHandler() { +// setTimeout(() => { +// Object.keys(scopeList).forEach((id) => { +// scopeList[id].centerFocus(true) +// }) +// gridUpdateSet(true) +// scheduleUpdate() +// }, 100) +// } -function GoInFullscreen(element) { - if (element.requestFullscreen) { - element.requestFullscreen() - } else if (element.mozRequestFullScreen) { - element.mozRequestFullScreen() - } else if (element.webkitRequestFullscreen) { - element.webkitRequestFullscreen() - } else if (element.msRequestFullscreen) { - element.msRequestFullscreen() - } -} +// function GoInFullscreen(element) { +// if (element.requestFullscreen) { +// element.requestFullscreen() +// } else if (element.mozRequestFullScreen) { +// element.mozRequestFullScreen() +// } else if (element.webkitRequestFullscreen) { +// element.webkitRequestFullscreen() +// } else if (element.msRequestFullscreen) { +// element.msRequestFullscreen() +// } +// } -function GoOutFullscreen() { - if (document.exitFullscreen) { - document.exitFullscreen() - } else if (document.mozCancelFullScreen) { - document.mozCancelFullScreen() - } else if (document.webkitExitFullscreen) { - document.webkitExitFullscreen() - } else if (document.msExitFullscreen) { - document.msExitFullscreen() - } -} +// function GoOutFullscreen() { +// if (document.exitFullscreen) { +// document.exitFullscreen() +// } else if (document.mozCancelFullScreen) { +// document.mozCancelFullScreen() +// } else if (document.webkitExitFullscreen) { +// document.webkitExitFullscreen() +// } else if (document.msExitFullscreen) { +// document.msExitFullscreen() +// } +// } -function getfullscreenelement() { - return ( - document.fullscreenElement || - document.webkitFullscreenElement || - document.mozFullScreenElement || - document.msFullscreenElement - ) -} +// function getfullscreenelement() { +// return ( +// document.fullscreenElement || +// document.webkitFullscreenElement || +// document.mozFullScreenElement || +// document.msFullscreenElement +// ) +// } -// Full screen Listeners -if (document.addEventListener) { - document.addEventListener('webkitfullscreenchange', exitHandler, false) - document.addEventListener('mozfullscreenchange', exitHandler, false) - document.addEventListener('fullscreenchange', exitHandler, false) - document.addEventListener('MSFullscreenChange', exitHandler, false) -} +// // Full screen Listeners +// if (document.addEventListener) { +// document.addEventListener('webkitfullscreenchange', exitHandler, false) +// document.addEventListener('mozfullscreenchange', exitHandler, false) +// document.addEventListener('fullscreenchange', exitHandler, false) +// document.addEventListener('MSFullscreenChange', exitHandler, false) +// } diff --git a/src/simulator/src/setup.js b/src/simulator/src/setup.js index 0140e1e7..92850329 100644 --- a/src/simulator/src/setup.js +++ b/src/simulator/src/setup.js @@ -12,7 +12,7 @@ import { dots } from './canvasApi' import { update, updateSimulationSet, updateCanvasSet } from './engine' import { setupUI } from './ux' import startMainListeners from './listeners' -import startEmbedListeners from './embedListeners' +// import startEmbedListeners from './embedListeners' import './embed' import { newCircuit, scopeList } from './circuit' import load from './data/load' @@ -199,14 +199,15 @@ function showTour() { * @category setup */ export function setup() { - let embed = false - const startListeners = embed ? startEmbedListeners : startMainListeners + // let embed = false + // const startListeners = embed ? startEmbedListeners : startMainListeners setupElementLists() setupEnvironment() if (!embed) { setupUI() + startMainListeners() } - startListeners() + // startListeners() loadProjectData() showTour() } From 068eadc9d2834a619b98637c2fe8bd2c96ffef4e Mon Sep 17 00:00:00 2001 From: Disha Talreja Date: Mon, 23 Oct 2023 12:37:47 +0530 Subject: [PATCH 12/22] Updated the Readme with setup information and pending tasks (#192) * Updated the readme with setup information --- README.md | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 9234081d..682eb35a 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,28 @@ -# GSoC'22 Project - [WIP]VueJS Simulator +# CircuitVerse Frontend Vue -## New Frontend Framework for Simulator UI. -- [Phase-1 Report](https://blog.circuitverse.org/posts/devjitchoudhury_gsoc22_phase1_report/) -- [Phase-2 Report](https://blog.circuitverse.org/posts/devjitchoudhury_gsoc22_phase2_report/) +## Installation +To set up the project on your local machine, follow these steps: -### Project Goals - -1. Replacing JqueryUI with a modern frontend framework. -2. Decoupling the Simulator from backend -3. Dividing into Components -4. State Management -5. Refactoring CSS -6. Internationalization using Vue-i18n +1. Clone the repository to your local machine using the following command: +``` +git clone https://github.com/CircuitVerse/cv-frontend-vue.git +``` +2. Navigate to the project directory: +``` +cd cv-frontend-vue +``` +3. Install the project dependencies: +``` +npm install +``` +4. Start the development server: +``` +npm run dev +``` - -### To Dos - -1. **Vue Project Integration** into the Main Repository or finding a way for the simulators in two different repositories to work in sync. -2. **API Integration and Testing** -3. **Embed Feature** - Discuss and implement the embeding of circuits feature. -4. **Internationalization of Simulator** - Internationalization is already set up using Vue-i18n but progressive work needs to be done on it. -5. **Refactoring of Styles** - Refactor the global stylesheet to local stylesheets for individual components. There is also a scope of removing SASS using modern CSS features. -6. Few components - Verilog Module, Quick-Button, Testbench, and Timing-Diagram are yet to be converted to Vue. -7. With the removal of jQuery-UI, there is also a scope of removing the use of jQuery from the project. +## To Dos - +1. **Creating the mobile version of the vue simulator** +2. **Testing and bug fixing** +3. **Typescript integration & style Refactoring** +4. **Creating the desktop application** +5. **Removing JQuery** From 6d01e25d5aca48ea6d7de2c0b69038be1c3d41f6 Mon Sep 17 00:00:00 2001 From: Aboobacker MK Date: Mon, 23 Oct 2023 12:40:23 +0530 Subject: [PATCH 13/22] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..f0f6ad1d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Satvik Ramaprasad + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From 5bef5c632ed10f2729ea5784d978f33c2e4a8d13 Mon Sep 17 00:00:00 2001 From: Aryann Dwivedi Date: Mon, 18 Dec 2023 11:10:32 +0530 Subject: [PATCH 14/22] feat(drag): bug fixes for drag.ts (#201) * fix(drag): fixes draggable-panel bug --- src/simulator/src/drag.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simulator/src/drag.ts b/src/simulator/src/drag.ts index 0ccbed64..2e14abca 100644 --- a/src/simulator/src/drag.ts +++ b/src/simulator/src/drag.ts @@ -73,8 +73,8 @@ export function dragging(targetEl: HTMLElement, DragEl: HTMLElement): void { }) $(DragEl).on('mousedown', () => { - $(`.draggable-panel:not(${DragEl})`).css('z-index', '100') - $(DragEl).css('z-index', '101') + $(`.draggable-panel:not(${DragEl})`).css('z-index', '99') + $(DragEl).css('z-index', '99') }) let panelElements = document.querySelectorAll( From 8a606cb4a785f75b404d4a49e47570652690ed73 Mon Sep 17 00:00:00 2001 From: Dhairya Majmudar <124715224+DhairyaMajmudar@users.noreply.github.com> Date: Wed, 3 Jan 2024 10:38:43 +0530 Subject: [PATCH 15/22] Removing console warnings and errors (#214) * Remove Console Error * build warning fixed * remove unnecessary comments --- package-lock.json | 14 +- package.json | 2 +- src/components/MessageBox/messageBox.vue | 1 - src/components/Navbar/Hamburger/Hamburger.vue | 4 +- .../ReportIssue/ReportIssueButton.vue | 1 - src/styles/color_theme.scss | 185 ++++++------------ src/styles/css/2-basics/base.scss | 7 +- src/styles/css/5-layout/simulator.scss | 2 +- 8 files changed, 74 insertions(+), 142 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2960b291..d1e3d229 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0", "hasInstallScript": true, "dependencies": { - "@fortawesome/fontawesome-free": "^5.15.4", + "@fortawesome/fontawesome-free": "^6.5.1", "@mdi/font": "5.9.55", "@tiptap/core": "^2.0.3", "@tiptap/extension-character-count": "^2.0.3", @@ -907,9 +907,9 @@ } }, "node_modules/@fortawesome/fontawesome-free": { - "version": "5.15.4", - "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.4.tgz", - "integrity": "sha512-eYm8vijH/hpzr/6/1CJ/V/Eb1xQFW2nnUKArb3z+yUWv7HTwj6M7SP957oMjfZjAHU6qpoNc2wQvIxBLWYa/Jg==", + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.5.1.tgz", + "integrity": "sha512-CNy5vSwN3fsUStPRLX7fUYojyuzoEMSXPl7zSLJ8TgtRfjv24LOnOWKT2zYwaHZCJGkdyRnTmstR0P+Ah503Gw==", "hasInstallScript": true, "engines": { "node": ">=6" @@ -7601,9 +7601,9 @@ } }, "@fortawesome/fontawesome-free": { - "version": "5.15.4", - "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.15.4.tgz", - "integrity": "sha512-eYm8vijH/hpzr/6/1CJ/V/Eb1xQFW2nnUKArb3z+yUWv7HTwj6M7SP957oMjfZjAHU6qpoNc2wQvIxBLWYa/Jg==" + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.5.1.tgz", + "integrity": "sha512-CNy5vSwN3fsUStPRLX7fUYojyuzoEMSXPl7zSLJ8TgtRfjv24LOnOWKT2zYwaHZCJGkdyRnTmstR0P+Ah503Gw==" }, "@humanwhocodes/config-array": { "version": "0.9.5", diff --git a/package.json b/package.json index c714a11e..9b96c8e3 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "postinstall": "husky install" }, "dependencies": { - "@fortawesome/fontawesome-free": "^5.15.4", + "@fortawesome/fontawesome-free": "^6.5.1", "@mdi/font": "5.9.55", "@tiptap/core": "^2.0.3", "@tiptap/extension-character-count": "^2.0.3", diff --git a/src/components/MessageBox/messageBox.vue b/src/components/MessageBox/messageBox.vue index 01c192fd..f008946f 100644 --- a/src/components/MessageBox/messageBox.vue +++ b/src/components/MessageBox/messageBox.vue @@ -49,7 +49,6 @@ - + diff --git a/src/components/ReportIssue/ReportIssueButton.vue b/src/components/ReportIssue/ReportIssueButton.vue index f67be3e3..128b6288 100644 --- a/src/components/ReportIssue/ReportIssueButton.vue +++ b/src/components/ReportIssue/ReportIssueButton.vue @@ -15,7 +15,6 @@ - - diff --git a/src/simulator/src/utils.js b/src/simulator/src/utils.js index 6549edfd..9d6a32b9 100644 --- a/src/simulator/src/utils.js +++ b/src/simulator/src/utils.js @@ -216,20 +216,8 @@ export function truncateString(str, num) { } export function bitConverterDialog() { - console.log('Open dialog box') - const simulatorStore = SimulatorStore() - simulatorStore.dialogBox.hex_bin_dec_converter_dialog = true - console.log(simulatorStore.dialogBox.hex_bin_dec_converter_dialog) - // $('#bitconverterprompt').dialog({ - // buttons: [ - // { - // text: 'Reset', - // click: function () { - // setBaseValues(0) - // }, - // }, - // ], - // }) + const simulatorStore = SimulatorStore(); + simulatorStore.dialogBox.hex_bin_dec_converter_dialog = true; } export function getImageDimensions(file) { @@ -250,15 +238,6 @@ export var convertors = { dec2bcd: (x) => parseInt(x.toString(10), 16).toString(2), } -export function setBaseValues(x) { - if (isNaN(x)) return - $('#binaryInput').val(convertors.dec2bin(x)) - $('#bcdInput').val(convertors.dec2bcd(x)) - $('#octalInput').val(convertors.dec2octal(x)) - $('#hexInput').val(convertors.dec2hex(x)) - $('#decimalInput').val(x) -} - export function parseNumber(num) { if (num instanceof Number) return num if (num.slice(0, 2).toLocaleLowerCase() == '0b') @@ -269,50 +248,6 @@ export function parseNumber(num) { return parseInt(num) } -export function setupBitConvertor() { - console.log('check bit convertor') - $('#decimalInput').on('keyup', function () { - var x = parseInt($('#decimalInput').val(), 10) - setBaseValues(x) - }) - - $('#binaryInput').on('keyup', function () { - var inp = $('#binaryInput').val() - var x - if (inp.slice(0, 2) == '0b') x = parseInt(inp.slice(2), 2) - else x = parseInt(inp, 2) - setBaseValues(x) - }) - $('#bcdInput').on('keyup', function () { - var input = $('#bcdInput').val() - var num = 0 - while (input.length % 4 !== 0) { - input = '0' + input - } - if (input !== 0) { - var i = 0 - while (i < input.length / 4) { - if (parseInt(input.slice(4 * i, 4 * (i + 1)), 2) < 10) - num = - num * 10 + parseInt(input.slice(4 * i, 4 * (i + 1)), 2) - else return setBaseValues(NaN) - i++ - } - } - return setBaseValues(x) - }) - - $('#hexInput').on('keyup', function () { - var x = parseInt($('#hexInput').val(), 16) - setBaseValues(x) - }) - - $('#octalInput').on('keyup', function () { - var x = parseInt($('#octalInput').val(), 8) - setBaseValues(x) - }) -} - export function promptFile(contentType, multiple) { var input = document.createElement('input') input.type = 'file' diff --git a/src/simulator/src/ux.js b/src/simulator/src/ux.js index f01bdcee..9d61a4dc 100644 --- a/src/simulator/src/ux.js +++ b/src/simulator/src/ux.js @@ -22,7 +22,6 @@ import { setProjectName, getProjectName } from './data/save' import { changeScale } from './canvasApi' import { generateImage, generateSaveData } from './data/save' import { setupVerilogExportCodeWindow } from './verilog' -import { setupBitConvertor } from './utils' import { updateTestbenchUI, setupTestbenchUI } from './testbench' import { applyVerilogTheme } from './Verilog2CV' import { dragging } from './drag' @@ -184,7 +183,6 @@ export function setupUI() { // $('#moduleProperty').draggable(); setupPanels() // setupVerilogExportCodeWindow() - setupBitConvertor() } /** @@ -631,63 +629,6 @@ export function deleteSelected() { updateRestrictedElementsInScope() } -/** - * listener for opening the prompt for bin conversion - * @category ux - */ -$('#bitconverter').on('click', () => { - console.log('something clicked') - $('#bitconverterprompt').dialog({ - resizable: false, - buttons: [ - { - text: 'Reset', - click() { - $('#decimalInput').val('0') - $('#binaryInput').val('0') - $('#octalInput').val('0') - $('#hexInput').val('0') - }, - }, - ], - }) -}) - -// convertors -const convertors = { - dec2bin: (x) => `0b${x.toString(2)}`, - dec2hex: (x) => `0x${x.toString(16)}`, - dec2octal: (x) => `0${x.toString(8)}`, -} - -function setBaseValues(x) { - if (isNaN(x)) return - $('#binaryInput').val(convertors.dec2bin(x)) - $('#octalInput').val(convertors.dec2octal(x)) - $('#hexInput').val(convertors.dec2hex(x)) - $('#decimalInput').val(x) -} - -$('#decimalInput').on('keyup', () => { - var x = parseInt($('#decimalInput').val(), 10) - setBaseValues(x) -}) - -$('#binaryInput').on('keyup', () => { - var x = parseInt($('#binaryInput').val(), 2) - setBaseValues(x) -}) - -$('#hexInput').on('keyup', () => { - var x = parseInt($('#hexInput').val(), 16) - setBaseValues(x) -}) - -$('#octalInput').on('keyup', () => { - var x = parseInt($('#octalInput').val(), 8) - setBaseValues(x) -}) - export function setupPanels() { // $('#dragQPanel') // .on('mousedown', () => From c9fba5224cde222dcba9a42d73ac050d813441c0 Mon Sep 17 00:00:00 2001 From: Josh Varga Date: Fri, 5 Jan 2024 12:05:15 -0600 Subject: [PATCH 20/22] Fixing event leak (#247) --- src/simulator/src/ux.js | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/simulator/src/ux.js b/src/simulator/src/ux.js index 9d61a4dc..aae20e3a 100644 --- a/src/simulator/src/ux.js +++ b/src/simulator/src/ux.js @@ -249,35 +249,23 @@ export function objectPropertyAttributeCheckedUpdate() { } export function checkPropertiesUpdate(value = 0) { - // console.log('update check') - + $('.objectPropertyAttribute').off( + 'change keyup paste click', + objectPropertyAttributeUpdate + ) $('.objectPropertyAttribute').on( 'change keyup paste click', objectPropertyAttributeUpdate ) + $('.objectPropertyAttributeChecked').off( + 'change keyup paste click', + objectPropertyAttributeCheckedUpdate + ) $('.objectPropertyAttributeChecked').on( 'change keyup paste click', objectPropertyAttributeCheckedUpdate ) - - //Duplicate of above (Handled above) - // $('.objectPropertyAttributeChecked').on('click', function () { - // if (this.name !== 'toggleLabelInLayoutMode') return // Hack to prevent toggleLabelInLayoutMode from toggling twice - // scheduleUpdate() - // updateCanvasSet(true) - // wireToBeCheckedSet(1) - // if ( - // simulationArea.lastSelected && - // simulationArea.lastSelected[this.name] - // ) { - // simulationArea.lastSelected[this.name](this.value) - // // Commented out due to property menu refresh bug - // // prevPropertyObjSet(simulationArea.lastSelected[this.name](this.value)) || prevPropertyObjGet(); - // } else { - // circuitProperty[this.name](this.checked) - // } - // }) } /** From f7b9d69780a00c43fbdff6140bb18280aa118cda Mon Sep 17 00:00:00 2001 From: Niladri Adhikary <91966855+niladrix719@users.noreply.github.com> Date: Sat, 6 Jan 2024 15:17:39 +0530 Subject: [PATCH 21/22] feat: added dragability for the circuit elements in panel (#250) --- src/components/Panels/ElementsPanel/ElementsPanel.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/Panels/ElementsPanel/ElementsPanel.vue b/src/components/Panels/ElementsPanel/ElementsPanel.vue index f1b36f58..7c5687f7 100644 --- a/src/components/Panels/ElementsPanel/ElementsPanel.vue +++ b/src/components/Panels/ElementsPanel/ElementsPanel.vue @@ -35,6 +35,7 @@ :title="element.label" class="icon logixModules" @click="createElement(element.name)" + @mousedown="createElement(element.name)" @mouseover="getTooltipText(element.name)" @mouseleave="tooltipText = 'null'" > @@ -74,6 +75,7 @@ :title="element.label" class="icon logixModules" @click="createElement(element.name)" + @mousedown="createElement(element.name)" @mouseover="getTooltipText(element.name)" @mouseleave="tooltipText = 'null'" > From b77fdb2ec66fc48641025eb739c50bdc32fd231b Mon Sep 17 00:00:00 2001 From: Vatsal Nadkarni <62395456+Yarlord@users.noreply.github.com> Date: Sat, 6 Jan 2024 20:11:04 +0530 Subject: [PATCH 22/22] feat: fixed printing bool tables (#227) * feat: fixed printing bool tables * Update src/components/DialogBox/CombinationalAnalysis.vue --------- Co-authored-by: Arnabdaz <96580571+Arnabdaz@users.noreply.github.com> --- src/components/DialogBox/BooleanTable.vue | 2 +- src/components/DialogBox/CombinationalAnalysis.vue | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/DialogBox/BooleanTable.vue b/src/components/DialogBox/BooleanTable.vue index 925ccc6e..f31f67bf 100644 --- a/src/components/DialogBox/BooleanTable.vue +++ b/src/components/DialogBox/BooleanTable.vue @@ -1,6 +1,6 @@