diff --git a/static/css/common.css b/static/css/common.css
index 2fcb8f4..2b46c96 100644
--- a/static/css/common.css
+++ b/static/css/common.css
@@ -3,6 +3,8 @@
min-width: 500px;
float: left;
}
+.error { color: #ff0000; }
+
/** Modal **/
.modal-bg {
display: none;
diff --git a/static/index.html b/static/index.html
index 42077f9..313d694 100644
--- a/static/index.html
+++ b/static/index.html
@@ -19,6 +19,7 @@
Your Keys
+
diff --git a/static/js/add_key.js b/static/js/add_key.js
index 0ea46c4..31ee4dc 100644
--- a/static/js/add_key.js
+++ b/static/js/add_key.js
@@ -5,13 +5,14 @@
}
var onSubmitKey = function($form) {
- var input = $form.pubkey.value.trim();
+ var input = $form.pubkey.value.trim(),
+ $error = document.getElementById('js-addkey-error');
// Format of key: algorithm (e.g. ssh-rsa), base64 encoded pubkey and an optional comment
var keyObj = input.match(/^(.+)\s((?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?)(?:\s(.+))?$/);
if (!keyObj) {
- console.error('Wrong format in submitted key. Example: "ssh-rsa AAAA...== user@host"');
- return;
+ $error.textContent = 'Wrong format in submitted key. Example: "ssh-rsa AAAA...== user@host"';
+ return;
}
var comment = keyObj[3] || '';
@@ -24,8 +25,14 @@
document.body.dispatchEvent(event);
};
+ var clearForm = function () {
+ $error.textContent = '';
+ $form.pubkey.value = '';
+ };
+
save(postData)
.then(triggerEvent)
+ .then(clearForm)
.catch(function(error) {
console.error("Error when saving new key", error);
});