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

Commit dcf3622

Browse files
authored
Merge pull request #613 from FlowzPlatform/issue-612
exclusive-gateway-functionality-added
2 parents 39feded + d772d40 commit dcf3622

File tree

5 files changed

+149
-36
lines changed

5 files changed

+149
-36
lines changed

client/src/components/SchemaView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ export default {
15531553
},
15541554
'dflowzdata': {
15551555
_created (data) {
1556-
console.log('================created==============', data)
1556+
// console.log('================created==============', data)
15571557
let keys = Object.keys(data)
15581558
for (let tName of keys) {
15591559
if (tName === this.$route.params.id.replace(/-/g, '_')) {

client/src/masterLayout/SideBar.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ export default {
472472
}
473473
},
474474
_removed (data) {
475+
// console.log('==============patched============', data)
475476
let keys = Object.keys(data)
476477
for (let tName of keys) {
477478
if (data[tName]._currentStatus) {

client/src/pages/schema/New.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,8 @@ export default {
665665
.ivu-form-item-error-tip {
666666
position: relative;
667667
}
668+
.ivu-select-dropdown-list {
669+
max-height: inherit;
670+
overflow-y: scroll;
671+
}
668672
</style>

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

Lines changed: 141 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const errors = require('@feathersjs/errors');
22
const uuidv4 = require('uuid/v4');
3+
const _ = require('lodash')
34

45
module.exports = {
56
before: {
@@ -112,6 +113,30 @@ function beforeCreate (hook) {
112113
hook.data._uuid = uuidv4()
113114
hook.data._next = null
114115
}
116+
if (res.processList[hook.data._state].type === 'exclusivegateway') {
117+
// console.log('???????????????????????????????????????????????????')
118+
let gatewayObj = res.processList[hook.data._state]
119+
// console.log('gatewayObj', gatewayObj)
120+
if (gatewayObj['var_name'] !== undefined && gatewayObj['var_name'] !== '' && gatewayObj.condition !== undefined && gatewayObj.condition !== '') {
121+
if (hook.data.hasOwnProperty(gatewayObj['var_name'])) {
122+
// console.log('hook.data', hook.data[gatewayObj['var_name']])
123+
if (gatewayObj.condition == '=') {
124+
// console.log('')
125+
let targetIndex = _.findIndex(gatewayObj.target, {label: hook.data[gatewayObj['var_name']]})
126+
// console.log('targetIndex', targetIndex)
127+
if (targetIndex !== -1) {
128+
// console.log('hook.data', hook.data, hook.params)
129+
// hook.data._previous =
130+
hook.params.isEGateway = true
131+
hook.data._currentStatus = false
132+
// hook.data._next = null
133+
// console.log('gatewayObj.target[targetIndex].id', gatewayObj.target[targetIndex].id)
134+
hook.params.isEGatewayTarget = gatewayObj.target[targetIndex].id
135+
}
136+
}
137+
}
138+
}
139+
}
115140
return hook;
116141
}).catch(err => {
117142
console.log('err', err)
@@ -135,40 +160,122 @@ function beforeCreate (hook) {
135160

136161

137162
function afterCreate (hook) {
138-
// console.log('afterCreate ================================', hook.data)
139163
// If first state found add another entry with nexttarget
140-
if (hook.params.done && hook.params.first !== undefined) {
141-
hook.data._state = hook.data._nextTarget
142-
hook.data._nextTarget = ''
143-
// hook.data._createdAt = new Date().toISOString()
144-
hook.data._previous = hook.result.id
145-
delete hook.params.first
146-
delete hook.data.id
147-
// console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', hook.data)
148-
return hook.app.service(hook.path).create(hook.data, hook.params).then(res => {
149-
return hook;
150-
}).catch(err => {
151-
console.log('err', err)
152-
throw new errors.BadRequest('Error', {
153-
errors: { message: err.toString() }
154-
});
155-
})
156-
} else {
157-
hook.params.headers.normalpatch = true
158-
// console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', hook.data._previous, hook.result.id)
159-
return hook.app.service(hook.path).patch(hook.data._previous, {
160-
// _state: hook.data._state,
161-
_next: hook.result.id,
162-
_completedAt: new Date().toISOString()
163-
// _currentStatus: false
164-
}, hook.params).then(resp => {
165-
return hook
166-
})
164+
165+
if (hook.params.done) { // to avoid called afterhook multiple times
166+
// console.log('*********************************************')
167+
168+
169+
if (hook.params.first !== undefined) {
170+
hook.data._state = hook.data._nextTarget
171+
hook.data._nextTarget = ''
172+
hook.data._previous = hook.result.id
173+
174+
delete hook.params.first
175+
delete hook.params.isEGateway
176+
delete hook.data.id
177+
178+
return hook.app.service(hook.path).create(hook.data, hook.params).then(res => {
179+
return hook;
180+
}).catch(err => {
181+
console.log('err', err)
182+
throw new errors.BadRequest('Error', {
183+
errors: { message: err.toString() }
184+
});
185+
})
186+
} else {
187+
// console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', hook.result.id)
188+
hook.params.headers.normalpatch = true
189+
// console.log('hook.data._previous', hook.data._previous)
190+
if (hook.params.isEGateway !== undefined) {
191+
return hook.app.service(hook.path).patch(hook.data._previous, {
192+
_next: hook.result.id,
193+
_completedAt: new Date().toISOString()
194+
}, hook.params).then(resp => {
195+
196+
hook.data._nextTarget = hook.params.isEGatewayTarget
197+
// hook.data._previous = hook.result.id
198+
delete hook.params.first
199+
delete hook.params.isEGateway
200+
delete hook.params.isEGatewayTarget
201+
// delete hook.data.id
202+
// console.log(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;', hook.data)
203+
let params = Object.assign({}, hook.params)
204+
205+
delete params.headers.normalpatch
206+
207+
return hook.app.service(hook.path).patch(hook.result.id, hook.data, params).then(res => {
208+
// hook.params.headers.normalpatch = true
209+
// console.log('hook.data._previous', hook.data._previous)
210+
// return hook.app.service(hook.path).patch(hook.data._previous, {
211+
// _next: hook.result.id,
212+
// _completedAt: new Date().toISOString()
213+
// }, hook.params).then(resp => {
214+
// return hook
215+
// })
216+
return hook;
217+
}).catch(err => {
218+
console.log('err', err)
219+
throw new errors.BadRequest('Error', {
220+
errors: { message: err.toString() }
221+
});
222+
})
223+
224+
return hook
225+
})
226+
} else {
227+
return hook.app.service(hook.path).patch(hook.data._previous, {
228+
_next: hook.result.id,
229+
_completedAt: new Date().toISOString()
230+
}, hook.params).then(resp => {
231+
return hook
232+
})
233+
}
234+
// hook.app.service(hook.path).patch(hook.data._previous, {
235+
// _next: hook.result.id,
236+
// _completedAt: new Date().toISOString()
237+
// }, hook.params).then(resp => {
238+
// return hook
239+
// })
240+
241+
// if (hook.params.isEGateway !== undefined) {
242+
// // console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>..', hook.params, hook.data, hook.result.id)
243+
// // hook.data._state = hook.data._nextTarget
244+
// hook.data._nextTarget = hook.params.isEGatewayTarget
245+
// // hook.data._previous = hook.result.id
246+
// delete hook.params.first
247+
// delete hook.params.isEGateway
248+
// delete hook.params.isEGatewayTarget
249+
// // delete hook.data.id
250+
// console.log(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;', hook.data)
251+
// delete hook.params.headers.normalpatch
252+
// return hook.app.service(hook.path).patch(hook.result.id, hook.data, hook.params).then(res => {
253+
// // hook.params.headers.normalpatch = true
254+
// // console.log('hook.data._previous', hook.data._previous)
255+
// // return hook.app.service(hook.path).patch(hook.data._previous, {
256+
// // _next: hook.result.id,
257+
// // _completedAt: new Date().toISOString()
258+
// // }, hook.params).then(resp => {
259+
// // return hook
260+
// // })
261+
// return hook;
262+
// }).catch(err => {
263+
// console.log('err', err)
264+
// throw new errors.BadRequest('Error', {
265+
// errors: { message: err.toString() }
266+
// });
267+
// })
268+
// }
269+
270+
}
271+
167272
}
168-
}
273+
274+
275+
} // end afterCreate function
169276

170277
function beforePatch (hook) {
171-
// console.log('beforePatch =============================>>>>>>>>>>>>>>>>>>>>', hook.params, hook.id, hook.data)
278+
// console.log('beforePatch ============================beforePatch=>>>>>>>>>>>>>>>>>>>>', hook.params, hook.id, hook.data)
172279
hook.params.done1 = true
173280
if (hook.params.headers.ftablename !== undefined) {
174281
if (hook.params.headers.normalpatch !== undefined) {
@@ -210,12 +317,13 @@ function beforePatch (hook) {
210317
}
211318

212319
function afterPatch (hook) {
213-
// console.log('================================ afterPatch', hook.data, hook.id)
320+
// console.log('================================ afterPatch', hook.id, hook.params.headers.normalpatch)
214321
if (hook.params.headers.normalpatch !== undefined) {
215322
// console.log('..................................... ', hook.params.headers.normalpatch)
216323
} else {
217324
if (hook.params.done1) {
218-
// console.log('111111111111111111111111111111111111111111111111111111111111111111', hook.path)
325+
// console.log('111111111111111111111111111111111111111111111111111111111111111111', hook.params)
326+
delete hook.params.done1
219327
return hook.app.service(hook.path).get(hook.id, hook.params).then(resp => {
220328
hook.data._state = hook.data._nextTarget
221329
hook.data._nextTarget = ''
@@ -228,7 +336,7 @@ function afterPatch (hook) {
228336
hook.data._next = null
229337
hook.data._uuid = resp._uuid
230338
delete hook.data.id
231-
// console.log('???????????????????????????????????????????????????????????????//', hook.path)
339+
// console.log('???????????????????????????????????????????????????????????????//', hook.data)
232340
return hook.app.service(hook.path).create(hook.data, hook.params).then(res => {
233341
return hook;
234342
}).catch(err => {

service/src/services/email-receive/email-receive.class.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class Service {
3737
let mdata = resp
3838
mdata._nextTarget = targetId
3939
mdata.userId = ''
40-
mdata.subscriptionId = ''
41-
mdata.subscriptionOwnerId = ''
40+
// mdata.subscriptionId = ''
41+
// mdata.subscriptionOwnerId = ''
4242

4343
mdata._currentStatus = false
4444
return this.app.service('dflowzdataInt').patch(resp.id, mdata, {headers: headers}).then(res => {

0 commit comments

Comments
 (0)