From: ChangHyun Lee Date: Wed, 12 Apr 2017 04:57:48 +0000 (+0900) Subject: [TIC-Web] add recipe import from file X-Git-Tag: v20170428~14^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dd441623a25945c625418b4bb4aa1749631e7073;p=archive%2F20170607%2Ftools%2Ftic.git [TIC-Web] add recipe import from file - add recipe import from file Change-Id: If27929039d042c0616462b826083e9e0eff131bd Signed-off-by: ChangHyun Lee --- diff --git a/config.json b/config.json index b3621e3..9e221cf 100644 --- a/config.json +++ b/config.json @@ -49,7 +49,8 @@ "PACKAGE": { "IMPORT": "/api/imports/", "EXPORT": "/api/exports/", - "ANALYSIS": "/api/analysis" + "ANALYSIS": "/api/analysis", + "RECIPE_UPLOAD": "/api/recipe/upload" }, "IMAGE": { "IMAGE_GET_ALL_COUNT": "/api/image/count/", diff --git a/controller/filesystem.js b/controller/filesystem.js index 6e8a5fd..b497513 100644 --- a/controller/filesystem.js +++ b/controller/filesystem.js @@ -8,18 +8,24 @@ var logger = JL('filesystem.js'); var FileSystem = {}; -FileSystem.readLogFile = function readLogFile (req, res) { - var strJobId, strJobLogPath; - +FileSystem.readLogFile = function readLogFile(req, res) { logger.info('readLogFile'); - strJobId = req.params.id; - - strJobLogPath = AppConfig.TIC_WEB.PATH + strJobId + '/' + AppConfig.MIC.LOG; + 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); }); } +FileSystem.uploadRecipeFile = function uploadRecipeFile(req, res) { + logger.info('uploadRecipeFile: ' + '"' + req.file.originalname + '"'); + + res.json({ + originalname: req.file.originalname, + filename: req.file.filename + }); +} + module.exports = FileSystem; diff --git a/controller/router.js b/controller/router.js index e4670dd..1b04e76 100644 --- a/controller/router.js +++ b/controller/router.js @@ -1,6 +1,7 @@ +// middle-ware var express = require('express'); var router = express.Router(); -var http = require('http'); +var multer = require('multer'); var core = require('./ticcore'); var client = require('./dbquery'); @@ -11,6 +12,8 @@ var filesystem = require('./filesystem'); var JL = require('jsnlog').JL; var logger = JL('router.js'); +var recipeUpload = multer({ dest: config.TIC_WEB.PATH_RECIPE_IMPORT }); + var server = null; var _init = function _init () { @@ -201,6 +204,15 @@ var init = function (serv) { session.deleteSession(req, res); }); + /** + * Upload recipe file + * @URI /api/recipe/upload + * @TYPE POST + */ + router.post('/recipe/upload', recipeUpload.single('file'), function (req, res) { + filesystem.uploadRecipeFile(req, res); + }); + return router; }; diff --git a/package.json b/package.json index 0c99f06..8813751 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "jquery": "~3.1.1", "express": "~4.14.0", "body-parser": "~1.15.2", + "multer": "~1.3.0", "socket.io": "~1.6.0", "mime": "~1.3.4", "mkdirp": "~0.5.1", diff --git a/public/src/css/style.css b/public/src/css/style.css index 105faa7..21e0d6b 100644 --- a/public/src/css/style.css +++ b/public/src/css/style.css @@ -551,3 +551,15 @@ a.log-view-content-download { padding-right: 0px; padding-left: 0px; } + +.dropzone { + min-height: 0px; + border: 2px dashed #0087F7; + border-radius: 5px; + padding: 0px; + margin-bottom: 10px; +} + +.dropzone .dz-preview .dz-progress { + margin-top: -15px; +} \ No newline at end of file diff --git a/public/src/index.html b/public/src/index.html index de31545..bc27c1e 100644 --- a/public/src/index.html +++ b/public/src/index.html @@ -11,6 +11,8 @@ + +