diff --git a/frappe/commands/site.py b/frappe/commands/site.py index 68f8a05815..3798c07e91 100755 --- a/frappe/commands/site.py +++ b/frappe/commands/site.py @@ -575,7 +575,7 @@ def browse(context, site): def start_recording(context): for site in context.sites: frappe.init(site=site) - frappe.cache().set("recorder-intercept", 1) + frappe.recorder.start() @click.command('stop-recording') @@ -583,7 +583,7 @@ def start_recording(context): def stop_recording(context): for site in context.sites: frappe.init(site=site) - frappe.cache().delete("recorder-intercept") + frappe.recorder.stop() commands = [ diff --git a/frappe/public/js/frappe/recorder/RecorderDetail.vue b/frappe/public/js/frappe/recorder/RecorderDetail.vue index df8953ea70..e12d6a665f 100644 --- a/frappe/public/js/frappe/recorder/RecorderDetail.vue +++ b/frappe/public/js/frappe/recorder/RecorderDetail.vue @@ -33,7 +33,7 @@
{{ columns[0].label }}
- @@ -44,7 +44,7 @@
- +
@@ -52,7 +52,7 @@ {{ request[columns[0].slug] }}
-
+
{{ request[column.slug] }}
@@ -70,7 +70,7 @@

Recorder is Inactive

-

+

No Requests found

@@ -107,11 +107,10 @@ export default { requests: [], columns: [ {label: "Time", slug: "time", sortable: true}, - {label: "Duration", slug: "duration", sortable: true}, - {label: "Time in Queries", slug: "time_queries", sortable: true}, - {label: "Queries", slug: "queries", sortable: true}, + {label: "Duration (ms)", slug: "duration", sortable: true, number: true}, + {label: "Time in Queries (ms)", slug: "time_queries", sortable: true, number: true}, + {label: "Queries", slug: "queries", sortable: true, number: true}, {label: "Method", slug: "method"}, - ], query: { sort: "time", @@ -127,11 +126,9 @@ export default { color: "grey", status: "Unknown", }, - last_fetched: null, }; }, mounted() { - frappe.socketio.init(9000); this.fetch_status(); this.refresh(); this.$root.page.set_secondary_action("Clear", () => { @@ -188,49 +185,35 @@ export default { 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.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"; - } - }, refresh: function() { - frappe.call("frappe.recorder.get").then( r => { - this.requests = r.message; - this.last_fetched = new Date(); - }); + frappe.call("frappe.recorder.get").then( r => this.requests = r.message); + }, + update: function(message) { + this.requests.push(JSON.parse(message)); }, clear: function() { - frappe.call("frappe.recorder.delete"); - this.refresh(); + frappe.call("frappe.recorder.delete").then(r => this.refresh()); }, - record: function(should_record) { - frappe.call({ - method: "frappe.recorder.set_recorder_state", - args: { - should_record: should_record - } - }).then(r => this.update_status(r.message)); + start: function() { + frappe.call("frappe.recorder.start").then(r => this.fetch_status()); + }, + stop: function() { + frappe.call("frappe.recorder.stop").then(r => this.fetch_status()); }, fetch_status: function() { - frappe.call("frappe.recorder.get_status").then(r => this.update_status(r.message)); + frappe.call("frappe.recorder.status").then(r => this.update_status(r.message)); }, - update_status: function(status) { - this.status = status; + update_status: function(result) { + if(result) { + this.status = {status: "Active", color: "green"} + } else { + this.status = {status: "Inactive", color: "red"} + } this.$root.page.set_indicator(this.status.status, this.status.color); if(this.status.status == "Active") { - frappe.realtime.on("recorder-dump-event", this.refresh); + frappe.realtime.on("recorder-dump-event", this.update); } else { - frappe.realtime.off("recorder-dump-event", this.refresh); + frappe.realtime.off("recorder-dump-event", this.update); } this.update_buttons(); @@ -238,22 +221,14 @@ export default { update_buttons: function() { if(this.status.status == "Active") { this.$root.page.set_primary_action("Stop", () => { - this.record(false); + this.stop(); }); } else { this.$root.page.set_primary_action("Start", () => { - this.record(true); + this.start(); }); } }, - }, - filters: { - elipsize: function (value) { - if (!value) return ''; - if (value.length > 30) - return value.substring(0, 30-3)+'...'; - return value; - } } }; diff --git a/frappe/public/js/frappe/recorder/RequestDetail.vue b/frappe/public/js/frappe/recorder/RequestDetail.vue index 95751692d4..8ce41a5708 100644 --- a/frappe/public/js/frappe/recorder/RequestDetail.vue +++ b/frappe/public/js/frappe/recorder/RequestDetail.vue @@ -1,85 +1,13 @@