فهرست منبع

use getNetboxData utility function in job handling

checktheroads 4 سال پیش
والد
کامیت
024f3962b2
3فایلهای تغییر یافته به همراه5 افزوده شده و 9 حذف شده
  1. 0 0
      netbox/project-static/dist/jobs.js
  2. 0 0
      netbox/project-static/dist/jobs.js.map
  3. 5 9
      netbox/project-static/src/jobs.ts

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
netbox/project-static/dist/jobs.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
netbox/project-static/dist/jobs.js.map


+ 5 - 9
netbox/project-static/src/jobs.ts

@@ -1,5 +1,5 @@
 import { createToast } from './bs';
-import { apiGetBase, hasError } from './util';
+import { apiGetBase, hasError, getNetboxData } from './util';
 
 let timeout: number = 1000;
 
@@ -21,19 +21,14 @@ function asyncTimeout(ms: number) {
  * JavaScript.
  */
 function getJobInfo(): JobInfo {
-  let id: Nullable<string> = null;
   let complete = false;
 
-  // Determine the Job ID, if present.
-  const jobIdElement = document.getElementById('jobId');
-  if (jobIdElement !== null && jobIdElement.getAttribute('data-value')) {
-    id = jobIdElement.getAttribute('data-value');
-  }
+  const id = getNetboxData('data-job-id');
+  const jobComplete = getNetboxData('data-job-complete');
 
   // Determine the job completion status, if present. If the job is not complete, the value will be
   // "None". Otherwise, it will be a stringified date.
-  const jobCompleteElement = document.getElementById('jobComplete');
-  if (jobCompleteElement !== null && jobCompleteElement.getAttribute('data-value') !== 'None') {
+  if (typeof jobComplete === 'string' && jobComplete.toLowerCase() !== 'none') {
     complete = true;
   }
   return { id, complete };
@@ -91,6 +86,7 @@ async function checkJobStatus(id: string) {
 
 function initJobs() {
   const { id, complete } = getJobInfo();
+
   if (id !== null && !complete) {
     // If there is a job ID and it is not completed, check for the job's status.
     Promise.resolve(checkJobStatus(id));

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است