[TIC-Web] fix the RESTful api 65/128665/1
authorChangHyun Lee <leechwin.lee@samsung.com>
Thu, 11 May 2017 04:02:26 +0000 (13:02 +0900)
committerChangHyun Lee <leechwin.lee@samsung.com>
Thu, 11 May 2017 04:02:26 +0000 (13:02 +0900)
- fix the '/api/exports' RESTful api

Change-Id: I646f34acc2492de0e2165166d12a04acd93a4268
Signed-off-by: ChangHyun Lee <leechwin.lee@samsung.com>
controller/router.js
controller/ticcore.js
public/src/js/page/export.js
public/src/js/page/package.js

index 76d47bf..584e6db 100644 (file)
@@ -232,10 +232,10 @@ var init = function (serv) {
 
     /**
      * Get ks file path from tic-core via RESTful API
-     * @URI /api/exports:format
+     * @URI /api/exports
      * @TYPE POST
      */
-    router.post('/exports/:format', function (req, res) {
+    router.post('/exports', function (req, res) {
         logger.info('an api called that /api/exports');
         core.getExports(req, res);
     });
index eaacc50..d3e664b 100644 (file)
@@ -86,6 +86,7 @@ ticcore.getAnalysis = function getAnalysis (req, res) {
  * Get recipe data from tic-core via RESTful API
  */
 ticcore.getImports = function getImports (req, res) {
+    logger.info('getImports');
     var postData = JSON.stringify(req.body);
     var addr = this.server.address();
 
@@ -124,17 +125,28 @@ ticcore.getImports = function getImports (req, res) {
 };
 
 ticcore.getExports = function getExports(req, res) {
-    var postData = JSON.stringify(req.body);
-    logger.info('getExports: ' + postData);
+    logger.info('getExports');
+    var format = req.body.format;
+    var defaultOutdir = AppConfig.TIC_WEB.PATH_RECIPE_EXPORT;
+    // FIXME: outdir setting for ks file when image creation
+    if (req.body.outdir) {
+        defaultOutdir = req.body.outdir;
+    }
+
+    var body = {
+        recipes: req.body.recipes,
+        packages: req.body.packages,
+        outdir: defaultOutdir
+    }
+    var postData = JSON.stringify(body);
 
     var addr = this.server.address();
-
     var options = {
         host: addr.address,
         port: AppConfig.TIC_CORE.PORT || addr.port + 1,
         method: 'POST',
         path: _.template(EXPORT_FORMAT)({
-            format: req.params.format
+            format: format
         }),
         headers: {
             'Content-Type': 'application/json',
index 1737898..446371c 100644 (file)
@@ -34,10 +34,10 @@ define([
     function showExportDialog() {
         Util.showConfirmDialog('Are you sure you want to export recipe?')
         .then(function () {
-            return Util.POST(CONFIG.EVENT.PACKAGE.EXPORT + CONFIG.EVENT.PACKAGE.EXPORT_RECIPE, {
+            return Util.POST(CONFIG.EVENT.PACKAGE.EXPORT, {
+                format: CONFIG.EVENT.PACKAGE.EXPORT_RECIPE,
                 recipes: require('js/page/settings').getRecipeStore(),
-                packages: _.map(require('js/page/package').getCheckedPackages(), 'name'),
-                outdir: CONFIG.TIC_WEB.PATH_RECIPE_EXPORT
+                packages: _.map(require('js/page/package').getCheckedPackages(), 'name')
             });
         })
         .then(function (res) {
index 50d66aa..f965988 100644 (file)
@@ -105,8 +105,10 @@ define([
             });
         }
 
+        // TODO: move to server side
         function getRecipeFile(newJobModel) {
             var msgData = {
+                format: AppConfig.EVENT.PACKAGE.EXPORT_KS,
                 recipes: Settings.getRecipeStore(),
                 packages: _.map(checkedPackagesList, 'name'),
                 outdir: newJobModel.getJobPath()
@@ -143,7 +145,7 @@ define([
             }
 
             function getKickStartFile () {
-                return Util.POST(AppConfig.EVENT.PACKAGE.EXPORT + AppConfig.EVENT.PACKAGE.EXPORT_KS, msgData);
+                return Util.POST(AppConfig.EVENT.PACKAGE.EXPORT, msgData);
             }
 
             return getKickStartFile()