1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-12-22 17:34:03 +03:00

finish ssh key pages ui

This commit is contained in:
FuXiaoHei 2014-03-10 21:12:49 +08:00
parent 3ca7a33907
commit efa039a0f7
6 changed files with 82 additions and 6 deletions

View File

@ -32,6 +32,10 @@ body {
background-color: transparent; background-color: transparent;
} }
.btn{
cursor: pointer;
}
/* gogits nav header */ /* gogits nav header */
.gogs-masthead { .gogs-masthead {
background-color: #428bca; background-color: #428bca;

View File

@ -30,7 +30,8 @@ var Gogits = {
return; return;
} }
$.each(modals, function (i, item) { $.each(modals, function (i, item) {
$(item).modal("hide"); var hide = $(item).data('modal');
$(item).modal(hide ? hide : "hide");
}); });
}; };
Gogits.initTooltips = function () { Gogits.initTooltips = function () {
@ -39,6 +40,30 @@ var Gogits = {
//container: "body" //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); })(jQuery);
@ -73,3 +98,17 @@ 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;
});
}

View File

@ -12,6 +12,7 @@ import (
"github.com/martini-contrib/render" "github.com/martini-contrib/render"
"github.com/martini-contrib/sessions" "github.com/martini-contrib/sessions"
"net/http" "net/http"
"strconv"
) )
func Setting(r render.Render, data base.TmplData, session sessions.Session) { 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) { 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 // add ssh key
if req.Method == "POST" { if req.Method == "POST" {
k := &models.PublicKey{OwnerId: auth.SignedInId(session), k := &models.PublicKey{OwnerId: auth.SignedInId(session),

View File

@ -1,7 +1,8 @@
<script> <script>
$(function(){ $(function(){
initCore(); initCore();{{if .PageIsSignUp}}
{{if .PageIsSignUp}}initRegister();{{end}} initRegister();{{end}}{{if .PageIsUserSetting}}
initUserSetting();{{end}}
}); });
</script> </script>
</body> </body>

View File

@ -2,7 +2,7 @@
<div class="container"> <div class="container">
<nav class="gogs-nav"> <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 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="#">Explore</a>
<a class="gogs-nav-item" href="#">Help</a>{{if .IsSigned}} <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> <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>

View File

@ -49,8 +49,8 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">Save changes</button> <button type="submit" class="btn btn-primary">Save SSH Key</button>
</div> </div>
</form> </form>
</div> </div>