hankehly commented on code in PR #24770:
URL: https://github.com/apache/airflow/pull/24770#discussion_r911549688
##########
airflow/www/static/js/dags.js:
##########
@@ -428,17 +433,42 @@ function refreshDagRuns(error, json) {
});
}
-function handleRefresh() {
+function getAllDagIds() {
+ const dagIds = $('[id^=toggle]').map(function () {
+ return $(this).data('dag-id');
+ }).get();
+ return dagIds;
+}
+
+function getActiveDagIds() {
+ const dagIds = $('[id^=toggle]').filter(':checked').map(function () {
+ return $(this).data('dag-id');
+ }).get();
+ return dagIds;
+}
+
+// To target a subset of dags, pass a function that returns an array
+// of dag ids. If no function is specified, all dags are targeted.
+function handleRefresh(getDagIds) {
+ if (typeof getDagIds !== 'function') {
+ getDagIds = getAllDagIds;
+ }
+ const params = new URLSearchParams();
+ getDagIds().forEach(dagId => {
+ params.append('dag_ids', dagId);
+ });
$('#loading-dots').css('display', 'inline-block');
- d3.json(lastDagRunsUrl)
- .header('X-CSRFToken', csrfToken)
- .post(encodedDagIds, lastDagRunsHandler);
- d3.json(dagStatsUrl)
- .header('X-CSRFToken', csrfToken)
- .post(encodedDagIds, refreshDagRuns);
- d3.json(taskStatsUrl)
- .header('X-CSRFToken', csrfToken)
- .post(encodedDagIds, refreshTaskStateHandler);
+ if (params.has('dag_ids')) {
Review Comment:
Don't send a request unless there are dags to refresh.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]