Browse Source

more minor fix on 1581

pull/1629/head
Unknwon 9 years ago
parent
commit
fa728d8dff
  1. 5
      conf/locale/locale_en-US.ini
  2. 6
      models/login.go
  3. 2
      models/models.go
  4. 4
      modules/bindata/bindata.go
  5. 2
      public/css/gogs.min.css
  6. 4
      public/less/_admin.less
  7. 6
      routers/admin/auths.go
  8. 10
      templates/admin/auth/edit.tmpl
  9. 101
      templates/admin/auth/list.tmpl

5
conf/locale/locale_en-US.ini

@ -14,7 +14,7 @@ version = Version
page = Page page = Page
template = Template template = Template
language = Language language = Language
create_new = Create new... create_new = Create...
user_profile_and_more = User profile and more user_profile_and_more = User profile and more
signed_in_as = Signed in as signed_in_as = Signed in as
@ -718,6 +718,7 @@ notices = System Notices
monitor = Monitoring monitor = Monitoring
prev = Prev. prev = Prev.
next = Next next = Next
total = Total: %d
dashboard.statistic = Statistic dashboard.statistic = Statistic
dashboard.operations = Operations dashboard.operations = Operations
@ -804,7 +805,7 @@ repos.stars = Stars
repos.issues = Issues repos.issues = Issues
auths.auth_manage_panel = Authentication Manage Panel auths.auth_manage_panel = Authentication Manage Panel
auths.new = Add New Authentication Source auths.new = Add New Source
auths.name = Name auths.name = Name
auths.type = Type auths.type = Type
auths.enabled = Enabled auths.enabled = Enabled

6
models/login.go

@ -134,6 +134,12 @@ func (source *LoginSource) PAM() *PAMConfig {
return source.Cfg.(*PAMConfig) return source.Cfg.(*PAMConfig)
} }
// CountLoginSources returns number of login sources.
func CountLoginSources() int64 {
count, _ := x.Count(new(LoginSource))
return count
}
func CreateSource(source *LoginSource) error { func CreateSource(source *LoginSource) error {
_, err := x.Insert(source) _, err := x.Insert(source)
return err return err

2
models/models.go

@ -237,7 +237,7 @@ func GetStatistic() (stats Statistic) {
stats.Counter.Follow, _ = x.Count(new(Follow)) stats.Counter.Follow, _ = x.Count(new(Follow))
stats.Counter.Mirror, _ = x.Count(new(Mirror)) stats.Counter.Mirror, _ = x.Count(new(Mirror))
stats.Counter.Release, _ = x.Count(new(Release)) stats.Counter.Release, _ = x.Count(new(Release))
stats.Counter.LoginSource, _ = x.Count(new(LoginSource)) stats.Counter.LoginSource = CountLoginSources()
stats.Counter.Webhook, _ = x.Count(new(Webhook)) stats.Counter.Webhook, _ = x.Count(new(Webhook))
stats.Counter.Milestone, _ = x.Count(new(Milestone)) stats.Counter.Milestone, _ = x.Count(new(Milestone))
stats.Counter.Label, _ = x.Count(new(Label)) stats.Counter.Label, _ = x.Count(new(Label))

4
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

2
public/css/gogs.min.css vendored

File diff suppressed because one or more lines are too long

4
public/less/_admin.less

@ -15,4 +15,8 @@
} }
} }
} }
.ui.header,
.ui.segment {
box-shadow: 0 1px 2px 0 rgba(34,36,38,.15);
}
} }

6
routers/admin/auths.go

