diff --git a/package-lock.json b/package-lock.json index 59ac443..3ab07a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,6 @@ "vee-validate": "^4.12.4", "vue": "^3.3.11", "vue-i18n": "^9.9.0", - "vuex": "^4.1.0", "zod": "^3.22.4" }, "devDependencies": { @@ -13201,17 +13200,6 @@ "vue": "^3.0.0" } }, - "node_modules/vuex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/vuex/-/vuex-4.1.0.tgz", - "integrity": "sha512-hmV6UerDrPcgbSy9ORAtNXDr9M4wlNP4pEFKye4ujJF8oqgFFuxDCdOLS3eNoRTtq5O3hoBDh9Doj1bQMYHRbQ==", - "dependencies": { - "@vue/devtools-api": "^6.0.0-beta.11" - }, - "peerDependencies": { - "vue": "^3.2.0" - } - }, "node_modules/watchpack": { "version": "1.7.5", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.7.5.tgz", diff --git a/package.json b/package.json index e325bca..de170cf 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "postinstall": "electron-builder install-app-deps", "postuninstall": "electron-builder install-app-deps", "preview": "vite preview", - "serve": "concurrently \"json-server --watch src/data/nanoConfig.json --port=3001\" \"vite\" " + "serve": "concurrently \"json-server src/data/nanoConfig.json --port=3001\" \"vite\" " }, "main": "background.js", "dependencies": { @@ -32,7 +32,6 @@ "vee-validate": "^4.12.4", "vue": "^3.3.11", "vue-i18n": "^9.9.0", - "vuex": "^4.1.0", "zod": "^3.22.4" }, "devDependencies": { diff --git a/src/components/ProfileButton.vue b/src/components/ProfileButton.vue new file mode 100644 index 0000000..a4e2160 --- /dev/null +++ b/src/components/ProfileButton.vue @@ -0,0 +1,114 @@ + + + + + + + + uID:{{ profile.id }} + + + + + + + {$refs.profileNameInput.focus()})"> + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/components/ProfileManager.vue b/src/components/ProfileManager.vue index 2076e6c..e6208c7 100644 --- a/src/components/ProfileManager.vue +++ b/src/components/ProfileManager.vue @@ -23,7 +23,8 @@ v-model="filter" :placeholder="$t('profiles.filter_placeholder')" class="grow h-full bg-transparent text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50"> - + @@ -37,7 +38,8 @@ @@ -45,53 +47,33 @@ {{ profileTag }} ({{ tagProfiles.length }}) - - - - - uID:{{ profile.id }} - - - - - - - - + - \ No newline at end of file diff --git a/src/data/nanoConfig.json b/src/data/nanoConfig.json index b675f3b..dbad3a5 100644 --- a/src/data/nanoConfig.json +++ b/src/data/nanoConfig.json @@ -51,6 +51,108 @@ "guiEnable": true } }, + { + "id": "1232", + "name": "Another", + "profileTag": "Binaris", + "profileConfig": { + "profileDesc": "KORG MINILOGUE OSCILLATOR 1", + "profileType": 1, + "showDesc": true + }, + "feedbackConfig": { + "feedbackEn": true, + "feedbackType": "fd", + "multiRev": false, + "feedbackStrength": 1, + "endstopStrength": 1, + "outputRamp": 10000, + "pos": 140, + "secondaryHaptic": true, + "secondaryVol": 5 + }, + "mappingConfig": { + "internalMacro": false, + "knobMap": "arrL", + "switchA": "shift", + "switchB": "ctrl", + "switchC": "alt", + "switchD": "esc" + }, + "ledConfig": { + "ledEnable": true, + "ledMode": 1, + "primary": { + "h": 255, + "s": 255, + "l": 100 + }, + "secondary": { + "h": 255, + "s": 255, + "l": 100 + }, + "pointer": { + "h": 255, + "s": 255, + "l": 10 + } + }, + "guiConfig": { + "guiEnable": true + } + }, + { + "id": "1232", + "name": "DUPLICATE ID", + "profileTag": "Binaris", + "profileConfig": { + "profileDesc": "KORG MINILOGUE OSCILLATOR 1", + "profileType": 1, + "showDesc": true + }, + "feedbackConfig": { + "feedbackEn": true, + "feedbackType": "fd", + "multiRev": false, + "feedbackStrength": 1, + "endstopStrength": 1, + "outputRamp": 10000, + "pos": 140, + "secondaryHaptic": true, + "secondaryVol": 5 + }, + "mappingConfig": { + "internalMacro": false, + "knobMap": "arrL", + "switchA": "shift", + "switchB": "ctrl", + "switchC": "alt", + "switchD": "esc" + }, + "ledConfig": { + "ledEnable": true, + "ledMode": 1, + "primary": { + "h": 255, + "s": 255, + "l": 100 + }, + "secondary": { + "h": 255, + "s": 255, + "l": 100 + }, + "pointer": { + "h": 255, + "s": 255, + "l": 10 + } + }, + "guiConfig": { + "guiEnable": true + } + }, { "id": "5238", "name": "sdfsdf", diff --git a/src/lang/en.json b/src/lang/en.json index 8acc75e..b43422f 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -100,6 +100,7 @@ "filter_placeholder": "Filter Profiles...", "not_found": "No profiles found ;-;", "subtitle": "Customize to your heart's content", - "title": "Device Profiles" + "title": "Device Profiles", + "name_placeholder": "Profile name" } } \ No newline at end of file diff --git a/src/main.js b/src/main.js index f5bee19..47f3f23 100644 --- a/src/main.js +++ b/src/main.js @@ -1,26 +1,39 @@ import './assets/main.css' +import Axios from 'axios' import { createApp } from 'vue' -import { createStore } from 'vuex' import { createI18n } from 'vue-i18n' -import en from './lang/en.json' +import en from '@/lang/en.json' -import App from './App.vue' +import App from '@/App.vue' + +import { store } from '@/store.js' import Ajv from 'ajv' +import schema from '@/data/profileSchema.json' -// Create a new store instance -const store = createStore({ - state() { - return { - device: { - connected: false, - profiles: [], - }, +const ajv = new Ajv() + +Axios.get('http://localhost:3001/profiles').then((res) => { + const profiles = res.data + console.log(profiles) + const ids = new Set() + const validate = ajv.compile(schema) + store.device.profiles = profiles.filter((profile) => { + if (!validate(profile)) { + console.error('Failed to validate profile: ' + profile.name, validate.errors) + return false } - }, - mutations: {}, + if (ids.has(profile.id)) { + console.error('Duplicate profile id: ' + profile.id + ' for profile: ' + profile.name) + return false + } + ids.add(profile.id) + return true + }) +}).catch((err) => { + console.error(err) }) // Create VueI18n instance with locales loaded from /lang directory @@ -31,10 +44,5 @@ const i18n = createI18n({ }) const app = createApp(App) - app.use(i18n) -app.use(store) - -app.provide('ajv', new Ajv()) - app.mount('#app') \ No newline at end of file diff --git a/src/store.js b/src/store.js new file mode 100644 index 0000000..71ae632 --- /dev/null +++ b/src/store.js @@ -0,0 +1,9 @@ +import { reactive } from 'vue' + +export const store = reactive({ + device: { + profiles: [], + activeProfile: null, + }, + currentProfile: null, +}) \ No newline at end of file