2 * Copyright (c) 2017 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 'js/model/JobStatusModel'
32 var logger = Logger('model/JobModel.js');
37 // define the downloadable status
38 var DOWNLOADABLE_STATUS = 'DONE';
40 // set the config information for the app
41 Util.getAppConfig().then(function (data) {
45 var JobModel = function (paramObj) {
47 this.jobStatus = null;
48 this.jobStatusText = null;
49 this.jobStatusClass = null;
50 this.jobImageName = null;
51 this.jobImageSize = null;
54 this.jobImagePath = null;
55 this.jobHasKsFile = false;
57 this.jobKsPath = null;
58 this.jobLogPath = null;
60 this.isDownload = false;
62 // for the href on a tag
63 this.jobAbsPath = null;
64 this.jobAbsImagePath = null;
65 this.jobAbsKsPath = null;
66 this.jobAbsLogPath = null;
67 this.jobUptime = null;
69 this.jobUserGroup = null;
76 JobModel.prototype.init = function (obj) {
77 logger.info('init: ' + JSON.stringify(obj));
79 this.setJobId(obj.job_id);
83 this.setJobStatus(obj.job_status);
84 this.setJobImageName(obj.job_image_name);
85 this.setJobImageSize(obj.job_image_size);
86 this.setJobPid(obj.job_pid);
88 this.setJobHasKsFile(obj.job_hasksfile);
89 this.setJobKs(obj.job_ks);
92 this.setJobArch(obj.job_arch);
94 this.setJobAbsLogPath();
96 this.setJobUptime(obj.job_uptime);
98 this.setJobUserGroup(obj.job_usergroup);
101 JobModel.prototype.getIsDownload = function () {
102 return this.isDownload;
105 JobModel.prototype.setIsDownload = function (value) {
106 this.isDownload = value || false;
109 JobModel.prototype.getJobUptime = function () {
110 return this.jobUptime;
113 JobModel.prototype.setJobUptime = function (value) {
114 this.jobUptime = value;
117 JobModel.prototype.getJobUserGroup = function () {
118 return this.jobUserGroup;
121 JobModel.prototype.setJobUserGroup = function (value) {
122 this.jobUserGroup = value;
125 JobModel.prototype.getJobLogPath = function () {
126 return this.jobLogPath;
129 JobModel.prototype.setJobLogPath = function () {
130 this.jobLogPath = this.getJobPath() + AppConfig.MIC.LOG;
133 JobModel.prototype.getJobArch = function () {
137 JobModel.prototype.setJobArch = function (value) {
141 * Confirm default value . armv7l right?
143 this.jobArch = value || 'armv7l';
146 JobModel.prototype.getJobAbsLogPath = function () {
147 return this.jobAbsLogPath;
150 JobModel.prototype.setJobAbsLogPath = function () {
151 this.jobAbsLogPath = this.getJobAbsPath() + AppConfig.MIC.LOG;
154 JobModel.prototype.getJobKsPath = function () {
155 return this.jobKsPath;
158 JobModel.prototype.setJobKsPath = function () {
159 this.jobKsPath = this.getJobPath() + this.getJobKs();
162 JobModel.prototype.getJobAbsKsPath = function () {
163 return this.jobAbsKsPath;
166 JobModel.prototype.setJobAbsKsPath = function () {
167 this.jobAbsKsPath = this.getJobAbsPath() + this.getJobKs();
170 JobModel.prototype.getJobHasKsFile = function () {
171 return this.jobHasKsFile;
174 JobModel.prototype.setJobHasKsFile = function (value) {
175 this.jobHasKsFile = value || false;
178 JobModel.prototype.getJobKs = function () {
182 JobModel.prototype.setJobKs = function (value) {
183 this.jobKs = value || '';
186 this.setJobAbsKsPath();
189 JobModel.prototype.getJobImagePath = function () {
190 return this.jobImagePath;
193 JobModel.prototype.setJobImagePath = function () {
194 this.jobImagePath = this.getJobPath() + this.getJobImageName();
197 JobModel.prototype.getJobImageSize = function () {
198 return this.jobImageSize;
201 JobModel.prototype.setJobImageSize = function (value) {
202 this.jobImageSize = value ? Util.bytesToSize(value) : '0KB';
205 JobModel.prototype.getJobPid = function () {
209 JobModel.prototype.setJobPid = function (value) {
210 this.jobPid = value || null;
213 JobModel.prototype.getJobPath = function () {
217 JobModel.prototype.setJobPath = function () {
218 this.jobPath = AppConfig.TIC_WEB.PATH + this.getJobId() + '/';
221 JobModel.prototype.getJobAbsImagePath = function () {
222 return this.jobAbsImagePath;
225 JobModel.prototype.setJobAbsImagePath = function () {
226 this.jobAbsImagePath = this.getJobAbsPath() + this.getJobImageName();
229 JobModel.prototype.getJobAbsPath = function () {
230 return this.jobAbsPath;
233 JobModel.prototype.setJobAbsPath = function () {
234 this.jobAbsPath = AppConfig.TIC_WEB.PATH_ABSTRACT + this.getJobId() + '/';
237 JobModel.prototype.getJobImageName = function () {
238 return this.jobImageName;
241 JobModel.prototype.setJobImageName = function (value) {
242 this.jobImageName = value || '-';
244 this.setJobImagePath();
245 this.setJobAbsImagePath();
248 JobModel.prototype.getJobStatusText = function () {
249 return this.jobStatusText;
252 JobModel.prototype.setJobStatusText = function (value) {
253 this.jobStatusText = value || '';
256 JobModel.prototype.getJobStatusClass = function (value) {
257 return this.jobStatusClass;
260 JobModel.prototype.setJobStatusClass = function (value) {
261 this.jobStatusClass = value || '';
264 JobModel.prototype.getJobStatus = function () {
265 return this.jobStatus;
268 JobModel.prototype.setJobStatus = function (status) {
269 var statusInfo, isDownloadable;
271 isDownloadable = false;
272 statusInfo = JobStatusModel.getStatusInfo(status);
281 this.jobStatus = statusInfo.value || '';
282 this.setJobStatusText(statusInfo.text);
283 this.setJobStatusClass(statusInfo.class);
285 if (this.getJobStatus() === DOWNLOADABLE_STATUS) {
286 isDownloadable = true;
289 this.setIsDownload(isDownloadable);
292 JobModel.prototype.getJobId = function () {
296 JobModel.prototype.setJobId = function (value) {
297 this.jobId = value || 0;