|
|
@@ -74,13 +74,14 @@ export default { |
|
|
|
}; |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
frappe.socketio.init(9000) |
|
|
|
this.fetch_status() |
|
|
|
frappe.socketio.init(9000); |
|
|
|
this.fetch_status(); |
|
|
|
this.refresh(); |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
pages: function() { |
|
|
|
const current_page = this.query.pagination.page |
|
|
|
const total_pages = this.query.pagination.total |
|
|
|
const current_page = this.query.pagination.page; |
|
|
|
const total_pages = this.query.pagination.total; |
|
|
|
return [{ |
|
|
|
label:"Previous", |
|
|
|
number: Math.max(current_page - 1, 1), |
|
|
@@ -93,53 +94,51 @@ export default { |
|
|
|
label:"Next", |
|
|
|
number: Math.min(current_page + 1, total_pages), |
|
|
|
status: (current_page == total_pages) ? "disabled" : "", |
|
|
|
}] |
|
|
|
}]; |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
filtered: function(requests) { |
|
|
|
requests = requests.slice() |
|
|
|
const filters = Object.entries(this.query.filters) |
|
|
|
requests = requests.slice(); |
|
|
|
const filters = Object.entries(this.query.filters); |
|
|
|
requests = requests.filter( |
|
|
|
(r) => filters.map((f) => (r[f[0]] || "").match(f[1])).every(Boolean) |
|
|
|
) |
|
|
|
this.query.pagination.total = Math.ceil(requests.length / this.query.pagination.limit) |
|
|
|
return requests |
|
|
|
); |
|
|
|
this.query.pagination.total = Math.ceil(requests.length / this.query.pagination.limit); |
|
|
|
return requests; |
|
|
|
}, |
|
|
|
paginated: function(requests) { |
|
|
|
requests = requests.slice() |
|
|
|
const begin = (this.query.pagination.page - 1) * (this.query.pagination.limit) |
|
|
|
const end = begin + this.query.pagination.limit |
|
|
|
return requests.slice(begin, end) |
|
|
|
requests = requests.slice(); |
|
|
|
const begin = (this.query.pagination.page - 1) * (this.query.pagination.limit); |
|
|
|
const end = begin + this.query.pagination.limit; |
|
|
|
return requests.slice(begin, end); |
|
|
|
}, |
|
|
|
sorted: function(requests) { |
|
|
|
requests = requests.slice() |
|
|
|
const order = (this.query.order == "asc") ? 1 : -1 |
|
|
|
const sort = this.query.sort |
|
|
|
return requests.sort((a,b) => (a[sort] > b[sort]) ? order : -order) |
|
|
|
requests = requests.slice(); |
|
|
|
const order = (this.query.order == "asc") ? 1 : -1; |
|
|
|
const sort = this.query.sort; |
|
|
|
return requests.sort((a,b) => (a[sort] > b[sort]) ? order : -order); |
|
|
|
}, |
|
|
|
sort: function(key) { |
|
|
|
if(key == this.query.sort) { |
|
|
|
this.query.order = (this.query.order == "asc") ? "desc" : "asc" |
|
|
|
} |
|
|
|
else { |
|
|
|
this.query.order = "asc" |
|
|
|
this.query.order = (this.query.order == "asc") ? "desc" : "asc"; |
|
|
|
} else { |
|
|
|
this.query.order = "asc"; |
|
|
|
} |
|
|
|
this.query.sort = key |
|
|
|
this.query.sort = key; |
|
|
|
}, |
|
|
|
glyphicon: function(key) { |
|
|
|
if(key == this.query.sort) { |
|
|
|
return (this.query.order == "asc") ? "glyphicon-sort-by-attributes" : "glyphicon-sort-by-attributes-alt" |
|
|
|
} |
|
|
|
else { |
|
|
|
return "glyphicon-sort" |
|
|
|
return (this.query.order == "asc") ? "glyphicon-sort-by-attributes" : "glyphicon-sort-by-attributes-alt"; |
|
|
|
} else { |
|
|
|
return "glyphicon-sort"; |
|
|
|
} |
|
|
|
}, |
|
|
|
refresh: function() { |
|
|
|
frappe.call("frappe.www.recorder.get_requests").then( r => { |
|
|
|
this.requests = r.message |
|
|
|
this.last_fetched = new Date() |
|
|
|
}) |
|
|
|
this.requests = r.message; |
|
|
|
this.last_fetched = new Date(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
record: function(should_record) { |
|
|
|
frappe.call({ |
|
|
@@ -147,27 +146,26 @@ export default { |
|
|
|
args: { |
|
|
|
should_record: should_record |
|
|
|
} |
|
|
|
}).then(r => this.update_status(r.message)) |
|
|
|
}).then(r => this.update_status(r.message)); |
|
|
|
}, |
|
|
|
fetch_status: function() { |
|
|
|
this.refresh() |
|
|
|
frappe.call("frappe.www.recorder.get_status").then(r => this.update_status(r.message)) |
|
|
|
frappe.call("frappe.www.recorder.get_status").then(r => this.update_status(r.message)); |
|
|
|
}, |
|
|
|
update_status: function(status) { |
|
|
|
this.status = status |
|
|
|
this.status = status; |
|
|
|
if(this.status.status == "Active") { |
|
|
|
frappe.realtime.on("recorder-dump-event", this.refresh) |
|
|
|
frappe.realtime.on("recorder-dump-event", this.refresh); |
|
|
|
} else { |
|
|
|
frappe.realtime.off("recorder-dump-event", this.refresh) |
|
|
|
frappe.realtime.off("recorder-dump-event", this.refresh); |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
filters: { |
|
|
|
elipsize: function (value) { |
|
|
|
if (!value) return '' |
|
|
|
if (!value) return ''; |
|
|
|
if (value.length > 30) |
|
|
|
return value.substring(0, 30-3)+'...'; |
|
|
|
return value |
|
|
|
return value; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|