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

Notification system (RENOP) #688

Merged
merged 1 commit into from
Nov 7, 2022
Merged
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
4 changes: 1 addition & 3 deletions cypress/integration/devtools/devtools.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ describe('Testing visibility of devtools option', () => {

it('check if devtools option gets visible', () => {
cy.setZclProperties()
cy.get(
'a.q-btn > .q-btn__wrapper > .q-btn__content > .material-icons'
).click()
cy.get('#preference > .q-btn__wrapper > .q-btn__content > .q-icon').click()
cy.get('[aria-label="Enable development tools"] > .q-toggle__label').click()
cy.get('.q-btn__wrapper').contains('Back').click()
cy.get('.q-gutter-y-md > :nth-child(1)').should('contain', 'Dev Tools')
Expand Down
11 changes: 11 additions & 0 deletions src-electron/db/db-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,17 @@ exports.map = {
value: x.VALUE,
}
},
notifications: (x) => {
if (x == null) return undefined
return {
ref: x.SESSION_REF,
type: x.NOTICE_TYPE,
message: x.NOTICE_MESSAGE,
severity: x.NOTICE_SEVERITY,
order: x.NOTICE_ORDER,
display: x.DISPLAY,
}
},
}

exports.reverseMap = {
Expand Down
84 changes: 84 additions & 0 deletions src-electron/db/query-notification.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src-electron/db/zap-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1117,4 +1117,17 @@ CREATE TABLE IF NOT EXISTS "SETTING" (
"VALUE" text,
UNIQUE(CATEGORY, KEY)
);
/*
Session Notification table
*/

CREATE TABLE IF NOT EXISTS "SESSION_NOTICE" (
"SESSION_REF" integer,
"NOTICE_TYPE" text,
"NOTICE_MESSAGE" text,
"NOTICE_SEVERITY" integer,
"NOTICE_ORDER" integer primary key autoincrement,
"DISPLAY" integer,
foreign key (SESSION_REF) references SESSION(SESSION_ID) on delete cascade
);
/* EO SCHEMA */
8 changes: 8 additions & 0 deletions src-electron/importexport/import-isc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const util = require('../util/util')
const dbEnum = require('../../src-shared/db-enum')
const restApi = require('../../src-shared/rest-api')
const env = require('../util/env')
const notification = require('../db/query-notification.js')

/**
* Locates or adds an attribute, and returns it.
Expand Down Expand Up @@ -640,6 +641,13 @@ async function loadSessionKeyValues(db, sessionId, keyValues) {
async function iscDataLoader(db, state, sessionId) {
let endpointTypes = state.endpointTypes
let promises = []
await notification.setNotification(
db,
'UPGRADE',
'ISC FILE UPGRADED TO ZAP FILE. PLEASE SAVE AS TO SAVE OFF NEWLY CREATED ZAP FILE.',
sessionId,
1
)

// We don't have the package info inside ISC file, so we
// do our best here.
Expand Down
66 changes: 52 additions & 14 deletions src-electron/rest/user-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const dbApi = require('../db/db-api.js')
const queryAttribute = require('../db/query-attribute.js')
const queryCommand = require('../db/query-command.js')
const queryConfig = require('../db/query-config.js')
const queryNotification = require('../db/query-notification.js')
const queryEndpointType = require('../db/query-endpoint-type.js')
const queryEndpoint = require('../db/query-endpoint.js')
const querySession = require('../db/query-session.js')
Expand Down Expand Up @@ -56,6 +57,20 @@ function httpGetSessionKeyValues(db) {
}
}

/**
* HTTP GET: session get notifications
*
* @param {*} db
* @returns callback for the express uri registration
*/
function httpGetNotifications(db) {
return async (request, response) => {
let sessionId = request.zapSessionId
let notifications = await queryNotification.getNotification(db, sessionId)
response.status(StatusCodes.OK).json(notifications)
}
}

/**
* HTTP POST: save session key value
*
Expand Down Expand Up @@ -722,7 +737,7 @@ function httpDeleteSessionPackage(db) {

/**
* Creating a duplicate for endpoint
*
*
* @param {*} db
* @returns newly created endpoint id
*/
Expand All @@ -737,48 +752,67 @@ function httpPostDuplicateEndpoint(db) {
endpointIdentifier,
endpointTypeId
)
res.status(StatusCodes.OK).json({id:id})
res.status(StatusCodes.OK).json({ id: id })
}
}

/**
* Creating a duplicate for endpoint-type and endpoint-type-attributes
*
*
* @param {*} db
* @returns newly created endpoint-type id
*/
function httpPostDuplicateEndpointType(db) {
return async (request, response) => {
let { endpointTypeId } = request.body
let newId = await queryConfig.duplicateEndpointType(
db, endpointTypeId
)
let newId = await queryConfig.duplicateEndpointType(db, endpointTypeId)

duplicateEndpointTypeClusters(db, endpointTypeId, newId)

response.status(StatusCodes.OK).json({
id: newId
id: newId,
})
}
}

/**
* duplicate all clusters and attributes of an old endpoint type, using oldEndpointType id and newly created endpointType id
*
*
* @param {*} db
* @param {*} oldEndpointTypeId
* @param {*} newEndpointTypeId
*/
async function duplicateEndpointTypeClusters(db, oldEndpointTypeId, newEndpointTypeId) {
let oldEndpointTypeClusters = await queryConfig.selectEndpointClusters(db, oldEndpointTypeId);
async function duplicateEndpointTypeClusters(
db,
oldEndpointTypeId,
newEndpointTypeId
) {
let oldEndpointTypeClusters = await queryConfig.selectEndpointClusters(
db,
oldEndpointTypeId
)
oldEndpointTypeClusters.forEach(async (endpointTypeCluster) => {
let newEndpointTypeClusterId = await queryConfig.insertOrReplaceClusterState(db,newEndpointTypeId,endpointTypeCluster.clusterRef,endpointTypeCluster.side, endpointTypeCluster.enabled)
let oldAttributes = await queryAttribute.selectEndpointTypeAttributesByEndpointTypeRefAndClusterRef(db,oldEndpointTypeId,endpointTypeCluster.endpointTypeClusterId)
let newEndpointTypeClusterId =
await queryConfig.insertOrReplaceClusterState(
db,
newEndpointTypeId,
endpointTypeCluster.clusterRef,
endpointTypeCluster.side,
endpointTypeCluster.enabled
)
let oldAttributes =
await queryAttribute.selectEndpointTypeAttributesByEndpointTypeRefAndClusterRef(
db,
oldEndpointTypeId,
endpointTypeCluster.endpointTypeClusterId
)
oldAttributes.forEach(async (attrubute) => {
await queryAttribute.duplicateEndpointTypeAttribute(db,
await queryAttribute.duplicateEndpointTypeAttribute(
db,
newEndpointTypeId,
newEndpointTypeClusterId,
attrubute)
attrubute
)
})
})
}
Expand Down Expand Up @@ -827,6 +861,10 @@ exports.get = [
uri: restApi.uri.getAllSessionKeyValues,
callback: httpGetSessionKeyValues,
},
{
uri: restApi.uri.notification,
callback: httpGetNotifications,
},
{
uri: restApi.uri.initialState,
callback: httpGetInitialState,
Expand Down
1 change: 1 addition & 0 deletions src-shared/db-enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ exports.pathRelativity = {
exports.wsCategory = {
generic: 'generic',
dirtyFlag: 'dirtyFlag',
upgrade: 'upgrade',
validation: 'validation',
sessionCreationError: 'sessionCreationError',
componentUpdateStatus: 'componentUpdateStatus',
Expand Down
9 changes: 8 additions & 1 deletion src-shared/rend-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ exports.renderer_api = {
dirtyFlag: {
arg: 'dirtyState',
},
notification: {
arg: 'notification',
},
fileBrowse: {
arg: 'browseObject',
},
Expand Down Expand Up @@ -120,7 +123,11 @@ exports.id = {
isDirty: 'isDirty',
}

exports.notifyKey = { dirtyFlag: 'dirtyFlag', fileBrowse: 'fileBrowse' }
exports.notifyKey = {
dirtyFlag: 'dirtyFlag',
fileBrowse: 'fileBrowse',
notification: 'notification',
}

exports.jsonPrefix = 'rendererApiJson:'

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 @@ -24,6 +24,7 @@ const uri = {
endpoint: '/endpoint',
endpointType: '/endpointType',
initialState: '/initialState',
notification: '/notification',
duplicateEndpoint: '/duplicateEndpoint',
duplicateEndpointType: '/duplicateEndpointType',
dirtyFlag: '/dirtyFlag',
Expand Down
8 changes: 8 additions & 0 deletions src/layouts/ZclConfiguratorLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ limitations under the License.
</div></Transition
>
</q-btn>
<q-btn flat icon="warning" to="/notifications" id="Notifications">
<Transition name="bounce">
<div v-if="displayButton" class="text-align q-ml-xs">
Notifications
</div></Transition
>
<q-tooltip> Notifications </q-tooltip>
</q-btn>
</q-toolbar>
<q-dialog
v-model="globalOptionsDialog"
Expand Down
10 changes: 5 additions & 5 deletions src/layouts/ZclLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ limitations under the License.
clickable
v-close-popup
@click="
generationButtonText = file.category
getGeneratedFile(file.category)
"
generationButtonText = file.category
getGeneratedFile(file.category)
"
paulr34 marked this conversation as resolved.
Show resolved Hide resolved
:label="generationButtonText"
>
<q-item-section>
Expand All @@ -159,7 +159,7 @@ limitations under the License.
<template>
<div class="q-ma-md">
<q-scroll-area style="height: 70vh" ref="generationScroll">
<pre class="q-ma-none container">{{
<pre class="q-ma-none container">{{
generationData
}}</pre>
<q-scroll-observer @scroll="onScroll" />
Expand Down Expand Up @@ -222,7 +222,7 @@ export default {
title: 'Select directory to generate into',
mode: 'directory',
defaultPath: currentPath,
buttonLabel: 'Generate'
buttonLabel: 'Generate',
})
},
getGeneratedFiles() {
Expand Down
Loading