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

Commit 266218c

Browse files
authored
Merge pull request #552 from FlowzPlatform/issue-504-n1
sidebar-changes-based-on-new-api
2 parents 2dd1409 + f97ab67 commit 266218c

File tree

1 file changed

+52
-78
lines changed

1 file changed

+52
-78
lines changed

client/src/masterLayout/SideBar.vue

Lines changed: 52 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@
7777

7878
<script>
7979
import flowzModal from '@/api/flowz'
80-
import finstanceModal from '@/api/finstance'
80+
// import finstanceModal from '@/api/finstance'
81+
import dflowzdataModal from '@/api/dflowzdata'
8182
import _ from 'lodash'
8283
import config from '@/config'
8384
import axios from 'axios'
@@ -93,7 +94,6 @@ export default {
9394
}
9495
},
9596
created () {
96-
// console.log('this.$store.state.activeFlow', this.$store.state.activeFlow)
9797
},
9898
methods: {
9999
getByOrder (array) {
@@ -102,35 +102,8 @@ export default {
102102
allProcess[array[key].order] = array[key]
103103
}
104104
return allProcess
105-
// return allProcess.sort((a, b) => {
106-
// return a.order - b.order
107-
// })
108105
},
109-
// createInstance (item, subItemID) {
110-
// // console.log('item', item)
111-
// this.$Loading.start()
112-
// let fheaders = null
113-
// if (subItemID !== undefined) {
114-
// fheaders = {
115-
// workflowid: 'workflow_' + item.id,
116-
// stateid: subItemID
117-
// }
118-
// }
119-
// finstanceModal.post({fid: item.id}, null, fheaders).then(res => {
120-
// this.$Notice.success({title: 'Instance Generated'})
121-
// this.$Loading.finish()
122-
// }).catch(e => {
123-
// this.$Loading.error()
124-
// console.log('error', e.response)
125-
// if (e.response.data.message) {
126-
// this.$Notice.error({title: 'Error', desc: e.response.data.message.toString()})
127-
// } else {
128-
// this.$Notice.error({title: 'Error', desc: 'Instace Not Generated'})
129-
// }
130-
// })
131-
// },
132106
viewProgress (item) {
133-
// console.log('item: ', item)
134107
if (item.id === this.$route.params.id) {
135108
let randomStr = this.makeid()
136109
this.$store.state.updateView = randomStr
@@ -148,17 +121,14 @@ export default {
148121
} else {
149122
this.$router.push({name: 'schemaview', params: {id: node[0], stateid: node[1]}})
150123
}
151-
// this.$router.push('/admin/schemaview/' + node[0] + '/' + node[1])
152124
} else {
153125
this.$router.push('/view/' + node[0] + '/' + node[1])
154126
}
155127
},
156128
makeid () {
157-
var text = ''
158-
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
159-
160-
for (var i = 0; i < 8; i++) { text += possible.charAt(Math.floor(Math.random() * possible.length)) }
161-
129+
let text = ''
130+
let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
131+
for (let i = 0; i < 8; i++) { text += possible.charAt(Math.floor(Math.random() * possible.length)) }
162132
return text
163133
},
164134
async getModuleRoles (moduleId) {
@@ -286,16 +256,17 @@ export default {
286256
setCounters (sitem) {
287257
if (sitem) {
288258
if (this.$store.state.role === 1) {
289-
finstanceModal.get(null, {
259+
dflowzdataModal.get(null, {
290260
$paginate: false,
291-
$select: ['currentStatus'],
292-
mainStatus: 'inprocess',
293-
fid: sitem.id
261+
$select: ['_state'],
262+
_currentStatus: true
263+
}, {
264+
ftablename: this.$route.params.id.replace(/-/g, '_')
294265
}).then(res => {
295-
// console.log('res count', res.data)
266+
console.log('res count', res.data)
296267
sitem.count = 0
297268
_.map(sitem.processList, (pitem) => {
298-
pitem.count = _.filter(res.data, {currentStatus: pitem.id}).length
269+
pitem.count = _.filter(res.data, {_state: pitem.id}).length
299270
sitem.count += pitem.count
300271
})
301272
// for (let pitem in sitem.processList) {
@@ -311,26 +282,26 @@ export default {
311282
sitem.count = 0
312283
for (let pitem in sitem.processList) {
313284
if (!once) {
314-
finstanceModal.get(null, {
285+
dflowzdataModal.get(null, {
315286
$paginate: false,
316-
$select: ['currentStatus'],
317-
mainStatus: 'inprocess',
318-
fid: sitem.id
287+
$select: ['_state'],
288+
_currentStatus: true
319289
}, {
320290
workflowid: 'workflow_' + sitem.id,
321-
stateid: sitem.processList[pitem].id
291+
stateid: sitem.processList[pitem].id,
292+
ftablename: this.$route.params.id.replace(/-/g, '_')
322293
}).then(res => {
323294
if (res.data.length > 0) {
324295
once = true
325296
mdata = res.data
326-
sitem.processList[pitem].count = _.filter(res.data, {currentStatus: sitem.processList[pitem].id}).length
297+
sitem.processList[pitem].count = _.filter(res.data, {_state: sitem.processList[pitem].id}).length
327298
sitem.count += sitem.processList[pitem].count
328299
}
329300
}).catch(err => {
330301
console.log('error', err)
331302
})
332303
} else {
333-
sitem.processList[pitem].count = _.filter(mdata, {currentStatus: sitem.processList[pitem].id}).length
304+
sitem.processList[pitem].count = _.filter(mdata, {_state: sitem.processList[pitem].id}).length
334305
sitem.count += sitem.processList[pitem].count
335306
}
336307
}
@@ -339,16 +310,17 @@ export default {
339310
for (let item of this.flowzList) {
340311
if (this.$store.state.role === 1) {
341312
// item.count = 9
342-
finstanceModal.get(null, {
313+
dflowzdataModal.get(null, {
343314
$paginate: false,
344-
$select: ['currentStatus'],
345-
mainStatus: 'inprocess',
346-
fid: item.id
315+
$select: ['_state'],
316+
_currentStatus: true
317+
}, {
318+
ftablename: this.$route.params.id.replace(/-/g, '_')
347319
}).then(res => {
348320
if (res.data.length > 0) {
349321
item.count = 0
350322
_.map(item.processList, (pitem) => {
351-
pitem.count = _.filter(res.data, {currentStatus: pitem.id}).length
323+
pitem.count = _.filter(res.data, {_state: pitem.id}).length
352324
item.count += pitem.count
353325
})
354326
}
@@ -361,26 +333,26 @@ export default {
361333
for (let key in item.processList) {
362334
// console.log('item', item)
363335
if (!isonce) {
364-
finstanceModal.get(null, {
336+
dflowzdataModal.get(null, {
365337
$paginate: false,
366-
$select: ['currentStatus'],
367-
mainStatus: 'inprocess',
368-
fid: item.id
338+
$select: ['_state'],
339+
_currentStatus: true
369340
}, {
370341
workflowid: 'workflow_' + item.id,
371-
stateid: item.processList[key].id
342+
stateid: item.processList[key].id,
343+
ftablename: this.$route.params.id.replace(/-/g, '_')
372344
}).then(res => {
373345
if (res.data.length > 0) {
374346
isonce = true
375347
pdata = res.data
376-
item.processList[key].count = _.filter(res.data, {currentStatus: item.processList[key].id}).length
348+
item.processList[key].count = _.filter(res.data, {_state: item.processList[key].id}).length
377349
item.count += item.processList[key].count
378350
}
379351
}).catch(err => {
380352
console.log('error', err)
381353
})
382354
} else {
383-
item.processList[key].count = _.filter(pdata, {currentStatus: item.processList[key].id}).length
355+
item.processList[key].count = _.filter(pdata, {_state: item.processList[key].id}).length
384356
item.count += item.processList[key].count
385357
}
386358
}
@@ -411,32 +383,34 @@ export default {
411383
},
412384
mounted () {
413385
// this.activeFlow(this.$store.state.activeFlow)
386+
console.log('this.$feathers', this.$feathers)
414387
this.init()
415388
},
416389
feathers: {
417-
'finstance': {
390+
'dflowzdata': {
418391
created (data) {
419-
let finx = _.findIndex(this.flowzList, {id: data.fid})
420-
if (finx !== -1) {
421-
// this.flowzList[finx].count += 1
422-
this.setCounters(this.flowzList[finx])
423-
}
392+
console.log('data')
393+
// let finx = _.findIndex(this.flowzList, {id: data.fid})
394+
// if (finx !== -1) {
395+
// // this.flowzList[finx].count += 1
396+
// this.setCounters(this.flowzList[finx])
397+
// }
424398
},
425399
updated (data) {
426-
// console.log('updated', data)
427-
let finx = _.findIndex(this.flowzList, {id: data.fid})
428-
if (finx !== -1) {
429-
// this.flowzList[finx].count += 1
430-
this.setCounters(this.flowzList[finx])
431-
}
400+
console.log('updated', data)
401+
// let finx = _.findIndex(this.flowzList, {id: data.fid})
402+
// if (finx !== -1) {
403+
// // this.flowzList[finx].count += 1
404+
// this.setCounters(this.flowzList[finx])
405+
// }
432406
},
433407
removed (data) {
434-
// console.log('removed', data)
435-
let finx = _.findIndex(this.flowzList, {id: data.fid})
436-
if (finx !== -1) {
437-
// this.flowzList[finx].count += 1
438-
this.setCounters(this.flowzList[finx])
439-
}
408+
console.log('removed', data)
409+
// let finx = _.findIndex(this.flowzList, {id: data.fid})
410+
// if (finx !== -1) {
411+
// // this.flowzList[finx].count += 1
412+
// this.setCounters(this.flowzList[finx])
413+
// }
440414
}
441415
},
442416
'flowz': {

0 commit comments

Comments
 (0)