Procházet zdrojové kódy

Merge pull request #14155 from rmehta/show-proceesslist

feat(minor): Show Processlist in System Console
version-14
Rushabh Mehta před 3 roky
committed by GitHub
rodič
revize
63186fca75
V databázi nebyl nalezen žádný známý klíč pro tento podpis ID GPG klíče: 4AEE18F83AFDEB23
3 změnil soubory, kde provedl 75 přidání a 4 odebrání
  1. +41
    -0
      frappe/desk/doctype/system_console/system_console.js
  2. +28
    -3
      frappe/desk/doctype/system_console/system_console.json
  3. +6
    -1
      frappe/desk/doctype/system_console/system_console.py

+ 41
- 0
frappe/desk/doctype/system_console/system_console.js Zobrazit soubor

@@ -20,5 +20,46 @@ frappe.ui.form.on('System Console', {
$btn.text(__('Execute'));
});
});
},

show_processlist: function(frm) {
if (frm.doc.show_processlist) {
// keep refreshing every 5 seconds
frm.events.refresh_processlist(frm);
frm.processlist_interval = setInterval(() => frm.events.refresh_processlist(frm), 5000);
} else {
if (frm.processlist_interval) {

// end it
clearInterval(frm.processlist_interval);
}
}
},

refresh_processlist: function(frm) {
let timestamp = new Date();
frappe.call('frappe.desk.doctype.system_console.system_console.show_processlist').then(r => {
let rows = '';
for (let row of r.message) {
rows += `<tr>
<td>${row.Id}</td>
<td>${row.Time}</td>
<td>${row.State}</td>
<td>${row.Info}</td>
<td>${row.Progress}</td>
</tr>`
}
frm.get_field('processlist').html(`
<p class='text-muted'>Requested on: ${timestamp}</p>
<table class='table-bordered' style='width: 100%'>
<thead><tr>
<th width='10%'>Id</ht>
<th width='10%'>Time</ht>
<th width='10%'>State</ht>
<th width='60%'>Info</ht>
<th width='10%'>Progress</ht>
</tr></thead>
<tbody>${rows}</thead>`);
});
}
});

+ 28
- 3
frappe/desk/doctype/system_console/system_console.json Zobrazit soubor

@@ -17,9 +17,13 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"execute_section",
"console",
"commit",
"output"
"output",
"database_processes_section",
"show_processlist",
"processlist"
],
"fields": [
{
@@ -40,13 +44,34 @@
"fieldname": "commit",
"fieldtype": "Check",
"label": "Commit"
},
{
"fieldname": "execute_section",
"fieldtype": "Section Break",
"label": "Execute"
},
{
"fieldname": "database_processes_section",
"fieldtype": "Section Break",
"label": "Database Processes"
},
{
"default": "0",
"fieldname": "show_processlist",
"fieldtype": "Check",
"label": "Show Processlist"
},
{
"fieldname": "processlist",
"fieldtype": "HTML",
"label": "processlist"
}
],
"hide_toolbar": 1,
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2020-08-21 14:44:35.296877",
"modified": "2021-09-09 13:10:14.237113",
"modified_by": "Administrator",
"module": "Desk",
"name": "System Console",
@@ -65,4 +90,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}
}

+ 6
- 1
frappe/desk/doctype/system_console/system_console.py Zobrazit soubor

@@ -33,4 +33,9 @@ class SystemConsole(Document):
def execute_code(doc):
console = frappe.get_doc(json.loads(doc))
console.run()
return console.as_dict()
return console.as_dict()

@frappe.whitelist()
def show_processlist():
frappe.only_for('System Manager')
return frappe.db.sql('show processlist', as_dict=1)

Načítá se…
Zrušit
Uložit