From: ChangHyun Lee Date: Tue, 18 Apr 2017 12:16:17 +0000 (+0900) Subject: [TIC-Web] fix for readlog error X-Git-Tag: v20170428~12^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=73f270fc903198da762242e81c1efc0ae6a6e07b;p=archive%2F20170607%2Ftools%2Ftic.git [TIC-Web] fix for readlog error - fix for readlog error Change-Id: I12b7ea9808a5442b26efb72749344242d095b6b8 Signed-off-by: ChangHyun Lee --- diff --git a/controller/filesystem.js b/controller/filesystem.js index 7292bfd..3f49861 100644 --- a/controller/filesystem.js +++ b/controller/filesystem.js @@ -30,8 +30,13 @@ FileSystem.readLogFile = function readLogFile(req, res) { var strJobId = req.params.id; var strJobLogPath = AppConfig.TIC_WEB.PATH + strJobId + '/' + AppConfig.MIC.LOG; - fs.readFile(strJobLogPath, { encoding: 'utf8' }, function (err, data ) { - res.json(data); + fs.readFile(strJobLogPath, { encoding: 'utf8' }, function (err, data) { + if (err) { + // log file is not exist + res.json({}); + } else { + res.json(data); + } }); } diff --git a/public/src/js/page/job.js b/public/src/js/page/job.js index 1e3faf5..3959f3b 100644 --- a/public/src/js/page/job.js +++ b/public/src/js/page/job.js @@ -122,9 +122,8 @@ define([ } function _updateDataModel(result) { + logger.info('_updateDataModel'); return new Promise(function (resolve, reject) { - logger.info('_updateDataModel'); - // model _.forEach(result, function (jobItem) { var item; @@ -142,10 +141,10 @@ define([ } function _getAllListItem() { + logger.info('_getAllListItem'); var msgData = { pageNum: pageNum }; - logger.info('_getAllListItem'); return Util.POST(AppConfig.EVENT.JOB.JOB_GET_ALL_LISTITEM, msgData); } @@ -230,7 +229,7 @@ define([ job_updater: UserInfo.email }; logger.info('MIC_ADD_PID_JOB_TO: ' + JSON.stringify(msgObj)); - return Util.POST(AppConfig.EVENT.JOB.JOB_EDIT_ONE + dataObj.jobId, msgObj); + Util.POST(AppConfig.EVENT.JOB.JOB_EDIT_ONE + dataObj.jobId, msgObj); }); /** @@ -323,32 +322,27 @@ define([ * ]; */ function addAnImage(arrFileInfo) { - return new Promise(function (resolve, reject) { - var imageInfo, msgObj; - /** - * imageInfo @type {Object} - * imageInfo = { - * mtime: "Thu, 09 Mar 2017 13:06:01 GMT", - * name: "default.tar.gz", - * size: 127013, - * type: "file" - * } - */ - imageInfo = _.find(arrFileInfo, {name: imageName}); - logger.info('IMAGE_ADD_FINISH.addAnImage: ' + JSON.stringify(imageInfo)); - if (imageInfo && imageInfo.type === 'file') { - msgObj = { - image_name: imageInfo.name, - image_type: 'external', - image_size: imageInfo.size - }; - - Util.POST(AppConfig.EVENT.IMAGE.IMAGE_ADD_ONE, msgObj) - .then(resolve, reject); - } else { - reject('This is not a valid image file'); - } - }); + /** + * imageInfo @type {Object} + * imageInfo = { + * mtime: "Thu, 09 Mar 2017 13:06:01 GMT", + * name: "default.tar.gz", + * size: 127013, + * type: "file" + * } + */ + var imageInfo = _.find(arrFileInfo, {name: imageName}); + logger.info('IMAGE_ADD_FINISH.addAnImage: ' + JSON.stringify(imageInfo)); + if (imageInfo && imageInfo.type === 'file') { + var msgObj = { + image_name: imageInfo.name, + image_type: 'external', + image_size: imageInfo.size + }; + return Util.POST(AppConfig.EVENT.IMAGE.IMAGE_ADD_ONE, msgObj); + } else { + return Promise.reject('This is not a valid image file'); + } } function getAnImageInfo() { @@ -413,7 +407,7 @@ define([ throw err; } - function doUpdateJobView (jobModel) { + function doUpdateJobView(jobModel) { logger.info('doCreateAnImage.doUpdateJobView'); Util.POST(AppConfig.EVENT.JOB.JOB_EDIT_ONE + jobModel.getJobId(), { job_status: JOB_STATUS_INPROGRESS, @@ -429,7 +423,7 @@ define([ function doCreate (jobModel) { return new Promise(function (resolve, reject) { - var pathKsFile, imageName, msgData, msgObj; + var pathKsFile, imageName, msgData; logger.info('doCreateAnImage.doCreate');