I have to say I changed my mind on display warning about no cdrom exist:)
Will it be better if we disable or hide 'manage media' when no cdrom
device present?
On 2014年07月28日 15:21, wenwang(a)linux.vnet.ibm.com wrote:
From: Wen Wang <wenwang(a)linux.vnet.ibm.com>
Add one line "No CDROM found" under "Manage Media" diaguage when
there
is no CDROM found for an VM.
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.guest_media_main.js | 15 ++++++++++-----
ui/pages/guest-media.html.tmpl | 5 +++++
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/ui/js/src/kimchi.guest_media_main.js b/ui/js/src/kimchi.guest_media_main.js
index d6dee2e..60d12ba 100644
--- a/ui/js/src/kimchi.guest_media_main.js
+++ b/ui/js/src/kimchi.guest_media_main.js
@@ -23,14 +23,19 @@ kimchi.guest_media_main = function() {
storageType: 'cdrom'
}, function(storages) {
var rowHTML = $('#cdrom-row-tmpl').html();
+ var noCDROMHTML = $('#empty-cdrom-tmpl').html();
var container = $('#guest-edit-cdrom-row-container');
$(container).empty();
- $.each(storages, function(index, storage) {
- storage['vm'] = kimchi.selectedGuest;
- var templated = kimchi.substitute(rowHTML, storage);
- container.append(templated);
- });
+ if(storages.length > 0) {
+ $.each(storages, function(index, storage) {
+ storage['vm'] = kimchi.selectedGuest;
+ var templated = kimchi.substitute(rowHTML, storage);
+ container.append(templated);
+ });
+ } else {
+ container.append(noCDROMHTML);
+ }
var replaceCDROM = function(event) {
event.preventDefault();
diff --git a/ui/pages/guest-media.html.tmpl b/ui/pages/guest-media.html.tmpl
index 83ad6ab..fe2e8ef 100644
--- a/ui/pages/guest-media.html.tmpl
+++ b/ui/pages/guest-media.html.tmpl
@@ -51,6 +51,11 @@
</div>
</div>
</script>
+<script id="empty-cdrom-tmpl" type="text/html">
+ <div>
+ $_("No CDROM found.")
+ </div>
+</script>
<script type="text/javascript">
kimchi.guest_media_main();