[Kimchi-devel] [PATCH v3 4/5] [UI] Repository Management - Edit Repository Support
Hongliang Wang
hlwang at linux.vnet.ibm.com
Thu Mar 13 09:18:49 UTC 2014
Edit repository support.
Signed-off-by: Hongliang Wang <hlwang at 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 at 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
More information about the Kimchi-devel
mailing list