[PATCH v3 0/5] [UI] Host Repository Management Support

Add host repositories management in this patch set. v2 -> v3: 3a) Added enable/disable repository function in grid toolbar button (Adam King's comment) v1 -> v2: 2a) Removed "Repository" in column names (Adam King's comment) 2b) Adjust column name sequence (Adam King's comment) 2c) Enabled is_mirror radio button in edit window (Adam King's comment) Hongliang Wang (5): [UI] Repository Management - Add i18n Strings [UI] Repository Management - Add API Support [UI] Repository Management - Add Repository Support [UI] Repository Management - Edit Repository Support [UI] Repository Management - Integrate into Host Tab po/POTFILES.in | 2 + ui/css/theme-default/host.css | 40 ++++++++ ui/css/theme-default/repository-add.css | 39 +++++++ ui/css/theme-default/repository-edit.css | 69 +++++++++++++ ui/js/src/kimchi.api.js | 76 +++++++++++++- ui/js/src/kimchi.host.js | 170 +++++++++++++++++++++++++++++++ ui/js/src/kimchi.repository_add_main.js | 84 +++++++++++++++ ui/js/src/kimchi.repository_edit_main.js | 85 ++++++++++++++++ ui/pages/i18n.html.tmpl | 19 ++++ ui/pages/repository-add.html.tmpl | 104 +++++++++++++++++++ ui/pages/repository-edit.html.tmpl | 110 ++++++++++++++++++++ ui/pages/tabs/host.html.tmpl | 13 +++ 12 files changed, 810 insertions(+), 1 deletion(-) create mode 100644 ui/css/theme-default/repository-add.css create mode 100644 ui/css/theme-default/repository-edit.css create mode 100644 ui/js/src/kimchi.repository_add_main.js create mode 100644 ui/js/src/kimchi.repository_edit_main.js create mode 100644 ui/pages/repository-add.html.tmpl create mode 100644 ui/pages/repository-edit.html.tmpl -- 1.8.1.4

Add i18n translation strings for repository management. Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com> --- ui/pages/i18n.html.tmpl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl index 2f47e50..e1ebd47 100644 --- a/ui/pages/i18n.html.tmpl +++ b/ui/pages/i18n.html.tmpl @@ -80,6 +80,25 @@ var i18n = { 'KCHHOST6008M': "$_("Shutting down or restarting host will cause unsaved work lost. Continue to shut down/restarting?")", + 'KCHREPO6001M': "$_("Confirm")", + 'KCHREPO6002M': "$_("Repository will be removed permanently and can't be recovered. Do you want to continue?")", + 'KCHREPO6003M': "$_("Repositories")", + 'KCHREPO6004M': "$_("ID")", + 'KCHREPO6005M': "$_("Name")", + 'KCHREPO6006M': "$_("Base URL")", + 'KCHREPO6007M': "$_("Is Mirror")", + 'KCHREPO6008M': "$_("URL Args")", + 'KCHREPO6009M': "$_("Enabled")", + 'KCHREPO6010M': "$_("GPG Check")", + 'KCHREPO6011M': "$_("GPG Key")", + 'KCHREPO6012M': "$_("Add")", + 'KCHREPO6013M': "$_("Edit")", + 'KCHREPO6014M': "$_("Remove")", + 'KCHREPO6015M': "$_("Failed.")", + 'KCHREPO6016M': "$_("Enable")", + 'KCHREPO6017M': "$_("Disable")", + + 'KCHUPD6001M': "$_("Software Updates")", 'KCHUPD6002M': "$_("Package Name")", 'KCHUPD6003M': "$_("Version")", -- 1.8.1.4

Reviewed-by: Adam King <rak@linux.vnet.ibm.com> On 03/13/2014 05:18 AM, Hongliang Wang wrote:
Add i18n translation strings for repository management.
Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com> --- ui/pages/i18n.html.tmpl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl index 2f47e50..e1ebd47 100644 --- a/ui/pages/i18n.html.tmpl +++ b/ui/pages/i18n.html.tmpl @@ -80,6 +80,25 @@ var i18n = { 'KCHHOST6008M': "$_("Shutting down or restarting host will cause unsaved work lost. Continue to shut down/restarting?")",
+ 'KCHREPO6001M': "$_("Confirm")", + 'KCHREPO6002M': "$_("Repository will be removed permanently and can't be recovered. Do you want to continue?")", + 'KCHREPO6003M': "$_("Repositories")", + 'KCHREPO6004M': "$_("ID")", + 'KCHREPO6005M': "$_("Name")", + 'KCHREPO6006M': "$_("Base URL")", + 'KCHREPO6007M': "$_("Is Mirror")", + 'KCHREPO6008M': "$_("URL Args")", + 'KCHREPO6009M': "$_("Enabled")", + 'KCHREPO6010M': "$_("GPG Check")", + 'KCHREPO6011M': "$_("GPG Key")", + 'KCHREPO6012M': "$_("Add")", + 'KCHREPO6013M': "$_("Edit")", + 'KCHREPO6014M': "$_("Remove")", + 'KCHREPO6015M': "$_("Failed.")", + 'KCHREPO6016M': "$_("Enable")", + 'KCHREPO6017M': "$_("Disable")", + + 'KCHUPD6001M': "$_("Software Updates")", 'KCHUPD6002M': "$_("Package Name")", 'KCHUPD6003M': "$_("Version")",
-- Adam King <rak@linux.vnet.ibm.com> IBM CSI

Add API calling in kimchi.api.js. Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com> --- ui/js/src/kimchi.api.js | 76 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js index 4310435..9ceed0b 100644 --- a/ui/js/src/kimchi.api.js +++ b/ui/js/src/kimchi.api.js @@ -856,5 +856,79 @@ var kimchi = { success : onResponse, error : err }); - } + }, + + createRepository : function(settings, suc, err) { + kimchi.requestJSON({ + url : "host/repositories", + type : "POST", + contentType : "application/json", + data : JSON.stringify(settings), + dataType : "json", + success: suc, + error: err + }); + }, + + retrieveRepository : function(repository, suc, err) { + var reposID = encodeURIComponent(repository); + kimchi.requestJSON({ + url : kimchi.url + "host/repositories/" + reposID, + type : 'GET', + contentType : 'application/json', + dataType : 'json', + success : suc, + error : err + }); + }, + + updateRepository : function(name, settings, suc, err) { + var reposID = encodeURIComponent(name); + $.ajax({ + url : kimchi.url + "host/repositories/" + reposID, + type : 'PUT', + contentType : 'application/json', + data : JSON.stringify(settings), + dataType : 'json', + success : suc, + error : err + }); + }, + + enableRepository : function(name, enable, suc, err) { + var reposID = encodeURIComponent(name); + $.ajax({ + url : kimchi.url + "host/repositories/" + reposID + + '/' + (enable === true ? 'enable' : 'disable'), + type : 'POST', + contentType : 'application/json', + dataType : 'json', + success : suc, + error : err + }); + }, + + deleteRepository : function(repository, suc, err) { + var reposID = encodeURIComponent(repository); + kimchi.requestJSON({ + url : kimchi.url + 'host/repositories/' + reposID, + type : 'DELETE', + contentType : 'application/json', + dataType : 'json', + success : suc, + error : err + }); + }, + + listRepositories : function(suc, err) { + kimchi.requestJSON({ + url : kimchi.url + 'host/repositories', + type : 'GET', + contentType : 'application/json', + dataType : 'json', + resend: true, + success : suc, + error : err + }); + } }; -- 1.8.1.4

