Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MCUDT-34530 #1480

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src-electron/rest/user-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1119,6 +1130,10 @@ exports.post = [
]

exports.get = [
{
uri: restApi.uri.getDirtyFlag,
callback: httpGetDirtyFlag,
},
{
uri: restApi.uri.endpointIds,
callback: httpGetEndpointIds
Expand Down
1 change: 1 addition & 0 deletions src-shared/rest-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const uri = {
duplicateEndpoint: '/duplicateEndpoint',
duplicateEndpointType: '/duplicateEndpointType',
dirtyFlag: '/dirtyFlag',
getDirtyFlag: '/getDirtyFlag',
option: '/option',
uiOptions: '/uiOptions',
commandUpdate: '/command/update',
Expand Down
27 changes: 14 additions & 13 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -68,7 +68,7 @@ window.addEventListener(
break
}
},
false
false,
)

async function initLoad(store) {
Expand Down Expand Up @@ -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),
)
},

Expand Down Expand Up @@ -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,
)
})
}
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -318,7 +318,7 @@ export default defineComponent({
rendApi.observable.progress_attribute,
(message) => {
this.setGenerationInProgress(message)
}
},
)

initLoad(this.$store).then(() => {
Expand All @@ -336,12 +336,8 @@ export default defineComponent({
dbEnum.wsCategory.updateSelectedUcComponents,
(resp) => {
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')
Expand All @@ -363,8 +359,13 @@ export default defineComponent({
hasMounted: true
}
},
'*'
'*',
)
if (this.$onWebSocket) {
this.$onWebSocket(dbEnum.wsCategory.dirtyFlag, () => {
this.$store.dispatch('zap/setDirtyState')
})
}
},
unmounted() {
document.body.classList.remove('matter', 'zigbee', 'multiprotocol')
Expand Down
11 changes: 4 additions & 7 deletions src/store/zap/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1216,13 +1216,10 @@
})
}

/**
* 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) {

Check failure on line 1219 in src/store/zap/actions.js

View workflow job for this annotation

GitHub Actions / Prepare Zap and regenerate Zigbee (20.x, ubuntu-22.04)

Missing JSDoc comment

Check failure on line 1219 in src/store/zap/actions.js

View workflow job for this annotation

GitHub Actions / Prepare zap for Matter generation (20.x, ubuntu-22.04)

Missing JSDoc comment

Check failure on line 1219 in src/store/zap/actions.js

View workflow job for this annotation

GitHub Actions / Cypress UI tests with Zigbee data (20.x, ubuntu-22.04)

Missing JSDoc comment

Check failure on line 1219 in src/store/zap/actions.js

View workflow job for this annotation

GitHub Actions / Generation and back-end tests (20.x, ubuntu-22.04)

Missing JSDoc comment

Check failure on line 1219 in src/store/zap/actions.js

View workflow job for this annotation

GitHub Actions / Cypress UI tests with Matter data (20.x, ubuntu-22.04)

Missing JSDoc comment
axiosRequests.$serverGet(restApi.uri.getDirtyFlag).then((resp) => {
context.commit('setDirtyState', resp.data)
})
}

/**
Expand Down
Loading