You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
const {logHeaderApi} = require("../../../../../rpdata/api/LogHeader")
|
|
|
|
module.exports = class {
|
|
onCreate(input) {
|
|
this.state = {
|
|
filter: input.filter,
|
|
logs: input.logs,
|
|
modal: null,
|
|
}
|
|
}
|
|
|
|
open(modal) {
|
|
this.state.modal = modal
|
|
}
|
|
|
|
close() {
|
|
this.state.modal = null
|
|
}
|
|
|
|
addFilter(type, filter) {
|
|
if (type === "search") {
|
|
this.state.filter = Object.assign({}, this.state.filter, {search: filter})
|
|
} else {
|
|
this.state.filter = Object.assign({}, this.state.filter, {[type]: (this.state.filter[type] || []).concat(filter)})
|
|
}
|
|
|
|
this.refresh()
|
|
}
|
|
|
|
removeFilter(type, filter) {
|
|
|
|
if (type === "search") {
|
|
this.state.filter = Object.assign({}, this.state.filter, {search: null})
|
|
this.refresh()
|
|
} else if ((this.state.filter[type] || []).length === 1) {
|
|
this.state.filter = Object.assign({}, this.state.filter, {[type]: null})
|
|
this.refresh()
|
|
} else {
|
|
const index = (this.state.filter[type] || []).indexOf(filter)
|
|
if (index !== -1) {
|
|
this.state.filter = Object.assign({}, this.state.filter, {[type]: this.state.filter[type].splice(0, index).concat(this.state.filter[type].splice(index + 1))},)
|
|
this.refresh()
|
|
}
|
|
}
|
|
}
|
|
|
|
refresh() {
|
|
logHeaderApi.list(this.state.filter).then(logs => {
|
|
this.state.logs = logs
|
|
})
|
|
}
|
|
}
|