Skip to content

Commit 40f4377

Browse files
appleboylunny
authored andcommitted
feat: fill in ssh key title automatically. (#863)
1 parent a6751ce commit 40f4377

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

public/js/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,4 +1486,13 @@ $(function () {
14861486
$('.list-search-style').html('.search-list li:not([data-title*="' + value + '"]) {display: none;}');
14871487
}
14881488
});
1489+
1490+
// Parse SSH Key
1491+
$("#ssh-key-content").on('change paste keyup',function(){
1492+
var value = $(this).val();
1493+
var arrays = value.split(" ");
1494+
if (arrays.length === 3 && arrays[2] !== "") {
1495+
$("#ssh-key-title").val(arrays[2]);
1496+
}
1497+
});
14891498
});

templates/user/settings/sshkeys.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353
{{.CsrfTokenHtml}}
5454
<div class="field {{if .Err_Title}}error{{end}}">
5555
<label for="title">{{.i18n.Tr "settings.key_name"}}</label>
56-
<input id="title" name="title" value="{{.title}}" autofocus required>
56+
<input id="ssh-key-title" name="title" value="{{.title}}" autofocus required>
5757
</div>
5858
<div class="field {{if .Err_Content}}error{{end}}">
5959
<label for="content">{{.i18n.Tr "settings.key_content"}}</label>
60-
<textarea id="content" name="content" required>{{.content}}</textarea>
60+
<textarea id="ssh-key-content" name="content" required>{{.content}}</textarea>
6161
</div>
6262
<button class="ui green button">
6363
{{.i18n.Tr "settings.add_key"}}

0 commit comments

Comments
 (0)