Reviewed-by: Adam King <rak@linux.vnet.ibm.com> On 03/13/2014 05:18 AM, Hongliang Wang wrote:
Add API calling in kimchi.api.js.
Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com> --- ui/js/src/kimchi.api.js | 76 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js index 4310435..9ceed0b 100644 --- a/ui/js/src/kimchi.api.js +++ b/ui/js/src/kimchi.api.js @@ -856,5 +856,79 @@ var kimchi = { success : onResponse, error : err }); - } + }, + + createRepository : function(settings, suc, err) { + kimchi.requestJSON({ + url : "host/repositories", + type : "POST", + contentType : "application/json", + data : JSON.stringify(settings), + dataType : "json", + success: suc, + error: err + }); + }, + + retrieveRepository : function(repository, suc, err) { + var reposID = encodeURIComponent(repository); + kimchi.requestJSON({ + url : kimchi.url + "host/repositories/" + reposID, + type : 'GET', + contentType : 'application/json', + dataType : 'json', + success : suc, + error : err + }); + }, + + updateRepository : function(name, settings, suc, err) { + var reposID = encodeURIComponent(name); + $.ajax({ + url : kimchi.url + "host/repositories/" + reposID, + type : 'PUT', + contentType : 'application/json', + data : JSON.stringify(settings), + dataType : 'json', + success : suc, + error : err + }); + }, + + enableRepository : function(name, enable, suc, err) { + var reposID = encodeURIComponent(name); + $.ajax({ + url : kimchi.url + "host/repositories/" + reposID + + '/' + (enable === true ? 'enable' : 'disable'), + type : 'POST', + contentType : 'application/json', + dataType : 'json', + success : suc, + error : err + }); + }, + + deleteRepository : function(repository, suc, err) { + var reposID = encodeURIComponent(repository); + kimchi.requestJSON({ + url : kimchi.url + 'host/repositories/' + reposID, + type : 'DELETE', + contentType : 'application/json', + dataType : 'json', + success : suc, + error : err + }); + }, + + listRepositories : function(suc, err) { + kimchi.requestJSON({ + url : kimchi.url + 'host/repositories', + type : 'GET', + contentType : 'application/json', + dataType : 'json', + resend: true, + success : suc, + error : err + }); + } };
-- Adam King <rak@linux.vnet.ibm.com> IBM CSI

