From e0fce7832891b69d11e18dc8715d8e6afdc0df95 Mon Sep 17 00:00:00 2001 From: ChangHyun Lee Date: Mon, 19 Dec 2016 13:27:38 +0900 Subject: [PATCH] [TIC-UI] add confirm dialog - Add confirm dialog - Add mime package Signed-off-by: ChangHyun Lee Change-Id: I28daa1c95634e9f61ad40537d77c011e2f9bae08 --- README.md | 42 ++++++++++++++++++++++++++++++++---------- package.json | 3 ++- public/src/index.html | 44 ++++++++++++++++++++------------------------ public/src/js/page/image.js | 28 ++++++++++++++-------------- public/src/js/util.js | 21 +++++++++++++++++++++ 5 files changed, 89 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index c6ba682..501e7e5 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,42 @@ # Tizen Image Configurator -# Install -Install command +## Install -- npm install -- ./node_modules/bower/bin/bower install -- ./node_modules/gulp/bin/gulp.js +> + npm install + ./node_modules/bower/bin/bower install + ./node_modules/gulp/bin/gulp.js -# Run -Run command +## Run -- ./node_modules/pm2/bin/pm2 start app.js +> + ./node_modules/pm2/bin/pm2 start app.js -# PM2 Options +### PM2 Options - ./node_modules/pm2/bin/pm2 start app.js -i 0 - ./node_modules/pm2/bin/pm2 stop all - ./node_modules/pm2/bin/pm2 delete all - ./node_modules/pm2/bin/pm2 start app.js --watch -- https://github.com/Unitech/pm2#commands-overview \ No newline at end of file +- https://github.com/Unitech/pm2#commands-overview + + +## Proxy Settings +### NPM proxy + +> + npm config set proxy http://yourProxy:yourPort + npm config set https-proxy https://yourProxy:yourPort + npm config set strict-ssl false + npm config set registry http://registry.npmjs.org/ + +### Bower proxy + +- Edit for .bowerrc file + +> + { + "directory": "bower_components", + "proxy": "http://yourProxy:yourPort", + "https-proxy":"https://yourProxy:yourPort", + "strict-ssl": false + } diff --git a/package.json b/package.json index e0f1702..139d831 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,8 @@ "jquery": "~3.1.1", "express": "~4.14.0", "body-parser": "~1.15.2", - "socket.io": "~1.6.0" + "socket.io": "~1.6.0", + "mime": "~1.3.4" }, "devDependencies": { "bower": "~1.8.0", diff --git a/public/src/index.html b/public/src/index.html index 2583932..9b79698 100644 --- a/public/src/index.html +++ b/public/src/index.html @@ -182,14 +182,13 @@
Image List
-

create a image

+

Create a image

-
-
+
-

image list

+

Image File list

    @@ -197,24 +196,6 @@ - - @@ -266,7 +247,7 @@ - + + + diff --git a/public/src/js/page/image.js b/public/src/js/page/image.js index 77c3136..6b858b7 100644 --- a/public/src/js/page/image.js +++ b/public/src/js/page/image.js @@ -59,7 +59,7 @@ define([ liElem.setAttribute('class', 'list-group-item image-item'); spanElem = document.createElement('span'); - spanElem.innerText = '(' + file.size + 'B / ' + file.mtime + ')'; + spanElem.innerText = '(' + Util.bytesToSize(file.size) + ' / ' + file.mtime + ')'; spanElem.setAttribute('class', 'image-list-time'); aElem = document.createElement('a'); @@ -109,8 +109,6 @@ define([ } function confirmCreateImage() { - var isOk; - $('#tic-image-create').prop('disabled', true); // when packages are checked nothing @@ -138,12 +136,13 @@ define([ var elem = document.createElement('p'); elem.innerText = data; tableDomElem.append(elem); + $('#tic-image-new').animate({ scrollTop : $('#tic-image-new').height() }, 'slow'); }); // when finished client.on('ws/fs/image/add/finished', function (data) { $('#tic-image-create').prop('disabled', false); - $('#tic-image-new').empty(); + $('#tic-image-new-log').empty(); updateList(); }); } @@ -193,18 +192,19 @@ define([ * $('#confirmModalCreateImage').modal('show'); */ // confirm - isOk = window.confirm('Are you sure?'); - if (isOk) { + Util.showConfirmDialog('Are you sure?') + .then(function () { getKickstartRecipeFile() - .then(createImage) - .catch(function (err) { - console.log(err); - Util.showLoadingDialog(false); - Util.showAlertDialog('Failed to create a image.
    Please check the ks file.'); - }); - } else { + .then(createImage) + .catch(function (err) { + console.error(err); + Util.showAlertDialog('Failed to create a image.
    Please check the ks file.'); + $('#tic-image-create').prop('disabled', false); + }); + }) + .catch(function () { $('#tic-image-create').prop('disabled', false); - } + }); } /** diff --git a/public/src/js/util.js b/public/src/js/util.js index d87093b..7617fb2 100644 --- a/public/src/js/util.js +++ b/public/src/js/util.js @@ -27,6 +27,19 @@ define([ $('#tic-alert-dialog').modal('show'); } + function showConfirmDialog(content) { + return new Promise(function (resolve, reject) { + $('#tic-confirm-content').html(content); + $('#tic-confirm-ok').on('click', function () { + resolve(); + }) + $('#tic-confirm-cancel').on('click', function () { + reject(); + }) + $('#tic-confirm-dialog').modal('show'); + }); + } + function bytesToSize(bytes) { var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; if (bytes == 0) { @@ -62,6 +75,14 @@ define([ */ showAlertDialog: showAlertDialog, + /** + * Display the confirm dialog. + * @method showLoadingDialog + * @param {string} content in dialog + * @return Promise + */ + showConfirmDialog: showConfirmDialog, + /* * Convert size in bytes to KB, MB, GB, TB * {@link http://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript} -- 2.7.4