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