Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][UPD] Forward port changes from 14.0 #730

Open
wants to merge 14 commits into
base: 15.0
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[IMP] queue_job: Display warning before displaying big dependency graphs
paradoxxxzero authored and florentx committed Dec 27, 2024
commit 2015e7a312b8a62d6c07d0ca09cc8cb2fc1132d7
20 changes: 20 additions & 0 deletions queue_job/static/src/js/queue_job_fields.js
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ odoo.define("queue_job.fields", function (require) {
init: function () {
this._super.apply(this, arguments);
this.network = null;
this.forceRender = false;
this.tabListenerInstalled = false;
},
start: function () {
@@ -89,6 +90,25 @@ odoo.define("queue_job.fields", function (require) {
});
});

if (nodes.length * edges.length > 5000 && !this.forceRender) {
const warningDiv = document.createElement("div");
warningDiv.className = "alert alert-warning";
warningDiv.innerText =
`This graph is big (${nodes.length} nodes, ` +
`${edges.length} edges), it may take a while to display.`;
const button = document.createElement("button");
button.innerText = "Display anyway";
button.className = "btn btn-secondary";
button.onclick = function () {
self.forceRender = true;
warningDiv.parentNode.removeChild(warningDiv);
self._render();
};
warningDiv.appendChild(button);
this.$el.append(warningDiv);
return;
}

var data = {
nodes: new vis.DataSet(nodes),
edges: new vis.DataSet(edges),
7 changes: 7 additions & 0 deletions queue_job/static/src/scss/queue_job_fields.scss
Original file line number Diff line number Diff line change
@@ -2,4 +2,11 @@
width: 600px;
height: 400px;
border: 1px solid lightgray;
.alert {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
}