From: Hongliang Wang <hlwang(a)linux.vnet.ibm.com>
Add repository.
Signed-off-by: Hongliang Wang <hlwang(a)linux.vnet.ibm.com>
Signed-off-by: Adam King <rak(a)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 | 115 ++++++++++++++++++++++++++++++++
3 files changed, 238 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(a)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..f08c209
--- /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(a)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 validateField = function(event) {
+ var valid=($(this).val()!=='');
+ $(addButton).prop('disabled', !valid);
+ return(valid);
+ };
+
+ var validateForm = function(event) {
+ var valid=false;
+ addForm.find('input.required').each( function() {
+ valid=($(this).val()!=='');
+ return(!valid);
+ });
+ return(valid);
+ }
+
+ addForm.find('input.required').on('input propertychange',
validateField);
+
+ var weedObject = function(obj) {
+ for (var key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ if((typeof(obj[key])==="object") &&
!Array.isArray(obj[key])) {
+ weedObject(obj[key]);
+ }
+ else if(obj[key] == '') {
+ delete obj[key];
+ }
+ }
+ }
+ }
+
+ var addRepository = function(event) {
+ var valid = validateForm();
+ if(!valid) {
+ return false;
+ }
+
+ var formData = $(addForm).serializeObject();
+ if (formData && formData.config) {
+ formData.config.gpgcheck=(String(formData.config.gpgcheck).toLowerCase() ===
'true');
+ }
+ weedObject(formData);
+
+
+ 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..991278e
--- /dev/null
+++ b/ui/pages/repository-add.html.tmpl
@@ -0,0 +1,115 @@
+#*
+ * Project Kimchi
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ * Hongliang Wang <hlwang(a)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>
+ <fieldset class="repository-edit-fieldset">
+ <div class="repository-id">
+ <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 class="repository-name">
+ <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"
class="yum" name="config[repo_name]" type="text" />
+ </div>
+ </div>
+ <div class="repository-dist">
+ <div class="repository-edit-wrapper-label">
+ <label
for="repository-edit-urlargs-textbox">$_("Distribution")</label>
+ </div>
+ <div class="repository-edit-wrapper-controls">
+ <input id="repository-edit-urlargs-textbox"
class="deb" name="config[dist]" type="text" />
+ </div>
+ </div>
+ <div class="repository-gpgcheck">
+ <div class="repository-edit-wrapper-label">
+ <label>$_("GPG Check")</label>
+ </div>
+ <div class="repository-edit-wrapper-controls">
+ <input id="repository-edit-gpgcheck-radio-true"
class="yum" name="config[gpgcheck]" type="radio"
value="true" />
+ <label
for="repository-edit-gpgcheck-radio-true">$_("Yes")</label>
+ <input id="repository-edit-gpgcheck-radio-false"
class="yum" name="config[gpgcheck]" type="radio"
value="false" checked="checked"/>
+ <label
for="repository-edit-gpgcheck-radio-false">$_("No")</label>
+ </div>
+ </div>
+ </fieldset>
+ <fieldset class="repository-edit-fieldset">
+ <div class="repository-url">
+ <div class="repository-edit-wrapper-label">
+ <label
for="repository-edit-baseurl-textbox">$_("URL")</label>
+ </div>
+ <div class="repository-edit-wrapper-controls">
+ <input id="repository-edit-baseurl-textbox"
class="required" name="baseurl" type="text" />
+ </div>
+ </div>
+ <div class="repository-mirrorlist">
+ <div class="repository-edit-wrapper-label">
+ <label
for="repository-edit-urlargs-textbox">$_("Mirror List
URL")</label>
+ </div>
+ <div class="repository-edit-wrapper-controls">
+ <input id="repository-edit-urlargs-textbox"
class="yum required" name="config[mirrorlist]" type="text"
/>
+ </div>
+ </div>
+ <div class="repository-comps">
+ <div class="repository-edit-wrapper-label">
+ <label
for="repository-edit-urlargs-textbox">$_("Components")</label>
+ </div>
+ <div class="repository-edit-wrapper-controls">
+ <input id="repository-edit-urlargs-textbox"
class="deb" name="config[comps]" type="text" />
+ </div>
+ </div>
+ <div class="repository-gpgkey">
+ <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"
class="yum" name="config[gpgkey]" type="text" />
+ </div>
+ </div>
+ </fieldset>
+ </header>
+ <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