[TIC-Web] Update Job List
[archive/20170607/tools/tic.git] / public / src / js / model / JobModel.js
index 47e57d7..4fbf389 100644 (file)
@@ -32,13 +32,16 @@ define([
         this.jobId = null;
         this.jobStatus = null;
         this.jobStatusText = null;
+        this.jobStatusClass = null;
         this.jobImageName = null;
         this.jobImageSize = null;
         this.jobPath = null;
         this.jobImagePath = null;
         this.jobHasKsFile = false;
+        this.jobKs = null;
         this.jobKsPath = null;
         this.jobLogPath = null;
+        this.jobArch = null;
         this.isDownload = false;
 
         // for the href on a tag
@@ -57,19 +60,19 @@ define([
         logger.info('init: ' + JSON.stringify(obj));
 
         this.setJobId(obj.job_id);
+        this.setJobAbsPath();
+        this.setJobPath();
+
         this.setJobStatus(obj.job_status);
         this.setJobImageName(obj.job_image_name);
         this.setJobImageSize(obj.job_image_size);
 
-        this.setJobPath();
-        this.setJobImagePath();
         this.setJobHasKsFile(obj.job_hasksfile);
-        this.setJobKsPath();
+        this.setJobKs(obj.job_ks);
+
         this.setJobLogPath();
+        this.setJobArch(obj.job_arch);
 
-        this.setJobAbsPath();
-        this.setJobAbsImagePath();
-        this.setJobAbsKsPath();
         this.setJobAbsLogPath();
 
         this.setJobUptime(obj.job_uptime);
@@ -99,6 +102,19 @@ define([
         this.jobLogPath = this.getJobPath() + AppConfig.TIC_WEB.LOG_FILE_NAME;
     };
 
+    JobModel.prototype.getJobArch = function () {
+        return this.jobArch;
+    };
+
+    JobModel.prototype.setJobArch = function (value) {
+        /**
+         * FIXME
+         *
+         * Confirm default value . armv7l right?
+         */
+        this.jobArch = value || 'armv7l';
+    };
+
     JobModel.prototype.getJobAbsLogPath = function () {
         return this.jobAbsLogPath;
     };
@@ -112,7 +128,7 @@ define([
     };
 
     JobModel.prototype.setJobKsPath = function () {
-        this.jobKsPath = this.getJobPath() + AppConfig.TIC_WEB.KS_FILE_NAME;
+        this.jobKsPath = this.getJobPath() + this.getJobKs();
     };
 
     JobModel.prototype.getJobAbsKsPath = function () {
@@ -120,7 +136,7 @@ define([
     };
 
     JobModel.prototype.setJobAbsKsPath = function () {
-        this.jobAbsKsPath = this.getJobAbsPath() + AppConfig.TIC_WEB.KS_FILE_NAME;
+        this.jobAbsKsPath = this.getJobAbsPath() + this.getJobKs();
     };
 
     JobModel.prototype.getJobHasKsFile = function () {
@@ -131,6 +147,17 @@ define([
         this.jobHasKsFile = value || false;
     };
 
+    JobModel.prototype.getJobKs = function () {
+        return this.jobKs;
+    };
+
+    JobModel.prototype.setJobKs = function (value) {
+        this.jobKs = value || '';
+
+        this.setJobKsPath();
+        this.setJobAbsKsPath();
+    };
+
     JobModel.prototype.getJobImagePath = function () {
         return this.jobImagePath;
     };
@@ -176,7 +203,10 @@ define([
     };
 
     JobModel.prototype.setJobImageName = function (value) {
-        this.jobImageName = value ? value : '-';
+        this.jobImageName = value || '-';
+
+        this.setJobImagePath();
+        this.setJobAbsImagePath();
     };
 
     JobModel.prototype.getJobStatusText = function () {
@@ -187,6 +217,14 @@ define([
         this.jobStatusText = value || '';
     };
 
+    JobModel.prototype.getJobStatusClass = function (value) {
+        return this.jobStatusClass;
+    };
+
+    JobModel.prototype.setJobStatusClass = function (value) {
+        this.jobStatusClass = value || '';
+    };
+
     JobModel.prototype.getJobStatus = function () {
         return this.jobStatus;
     };
@@ -196,9 +234,17 @@ define([
 
         isDownloadable = false;
         statusInfo = JobStatusModel.getStatusInfo(status);
+        /**
+         * statusInfo = {
+         *      value: 'READY',
+         *      text: 'Ready',
+         *      class: 'fa'
+         * }
+         */
 
         this.jobStatus = statusInfo.value || '';
         this.setJobStatusText(statusInfo.text);
+        this.setJobStatusClass(statusInfo.class);
 
         if (this.getJobStatus() === DOWNLOADABLE_STATUS) {
             isDownloadable = true;