@@ -11,7 +11,6 @@ import (
11
11
"time"
12
12
13
13
"github.com/json-iterator/go"
14
- "github.com/unknwon/com"
15
14
16
15
"github.com/G-Node/gogs/internal/conf"
17
16
"github.com/G-Node/gogs/internal/context"
@@ -110,68 +109,11 @@ func updateSystemStatus() {
110
109
sysStatus .NumGC = m .NumGC
111
110
}
112
111
113
- // Operation types.
114
- type AdminOperation int
115
-
116
- const (
117
- CLEAN_INACTIVATE_USER AdminOperation = iota + 1
118
- CLEAN_REPO_ARCHIVES
119
- CLEAN_MISSING_REPOS
120
- GIT_GC_REPOS
121
- SYNC_SSH_AUTHORIZED_KEY
122
- SYNC_REPOSITORY_HOOKS
123
- REINIT_MISSING_REPOSITORY
124
- REBUILD_SEARCH_INDEX
125
- )
126
-
127
112
func Dashboard (c * context.Context ) {
128
113
c .Title ("admin.dashboard" )
129
114
c .PageIs ("Admin" )
130
115
c .PageIs ("AdminDashboard" )
131
116
132
- // Run operation.
133
- op , _ := com .StrTo (c .Query ("op" )).Int ()
134
- if op > 0 {
135
- var err error
136
- var success string
137
-
138
- switch AdminOperation (op ) {
139
- case CLEAN_INACTIVATE_USER :
140
- success = c .Tr ("admin.dashboard.delete_inactivate_accounts_success" )
141
- err = db .DeleteInactivateUsers ()
142
- case CLEAN_REPO_ARCHIVES :
143
- success = c .Tr ("admin.dashboard.delete_repo_archives_success" )
144
- err = db .DeleteRepositoryArchives ()
145
- case CLEAN_MISSING_REPOS :
146
- success = c .Tr ("admin.dashboard.delete_missing_repos_success" )
147
- err = db .DeleteMissingRepositories ()
148
- case GIT_GC_REPOS :
149
- success = c .Tr ("admin.dashboard.git_gc_repos_success" )
150
- err = db .GitGcRepos ()
151
- case SYNC_SSH_AUTHORIZED_KEY :
152
- success = c .Tr ("admin.dashboard.resync_all_sshkeys_success" )
153
- err = db .RewriteAuthorizedKeys ()
154
- case SYNC_REPOSITORY_HOOKS :
155
- success = c .Tr ("admin.dashboard.resync_all_hooks_success" )
156
- err = db .SyncRepositoryHooks ()
157
- case REINIT_MISSING_REPOSITORY :
158
- success = c .Tr ("admin.dashboard.reinit_missing_repos_success" )
159
- err = db .ReinitMissingRepositories ()
160
- case REBUILD_SEARCH_INDEX :
161
- // TODO: Add success message to locale files
162
- success = "All repositories have been submitted to the indexing service successfully."
163
- err = db .RebuildIndex ()
164
- }
165
-
166
- if err != nil {
167
- c .Flash .Error (err .Error ())
168
- } else {
169
- c .Flash .Success (success )
170
- }
171
- c .RedirectSubpath ("/admin" )
172
- return
173
- }
174
-
175
117
c .Data ["GitVersion" ] = conf .Git .Version
176
118
c .Data ["GoVersion" ] = runtime .Version ()
177
119
c .Data ["BuildTime" ] = conf .BuildTime
@@ -184,6 +126,55 @@ func Dashboard(c *context.Context) {
184
126
c .Success (DASHBOARD )
185
127
}
186
128
129
+ // Operation types.
130
+ type AdminOperation int
131
+
132
+ const (
133
+ CleanInactivateUser AdminOperation = iota + 1
134
+ CleanRepoArchives
135
+ CleanMissingRepos
136
+ GitGCRepos
137
+ SyncSSHAuthorizedKey
138
+ SyncRepositoryHooks
139
+ ReinitMissingRepository
140
+ )
141
+
142
+ func Operation (c * context.Context ) {
143
+ var err error
144
+ var success string
145
+ switch AdminOperation (c .QueryInt ("op" )) {
146
+ case CleanInactivateUser :
147
+ success = c .Tr ("admin.dashboard.delete_inactivate_accounts_success" )
148
+ err = db .DeleteInactivateUsers ()
149
+ case CleanRepoArchives :
150
+ success = c .Tr ("admin.dashboard.delete_repo_archives_success" )
151
+ err = db .DeleteRepositoryArchives ()
152
+ case CleanMissingRepos :
153
+ success = c .Tr ("admin.dashboard.delete_missing_repos_success" )
154
+ err = db .DeleteMissingRepositories ()
155
+ case GitGCRepos :
156
+ success = c .Tr ("admin.dashboard.git_gc_repos_success" )
157
+ err = db .GitGcRepos ()
158
+ case SyncSSHAuthorizedKey :
159
+ success = c .Tr ("admin.dashboard.resync_all_sshkeys_success" )
160
+ err = db .RewriteAuthorizedKeys ()
161
+ case SyncRepositoryHooks :
162
+ success = c .Tr ("admin.dashboard.resync_all_hooks_success" )
163
+ err = db .SyncRepositoryHooks ()
164
+ case ReinitMissingRepository :
165
+ success = c .Tr ("admin.dashboard.reinit_missing_repos_success" )
166
+ err = db .ReinitMissingRepositories ()
167
+ }
168
+
169
+ if err != nil {
170
+ c .Flash .Error (err .Error ())
171
+ } else {
172
+ c .Flash .Success (success )
173
+ }
174
+ c .RedirectSubpath ("/admin" )
175
+ return
176
+ }
177
+
187
178
func SendTestMail (c * context.Context ) {
188
179
emailAddr := c .Query ("email" )
189
180
// Send a test email to the user's email address and redirect back to Config
0 commit comments