<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">
$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);
// 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() {
$('#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);
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
},
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 + ')');
+ }
}
});
};
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;