Fix jshint errors

This commit is contained in:
mabashian 2020-02-26 10:15:24 -05:00 committed by Rebeccah
parent b09ac71647
commit 48a615231b
2 changed files with 90 additions and 92 deletions

View File

@ -19,6 +19,94 @@ export default ['$scope','Wait', '$timeout', 'i18n',
let newJobs = [];
let newTemplates =[];
const fetchDashboardData = () => {
Rest.setUrl(GetBasePath('dashboard'));
Rest.get()
.then(({data}) => {
$scope.dashboardData = data;
})
.catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'), msg: i18n._(`Failed to get dashboard host graph data: ${status}`) });
});
if ($scope.graphData) {
Rest.setUrl(`${GetBasePath('dashboard')}graphs/jobs/?period=${$scope.graphData.period}&job_type=${$scope.graphData.jobType}`);
Rest.setHeader({'X-WS-Session-Quiet': true});
Rest.get()
.then(function(value) {
if($scope.graphData.status === "successful" || $scope.graphData.status === "failed"){
delete value.data.jobs[$scope.graphData.status];
}
$scope.graphData.jobStatus = value.data;
})
.catch(function({data, status}) {
ProcessErrors(null, data, status, null, { hdr: i18n._('Error!'), msg: i18n._(`Failed to get dashboard graph data: ${status}`)});
});
}
pendingDashboardRefresh = false;
dashboardTimerRunning = true;
$timeout(() => {
if (pendingDashboardRefresh) {
fetchDashboardData();
} else {
dashboardTimerRunning = false;
}
}, 5000);
};
const fetchNewJobs = () => {
newJobsTimerRunning = true;
const newJobIdsFilter = newJobs.join(',');
newJobs = [];
Rest.setUrl(`${GetBasePath("unified_jobs")}?id__in=${newJobIdsFilter}&order_by=-finished&finished__isnull=false&type=workflow_job,job&count_disabled=1`);
Rest.get()
.then(({ data }) => {
const joinedJobs = data.results.concat($scope.dashboardJobsListData);
$scope.dashboardJobsListData =
joinedJobs.length > 5 ? joinedJobs.slice(0, 5) : joinedJobs;
$timeout(() => {
if (newJobs.length > 0) {
fetchNewJobs();
} else {
newJobsTimerRunning = false;
}
}, 5000);
})
.catch(({ data, status }) => {
ProcessErrors($scope, data, status, null, {
hdr: i18n._('Error!'),
msg: i18n._(`Failed to get new jobs for dashboard: ${status}`)
});
});
};
const fetchNewTemplates = () => {
newTemplatesTimerRunning = true;
const newTemplateIdsFilter = newTemplates.join(',');
newTemplates = [];
Rest.setUrl(`${GetBasePath("unified_job_templates")}?id__in=${newTemplateIdsFilter}&order_by=-last_job_run&last_job_run__isnull=false&type=workflow_job_template,job_template&count_disabled=1"`);
Rest.get()
.then(({ data }) => {
const joinedTemplates = data.results.concat($scope.dashboardJobTemplatesListData).sort((a, b) => new Date(b.last_job_run) - new Date(a.last_job_run));
$scope.dashboardJobTemplatesListData =
joinedTemplates.length > 5 ? joinedTemplates.slice(0, 5) : joinedTemplates;
$timeout(() => {
if (newTemplates.length > 0 && !launchModalOpen) {
fetchNewTemplates();
} else {
newTemplatesTimerRunning = false;
}
}, 5000);
})
.catch(({ data, status }) => {
ProcessErrors($scope, data, status, null, {
hdr: i18n._('Error!'),
msg: i18n._(`Failed to get new templates for dashboard: ${status}`)
});
});
};
$scope.$on('ws-jobs', function (e, msg) {
if (msg.status === 'successful' || msg.status === 'failed' || msg.status === 'canceled') {
newJobs.push(msg.unified_job_id);
@ -59,7 +147,7 @@ export default ['$scope','Wait', '$timeout', 'i18n',
}
break;
}
};
}
if (msg.status === 'successful' || msg.status === 'failed' || msg.status === 'canceled') {
$scope.dashboardJobTemplatesListData.sort((a, b) => new Date(b.last_job_run) - new Date(a.last_job_run));
@ -124,96 +212,6 @@ export default ['$scope','Wait', '$timeout', 'i18n',
$scope.$emit('dashboardDataLoadComplete');
});
const fetchDashboardData = () => {
Rest.setUrl(GetBasePath('dashboard'));
Rest.get()
.then(({data}) => {
$scope.dashboardData = data;
})
.catch(({data, status}) => {
ProcessErrors($scope, data, status, null, { hdr: i18n._('Error!'), msg: i18n._(`Failed to get dashboard host graph data: ${status}`) });
});
if ($scope.graphData) {
Rest.setUrl(`${GetBasePath('dashboard')}graphs/jobs/?period=${$scope.graphData.period}&job_type=${$scope.graphData.jobType}`);
Rest.setHeader({'X-WS-Session-Quiet': true});
Rest.get()
.then(function(value) {
if($scope.graphData.status === "successful" || $scope.graphData.status === "failed"){
delete value.data.jobs[$scope.graphData.status];
}
$scope.graphData.jobStatus = value.data;
})
.catch(function({data, status}) {
ProcessErrors(null, data, status, null, { hdr: i18n._('Error!'), msg: i18n._(`Failed to get dashboard graph data: ${status}`)});
});
}
pendingDashboardRefresh = false;
dashboardTimerRunning = true;
$timeout(() => {
if (pendingDashboardRefresh) {
fetchDashboardData();
} else {
dashboardTimerRunning = false;
}
}, 5000);
};
const fetchNewJobs = () => {
newJobsTimerRunning = true;
const newJobIdsFilter = newJobs.join(',');
newJobs = [];
Rest.setUrl(`${GetBasePath("unified_jobs")}?id__in=${newJobIdsFilter}&order_by=-finished&finished__isnull=false&type=workflow_job,job&count_disabled=1`);
Rest.get()
.then(({ data }) => {
const joinedJobs = data.results.concat($scope.dashboardJobsListData);
$scope.dashboardJobsListData = joinedJobs.length > 5
? joinedJobs.slice(0, 5)
: joinedJobs;
$timeout(() => {
if (newJobs.length > 0) {
fetchNewJobs();
} else {
newJobsTimerRunning = false;
}
}, 5000);
})
.catch(({ data, status }) => {
ProcessErrors($scope, data, status, null, {
hdr: i18n._('Error!'),
msg: i18n._(`Failed to get new jobs for dashboard: ${status}`)
});
});
};
const fetchNewTemplates = () => {
newTemplatesTimerRunning = true;
const newTemplateIdsFilter = newTemplates.join(',');
newTemplates = [];
Rest.setUrl(`${GetBasePath("unified_job_templates")}?id__in=${newTemplateIdsFilter}&order_by=-last_job_run&last_job_run__isnull=false&type=workflow_job_template,job_template&count_disabled=1"`);
Rest.get()
.then(({ data }) => {
const joinedTemplates = data.results.concat($scope.dashboardJobTemplatesListData).sort((a, b) => new Date(b.last_job_run) - new Date(a.last_job_run));
$scope.dashboardJobTemplatesListData = joinedTemplates.length > 5
? joinedTemplates.slice(0, 5)
: joinedTemplates;
$timeout(() => {
if (newTemplates.length > 0 && !launchModalOpen) {
fetchNewTemplates();
} else {
newTemplatesTimerRunning = false;
}
}, 5000);
})
.catch(({ data, status }) => {
ProcessErrors($scope, data, status, null, {
hdr: i18n._('Error!'),
msg: i18n._(`Failed to get new templates for dashboard: ${status}`)
});
});
};
Wait('start');
Rest.setUrl(GetBasePath('dashboard'));
Rest.get()

View File

@ -39,7 +39,7 @@ export default ['$scope', '$stateParams', 'Rest', 'GetBasePath', '$state', 'OrgJ
}
break;
}
};
}
}
}
}