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

Commit

Permalink
Merge pull request #566 from FlowzPlatform/issue-504-n3
Browse files Browse the repository at this point in the history
subscription-added-to-backend-and-sidebar-count
  • Loading branch information
nikitam747 authored Sep 26, 2018
2 parents 4234a37 + a0c0eb8 commit 51d2922
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 46 deletions.
3 changes: 0 additions & 3 deletions client/src/components/SchemaView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -914,11 +914,9 @@ export default {
// data: obj.data[0]
// }
let saveObj = obj.data[0]
console.log('Save Object: ', saveObj)
delete saveObj['_index']
delete saveObj['_rowKey']
saveObj._state = this.$route.params.stateid
console.log('this.item.currentStatus', this.item.currentStatus)
if (this.isMultiple) {
saveObj._nextTarget = this.nextTarget.value
}
Expand All @@ -930,7 +928,6 @@ export default {
}
}
// if (fheaders !== null) {
console.log('saveObj', saveObj)
dflowzdata.patch(saveObj.id, saveObj, null, fheaders)
.then(res => {
this.id = null
Expand Down
101 changes: 61 additions & 40 deletions client/src/masterLayout/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,24 @@ import config from '@/config'
import axios from 'axios'
const io = require('socket.io-client')
const socket = io(config.socketURI)
socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_created', data => {
// console.log('===d8finstance created==', data)
})
socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_updated', data => {
// console.log('===d6finstance updated==', data)
})
socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_removed', data => {
// console.log('===d6finstance removed==', data)
})
// socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_created', data => {
// console.log('===d8finstance created==', data)
// if (data._currentStatus) {
// console.log('data._currentStatus', data._currentStatus, this.flowzList)
// let finx = _.findIndex(this.flowzList, {id: '5a6e2e8b_cfeb_4060_b420_6ca95184b884'.replace(/_/g, '-')})
// if (finx !== -1) {
// console.log('Index', finx)
// // this.flowzList[finx].count += 1
// this.flowzList[finx].processList[data._state].count++
// }
// }
// })
// socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_updated', data => {
// console.log('===d6finstance updated==', data)
// })
// socket.on('5a6e2e8b_cfeb_4060_b420_6ca95184b884_removed', data => {
// console.log('===d6finstance removed==', data)
// })
export default {
data () {
return {
Expand All @@ -105,6 +114,11 @@ export default {
}
},
created () {
// console.log('created', socket._callbacks)
},
beforeDestroy () {
// alert('beforeDestroy')
// console.log(socket, socket.disconnected)
},
methods: {
getByOrder (array) {
Expand Down Expand Up @@ -179,6 +193,44 @@ export default {
p.count = 0
return p
})
if (socket._callbacks['$' + m.id.replace(/-/g, '_') + '_created'] === undefined) {
socket.on(m.id.replace(/-/g, '_') + '_created', (data) => {
// console.log('===created==', data)
if (data._currentStatus) {
let finx = _.findIndex(this.flowzList, {id: m.id})
if (finx !== -1) {
this.flowzList[finx].processList[data._state].count++
this.flowzList[finx].count++
}
}
})
}
if (socket._callbacks['$' + m.id.replace(/-/g, '_') + '_patched'] === undefined) {
socket.on(m.id.replace(/-/g, '_') + '_patched', (data) => {
// console.log('===patched==', data)
let finx = _.findIndex(this.flowzList, {id: m.id})
if (finx !== -1 && !data._currentStatus && data._next === null) {
if (this.flowzList[finx].processList[data._state].count > 0) {
this.flowzList[finx].processList[data._state].count--
}
if (this.flowzList[finx].count > 0) {
this.flowzList[finx].count--
}
}
})
}
if (socket._callbacks['$' + m.id.replace(/-/g, '_') + '_removed'] === undefined) {
socket.on(m.id.replace(/-/g, '_') + '_removed', (data) => {
// console.log('===removed==', data)
if (data._currentStatus) {
let finx = _.findIndex(this.flowzList, {id: m.id})
if (finx !== -1) {
this.flowzList[finx].processList[data._state].count--
this.flowzList[finx].count--
}
}
})
}
return m
})
this.loading = false
Expand Down Expand Up @@ -399,37 +451,6 @@ export default {
this.init()
},
feathers: {
'5a6e2e8b_cfeb_4060_b420_6ca95184b884_created': {
created (data) {
console.log('>>>>>>>>>>', data)
}
},
'dflowzdata': {
created (data) {
// console.log('created', data)
// let finx = _.findIndex(this.flowzList, {id: data.fid})
// if (finx !== -1) {
// // this.flowzList[finx].count += 1
// this.setCounters(this.flowzList[finx])
// }
},
updated (data) {
console.log('updated', data)
// let finx = _.findIndex(this.flowzList, {id: data.fid})
// if (finx !== -1) {
// // this.flowzList[finx].count += 1
// this.setCounters(this.flowzList[finx])
// }
},
removed (data) {
console.log('removed', data)
// let finx = _.findIndex(this.flowzList, {id: data.fid})
// if (finx !== -1) {
// // this.flowzList[finx].count += 1
// this.setCounters(this.flowzList[finx])
// }
}
},
'flowz': {
created (data) {
if (this.$store.state.role === 1) {
Expand Down
3 changes: 2 additions & 1 deletion service/src/middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module.exports = function () {
'flowzdata': ['update', 'patch'],
'schema': ['create','update', 'patch', 'remove'],
'bpmnplugins': ['create','update', 'patch', 'remove'],
'emailtemplate': ['create','update', 'patch', 'remove']
'emailtemplate': ['create','update', 'patch', 'remove'],
'dflowzdata': ['create','update', 'patch', 'remove']
};

subscription.moduleResource.registerAppModule = registerAppModule;
Expand Down
2 changes: 1 addition & 1 deletion service/src/services/dflowzdata/dflowzdata.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Service {
this.app.io.emit(this.service.options.name+'_updated', data);
});
this.on('patched',(data) => {
this.app.io.emit(this.service.options.name+'_updated', data);
this.app.io.emit(this.service.options.name+'_patched', data);
});
this.on('removed',(data) => {
this.app.io.emit(this.service.options.name+'_removed', data);
Expand Down
2 changes: 1 addition & 1 deletion service/src/services/dflowzdata/dflowzdata.hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ let beforeFind = function (hook) {

function beforeCreate (hook) {
try {
// console.log('before create ================================', hook.data, hook.params)
console.log('before create ================================', hook.params)
hook.params.done = true
if (hook.params.headers.ftablename !== undefined && hook.data._state !== undefined) {
let regex = /_/g
Expand Down

0 comments on commit 51d2922

Please sign in to comment.