Add repository. Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com> --- ui/css/theme-default/repository-add.css | 39 ++++++++++++ ui/js/src/kimchi.repository_add_main.js | 84 ++++++++++++++++++++++++++ ui/pages/repository-add.html.tmpl | 104 ++++++++++++++++++++++++++++++++ 3 files changed, 227 insertions(+) create mode 100644 ui/css/theme-default/repository-add.css create mode 100644 ui/js/src/kimchi.repository_add_main.js create mode 100644 ui/pages/repository-add.html.tmpl diff --git a/ui/css/theme-default/repository-add.css b/ui/css/theme-default/repository-add.css new file mode 100644 index 0000000..2434efd --- /dev/null +++ b/ui/css/theme-default/repository-add.css @@ -0,0 +1,39 @@ +/* + * Project Kimchi + * + * Copyright IBM, Corp. 2013 + * + * Authors: + * Hongliang Wang <hlwang@linux.vnet.ibm.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#repository-add-window { + height: 680px; + width: 1000px; +} + +#repository-add-window .required { + color: red; + padding-left: 5px; + vertical-align: top; +} + +#repository-add-window .textbox-wrapper input[type="text"] { + box-sizing: border-box; + width: 100%; +} + +#repository-add-window .textbox-wrapper label { + vertical-align: middle; +} diff --git a/ui/js/src/kimchi.repository_add_main.js b/ui/js/src/kimchi.repository_add_main.js new file mode 100644 index 0000000..675f803 --- /dev/null +++ b/ui/js/src/kimchi.repository_add_main.js @@ -0,0 +1,84 @@ +/* + * Project Kimchi + * + * Copyright IBM, Corp. 2013 + * + * Authors: + * Hongliang Wang <hlwang@linux.vnet.ibm.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +kimchi.repository_add_main = function() { + + var addForm = $('#form-repository-add'); + var addButton = $('#button-repository-add'); + + var nameBox = $('input[name="repo_id"]', addForm); + var urlBox = $('input[name="baseurl"]', addForm); + var isMirrorButton = $('input[name="is_mirror"]', addForm); + var urlArgsBox = $('input[name="url_args"]', addForm); + var gpgkeyBox = $('input[name="gpgkey"]', addForm); + + var validateForm = function(event) { + var valid = $(urlBox).val() !== ''; + $(addButton).prop('disabled', !valid); + return valid; + }; + + $(urlBox).on('input propertychange', validateForm); + + var booleanFields = ['is_mirror']; + + var addRepository = function(event) { + var valid = validateForm(); + if(!valid) { + return false; + } + + var formData = $(addForm).serializeObject(); + for(var p in formData) { + if(formData[p] == '') { + delete formData[p]; + } + } + + $(booleanFields).each(function(i, f) { + switch(formData[f]) { + case 'true': + formData[f] = true; + break; + case 'false': + formData[f] = false; + break; + default: + delete formData[f]; + break; + } + }); + + kimchi.createRepository(formData, function() { + kimchi.topic('kimchi/repositoryAdded').publish(); + kimchi.window.close(); + }, function(jqXHR, textStatus, errorThrown) { + var reason = jqXHR && + jqXHR['responseJSON'] && + jqXHR['responseJSON']['reason']; + reason = reason ? ': ' + reason : ''; + kimchi.message.error(i18n['KCHREPO6015M'] + reason); + }); + + return false; + }; + + $(addForm).on('submit', addRepository); +}; diff --git a/ui/pages/repository-add.html.tmpl b/ui/pages/repository-add.html.tmpl new file mode 100644 index 0000000..99ffc33 --- /dev/null +++ b/ui/pages/repository-add.html.tmpl @@ -0,0 +1,104 @@ +#* + * Project Kimchi + * + * Copyright IBM, Corp. 2013 + * + * Authors: + * Hongliang Wang <hlwang@linux.vnet.ibm.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *# +#unicode UTF-8 +#import gettext +#from kimchi.cachebust import href +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang) +#silent _ = t.gettext +#silent _t = t.gettext +<div id="repository-add-window" class="window"> + <form id="form-repository-add"> + <header class="window-header"> + <h1 class="title">$_("Add a Repository")</h1> + <div class="close">X</div> + </header> + <div class="content"> + <section class="form-section"> + <h2>1. $_("Name")</h2> + <div class="field"> + <p class="text-help"> + $_("Unique repository name for each repository, one word.") + </p> + <div class="textbox-wrapper"> + <input type="text" class="text" name="repo_id" /> + </div> + </div> + </section> + <section class="form-section"> + <h2>2. $_("Base URL")<span class="required" role="presentation" title="$_("Required Field")">*</span></h2> + <div class="field"> + <p class="text-help"> + $_("URL to the repodata directory when \"is_mirror\" is false. Otherwise, it can be URL to the mirror system for YUM. Can be an http://, ftp:// or file:// URL.") + </p> + <div class="textbox-wrapper"> + <input type="text" class="text" name="baseurl" /> + </div> + </div> + </section> + <section class="form-section"> + <h2>3. $_("Is Mirror")</h2> + <div class="field"> + <p class="text-help"> + $_("Set the given URI of baseurl as a mirror list, instead of use baseurl in repository configuration.") + </p> + <div class="textbox-wrapper"> + <input type="radio" id="isMirrorRadioTrue" name="is_mirror" value="true" /> + <label for="isMirrorRadioTrue">$_("Yes")</label> + <input type="radio" id="isMirrorRadioFalse" name="is_mirror" value="false" /> + <label for="isMirrorRadioFalse">$_("No")</label> + </div> + </div> + </section> + <section class="form-section"> + <h2>4. $_("URL Args")</h2> + <div class="field"> + <p class="text-help"> + $_("Arguments to be passed to baseurl, like the list of APT repositories provided by the same baseurl.") + </p> + <div class="textbox-wrapper"> + <input type="text" class="text" name="url_args" /> + </div> + </div> + </section> + <section class="form-section"> + <h2>5. $_("GPG Key")</h2> + <div class="field"> + <p class="text-help"> + $_("URL pointing to the ASCII-armored GPG key file for the repository. This option is used if yum needs a public key to verify a package and the required key hasn't been imported into the RPM database.") + </p> + <div class="textbox-wrapper"> + <input type="text" class="text" name="gpgkey" /> + </div> + </div> + </section> + </div> + <footer> + <div class="btn-group"> + <button type="submit" id="button-repository-add" class="btn-normal" disabled="disabled"> + <span class="text">$_("Add")</span> + </button> + </div> + </footer> + </form> +</div> +<script> + kimchi.repository_add_main(); +</script> -- 1.8.1.4

Edit repository support. Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com> --- ui/css/theme-default/repository-edit.css | 69 +++++++++++++++++++ ui/js/src/kimchi.repository_edit_main.js | 85 ++++++++++++++++++++++++ ui/pages/repository-edit.html.tmpl | 110 +++++++++++++++++++++++++++++++ 3 files changed, 264 insertions(+) create mode 100644 ui/css/theme-default/repository-edit.css create mode 100644 ui/js/src/kimchi.repository_edit_main.js create mode 100644 ui/pages/repository-edit.html.tmpl diff --git a/ui/css/theme-default/repository-edit.css b/ui/css/theme-default/repository-edit.css new file mode 100644 index 0000000..9f4701c --- /dev/null +++ b/ui/css/theme-default/repository-edit.css @@ -0,0 +1,69 @@ +/* + * Project Kimchi + * + * Copyright IBM, Corp. 2013 + * + * Authors: + * Hongliang Wang <hlwang@linux.vnet.ibm.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#repository-edit-window { + height: 420px; + width: 1000px; +} + +.repository-edit-fieldset { + float: left; + padding: 1em; +} + +.repository-edit-wrapper-label, .repository-edit-wrapper-controls { + display: inline-block; + height: 38px; + line-height: 38px; + margin-top: 5px; + vertical-align: top; +} + +.repository-edit-wrapper-label { + width: 150px; +} + +.repository-edit-wrapper-controls label { + vertical-align: middle; +} + +.repository-edit-wrapper-controls { + width: 300px; +} + +.repository-edit-wrapper-controls input[type="text"] { + font-size: 16px; + height: 38px; + line-height: 38px; + background: #fff; + -webkit-border-radius: 5px; + border-radius: 5px; + box-shadow: 2px 2px 2px #eee inset; + border-top: 1px solid #bbb; + border-left: 1px solid #bbb; + padding: 0 10px; + width: 250px; +} + +.repository-edit-wrapper-controls input[type="text"][disabled] { + color: #bbb; + background-color: #fafafa; + cursor: not-allowed; +} diff --git a/ui/js/src/kimchi.repository_edit_main.js b/ui/js/src/kimchi.repository_edit_main.js new file mode 100644 index 0000000..19e8ba3 --- /dev/null +++ b/ui/js/src/kimchi.repository_edit_main.js @@ -0,0 +1,85 @@ +/* + * Project Kimchi + * + * Copyright IBM, Corp. 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +kimchi.repository_edit_main = function() { + + var editForm = $('#form-repository-edit'); + var saveButton = $('#repository-edit-button-save'); + + kimchi.retrieveRepository(kimchi.selectedRepository, function(repository) { + for(var prop in repository) { + var control = $('input[name="' + prop + '"]', editForm); + switch($(control).attr('type')) { + case 'text': + $(control).val(repository[prop]); + break; + case 'radio': + case 'checkbox': + $(control).each(function(i, c) { + var matched = ('' + repository[prop]) == $(c).val(); + $(c).prop('checked', matched); + }); + break; + default: + break; + } + + } + + $('input', editForm).on('input propertychange', function(event) { + if($(this).val() !== '') { + $(saveButton).prop('disabled', false); + } + }); + }); + + var booleanFields = ['is_mirror', 'gpgcheck']; + + var editRepository = function(event) { + var formData = $(editForm).serializeObject(); + + $(booleanFields).each(function(i, f) { + switch(formData[f]) { + case 'true': + formData[f] = true; + break; + case 'false': + formData[f] = false; + break; + default: + delete formData[f]; + break; + } + }); + + kimchi.updateRepository(kimchi.selectedRepository, formData, function() { + kimchi.topic('kimchi/repositoryUpdated').publish(); + kimchi.window.close(); + }, function(jqXHR, textStatus, errorThrown) { + var reason = jqXHR && + jqXHR['responseJSON'] && + jqXHR['responseJSON']['reason']; + reason = reason ? ': ' + reason : ''; + kimchi.message.error(i18n['KCHREPO6015M'] + reason); + }); + + return false; + }; + + $(editForm).on('submit', editRepository); + $(saveButton).on('click', editRepository); +}; diff --git a/ui/pages/repository-edit.html.tmpl b/ui/pages/repository-edit.html.tmpl new file mode 100644 index 0000000..bb3d03f --- /dev/null +++ b/ui/pages/repository-edit.html.tmpl @@ -0,0 +1,110 @@ +#* + * Project Kimchi + * + * Copyright IBM, Corp. 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *# +#unicode UTF-8 +#import gettext +#from kimchi.cachebust import href +#silent t = gettext.translation($lang.domain, $lang.localedir, languages=$lang.lang) +#silent _ = t.gettext +#silent _t = t.gettext + +<div id="repository-edit-window" class="window"> + <header> + <h1 class="title">$_("Edit Repository")</h1> + <div class="close">X</div> + </header> + <div class="content"> + <form id="form-repository-edit"> + <fieldset class="repository-edit-fieldset"> + <div> + <div class="repository-edit-wrapper-label"> + <label for="repository-edit-id-textbox">$_("ID")</label> + </div> + <div class="repository-edit-wrapper-controls"> + <input id="repository-edit-id-textbox" name="repo_id" type="text" /> + </div> + </div> + <div> + <div class="repository-edit-wrapper-label"> + <label for="repository-edit-name-textbox">$_("Name")</label> + </div> + <div class="repository-edit-wrapper-controls"> + <input id="repository-edit-name-textbox" name="repo_name" type="text" /> + </div> + </div> + <div> + <div class="repository-edit-wrapper-label"> + <label for="repository-edit-baseurl-textbox">$_("Base URL")</label> + </div> + <div class="repository-edit-wrapper-controls"> + <input id="repository-edit-baseurl-textbox" name="baseurl" type="text" /> + </div> + </div> + <div> + <div class="repository-edit-wrapper-label"> + <label for="repository-edit-urlargs-textbox">$_("URL Args")</label> + </div> + <div class="repository-edit-wrapper-controls"> + <input id="repository-edit-urlargs-textbox" name="url_args" type="text" /> + </div> + </div> + </fieldset> + <fieldset class="repository-edit-fieldset"> + <div> + <div class="repository-edit-wrapper-label"> + <label>$_("Is Mirror")</label> + </div> + <div class="repository-edit-wrapper-controls"> + <input id="repository-edit-ismirror-radio-true" name="is_mirror" type="radio" value="true" /> + <label for="repository-edit-ismirror-radio-true">$_("Yes")</label> + <input id="repository-edit-ismirror-radio-false" name="is_mirror" type="radio" value="false" /> + <label for="repository-edit-ismirror-radio-false">$_("No")</label> + </div> + </div> + <div> + <div class="repository-edit-wrapper-label"> + <label>$_("GPG Check")</label> + </div> + <div class="repository-edit-wrapper-controls"> + <input id="repository-edit-gpgcheck-radio-true" name="gpgcheck" type="radio" value="true" /> + <label for="repository-edit-gpgcheck-radio-true">$_("Yes")</label> + <input id="repository-edit-gpgcheck-radio-false" name="gpgcheck" type="radio" value="false" /> + <label for="repository-edit-gpgcheck-radio-false">$_("No")</label> + </div> + </div> + <div> + <div class="repository-edit-wrapper-label"> + <label for="repository-edit-gpgkey-textbox">$_("GPG Key")</label> + </div> + <div class="repository-edit-wrapper-controls"> + <input id="repository-edit-gpgkey-textbox" name="gpgkey" type="text" /> + </div> + </div> + </fieldset> + </form> + </div> + <footer> + <div class="btn-group"> + <button id="repository-edit-button-save" class="btn-normal"> + <span class="text">$_("Save")</span> + </button> + </div> + </footer> +</div> +<script type="text/javascript"> + kimchi.repository_edit_main(); +</script> -- 1.8.1.4

Integrate add/enable/disalbe/edit/remove a repository feature into host tab. Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com> --- po/POTFILES.in | 2 + ui/css/theme-default/host.css | 40 ++++++++++ ui/js/src/kimchi.host.js | 170 ++++++++++++++++++++++++++++++++++++++++++ ui/pages/tabs/host.html.tmpl | 13 ++++ 4 files changed, 225 insertions(+) diff --git a/po/POTFILES.in b/po/POTFILES.in index 4ff7eaa..955a675 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -7,6 +7,8 @@ ui/pages/i18n.html.tmpl ui/pages/kimchi-ui.html.tmpl ui/pages/login-window.html.tmpl ui/pages/report-add.html.tmpl +ui/pages/repository-add.html.tmpl +ui/pages/repository-edit.html.tmpl ui/pages/storagepool-add.html.tmpl ui/pages/tabs/guests.html.tmpl ui/pages/tabs/host.html.tmpl diff --git a/ui/css/theme-default/host.css b/ui/css/theme-default/host.css index 0f8b941..98c63da 100644 --- a/ui/css/theme-default/host.css +++ b/ui/css/theme-default/host.css @@ -253,3 +253,43 @@ width: 846px; } /* End of Software Updates */ + +/* Repository */ +.host-panel #repositories-grid { + border-color: #ddd; + height: 200px; + width: 850px; +} + +.repository-id { + width: 70px; +} + +.repository-name { + width: 180px; +} + +.repository-baseurl { + width: 300px; +} + +.repository-ismirror { + width: 60px; +} + +.repository-urlargs { + width: 70px; +} + +.repository-enabled { + width: 60px; +} + +.repository-gpgcheck { + width: 60px; +} + +.repository-gpgkey { + width: 300px; +} +/* End of Repository */ diff --git a/ui/js/src/kimchi.host.js b/ui/js/src/kimchi.host.js index 6300f37..bb07333 100644 --- a/ui/js/src/kimchi.host.js +++ b/ui/js/src/kimchi.host.js @@ -22,6 +22,157 @@ kimchi.host_main = function() { $(header).attr('aria-expanded', toExpand ? 'true' : 'false'); }; + var repositoriesGridID = 'repositories-grid'; + var repositoriesGrid = null; + var initRepositoriesGrid = function(repositories) { + repositoriesGrid = new kimchi.widget.Grid({ + container: 'repositories-grid-container', + id: repositoriesGridID, + title: i18n['KCHREPO6003M'], + toolbarButtons: [{ + id: repositoriesGridID + '-add-button', + label: i18n['KCHREPO6012M'], + onClick: function(event) { + kimchi.window.open('repository-add.html'); + } + }, { + id: repositoriesGridID + '-enable-button', + label: i18n['KCHREPO6016M'], + disabled: true, + onClick: function(event) { + var repository = repositoriesGrid.getSelected(); + if(!repository) { + return; + } + var name = repository['repo_id']; + var enable = !repository['enabled']; + $(this).prop('disabled', true); + kimchi.enableRepository(name, enable, function() { + kimchi.topic('kimchi/repositoryUpdated').publish(); + }); + } + }, { + id: repositoriesGridID + '-edit-button', + label: i18n['KCHREPO6013M'], + disabled: true, + onClick: function(event) { + var repository = repositoriesGrid.getSelected(); + if(!repository) { + return; + } + kimchi.selectedRepository = repository['repo_id']; + kimchi.window.open('repository-edit.html'); + } + }, { + id: repositoriesGridID + '-remove-button', + label: i18n['KCHREPO6014M'], + disabled: true, + onClick: function(event) { + var repository = repositoriesGrid.getSelected(); + if(!repository) { + return; + } + + var settings = { + title : i18n['KCHREPO6001M'], + content : i18n['KCHREPO6002M'], + confirm : i18n['KCHAPI6004M'], + cancel : i18n['KCHAPI6003M'] + }; + + kimchi.confirm(settings, function() { + kimchi.deleteRepository( + repository['repo_id'], + function(result) { + kimchi.topic('kimchi/repositoryDeleted').publish(result); + }, function(error) { + } + ); + }); + } + }], + onRowSelected: function(row) { + var repository = repositoriesGrid.getSelected(); + if(!repository) { + return; + } + + $('#' + repositoriesGridID + '-remove-button') + .prop('disabled', false); + $('#' + repositoriesGridID + '-edit-button') + .prop('disabled', false); + + var enabled = repository['enabled']; + $('#' + repositoriesGridID + '-enable-button') + .text(i18n[enabled ? 'KCHREPO6017M' : 'KCHREPO6016M']) + .prop('disabled', false); + }, + frozenFields: [], + fields: [{ + name: 'repo_id', + label: i18n['KCHREPO6004M'], + 'class': 'repository-id' + }, { + name: 'repo_name', + label: i18n['KCHREPO6005M'], + 'class': 'repository-name' + }, { + name: 'enabled', + label: i18n['KCHREPO6009M'], + 'class': 'repository-enabled' + }, { + name: 'baseurl', + label: i18n['KCHREPO6006M'], + makeTitle: true, + 'class': 'repository-baseurl' + }, { + name: 'url_args', + label: i18n['KCHREPO6008M'], + 'class': 'repository-urlargs' + }, { + name: 'is_mirror', + label: i18n['KCHREPO6007M'], + 'class': 'repository-ismirror' + }, { + name: 'gpgcheck', + label: i18n['KCHREPO6010M'], + 'class': 'repository-gpgcheck' + }, { + name: 'gpgkey', + label: i18n['KCHREPO6011M'], + 'class': 'repository-gpgkey' + }], + data: listRepositories + }); + }; + + var listRepositories = function(gridCallback) { + kimchi.listRepositories(function(repositories) { + $.each(repositories, function(i, item) { + repositories[i]['rowno'] = i + 1; + }); + + if($.isFunction(gridCallback)) { + gridCallback(repositories); + } + else { + if(repositoriesGrid) { + repositoriesGrid.setData(repositories); + } + else { + initRepositoriesGrid(repositories); + } + } + }); + + $('#' + repositoriesGridID + '-remove-button') + .prop('disabled', true); + $('#' + repositoriesGridID + '-edit-button') + .prop('disabled', true); + $('#' + repositoriesGridID + '-enable-button') + .prop('disabled', true); + }; + var softwareUpdatesGridID = 'software-updates-grid'; var softwareUpdatesGrid = null; var progressAreaID = 'software-updates-progress-textarea'; @@ -271,6 +422,17 @@ kimchi.host_main = function() { }); kimchi.getCapabilities(function(capabilities) { + if(capabilities['repo_mngt_tool']) { + $('#repository-management-section').removeClass('hidden'); + initRepositoriesGrid(); + kimchi.topic('kimchi/repositoryAdded') + .subscribe(listRepositories); + kimchi.topic('kimchi/repositoryUpdated') + .subscribe(listRepositories); + kimchi.topic('kimchi/repositoryDeleted') + .subscribe(listRepositories); + } + if(capabilities['update_tool']) { $('#software-update-section').removeClass('hidden'); initSoftwareUpdatesGrid(); @@ -552,6 +714,14 @@ kimchi.host_main = function() { delete kimchi.hostTimer; } + repositoriesGrid && repositoriesGrid.destroy(); + kimchi.topic('kimchi/repositoryAdded') + .unsubscribe(listRepositories); + kimchi.topic('kimchi/repositoryUpdated') + .unsubscribe(listRepositories); + kimchi.topic('kimchi/repositoryDeleted') + .unsubscribe(listRepositories); + softwareUpdatesGrid && softwareUpdatesGrid.destroy(); kimchi.topic('kimchi/softwareUpdated').unsubscribe(listSoftwareUpdates); diff --git a/ui/pages/tabs/host.html.tmpl b/ui/pages/tabs/host.html.tmpl index 179deba..4933b31 100644 --- a/ui/pages/tabs/host.html.tmpl +++ b/ui/pages/tabs/host.html.tmpl @@ -120,6 +120,19 @@ </div> </div> </div> + <div id="repositories-section" class="host-section"> + <h3 class="section-header" + aria-controls="content-repositories"> + $_("Repositories") + </h3> + <div id="content-repositories" class="section-content"> + <div class="section-row"> + <div class="section-value"> + <div id="repositories-grid-container"></div> + </div> + </div> + </div> + </div> <div id="software-update-section" class="host-section hidden"> <h3 class="section-header" aria-controls="content-software-update"> -- 1.8.1.4

