Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.

Commit 51d2922

Browse files
authored
Merge pull request #566 from FlowzPlatform/issue-504-n3
subscription-added-to-backend-and-sidebar-count
2 parents 4234a37 + a0c0eb8 commit 51d2922

File tree

5 files changed

+65
-46
lines changed

5 files changed

+65
-46
lines changed

client/src/components/SchemaView.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -914,11 +914,9 @@ export default {
914914
// data: obj.data[0]
915915
// }
916916
let saveObj = obj.data[0]
917-
console.log('Save Object: ', saveObj)
918917
delete saveObj['_index']
919918
delete saveObj['_rowKey']
920919
saveObj._state = this.$route.params.stateid
921-
console.log('this.item.currentStatus', this.item.currentStatus)
922920
if (this.isMultiple) {
923921
saveObj._nextTarget = this.nextTarget.value
924922
}
@@ -930,7 +928,6 @@ export default {
930928
}
931929
}
932930
// if (fheaders !== null) {
933-
console.log('saveObj', saveObj)
934931
dflowzdata.patch(saveObj.id, saveObj, null, fheaders)
935932
.then(res => {
936933
this.id = null

client/src/masterLayout/SideBar.vue

Lines changed: 61 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,24 @@ import config from '@/config'
8484
import axios from 'axios'
8585
const io = require('socket.io-client')
8686
const socket = io(config.socketURI)
87-
socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_created', data => {
88-
// console.log('===d8finstance created==', data)
89-
})
90-
socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_updated', data => {
91-
// console.log('===d6finstance updated==', data)
92-
})
93-
socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_removed', data => {
94-
// console.log('===d6finstance removed==', data)
95-
})
87+
// socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_created', data => {
88+
// console.log('===d8finstance created==', data)
89+
// if (data._currentStatus) {
90+
// console.log('data._currentStatus', data._currentStatus, this.flowzList)
91+
// let finx = _.findIndex(this.flowzList, {id: '5a6e2e8b_cfeb_4060_b420_6ca95184b884'.replace(/_/g, '-')})
92+
// if (finx !== -1) {
93+
// console.log('Index', finx)
94+
// // this.flowzList[finx].count += 1
95+
// this.flowzList[finx].processList[data._state].count++
96+
// }
97+
// }
98+
// })
99+
// socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_updated', data => {
100+
// console.log('===d6finstance updated==', data)
101+
// })
102+
// socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_removed', data => {
103+
// console.log('===d6finstance removed==', data)
104+
// })
96105
export default {
97106
data () {
98107
return {
@@ -105,6 +114,11 @@ export default {
105114
}
106115
},
107116
created () {
117+
// console.log('created', socket._callbacks)
118+
},
119+
beforeDestroy () {
120+
// alert('beforeDestroy')
121+
// console.log(socket, socket.disconnected)
108122
},
109123
methods: {
110124
getByOrder (array) {
@@ -179,6 +193,44 @@ export default {
179193
p.count = 0
180194
return p
181195
})
196+
if (socket._callbacks['$' + m.id.replace(/-/g, '_') + '_created'] === undefined) {
197+
socket.on(m.id.replace(/-/g, '_') + '_created', (data) => {
198+
// console.log('===created==', data)
199+
if (data._currentStatus) {
200+
let finx = _.findIndex(this.flowzList, {id: m.id})
201+
if (finx !== -1) {
202+
this.flowzList[finx].processList[data._state].count++
203+
this.flowzList[finx].count++
204+
}
205+
}
206+
})
207+
}
208+
if (socket._callbacks['$' + m.id.replace(/-/g, '_') + '_patched'] === undefined) {
209+
socket.on(m.id.replace(/-/g, '_') + '_patched', (data) => {
210+
// console.log('===patched==', data)
211+
let finx = _.findIndex(this.flowzList, {id: m.id})
212+
if (finx !== -1 && !data._currentStatus && data._next === null) {
213+
if (this.flowzList[finx].processList[data._state].count > 0) {
214+
this.flowzList[finx].processList[data._state].count--
215+
}
216+
if (this.flowzList[finx].count > 0) {
217+
this.flowzList[finx].count--
218+
}
219+
}
220+
})
221+
}
222+
if (socket._callbacks['$' + m.id.replace(/-/g, '_') + '_removed'] === undefined) {
223+
socket.on(m.id.replace(/-/g, '_') + '_removed', (data) => {
224+
// console.log('===removed==', data)
225+
if (data._currentStatus) {
226+
let finx = _.findIndex(this.flowzList, {id: m.id})
227+
if (finx !== -1) {
228+
this.flowzList[finx].processList[data._state].count--
229+
this.flowzList[finx].count--
230+
}
231+
}
232+
})
233+
}
182234
return m
183235
})
184236
this.loading = false
@@ -399,37 +451,6 @@ export default {
399451
this.init()
400452
},
401453
feathers: {
402-
'5a6e2e8b_cfeb_4060_b420_6ca95184b884_created': {
403-
created (data) {
404-
console.log('>>>>>>>>>>', data)
405-
}
406-
},
407-
'dflowzdata': {
408-
created (data) {
409-
// console.log('created', data)
410-
// let finx = _.findIndex(this.flowzList, {id: data.fid})
411-
// if (finx !== -1) {
412-
// // this.flowzList[finx].count += 1
413-
// this.setCounters(this.flowzList[finx])
414-
// }
415-
},
416-
updated (data) {
417-
console.log('updated', data)
418-
// let finx = _.findIndex(this.flowzList, {id: data.fid})
419-
// if (finx !== -1) {
420-
// // this.flowzList[finx].count += 1
421-
// this.setCounters(this.flowzList[finx])
422-
// }
423-
},
424-
removed (data) {
425-
console.log('removed', data)
426-
// let finx = _.findIndex(this.flowzList, {id: data.fid})
427-
// if (finx !== -1) {
428-
// // this.flowzList[finx].count += 1
429-
// this.setCounters(this.flowzList[finx])
430-
// }
431-
}
432-
},
433454
'flowz': {
434455
created (data) {
435456
if (this.$store.state.role === 1) {

service/src/middleware/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ module.exports = function () {
1717
'flowzdata': ['update', 'patch'],
1818
'schema': ['create','update', 'patch', 'remove'],
1919
'bpmnplugins': ['create','update', 'patch', 'remove'],
20-
'emailtemplate': ['create','update', 'patch', 'remove']
20+
'emailtemplate': ['create','update', 'patch', 'remove'],
21+
'dflowzdata': ['create','update', 'patch', 'remove']
2122
};
2223

2324
subscription.moduleResource.registerAppModule = registerAppModule;

service/src/services/dflowzdata/dflowzdata.class.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Service {
1919
this.app.io.emit(this.service.options.name+'_updated', data);
2020
});
2121
this.on('patched',(data) => {
22-
this.app.io.emit(this.service.options.name+'_updated', data);
22+
this.app.io.emit(this.service.options.name+'_patched', data);
2323
});
2424
this.on('removed',(data) => {
2525
this.app.io.emit(this.service.options.name+'_removed', data);

service/src/services/dflowzdata/dflowzdata.hooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let beforeFind = function (hook) {
6464

6565
function beforeCreate (hook) {
6666
try {
67-
// console.log('before create ================================', hook.data, hook.params)
67+
console.log('before create ================================', hook.params)
6868
hook.params.done = true
6969
if (hook.params.headers.ftablename !== undefined && hook.data._state !== undefined) {
7070
let regex = /_/g

0 commit comments

Comments
 (0)