mirror of
https://gitee.com/gitea/gitea.git
synced 2024-11-30 02:37:38 +08:00
finish ssh key pages ui
This commit is contained in:
parent
3ca7a33907
commit
efa039a0f7
@ -32,6 +32,10 @@ body {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.btn{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* gogits nav header */
|
||||
.gogs-masthead {
|
||||
background-color: #428bca;
|
||||
|
@ -30,7 +30,8 @@ var Gogits = {
|
||||
return;
|
||||
}
|
||||
$.each(modals, function (i, item) {
|
||||
$(item).modal("hide");
|
||||
var hide = $(item).data('modal');
|
||||
$(item).modal(hide ? hide : "hide");
|
||||
});
|
||||
};
|
||||
Gogits.initTooltips = function () {
|
||||
@ -39,6 +40,30 @@ var Gogits = {
|
||||
//container: "body"
|
||||
});
|
||||
};
|
||||
Gogits.initTabs = function () {
|
||||
var $tabs = $('[data-toggle=tab]');
|
||||
$tabs.tab("show");
|
||||
$tabs.find("li:eq(" + index + ") a").tab("show");
|
||||
}
|
||||
})(jQuery);
|
||||
|
||||
// ajax utils
|
||||
(function ($) {
|
||||
Gogits.ajaxDelete = function (url, data, success) {
|
||||
data = data || {};
|
||||
data._method = "DELETE";
|
||||
$.ajax({
|
||||
url: url,
|
||||
data: data,
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
if (success) {
|
||||
success(json);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})(jQuery);
|
||||
|
||||
|
||||
@ -72,4 +97,18 @@ function initRegister() {
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function initUserSetting(){
|
||||
$('#gogs-ssh-keys').on("click",".delete",function(){
|
||||
var $this = $(this);
|
||||
Gogits.ajaxDelete("",{"id":$this.data("del")},function(json){
|
||||
if(json.ok){
|
||||
$this.parent().remove();
|
||||
}else{
|
||||
alert(json.err);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
@ -12,6 +12,7 @@ import (
|
||||
"github.com/martini-contrib/render"
|
||||
"github.com/martini-contrib/sessions"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Setting(r render.Render, data base.TmplData, session sessions.Session) {
|
||||
@ -21,6 +22,37 @@ func Setting(r render.Render, data base.TmplData, session sessions.Session) {
|
||||
}
|
||||
|
||||
func SettingSSHKeys(r render.Render, data base.TmplData, req *http.Request, session sessions.Session) {
|
||||
// del ssh ky
|
||||
if req.Method == "DELETE" || req.FormValue("_method") == "DELETE" {
|
||||
id, err := strconv.ParseInt(req.FormValue("id"), 10, 64)
|
||||
if err != nil {
|
||||
data["ErrorMsg"] = err
|
||||
log.Error("ssh.DelPublicKey: %v", err)
|
||||
r.JSON(200, map[string]interface{}{
|
||||
"ok": false,
|
||||
"err": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
k := &models.PublicKey{
|
||||
Id: id,
|
||||
OwnerId: auth.SignedInId(session),
|
||||
}
|
||||
err = models.DeletePublicKey(k)
|
||||
if err != nil {
|
||||
data["ErrorMsg"] = err
|
||||
log.Error("ssh.DelPublicKey: %v", err)
|
||||
r.JSON(200, map[string]interface{}{
|
||||
"ok": false,
|
||||
"err": err.Error(),
|
||||
})
|
||||
} else {
|
||||
r.JSON(200, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
// add ssh key
|
||||
if req.Method == "POST" {
|
||||
k := &models.PublicKey{OwnerId: auth.SignedInId(session),
|
||||
|
@ -1,7 +1,8 @@
|
||||
<script>
|
||||
$(function(){
|
||||
initCore();
|
||||
{{if .PageIsSignUp}}initRegister();{{end}}
|
||||
initCore();{{if .PageIsSignUp}}
|
||||
initRegister();{{end}}{{if .PageIsUserSetting}}
|
||||
initUserSetting();{{end}}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="container">
|
||||
<nav class="gogs-nav">
|
||||
<a id="gogs-nav-logo" class="gogs-nav-item{{if .PageIsHome}} active{{end}}" href="/"><img src="/img/favicon.png" alt="Gogs Logo" id="gogs-logo"></a>
|
||||
<a class="gogs-nav-item{{if .PageIsUserDashboard}} active{{end}}" href="#">Dashboard</a>
|
||||
<a class="gogs-nav-item{{if .PageIsUserDashboard}} active{{end}}" href="/">Dashboard</a>
|
||||
<a class="gogs-nav-item" href="#">Explore</a>
|
||||
<a class="gogs-nav-item" href="#">Help</a>{{if .IsSigned}}
|
||||
<a id="gogs-nav-out" class="gogs-nav-item navbar-right navbar-btn btn btn-danger" href="/user/logout/"><i class="fa fa-power-off fa-lg"></i></a>
|
||||
|
@ -49,8 +49,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Save SSH Key</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user