[TIC-Web] add notification dialog when image creation 94/110194/3
authorChangHyun Lee <leechwin.lee@samsung.com>
Fri, 13 Jan 2017 07:33:37 +0000 (16:33 +0900)
committerChangHyun Lee <leechwin.lee@samsung.com>
Fri, 13 Jan 2017 09:00:04 +0000 (18:00 +0900)
- add notification dialog

Change-Id: I94e553f680229466bc3f834bd3be328719558a9f
Signed-off-by: ChangHyun Lee <leechwin.lee@samsung.com>
public/src/index.html
public/src/js/page/image.js
public/src/js/util.js
server/fs/mic.js
server/fs/socketEvent.js

index a36336f..094f8cd 100644 (file)
             <i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
         </div><!-- /End Loading Dialog -->
 
+        <!-- Info Dialog -->
+        <div class="modal fade" id="tic-info-dialog" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
+            <div class="modal-dialog modal-sm">
+                <div class="modal-content">
+                    <div class="modal-body">
+                        <p id="tic-info-content"></p>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-success" data-dismiss="modal">Close</button>
+                </div>
+                </div>
+            </div>
+        </div><!-- /End Info Dialog -->
+
         <!-- Alert Dialog -->
         <div class="modal fade" id="tic-alert-dialog" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
             <div class="modal-dialog modal-sm">
index e78ca44..75dba14 100644 (file)
@@ -62,18 +62,15 @@ define([
             $imageNewLog.animate({ scrollTop : $imageNewLog.height() }, 'slow');
         });
 
-        /**
-         * TODO
-         *
-         * manage the logs for file.
-         */
         // when finish
         client.on('ws/fs/image/add/finish', function (data) {
             var logItem = _.template(IMAGE_LOG)({
-                log: data
+                log: 'Image created successfully.'
             });
             var $imageNewLog = $('#tic-image-new-log').append(logItem);
-            $imageNewLog.animate({ scrollTop : $imageNewLog.height() }, 'slow');
+
+            // notification popup
+            Util.showInfoDialog('Image created successfully.');
 
             // button enabled
             $('#tic-image-create').prop('disabled', false);
@@ -82,6 +79,24 @@ define([
             // upate the list of images
             updateList();
         });
+
+        client.on('ws/fs/image/add/fail', function (data) {
+            var logItem = _.template(IMAGE_LOG)({
+                log: 'Failed to create image.'
+            });
+            var $imageNewLog = $('#tic-image-new-log').append(logItem);
+
+            // notification popup
+            Util.showAlertDialog('Failed to create image.');
+
+            // button enabled
+            $('#tic-image-create').prop('disabled', false);
+            $('#tic-image-cancel').toggleClass('hidden', true);
+
+            // upate the list of images
+            updateList();
+        });
+
     }
 
     function updateList() {
index b390453..a949fdb 100644 (file)
@@ -29,6 +29,11 @@ define([
         $('#tic-alert-dialog').modal('show');
     }
 
+    function showInfoDialog(content) {
+        $('#tic-info-content').html(content);
+        $('#tic-info-dialog').modal('show');
+    }
+
     function showConfirmDialog(content) {
         return new Promise(function (resolve, reject) {
             $('#tic-confirm-content').html(content);
@@ -109,6 +114,13 @@ define([
         showLoadingDialog: showLoadingDialog,
 
         /**
+         * Display the info dialog.
+         * @method showInfoDialog
+         * @param {string} content in dialog
+         */
+        showInfoDialog: showInfoDialog,
+
+        /**
          * Display the alert dialog.
          * @method showAlertDialog
          * @param {string} content in dialog
index 423f6f4..dc21ec6 100644 (file)
@@ -59,12 +59,17 @@ Mic.create = function (paramObj, io) {
         },
         error: function (out) {
             logger.info(out);
-            sendMsg(SocketEvent.FS_IMAGE_ADD_TO, out);
+            sendMsg(SocketEvent.FS_IMAGE_ADD_FAIL, 'Failed (' + code + ')');
         },
         exit: function (code) {
+            // code is the final exit code of the process, otherwise null
             ps = null;
             logger.error('Terminated (' + code + ')');
-            sendMsg(SocketEvent.FS_IMAGE_ADD_FINISH, 'Terminated (' + code + ')');
+            if (code != null) {
+                sendMsg(SocketEvent.FS_IMAGE_ADD_FINISH, 'Terminated (' + code + ')');
+            } else {
+                sendMsg(SocketEvent.FS_IMAGE_ADD_FAIL, 'Failed (' + code + ')');
+            }
         }
     });
 };
index 72c895c..8a281b2 100644 (file)
@@ -14,6 +14,7 @@ SocketEvent.FS_IMAGE_LIST_FROM = 'ws/fs/image/list/from';
 SocketEvent.FS_IMAGE_ADD_TO = 'ws/fs/image/add/to';
 SocketEvent.FS_IMAGE_ADD_FROM = 'ws/fs/image/add/from';
 SocketEvent.FS_IMAGE_ADD_KILL = 'ws/fs/image/add/kill';
+SocketEvent.FS_IMAGE_ADD_FAIL = 'ws/fs/image/add/fail';
 SocketEvent.FS_IMAGE_ADD_FINISH = 'ws/fs/image/add/finish';
 
 module.exports = SocketEvent;