The frontend/UI server, written in JS using the MarkoJS library
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.
 
 
 
 

57 lines
1.5 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)})
}
console.log("FILTER:", this.state.filter)
this.refresh()
}
removeFilter(type, filter) {
console.log(type, filter, this.state.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() {
console.log("REFRESH", this.state.filter)
logHeaderApi.list(this.state.filter).then(logs => {
this.state.logs = logs
})
}
}