[Kimchi-devel] [PATCH] [Kimchi] Disable ISOs templates with wrong permission

peterpnns at gmail.com peterpnns at gmail.com
Tue Jun 28 15:30:37 UTC 2016


From: peterpennings <peterpnns at gmail.com>

Signed-off-by: peterpennings <peterpnns at gmail.com>
---
 ui/css/kimchi.css                     | 11 +++++++++++
 ui/css/src/modules/_templates.scss    |  9 +++++++++
 ui/js/src/kimchi.template_add_main.js | 12 +++++++++++-
 ui/pages/template-add.html.tmpl       |  3 ++-
 4 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/ui/css/kimchi.css b/ui/css/kimchi.css
index 9a7c555..261d203 100644
--- a/ui/css/kimchi.css
+++ b/ui/css/kimchi.css
@@ -1719,6 +1719,17 @@ body.wok-gallery {
   font-size: 32px;
 }
 
+#template-add-window span.iso-image-alert {
+  position: absolute;
+  bottom: 17px;
+  right: 45px;
+  font-size: 20px;
+}
+
+#template-add-window .tooltip-arrow {
+  display: none;
+}
+
 /* VM List View classes*/
 #templates-root-container .grid-control input[type="text"] {
   height: 38px;
diff --git a/ui/css/src/modules/_templates.scss b/ui/css/src/modules/_templates.scss
index 04bcadc..2f58385 100644
--- a/ui/css/src/modules/_templates.scss
+++ b/ui/css/src/modules/_templates.scss
@@ -261,6 +261,15 @@
         right: 10px;
         font-size: 32px;
     }
+    span.iso-image-alert {
+        position: absolute;
+        bottom: 17px;
+        right: 45px;
+        font-size: 20px;
+    }
+    .tooltip-arrow {
+        display: none;
+    }
 }
 
 
diff --git a/ui/js/src/kimchi.template_add_main.js b/ui/js/src/kimchi.template_add_main.js
index 948f710..7bdfc51 100644
--- a/ui/js/src/kimchi.template_add_main.js
+++ b/ui/js/src/kimchi.template_add_main.js
@@ -32,6 +32,7 @@ kimchi.template_add_main = function() {
                     $(button + '-loading').show();
                 }
                 showLocalIsoField(isos);
+                $('[data-toggle="tooltip"]').tooltip();
             } else {
                 if (isFinished) {
                     wok.message.warn(i18n['KCHTMPL6001W'], '#local-iso-warning-container');
@@ -77,6 +78,14 @@ kimchi.template_add_main = function() {
             } else {
                 volume.icon = 'fa fa-globe';
             }
+            if (!volume.hasOwnProperty('has_permission')) {
+                volume.has_permission = true;
+            }
+            if (volume.has_permission){
+                volume.volume_hidden = 'hidden';
+            } else {
+                volume.disabled = "disabled";
+            }
             var isoId = volume.os_distro + '*' + volume.name + '*' + volume.os_version;
             if (!kimchi.isoInfo[isoId]) {
                 volume.isoId = isoId;
@@ -131,6 +140,7 @@ kimchi.template_add_main = function() {
                 $('#iso-search').show();
             }
             $('#loading-isos').fadeOut(100, function() {});
+            $('[data-toggle="tooltip"]').tooltip();
         });
     }, function(err) {
         wok.message.error(err.responseJSON.reason, '#local-iso-error-container');
@@ -216,7 +226,7 @@ kimchi.template_add_main = function() {
     });
 
     $('#select-all-local-iso').click(function() {
-        $('#list-local-iso [type="checkbox"]').prop('checked', $(this).prop('checked'));
+        $('#list-local-iso [data-permission="true"]').prop('checked', $(this).prop('checked'));
         if ($(this).prop('checked')) {
             $('#iso-file').val('');
             $('#iso-file').parent().removeClass('has-error');
diff --git a/ui/pages/template-add.html.tmpl b/ui/pages/template-add.html.tmpl
index 4226a8f..5584f00 100644
--- a/ui/pages/template-add.html.tmpl
+++ b/ui/pages/template-add.html.tmpl
@@ -76,7 +76,7 @@
                                         <script id="tmpl-list-local-iso" type="text/html">
                                             <li class="col-md-3">
                                                 <label class="box-iso-outer">
-                                                    <input type="checkbox" class="iso-checkbox-hidden" name="iso" value="{isoId}">
+                                                    <input type="checkbox" class="iso-checkbox-hidden" name="iso" value="{isoId}" {disabled} data-permission="{has_permission}">
                                                     <span class="box-iso-border">
                                                         <span class="box-iso-inner">
                                                             <h3 class="iso-title {os_distro}" title="{name}">
@@ -90,6 +90,7 @@
                                                                 <dt>{capacity}</dt>
                                                                 <dd>$_("Size")</dd>
                                                             </dl>
+                                                            <span data-toggle="tooltip" title="$_('QEMU does not have enough permission to work with this file')" class="{volume_hidden} iso-image-alert"><i class="fa fa-exclamation-triangle fa-lg"></i></span>
                                                             <span class="iso-image-indicator"><i class="{icon}"></i></span>
                                                         </span>
                                                     </span>
-- 
2.5.0




More information about the Kimchi-devel mailing list