@ -34,6 +34,8 @@ func Authentications(ctx *middleware.Context) {
ctx.Handle(500, "GetAuths", err) ctx.Handle(500, "GetAuths", err)
return return
} }
ctx.Data["Total"] = models.CountLoginSources()
ctx.HTML(200, AUTHS) ctx.HTML(200, AUTHS)
} }
@ -61,7 +63,7 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
var u core.Conversion var u core.Conversion
switch models.LoginType(form.Type) { switch models.LoginType(form.Type) {
case models.LDAP: case models.LDAP:
fallthrough fallthrough
case models.DLDAP: case models.DLDAP:
u = &models.LDAPConfig{ u = &models.LDAPConfig{
Ldapsource: ldap.Ldapsource{ Ldapsource: ldap.Ldapsource{
@ -152,7 +154,7 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) {
var config core.Conversion var config core.Conversion
switch models.LoginType(form.Type) { switch models.LoginType(form.Type) {
case models.LDAP: case models.LDAP:
fallthrough fallthrough
case models.DLDAP: case models.DLDAP:
config = &models.LDAPConfig{ config = &models.LDAPConfig{
Ldapsource: ldap.Ldapsource{ Ldapsource: ldap.Ldapsource{

10
templates/admin/auth/edit.tmpl

@ -30,7 +30,7 @@
<input class="ipt ipt-large ipt-radius {{if .Err_AuthName}}ipt-error{{end}}" id="name" name="name" value="{{.Source.Name}}" required /> <input class="ipt ipt-large ipt-radius {{if .Err_AuthName}}ipt-error{{end}}" id="name" name="name" value="{{.Source.Name}}" required />
</div> </div>
{{if eq $type 2 3}} {{if eq $type 2 5}}
<div class="field"> <div class="field">
<label class="req" for="host">{{.i18n.Tr "admin.auths.host"}}</label> <label class="req" for="host">{{.i18n.Tr "admin.auths.host"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_Host}}ipt-error{{end}}" id="host" name="host" value="{{.Source.LDAP.Host}}" required /> <input class="ipt ipt-large ipt-radius {{if .Err_Host}}ipt-error{{end}}" id="host" name="host" value="{{.Source.LDAP.Host}}" required />
@ -57,7 +57,7 @@
<input class="ipt ipt-large ipt-radius {{if .Err_UserBase}}ipt-error{{end}}" id="user_base" name="user_base" value="{{.Source.LDAP.UserBase}}" /> <input class="ipt ipt-large ipt-radius {{if .Err_UserBase}}ipt-error{{end}}" id="user_base" name="user_base" value="{{.Source.LDAP.UserBase}}" />
</div> </div>
{{end}} {{end}}
{{if eq $type 3}} {{if eq $type 5}}
<div class="field"> <div class="field">
<label class="req" for="user_dn">{{.i18n.Tr "admin.auths.user_dn"}}</label> <label class="req" for="user_dn">{{.i18n.Tr "admin.auths.user_dn"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_UserDN}}ipt-error{{end}}" id="user_dn" name="user_dn" value="{{.Source.LDAP.UserDN}}" /> <input class="ipt ipt-large ipt-radius {{if .Err_UserDN}}ipt-error{{end}}" id="user_dn" name="user_dn" value="{{.Source.LDAP.UserDN}}" />
@ -85,7 +85,7 @@
</div> </div>
{{else if eq $type 4}} {{else if eq $type 3}}
<div class="field"> <div class="field">
<label class="req">{{.i18n.Tr "admin.auths.smtp_auth"}}</label> <label class="req">{{.i18n.Tr "admin.auths.smtp_auth"}}</label>
<select name="smtp_auth"> <select name="smtp_auth">
@ -105,7 +105,7 @@
<input class="ipt ipt-large ipt-radius {{if .Err_SmtpPort}}ipt-error{{end}}" id="smtp_port" name="smtp_port" value="{{.Source.SMTP.Port}}" /> <input class="ipt ipt-large ipt-radius {{if .Err_SmtpPort}}ipt-error{{end}}" id="smtp_port" name="smtp_port" value="{{.Source.SMTP.Port}}" />
</div> </div>
{{else if eq $type 5}} {{else if eq $type 4}}
<div class="field"> <div class="field">
<label class="req" for="pam_service_name">{{.i18n.Tr "admin.auths.pam_service_name"}}</label> <label class="req" for="pam_service_name">{{.i18n.Tr "admin.auths.pam_service_name"}}</label>
<input class="ipt ipt-large ipt-radius {{if .Err_PAMServiceName}}ipt-error{{end}}" id="pam_service_name" name="pam_service_name" value="{{.Source.PAM.ServiceName}}" /> <input class="ipt ipt-large ipt-radius {{if .Err_PAMServiceName}}ipt-error{{end}}" id="pam_service_name" name="pam_service_name" value="{{.Source.PAM.ServiceName}}" />
@ -113,7 +113,7 @@
{{end}} {{end}}
<div class="field"> <div class="field">
{{if eq $type 4}} {{if eq $type 3}}
<label></label> <label></label>
<input name="tls" type="checkbox" {{if .Source.SMTP.TLS}}checked{{end}}> <input name="tls" type="checkbox" {{if .Source.SMTP.TLS}}checked{{end}}>
<strong>{{.i18n.Tr "admin.auths.enable_tls"}}</strong> <strong>{{.i18n.Tr "admin.auths.enable_tls"}}</strong>

101
templates/admin/auth/list.tmpl

@ -1,59 +1,46 @@
{{template "ng/base/head" .}} {{template "base/head" .}}
{{template "ng/base/header" .}} <div class="admin authentication">
<div id="admin-wrapper"> <div class="ui container">
<div id="setting-wrapper" class="main-wrapper"> <div class="ui grid">
<div id="admin-setting" class="container clear"> {{template "admin/navbar" .}}
{{template "admin/nav" .}} <div class="twelve wide column content">
<div class="grid-4-5 left"> {{template "base/alert" .}}
<div class="setting-content"> <h4 class="ui top attached header">
{{template "ng/base/alert" .}} {{.i18n.Tr "admin.auths.auth_manage_panel"}} ({{.i18n.Tr "admin.total" .Total}})
<div id="setting-content"> <div class="ui right">
<div class="panel panel-radius"> <a class="ui blue tiny button" href="{{AppSubUrl}}/admin/auths/new">{{.i18n.Tr "admin.auths.new"}}</a>
<div class="panel-header"> </div>
<strong>{{.i18n.Tr "admin.auths.auth_manage_panel"}}</strong> </h4>
</div> <div class="ui attached table segment">
<div class="panel-body admin-panel"> <table class="ui very basic striped table">
<a class="btn-blue btn-medium btn-link btn-radius" href="{{AppSubUrl}}/admin/auths/new">{{.i18n.Tr "admin.auths.new"}}</a> <thead>
<div class="admin-table"> <tr>
<table class="table table-striped"> <th>ID</th>
<thead> <th>{{.i18n.Tr "admin.auths.name"}}</th>
<tr> <th>{{.i18n.Tr "admin.auths.type"}}</th>
<th>Id</th> <th>{{.i18n.Tr "admin.auths.enabled"}}</th>
<th>{{.i18n.Tr "admin.auths.name"}}</th> <th>{{.i18n.Tr "admin.auths.updated"}}</th>
<th>{{.i18n.Tr "admin.auths.type"}}</th> <th>{{.i18n.Tr "admin.users.created"}}</th>
<th>{{.i18n.Tr "admin.auths.enabled"}}</th> <th>{{.i18n.Tr "admin.users.edit"}}</th>
<th>{{.i18n.Tr "admin.auths.updated"}}</th> </tr>
<th>{{.i18n.Tr "admin.users.created"}}</th> </thead>
<th>{{.i18n.Tr "admin.users.edit"}}</th> <tbody>
</tr> {{range .Sources}}
</thead> <tr>
<tbody> <td>{{.ID}}</td>
{{range .Sources}} <td><a href="{{AppSubUrl}}/admin/auths/{{.ID}}">{{.Name}}</a></td>
<tr> <td>{{.TypeString}}</td>
<td>{{.ID}}</td> <td><i class="fa fa{{if .IsActived}}-check{{end}}-square-o"></i></td>
<td><a href="{{AppSubUrl}}/admin/auths/{{.ID}}">{{.Name}}</a></td> <td><span class="poping up" data-content="{{DateFmtLong .Updated}}" data-variation="tiny">{{DateFmtShort .Updated}}</span></td>
<td>{{.TypeString}}</td> <td><span class="poping up" data-content="{{DateFmtLong .Created}}" data-variation="tiny">{{DateFmtShort .Created}}</span></td>
<td><i class="fa fa{{if .IsActived}}-check{{end}}-square-o"></i></td> <td><a href="{{AppSubUrl}}/admin/auths/{{.ID}}"><i class="fa fa-pencil-square-o"></i></a></td>
<td><span title="{{DateFmtLong .Updated}}">{{DateFmtShort .Updated}}</span></td> </tr>
<td><span title="{{DateFmtLong .Created}}">{{DateFmtShort .Created}}</span></td> {{end}}
<td><a href="{{AppSubUrl}}/admin/auths/{{.ID}}"><i class="fa fa-pencil-square-o"></i></a></td> </tbody>
</tr> </table>
{{end}} </div>
</tbody> </div>
</table>
{{if or .LastPageNum .NextPageNum}}
<ul class="pagination">
{{if .LastPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{AppSubUrl}}/admin/auths?p={{.LastPageNum}}">&laquo; Prev.</a></li>{{end}}
{{if .NextPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{AppSubUrl}}/admin/auths?p={{.NextPageNum}}">&raquo; Next</a></li>{{end}}
</ul>
{{end}}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div> </div>
</div>
</div> </div>
{{template "ng/base/footer" .}} {{template "base/footer" .}}
Loading…
Cancel
Save