summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFuXiaoHei <fuxiaohei@hexiaz.com>2014-03-10 21:12:49 +0800
committerFuXiaoHei <fuxiaohei@hexiaz.com>2014-03-10 21:12:49 +0800
commitefa039a0f75ff9ba9376af1cbd3d948752c074fc (patch)
treec98399f49124b90f513d2a8e029118802849ef29
parent3ca7a33907e674c2c90e9f795b57bf87868f16b7 (diff)
downloadgitea-efa039a0f75ff9ba9376af1cbd3d948752c074fc.tar.gz
gitea-efa039a0f75ff9ba9376af1cbd3d948752c074fc.zip
finish ssh key pages ui
-rwxr-xr-xpublic/css/gogs.css4
-rw-r--r--public/js/app.js41
-rw-r--r--routers/user/setting.go32
-rw-r--r--templates/base/footer.tmpl5
-rw-r--r--templates/base/navbar.tmpl2
-rw-r--r--templates/user/publickey.tmpl4
6 files changed, 82 insertions, 6 deletions
diff --git a/public/css/gogs.css b/public/css/gogs.css
index 9205178f4d..4a4144babd 100755
--- a/public/css/gogs.css
+++ b/public/css/gogs.css
@@ -32,6 +32,10 @@ body {
background-color: transparent;
}
+.btn{
+ cursor: pointer;
+}
+
/* gogits nav header */
.gogs-masthead {
background-color: #428bca;
diff --git a/public/js/app.js b/public/js/app.js
index 59d521090c..f6e1471204 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -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;
+ });
} \ No newline at end of file
diff --git a/routers/user/setting.go b/routers/user/setting.go
index 84be138170..aabbc21293 100644
--- a/routers/user/setting.go
+++ b/routers/user/setting.go
@@ -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),
diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl
index 4ae4a95fa0..a2131a9532 100644
--- a/templates/base/footer.tmpl
+++ b/templates/base/footer.tmpl
@@ -1,7 +1,8 @@
<script>
$(function(){
- initCore();
- {{if .PageIsSignUp}}initRegister();{{end}}
+ initCore();{{if .PageIsSignUp}}
+ initRegister();{{end}}{{if .PageIsUserSetting}}
+ initUserSetting();{{end}}
});
</script>
</body>
diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl
index e78f6bb221..38fc0a3992 100644
--- a/templates/base/navbar.tmpl
+++ b/templates/base/navbar.tmpl
@@ -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>
diff --git a/templates/user/publickey.tmpl b/templates/user/publickey.tmpl
index fbd12adbd0..0c8b527db9 100644
--- a/templates/user/publickey.tmpl
+++ b/templates/user/publickey.tmpl
@@ -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>