Reviewed-by: Adam King <rak@linux.vnet.ibm.com> On 03/13/2014 05:18 AM, Hongliang Wang wrote:
Integrate add/enable/disalbe/edit/remove a repository feature into host tab.
Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com> --- po/POTFILES.in | 2 + ui/css/theme-default/host.css | 40 ++++++++++ ui/js/src/kimchi.host.js | 170 ++++++++++++++++++++++++++++++++++++++++++ ui/pages/tabs/host.html.tmpl | 13 ++++ 4 files changed, 225 insertions(+)
diff --git a/po/POTFILES.in b/po/POTFILES.in index 4ff7eaa..955a675 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -7,6 +7,8 @@ ui/pages/i18n.html.tmpl ui/pages/kimchi-ui.html.tmpl ui/pages/login-window.html.tmpl ui/pages/report-add.html.tmpl +ui/pages/repository-add.html.tmpl +ui/pages/repository-edit.html.tmpl ui/pages/storagepool-add.html.tmpl ui/pages/tabs/guests.html.tmpl ui/pages/tabs/host.html.tmpl diff --git a/ui/css/theme-default/host.css b/ui/css/theme-default/host.css index 0f8b941..98c63da 100644 --- a/ui/css/theme-default/host.css +++ b/ui/css/theme-default/host.css @@ -253,3 +253,43 @@ width: 846px; } /* End of Software Updates */ + +/* Repository */ +.host-panel #repositories-grid { + border-color: #ddd; + height: 200px; + width: 850px; +} + +.repository-id { + width: 70px; +} + +.repository-name { + width: 180px; +} + +.repository-baseurl { + width: 300px; +} + +.repository-ismirror { + width: 60px; +} + +.repository-urlargs { + width: 70px; +} + +.repository-enabled { + width: 60px; +} + +.repository-gpgcheck { + width: 60px; +} + +.repository-gpgkey { + width: 300px; +} +/* End of Repository */ diff --git a/ui/js/src/kimchi.host.js b/ui/js/src/kimchi.host.js index 6300f37..bb07333 100644 --- a/ui/js/src/kimchi.host.js +++ b/ui/js/src/kimchi.host.js @@ -22,6 +22,157 @@ kimchi.host_main = function() { $(header).attr('aria-expanded', toExpand ? 'true' : 'false'); };
+ var repositoriesGridID = 'repositories-grid'; + var repositoriesGrid = null; + var initRepositoriesGrid = function(repositories) { + repositoriesGrid = new kimchi.widget.Grid({ + container: 'repositories-grid-container', + id: repositoriesGridID, + title: i18n['KCHREPO6003M'], + toolbarButtons: [{ + id: repositoriesGridID + '-add-button', + label: i18n['KCHREPO6012M'], + onClick: function(event) { + kimchi.window.open('repository-add.html'); + } + }, { + id: repositoriesGridID + '-enable-button', + label: i18n['KCHREPO6016M'], + disabled: true, + onClick: function(event) { + var repository = repositoriesGrid.getSelected(); + if(!repository) { + return; + } + var name = repository['repo_id']; + var enable = !repository['enabled']; + $(this).prop('disabled', true); + kimchi.enableRepository(name, enable, function() { + kimchi.topic('kimchi/repositoryUpdated').publish(); + }); + } + }, { + id: repositoriesGridID + '-edit-button', + label: i18n['KCHREPO6013M'], + disabled: true, + onClick: function(event) { + var repository = repositoriesGrid.getSelected(); + if(!repository) { + return; + } + kimchi.selectedRepository = repository['repo_id']; + kimchi.window.open('repository-edit.html'); + } + }, { + id: repositoriesGridID + '-remove-button', + label: i18n['KCHREPO6014M'], + disabled: true, + onClick: function(event) { + var repository = repositoriesGrid.getSelected(); + if(!repository) { + return; + } + + var settings = { + title : i18n['KCHREPO6001M'], + content : i18n['KCHREPO6002M'], + confirm : i18n['KCHAPI6004M'], + cancel : i18n['KCHAPI6003M'] + }; + + kimchi.confirm(settings, function() { + kimchi.deleteRepository( + repository['repo_id'], + function(result) { + kimchi.topic('kimchi/repositoryDeleted').publish(result); + }, function(error) { + } + ); + }); + } + }], + onRowSelected: function(row) { + var repository = repositoriesGrid.getSelected(); + if(!repository) { + return; + } + + $('#' + repositoriesGridID + '-remove-button') + .prop('disabled', false); + $('#' + repositoriesGridID + '-edit-button') + .prop('disabled', false); + + var enabled = repository['enabled']; + $('#' + repositoriesGridID + '-enable-button') + .text(i18n[enabled ? 'KCHREPO6017M' : 'KCHREPO6016M']) + .prop('disabled', false); + }, + frozenFields: [], + fields: [{ + name: 'repo_id', + label: i18n['KCHREPO6004M'], + 'class': 'repository-id' + }, { + name: 'repo_name', + label: i18n['KCHREPO6005M'], + 'class': 'repository-name' + }, { + name: 'enabled', + label: i18n['KCHREPO6009M'], + 'class': 'repository-enabled' + }, { + name: 'baseurl', + label: i18n['KCHREPO6006M'], + makeTitle: true, + 'class': 'repository-baseurl' + }, { + name: 'url_args', + label: i18n['KCHREPO6008M'], + 'class': 'repository-urlargs' + }, { + name: 'is_mirror', + label: i18n['KCHREPO6007M'], + 'class': 'repository-ismirror' + }, { + name: 'gpgcheck', + label: i18n['KCHREPO6010M'], + 'class': 'repository-gpgcheck' + }, { + name: 'gpgkey', + label: i18n['KCHREPO6011M'], + 'class': 'repository-gpgkey' + }], + data: listRepositories + }); + }; + + var listRepositories = function(gridCallback) { + kimchi.listRepositories(function(repositories) { + $.each(repositories, function(i, item) { + repositories[i]['rowno'] = i + 1; + }); + + if($.isFunction(gridCallback)) { + gridCallback(repositories); + } + else { + if(repositoriesGrid) { + repositoriesGrid.setData(repositories); + } + else { + initRepositoriesGrid(repositories); + } + } + }); + + $('#' + repositoriesGridID + '-remove-button') + .prop('disabled', true); + $('#' + repositoriesGridID + '-edit-button') + .prop('disabled', true); + $('#' + repositoriesGridID + '-enable-button') + .prop('disabled', true); + }; + var softwareUpdatesGridID = 'software-updates-grid'; var softwareUpdatesGrid = null; var progressAreaID = 'software-updates-progress-textarea'; @@ -271,6 +422,17 @@ kimchi.host_main = function() { });
kimchi.getCapabilities(function(capabilities) { + if(capabilities['repo_mngt_tool']) { + $('#repository-management-section').removeClass('hidden'); + initRepositoriesGrid(); + kimchi.topic('kimchi/repositoryAdded') + .subscribe(listRepositories); + kimchi.topic('kimchi/repositoryUpdated') + .subscribe(listRepositories); + kimchi.topic('kimchi/repositoryDeleted') + .subscribe(listRepositories); + } + if(capabilities['update_tool']) { $('#software-update-section').removeClass('hidden'); initSoftwareUpdatesGrid(); @@ -552,6 +714,14 @@ kimchi.host_main = function() { delete kimchi.hostTimer; }
+ repositoriesGrid && repositoriesGrid.destroy(); + kimchi.topic('kimchi/repositoryAdded') + .unsubscribe(listRepositories); + kimchi.topic('kimchi/repositoryUpdated') + .unsubscribe(listRepositories); + kimchi.topic('kimchi/repositoryDeleted') + .unsubscribe(listRepositories); + softwareUpdatesGrid && softwareUpdatesGrid.destroy(); kimchi.topic('kimchi/softwareUpdated').unsubscribe(listSoftwareUpdates);
diff --git a/ui/pages/tabs/host.html.tmpl b/ui/pages/tabs/host.html.tmpl index 179deba..4933b31 100644 --- a/ui/pages/tabs/host.html.tmpl +++ b/ui/pages/tabs/host.html.tmpl @@ -120,6 +120,19 @@ </div> </div> </div> + <div id="repositories-section" class="host-section"> + <h3 class="section-header" + aria-controls="content-repositories"> + $_("Repositories") + </h3> + <div id="content-repositories" class="section-content"> + <div class="section-row"> + <div class="section-value"> + <div id="repositories-grid-container"></div> + </div> + </div> + </div> + </div> <div id="software-update-section" class="host-section hidden"> <h3 class="section-header" aria-controls="content-software-update">
-- Adam King <rak@linux.vnet.ibm.com> IBM CSI

Integrate add/enable/disalbe/edit/remove a repository feature into host tab.
Signed-off-by: Hongliang Wang <hlwang@linux.vnet.ibm.com> --- po/POTFILES.in | 2 + ui/css/theme-default/host.css | 40 ++++++++++ ui/js/src/kimchi.host.js | 170 ++++++++++++++++++++++++++++++++++++++++++ ui/pages/tabs/host.html.tmpl | 13 ++++ 4 files changed, 225 insertions(+)
diff --git a/po/POTFILES.in b/po/POTFILES.in index 4ff7eaa..955a675 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -7,6 +7,8 @@ ui/pages/i18n.html.tmpl ui/pages/kimchi-ui.html.tmpl ui/pages/login-window.html.tmpl ui/pages/report-add.html.tmpl +ui/pages/repository-add.html.tmpl +ui/pages/repository-edit.html.tmpl ui/pages/storagepool-add.html.tmpl ui/pages/tabs/guests.html.tmpl ui/pages/tabs/host.html.tmpl diff --git a/ui/css/theme-default/host.css b/ui/css/theme-default/host.css index 0f8b941..98c63da 100644 --- a/ui/css/theme-default/host.css +++ b/ui/css/theme-default/host.css @@ -253,3 +253,43 @@ width: 846px; } /* End of Software Updates */ + +/* Repository */ +.host-panel #repositories-grid { + border-color: #ddd; + height: 200px; + width: 850px; +} + +.repository-id { + width: 70px; +} + +.repository-name { + width: 180px; +} + +.repository-baseurl { + width: 300px; +} + +.repository-ismirror { + width: 60px; +} + +.repository-urlargs { + width: 70px; +} + +.repository-enabled { + width: 60px; +} + +.repository-gpgcheck { + width: 60px; +} + +.repository-gpgkey { + width: 300px; +} +/* End of Repository */ diff --git a/ui/js/src/kimchi.host.js b/ui/js/src/kimchi.host.js index 6300f37..bb07333 100644 --- a/ui/js/src/kimchi.host.js +++ b/ui/js/src/kimchi.host.js @@ -22,6 +22,157 @@ kimchi.host_main = function() { $(header).attr('aria-expanded', toExpand ? 'true' : 'false'); };
+ var repositoriesGridID = 'repositories-grid'; + var repositoriesGrid = null; + var initRepositoriesGrid = function(repositories) { + repositoriesGrid = new kimchi.widget.Grid({ + container: 'repositories-grid-container', + id: repositoriesGridID, + title: i18n['KCHREPO6003M'], + toolbarButtons: [{ + id: repositoriesGridID + '-add-button', I'd rather not construct the IDs dynamically. It makes it difficult to take an ID from the DOM inspector and find the code that operates on
+ label: i18n['KCHREPO6012M'], + onClick: function(event) { + kimchi.window.open('repository-add.html'); + } + }, { + id: repositoriesGridID + '-enable-button', I'd rather not construct the IDs dynamically. It makes it difficult to take an ID from the DOM inspector and find the code that operates on
+ label: i18n['KCHREPO6016M'], + disabled: true, + onClick: function(event) { + var repository = repositoriesGrid.getSelected(); + if(!repository) { + return; + } + var name = repository['repo_id']; + var enable = !repository['enabled']; + $(this).prop('disabled', true); + kimchi.enableRepository(name, enable, function() { + kimchi.topic('kimchi/repositoryUpdated').publish(); + }); + } + }, { + id: repositoriesGridID + '-edit-button', I'd rather not construct the IDs dynamically. It makes it difficult to take an ID from the DOM inspector and find the code that operates on
+ label: i18n['KCHREPO6013M'], + disabled: true, + onClick: function(event) { + var repository = repositoriesGrid.getSelected(); + if(!repository) { + return; + } + kimchi.selectedRepository = repository['repo_id']; + kimchi.window.open('repository-edit.html'); + } + }, { + id: repositoriesGridID + '-remove-button', I'd rather not construct the IDs dynamically. It makes it difficult to take an ID from the DOM inspector and find the code that operates on
There are a number of places where we construct the DOM node ID dynamically. While functional, it makes it though to take an ID from the template or DOM inspector and search the code for all the places that ID is used. While functional, I'd prefer we reference the ID statically so its easier to find your way from one part of the implementation to another. Adam On 03/13/2014 05:18 AM, Hongliang Wang wrote: that code. that code. that code. that code.
+ label: i18n['KCHREPO6014M'], + disabled: true, + onClick: function(event) { + var repository = repositoriesGrid.getSelected(); + if(!repository) { + return; + } + + var settings = { + title : i18n['KCHREPO6001M'], + content : i18n['KCHREPO6002M'], + confirm : i18n['KCHAPI6004M'], + cancel : i18n['KCHAPI6003M'] + }; + + kimchi.confirm(settings, function() { + kimchi.deleteRepository( + repository['repo_id'], + function(result) { + kimchi.topic('kimchi/repositoryDeleted').publish(result); + }, function(error) { + } + ); + }); + } + }], + onRowSelected: function(row) { + var repository = repositoriesGrid.getSelected(); + if(!repository) { + return; + } + + $('#' + repositoriesGridID + '-remove-button') + .prop('disabled', false); + $('#' + repositoriesGridID + '-edit-button') + .prop('disabled', false); + + var enabled = repository['enabled']; + $('#' + repositoriesGridID + '-enable-button') + .text(i18n[enabled ? 'KCHREPO6017M' : 'KCHREPO6016M']) + .prop('disabled', false); + }, + frozenFields: [], + fields: [{ + name: 'repo_id', + label: i18n['KCHREPO6004M'], + 'class': 'repository-id' + }, { + name: 'repo_name', + label: i18n['KCHREPO6005M'], + 'class': 'repository-name' + }, { + name: 'enabled', + label: i18n['KCHREPO6009M'], + 'class': 'repository-enabled' + }, { + name: 'baseurl', + label: i18n['KCHREPO6006M'], + makeTitle: true, + 'class': 'repository-baseurl' + }, { + name: 'url_args', + label: i18n['KCHREPO6008M'], + 'class': 'repository-urlargs' + }, { + name: 'is_mirror', + label: i18n['KCHREPO6007M'], + 'class': 'repository-ismirror' + }, { + name: 'gpgcheck', + label: i18n['KCHREPO6010M'], + 'class': 'repository-gpgcheck' + }, { + name: 'gpgkey', + label: i18n['KCHREPO6011M'], + 'class': 'repository-gpgkey' + }], + data: listRepositories + }); + }; + + var listRepositories = function(gridCallback) { + kimchi.listRepositories(function(repositories) { + $.each(repositories, function(i, item) { + repositories[i]['rowno'] = i + 1; + }); + + if($.isFunction(gridCallback)) { + gridCallback(repositories); + } + else { + if(repositoriesGrid) { + repositoriesGrid.setData(repositories); + } + else { + initRepositoriesGrid(repositories); + } + } + }); + + $('#' + repositoriesGridID + '-remove-button') + .prop('disabled', true); + $('#' + repositoriesGridID + '-edit-button') + .prop('disabled', true); + $('#' + repositoriesGridID + '-enable-button') + .prop('disabled', true); + }; + var softwareUpdatesGridID = 'software-updates-grid'; var softwareUpdatesGrid = null; var progressAreaID = 'software-updates-progress-textarea'; @@ -271,6 +422,17 @@ kimchi.host_main = function() { });
kimchi.getCapabilities(function(capabilities) { + if(capabilities['repo_mngt_tool']) { + $('#repository-management-section').removeClass('hidden'); + initRepositoriesGrid(); + kimchi.topic('kimchi/repositoryAdded') + .subscribe(listRepositories); + kimchi.topic('kimchi/repositoryUpdated') + .subscribe(listRepositories); + kimchi.topic('kimchi/repositoryDeleted') + .subscribe(listRepositories); + } + if(capabilities['update_tool']) { $('#software-update-section').removeClass('hidden'); initSoftwareUpdatesGrid(); @@ -552,6 +714,14 @@ kimchi.host_main = function() { delete kimchi.hostTimer; }
+ repositoriesGrid && repositoriesGrid.destroy(); + kimchi.topic('kimchi/repositoryAdded') + .unsubscribe(listRepositories); + kimchi.topic('kimchi/repositoryUpdated') + .unsubscribe(listRepositories); + kimchi.topic('kimchi/repositoryDeleted') + .unsubscribe(listRepositories); + softwareUpdatesGrid && softwareUpdatesGrid.destroy(); kimchi.topic('kimchi/softwareUpdated').unsubscribe(listSoftwareUpdates);
diff --git a/ui/pages/tabs/host.html.tmpl b/ui/pages/tabs/host.html.tmpl index 179deba..4933b31 100644 --- a/ui/pages/tabs/host.html.tmpl +++ b/ui/pages/tabs/host.html.tmpl @@ -120,6 +120,19 @@ </div> </div> </div> + <div id="repositories-section" class="host-section"> + <h3 class="section-header" + aria-controls="content-repositories"> + $_("Repositories") + </h3> + <div id="content-repositories" class="section-content"> + <div class="section-row"> + <div class="section-value"> + <div id="repositories-grid-container"></div> + </div> + </div> + </div> + </div> <div id="software-update-section" class="host-section hidden"> <h3 class="section-header" aria-controls="content-software-update">
-- Adam King <rak@linux.vnet.ibm.com> IBM CSI

v3 dropped the default radio button check from the add repo panel. Adding it again. Signed-off-by: Adam King <rak@linux.vnet.ibm.com> --- ui/pages/repository-add.html.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/pages/repository-add.html.tmpl b/ui/pages/repository-add.html.tmpl index a170f1d..4a97fd3 100644 --- a/ui/pages/repository-add.html.tmpl +++ b/ui/pages/repository-add.html.tmpl @@ -62,7 +62,7 @@ <div class="textbox-wrapper"> <input type="radio" id="isMirrorRadioTrue" name="is_mirror" value="true" /> <label for="isMirrorRadioTrue">$_("Yes")</label> - <input type="radio" id="isMirrorRadioFalse" name="is_mirror" value="false" /> + <input type="radio" id="isMirrorRadioFalse" checked="checked" name="is_mirror" value="false" /> <label for="isMirrorRadioFalse">$_("No")</label> </div> </div> -- 1.8.1.4
participants (2)
-
Adam King
-
Hongliang Wang