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

filter-by-date-view #625

Merged
merged 1 commit into from
Oct 12, 2018
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
47 changes: 46 additions & 1 deletion client/src/components/SchemaView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,38 @@ export default {
'schemasubformview': (resolve) => { require(['./SchemaSubFormView'], resolve) }
},
methods: {
getFilterDate (type) {
let date = ''
switch (type) {
case '12hours':
date = new Date()
date.setHours(date.getHours() - 12)
break
case '24hours':
date = new Date()
date.setDate(date.getDate() - 1)
break
case '7days':
date = new Date()
date.setDate(date.getDate() - 7)
break
case '30days':
date = new Date()
date.setMonth(date.getMonth() - 1)
break
case '3months':
date = new Date()
date.setMonth(date.getMonth() - 3)
break
case 'thisYear':
date = new Date()
date.setFullYear(date.getFullYear() - 1)
break
}
return date.toISOString()
},
searchData (query, sort) {
console.log('query', query, sort)
// console.log('query', query, sort)
this.dataLoading = true

// New Custom Dynamic FLowz Data call
Expand All @@ -389,6 +419,21 @@ export default {
// 'id[$search]': '^' + query.text
'$search': query.text
}
if (query.filterBy !== null && query.filterBy !== undefined) {
if (query.filterBy === 'customRange') {
console.log('Custom Range Found', query.customValue)
if (query.customValue.length >= 1) {
if (query.customValue[0] !== '' && query.customValue[1] !== '') {
params['_createdAt[$gte]'] = query.customValue[0].toISOString()
params['_createdAt[$lte]'] = query.customValue[1].toISOString()
}
}
} else {
let dateRange = this.getFilterDate(query.filterBy)
// console.log('Normal Range Found', this.selectedFilterBy, $lte, new Date().toISOString())
params['_createdAt[$gte]'] = dateRange
}
}
if (sort !== undefined) {
if (sort.order === 'asc') {
params['$sort[' + sort.key + ']'] = 1
Expand Down
65 changes: 56 additions & 9 deletions client/src/pages/flow/analytics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export default {
},
fid: null,
schemaId: '',
searchQuery: null,
searchQuery: '',
filterBy: [
{
'label': 'Last 12 Hours',
Expand Down Expand Up @@ -280,6 +280,36 @@ export default {
}
},
methods: {
getFilterDate (type) {
let date = ''
switch (type) {
case '12hours':
date = new Date()
date.setHours(date.getHours() - 12)
break
case '24hours':
date = new Date()
date.setDate(date.getDate() - 1)
break
case '7days':
date = new Date()
date.setDate(date.getDate() - 7)
break
case '30days':
date = new Date()
date.setMonth(date.getMonth() - 1)
break
case '3months':
date = new Date()
date.setMonth(date.getMonth() - 3)
break
case 'thisYear':
date = new Date()
date.setFullYear(date.getFullYear() - 1)
break
}
return date.toISOString()
},
handlePage (page) {
this.cpage = page
this.skip = (page * this.limit) - this.limit
Expand Down Expand Up @@ -321,25 +351,42 @@ export default {
let heads = {
ftablename: this.flowzData.id.replace(/-/g, '_')
}
if (query === null) {
query = {
text: '',
filter: ''
}
}
// if (query === null) {
// query = {
// text: '',
// filter: ''
// }
// }
let params = {
$skip: this.skip,
$limit: this.limit,
'_currentStatus': true,
'_state': this.$route.params.stateid,
// 'id[$search]': '^' + query.text
'$search': query,
$group: '_uuid'
}
if (query !== '') {
params['$search'] = query
}
if (this.$store.state.role === 2) {
params._creatorid = this.$store.state.user._id
params.subscriptionId = this.$store.state.subscription
}
if (this.selectedFilterBy !== null && this.selectedFilterBy !== undefined) {
if (this.selectedFilterBy === 'customRange') {
console.log('Custom Range Found', this.enteredDateRange)
if (this.enteredDateRange.length >= 1) {
if (this.enteredDateRange[0] !== '' && this.enteredDateRange[1] !== '') {
params['_createdAt[$gte]'] = this.enteredDateRange[0].toISOString()
params['_createdAt[$lte]'] = this.enteredDateRange[1].toISOString()
}
}
} else {
let dateRange = this.getFilterDate(this.selectedFilterBy)
// console.log('Normal Range Found', this.selectedFilterBy, $lte, new Date().toISOString())
params['_createdAt[$gte]'] = dateRange
}
}
if (sort !== undefined || sort !== null) {
if (sort === 'asc') {
params['$sort[' + sort + ']'] = 1
Expand Down Expand Up @@ -450,7 +497,7 @@ export default {
// console.log('res.data.processList: ', res.data.processList)
let listing = this.getByOrder(this.flowzData.processList)
for (let col of listing) {
if (col.type !== 'startevent' && col.type !== 'endevent') {
if (col.type !== 'startevent' && col.type !== 'endevent' && col.type !== 'exclusivegateway') {
cols.push({
title: col.name || col.id,
key: col.id,
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/user/SchemaList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,9 @@
text: this.searchQuery,
filterBy: this.selectedFilterBy
}
if (this.selectedFilterBy === 'customRange') {
object['customValue'] = this.enteredDateRange
}
this.$emit('search-data', object)
},
sortTableData (object) {
Expand Down