From 3baac236183e0f88da0f428eb859bf37da1f16b6 Mon Sep 17 00:00:00 2001 From: Paul Regan Date: Tue, 23 Apr 2024 13:25:12 -0400 Subject: [PATCH 1/3] Studio V6 Integration- updating Dirty State and saving files --- src-electron/rest/user-data.js | 15 +++++++++++++++ src-shared/rest-api.js | 2 +- src/App.vue | 9 +++++---- src/store/zap/actions.js | 11 ++++------- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src-electron/rest/user-data.js b/src-electron/rest/user-data.js index cc154529f7..35339744f0 100644 --- a/src-electron/rest/user-data.js +++ b/src-electron/rest/user-data.js @@ -526,6 +526,17 @@ function httpGetOption(db) { response.status(StatusCodes.OK).json(data) } } +function httpGetDirtyFlag(db) { + return async (request, response) => { + let sessionUuid = request.query[restApi.param.sessionId] + let zapSessionId + if (`zapSessionId` in request.session) { + zapSessionId = request.session.zapSessionId[sessionUuid] + } + let dirtyFlag = await querySession.getSessionDirtyFlag(db, zapSessionId) + response.status(StatusCodes.OK).json(dirtyFlag) + } +} /** * HTTP GET: ui_options @@ -1119,6 +1130,10 @@ exports.post = [ ] exports.get = [ + { + uri: restApi.uri.getDirtyFlag, + callback: httpGetDirtyFlag, + }, { uri: restApi.uri.endpointIds, callback: httpGetEndpointIds diff --git a/src-shared/rest-api.js b/src-shared/rest-api.js index ed76449be4..c36c873ed4 100644 --- a/src-shared/rest-api.js +++ b/src-shared/rest-api.js @@ -40,7 +40,7 @@ const uri = { deletePackageNotification: 'deletePackageNotification', duplicateEndpoint: '/duplicateEndpoint', duplicateEndpointType: '/duplicateEndpointType', - dirtyFlag: '/dirtyFlag', + getDirtyFlag: '/getDirtyFlag', option: '/option', uiOptions: '/uiOptions', commandUpdate: '/command/update', diff --git a/src/App.vue b/src/App.vue index 26ccf446d0..30d9aa3c65 100644 --- a/src/App.vue +++ b/src/App.vue @@ -338,10 +338,6 @@ export default defineComponent({ this.$store.dispatch('zap/updateSelectedUcComponentState', resp) } ) - - this.$onWebSocket(dbEnum.wsCategory.dirtyFlag, (resp) => { - this.$store.dispatch('zap/setDirtyState', resp) - }) }, addClassToBody() { document.body.classList.remove('matter', 'zigbee', 'multiprotocol') @@ -365,6 +361,11 @@ export default defineComponent({ }, '*' ) + if (this.$onWebSocket) { + this.$onWebSocket(dbEnum.wsCategory.dirtyFlag, (resp) => { + this.$store.dispatch('zap/setDirtyState') + }) + } }, unmounted() { document.body.classList.remove('matter', 'zigbee', 'multiprotocol') diff --git a/src/store/zap/actions.js b/src/store/zap/actions.js index c7c714663f..31489c765a 100644 --- a/src/store/zap/actions.js +++ b/src/store/zap/actions.js @@ -1216,13 +1216,10 @@ export function updateSelectedUcComponentState(context, projectInfo) { }) } -/** - * Set the dirty state for ZAP config when there are unsaved changes. - * @param {*} context - * @param {*} isDirty - */ -export function setDirtyState(context, isDirty) { - context.commit('setDirtyState', isDirty) +export function setDirtyState(context) { + axiosRequests.$serverGet(restApi.uri.getDirtyFlag).then((resp) => { + context.commit('setDirtyState', resp.data) + }) } /** From 68fe09a91c83c5cc06e4f0be3ef512a7dc3c2784 Mon Sep 17 00:00:00 2001 From: Paul Regan Date: Tue, 23 Apr 2024 16:20:16 -0400 Subject: [PATCH 2/3] add back other dirtyflag api --- src-shared/rest-api.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src-shared/rest-api.js b/src-shared/rest-api.js index c36c873ed4..50ae2ff791 100644 --- a/src-shared/rest-api.js +++ b/src-shared/rest-api.js @@ -40,6 +40,7 @@ const uri = { deletePackageNotification: 'deletePackageNotification', duplicateEndpoint: '/duplicateEndpoint', duplicateEndpointType: '/duplicateEndpointType', + dirtyFlag: '/dirtyFlag', getDirtyFlag: '/getDirtyFlag', option: '/option', uiOptions: '/uiOptions', From a12db02b87d6a498d1c666b740edcf565fc2c25a Mon Sep 17 00:00:00 2001 From: Paul Regan Date: Tue, 12 Nov 2024 12:53:30 -0500 Subject: [PATCH 3/3] remove resp --- src/App.vue | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/App.vue b/src/App.vue index 30d9aa3c65..aaaa8f4e27 100644 --- a/src/App.vue +++ b/src/App.vue @@ -52,7 +52,7 @@ window.addEventListener( case 'theme': window[rendApi.GLOBAL_SYMBOL_EXECUTE]( rendApi.id.setDarkTheme, - eventData.theme === 'dark' + eventData.theme === 'dark', ) break case 'save': @@ -68,7 +68,7 @@ window.addEventListener( break } }, - false + false, ) async function initLoad(store) { @@ -195,7 +195,7 @@ export default defineComponent({ setTheme() { window[rendApi.GLOBAL_SYMBOL_EXECUTE]( rendApi.id.setDarkTheme, - storage.getItem(rendApi.storageKey.isDarkThemeActive) + storage.getItem(rendApi.storageKey.isDarkThemeActive), ) }, @@ -268,7 +268,7 @@ export default defineComponent({ this.$serverGet(restApi.uri.uiOptions).then((res) => { this.$store.commit( 'zap/updateIsProfileIdShown', - res.data.showProfileId + res.data.showProfileId, ) }) } @@ -288,7 +288,7 @@ export default defineComponent({ if (`debugNavBar` in query) { this.$store.dispatch( 'zap/setDebugNavBar', - query[`debugNavBar`] === 'true' + query[`debugNavBar`] === 'true', ) } else { // If we don't specify it, default is on. @@ -302,7 +302,7 @@ export default defineComponent({ if (`setSaveButtonVisible` in query) { this.$store.dispatch( 'zap/setSaveButtonVisible', - query[`setSaveButtonVisible`] === 'true' + query[`setSaveButtonVisible`] === 'true', ) } else { // If we don't specify it, default is off. @@ -318,7 +318,7 @@ export default defineComponent({ rendApi.observable.progress_attribute, (message) => { this.setGenerationInProgress(message) - } + }, ) initLoad(this.$store).then(() => { @@ -336,7 +336,7 @@ export default defineComponent({ dbEnum.wsCategory.updateSelectedUcComponents, (resp) => { this.$store.dispatch('zap/updateSelectedUcComponentState', resp) - } + }, ) }, addClassToBody() { @@ -359,10 +359,10 @@ export default defineComponent({ hasMounted: true } }, - '*' + '*', ) if (this.$onWebSocket) { - this.$onWebSocket(dbEnum.wsCategory.dirtyFlag, (resp) => { + this.$onWebSocket(dbEnum.wsCategory.dirtyFlag, () => { this.$store.dispatch('zap/setDirtyState') }) }