Skip to content

Commit f0511aa

Browse files
committed
[IMP] queue_job: Display warning before displaying big dependency graphs
1 parent 76a42e2 commit f0511aa

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

queue_job/static/src/js/queue_job_fields.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ odoo.define("queue_job.fields", function (require) {
1616
init: function () {
1717
this._super.apply(this, arguments);
1818
this.network = null;
19+
this.forceRender = false;
1920
this.tabListenerInstalled = false;
2021
},
2122
start: function () {
@@ -88,6 +89,25 @@ odoo.define("queue_job.fields", function (require) {
8889
});
8990
});
9091

92+
if (nodes.length * edges.length > 5000 && !this.forceRender) {
93+
const warningDiv = document.createElement("div");
94+
warningDiv.className = "alert alert-warning";
95+
warningDiv.innerText =
96+
`This graph is big (${nodes.length} nodes, ` +
97+
`${edges.length} edges), it may take a while to display.`;
98+
const button = document.createElement("button");
99+
button.innerText = "Display anyway";
100+
button.className = "btn btn-secondary";
101+
button.onclick = function () {
102+
self.forceRender = true;
103+
warningDiv.parentNode.removeChild(warningDiv);
104+
self._render();
105+
};
106+
warningDiv.appendChild(button);
107+
this.$el.append(warningDiv);
108+
return;
109+
}
110+
91111
var data = {
92112
// eslint-disable-next-line no-undef
93113
nodes: new vis.DataSet(nodes),

queue_job/static/src/scss/queue_job_fields.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@
22
width: 600px;
33
height: 400px;
44
border: 1px solid lightgray;
5+
.alert {
6+
height: 100%;
7+
display: flex;
8+
flex-direction: column;
9+
align-items: center;
10+
justify-content: center;
11+
}
512
}

0 commit comments

Comments
 (0)