From: Wen Wang <wenwang(a)linux.vnet.ibm.com>
V1 -> V2:
Changed the [+] button invisible by default and show if the _tabMode is
admin.(Yu Xin)
This patch removes [+] icon from the toolbar for users without 'admin'
role
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.guest_main.js | 10 +++++++---
ui/js/src/kimchi.network.js | 6 +++++-
ui/js/src/kimchi.storage_main.js | 10 +++++++---
ui/js/src/kimchi.template_main.js | 21 +++++++++++++--------
ui/pages/tabs/guests.html.tmpl | 4 ++--
ui/pages/tabs/network.html.tmpl | 2 +-
ui/pages/tabs/storage.html.tmpl | 2 +-
ui/pages/tabs/templates.html.tmpl | 2 +-
8 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js
index acbae15..d81c6b7 100644
--- a/ui/js/src/kimchi.guest_main.js
+++ b/ui/js/src/kimchi.guest_main.js
@@ -323,9 +323,13 @@ kimchi.guestSetRequestHeader = function(xhr) {
};
kimchi.guest_main = function() {
- $("#vm-add").on("click", function(event) {
- kimchi.window.open('guest-add.html');
- });
+ var guestsMode = _tabMode['guests'];
+ if(guestsMode === 'admin') {
+ $('.tools').attr('style','display');
+ $("#vm-add").on("click", function(event) {
+ kimchi.window.open('guest-add.html');
+ });
+ }
kimchi.guestTemplate = $('#guest-tmpl').html();
kimchi.guestElem=$('<div/>').html(kimchi.guestTemplate).find('li');
$('#guests-root-container').on('remove', function() {
diff --git a/ui/js/src/kimchi.network.js b/ui/js/src/kimchi.network.js
index cbd967f..c0978da 100644
--- a/ui/js/src/kimchi.network.js
+++ b/ui/js/src/kimchi.network.js
@@ -19,9 +19,13 @@
kimchi.NETWORK_TYPE_BRIDGE = "bridged";
kimchi.initNetwork = function() {
+ var networkMode = _tabMode['network'];
+ if(networkMode === 'admin') {
+ $('.tools').attr('style','display');
+ kimchi.initNetworkCreation();
+ }
kimchi.initNetworkListView();
kimchi.initNetworkDialog();
- kimchi.initNetworkCreation();
kimchi.initNetworkCleanup();
};
diff --git a/ui/js/src/kimchi.storage_main.js b/ui/js/src/kimchi.storage_main.js
index 3a18f82..a84ce0f 100644
--- a/ui/js/src/kimchi.storage_main.js
+++ b/ui/js/src/kimchi.storage_main.js
@@ -234,9 +234,13 @@ kimchi.initLogicalPoolExtend = function() {
}
kimchi.storage_main = function() {
- $('#storage-pool-add').on('click', function() {
- kimchi.window.open('storagepool-add.html');
- });
+ var storageMode = _tabMode['storage'];
+ if(storageMode === 'admin') {
+ $('.tools').attr('style','display');
+ $('#storage-pool-add').on('click', function() {
+ kimchi.window.open('storagepool-add.html');
+ });
+ }
kimchi.doListStoragePools();
kimchi.initLogicalPoolExtend();
}
diff --git a/ui/js/src/kimchi.template_main.js b/ui/js/src/kimchi.template_main.js
index 48354c9..7ce408f 100644
--- a/ui/js/src/kimchi.template_main.js
+++ b/ui/js/src/kimchi.template_main.js
@@ -83,15 +83,20 @@ kimchi.hideTitle = function() {
};
kimchi.template_main = function() {
- $("#template-add").on("click", function(event) {
- kimchi.window.open({
- url: 'template-add.html',
- close: function() {
- if (kimchi.deepScanHandler) {
- kimchi.deepScanHandler.stop = true;
+ var templatesMode = _tabMode['templates'];
+ if(templatesMode === 'admin') {
+ $('.tools').attr('style','display');
+ $("#template-add").on("click", function(event) {
+ kimchi.window.open({
+ url: 'template-add.html',
+ close: function() {
+ if (kimchi.deepScanHandler) {
+ kimchi.deepScanHandler.stop = true;
+ }
}
- }
+ });
});
- });
+ }
+
kimchi.doListTemplates();
};
diff --git a/ui/pages/tabs/guests.html.tmpl b/ui/pages/tabs/guests.html.tmpl
index 3aa2fdd..bc6a0cf 100644
--- a/ui/pages/tabs/guests.html.tmpl
+++ b/ui/pages/tabs/guests.html.tmpl
@@ -28,11 +28,11 @@
<div id="guests-root-container">
<div class="toolbar">
- <div class="tools">
+ <div class="tools" style="display:none">
<a id="vm-add" class="btn-tool"
href="javascript:void(0);"><span class="icon
add">+</span></a>
</div>
</div>
- <div id="guestListField" style="display: none;">
+ <div id="guestListField" style="display: none">
<ul class="list-title">
<li class="guest-type">$_("Name")</li>
<li class="guest-cpu">$_("CPU")</li>
diff --git a/ui/pages/tabs/network.html.tmpl b/ui/pages/tabs/network.html.tmpl
index 92985ff..b6091f8 100644
--- a/ui/pages/tabs/network.html.tmpl
+++ b/ui/pages/tabs/network.html.tmpl
@@ -26,7 +26,7 @@
<html>
<body>
<div class="toolbar">
- <div class="tools">
+ <div class="tools" style="display:none">
<a id="networkAdd" class="btn-tool"
href="javascript:void(0);"><span class="icon
add">+</span></a>
</div>
</div>
diff --git a/ui/pages/tabs/storage.html.tmpl b/ui/pages/tabs/storage.html.tmpl
index d4d54ea..72eaafd 100644
--- a/ui/pages/tabs/storage.html.tmpl
+++ b/ui/pages/tabs/storage.html.tmpl
@@ -25,7 +25,7 @@
<html>
<body>
<div class="toolbar">
- <div class="tools">
+ <div class="tools" style="display:none">
<a id="storage-pool-add" class="btn-tool"
href="javascript:void(0);"><span class="icon
add">+</span></a>
</div>
</div>
diff --git a/ui/pages/tabs/templates.html.tmpl b/ui/pages/tabs/templates.html.tmpl
index 5e6b5aa..5551d66 100644
--- a/ui/pages/tabs/templates.html.tmpl
+++ b/ui/pages/tabs/templates.html.tmpl
@@ -25,7 +25,7 @@
<html>
<body>
<div class="toolbar">
- <div class="tools">
+ <div class="tools" style="display:none">
<a id="template-add" class="btn-tool"
href="javascript:void(0);"><span class="icon
add">+</span></a>
</div>
</div>
--
1.7.1