14 var logger = Logger('model/ImageModel.js');
19 // define the downloadable status
20 var DOWNLOADABLE_STATUS = 'DONE';
21 // define the default status
22 var DEFAULT_STATUS = 'READY';
24 // set the config information for the app
25 Util.getAppConfig().then(function (data) {
29 var ImageModel = function (paramObj) {
40 this.imageIsDownload;//{boolean}
42 // for the href on a tag
53 ImageModel.prototype.init = function (obj) {
54 logger.info('init: ' + JSON.stringify(obj));
56 this.setImageId(obj.image_id);
57 this.setImageName(obj.image_name);
58 this.setImageSize(obj.image_size);
59 this.setImageUptime(obj.image_uptime);
60 this.setImageStatus(obj.image_status);
62 this.setImageJobId(obj.image_job_id);
64 this.setImageHasKsFile(obj.image_hasksfile);
65 this.setImageIsDownload(obj.image_status);
68 this.setJobAbsImagePath();
69 this.setJobAbsKsPath();
70 this.setJobAbsLogPath();
73 ImageModel.prototype.getJobAbsLogPath = function getJobAbsLogPath () {
74 return this.jobAbsLogPath;
77 ImageModel.prototype.setJobAbsLogPath = function setJobAbsLogPath () {
78 this.jobAbsLogPath = this.getJobAbsPath() + AppConfig.TIC_WEB.LOG_FILE_NAME;
81 ImageModel.prototype.getJobAbsKsPath = function getJobAbsKsPath (value) {
82 return this.jobAbsKsPath = value;
85 ImageModel.prototype.setJobAbsKsPath = function setJobAbsKsPath (value) {
86 this.jobAbsKsPath = value || this.getJobAbsPath() + AppConfig.TIC_WEB.KS_FILE_NAME;
89 ImageModel.prototype.getJobAbsImagePath = function getJobAbsImagePath () {
90 return this.jobAbsImagePath;
93 ImageModel.prototype.setJobAbsImagePath = function setJobAbsImagePath (value) {
94 this.jobAbsImagePath = value || this.getJobAbsPath() + this.getImageName();
97 ImageModel.prototype.getJobAbsPath = function getJobAbsPath (value) {
98 return this.jobAbsPath;
101 ImageModel.prototype.setJobAbsPath = function setJobAbsPath (value) {
102 this.jobAbsPath = value || AppConfig.TIC_WEB.PATH_ABSTRACT + this.getImageJobId() + '/';
105 ImageModel.prototype.getImageIsDownload = function getImageIsDownload () {
106 return this.imageIsDownload;
109 ImageModel.prototype.setImageIsDownload = function setImageIsDownload (value) {
110 var status, isDownloadable;
112 isDownloadable = false;
113 status = value || this.getImageStatus();
115 if (status === DOWNLOADABLE_STATUS) {
116 isDownloadable = true;
118 this.imageIsDownload = isDownloadable;
121 ImageModel.prototype.getImageHasKsFile = function getImageHasKsFile () {
122 return this.imageHasKsFile;
125 ImageModel.prototype.setImageHasKsFile = function setImageHasKsFile (value) {
126 this.imageHasKsFile = value || false;
129 ImageModel.prototype.getImageJobId = function getImageJobId (value) {
130 return this.imageJobId;
133 ImageModel.prototype.setImageJobId = function setImageJobId (value) {
134 this.imageJobId = value || 0;
137 ImageModel.prototype.getImageStatus = function getImageStatus () {
138 return this.imageStatus;
141 ImageModel.prototype.setImageStatus = function setImageStatus (value) {
142 this.imageStatus = value || DEFAULT_STATUS;
145 ImageModel.prototype.getImageUptime = function getImageUptime (value) {
146 return this.imageUptime;
149 ImageModel.prototype.setImageUptime = function setImageUptime (value) {
150 this.imageUptime = value || '';
153 ImageModel.prototype.getImageSize = function getImageSize () {
154 return this.imageSize;
157 ImageModel.prototype.setImageSize = function setImageSize (value) {
158 this.imageSize = value ? Util.bytesToSize(value) : '0KB';
161 ImageModel.prototype.getImageName = function getImageName () {
162 return this.imageName;
165 ImageModel.prototype.setImageName = function setImageName (value) {
166 this.imageName = value || '-';
169 ImageModel.prototype.getImageId = function getImageId () {
173 ImageModel.prototype.setImageId = function setImageId (value) {
174 this.imageId = value;