コード例 #1
0
ファイル: admin.go プロジェクト: JustStone/gogs
func Dashboard(ctx *middleware.Context) {
	ctx.Data["Title"] = "Admin Dashboard"
	ctx.Data["PageIsDashboard"] = true

	// Run operation.
	op, _ := base.StrTo(ctx.Query("op")).Int()
	if op > 0 {
		var err error
		var success string

		switch AdminOperation(op) {
		case CLEAN_UNBIND_OAUTH:
			success = "All unbind OAuthes have been deleted."
			err = models.CleanUnbindOauth()
		case CLEAN_INACTIVATE_USER:
			success = "All inactivate accounts have been deleted."
			err = models.DeleteInactivateUsers()
		}

		if err != nil {
			ctx.Flash.Error(err.Error())
		} else {
			ctx.Flash.Success(success)
		}
		ctx.Redirect("/admin")
		return
	}

	ctx.Data["Stats"] = models.GetStatistic()
	updateSystemStatus()
	ctx.Data["SysStatus"] = sysStatus
	ctx.HTML(200, DASHBOARD)
}
コード例 #2
0
ファイル: admin.go プロジェクト: numo16/gogs
func Dashboard(ctx *middleware.Context) {
	ctx.Data["Title"] = "Admin Dashboard"
	ctx.Data["PageIsDashboard"] = true

	// Run operation.
	op, _ := base.StrTo(ctx.Query("op")).Int()
	if op > 0 {
		var err error
		var success string

		switch op {
		case OT_CLEAN_OAUTH:
			success = "All unbind OAuthes have been deleted."
			err = models.CleanUnbindOauth()
		}

		if err != nil {
			ctx.Flash.Error(err.Error())
		} else {
			ctx.Flash.Success(success)
		}
		ctx.Redirect("/admin")
		return
	}

	ctx.Data["Stats"] = models.GetStatistic()
	updateSystemStatus()
	ctx.Data["SysStatus"] = sysStatus
	ctx.HTML(200, "admin/dashboard")
}
コード例 #3
0
ファイル: admin.go プロジェクト: Keleir/gogs
func Dashboard(ctx *middleware.Context) {
	ctx.Data["Title"] = ctx.Tr("admin.dashboard")
	ctx.Data["PageIsAdmin"] = true
	ctx.Data["PageIsAdminDashboard"] = true

	// Run operation.
	op, _ := com.StrTo(ctx.Query("op")).Int()
	if op > 0 {
		var err error
		var success string

		switch AdminOperation(op) {
		case CLEAN_UNBIND_OAUTH:
			success = ctx.Tr("admin.dashboard.clean_unbind_oauth_success")
			err = models.CleanUnbindOauth()
		case CLEAN_INACTIVATE_USER:
			success = ctx.Tr("admin.dashboard.delete_inactivate_accounts_success")
			err = models.DeleteInactivateUsers()
		case CLEAN_REPO_ARCHIVES:
			success = ctx.Tr("admin.dashboard.delete_repo_archives_success")
			err = models.DeleteRepositoryArchives()
		case GIT_GC_REPOS:
			success = ctx.Tr("admin.dashboard.git_gc_repos_success")
			err = models.GitGcRepos()
		case SYNC_SSH_AUTHORIZED_KEY:
			success = ctx.Tr("admin.dashboard.resync_all_sshkeys_success")
			err = models.RewriteAllPublicKeys()
		case SYNC_REPOSITORY_UPDATE_HOOK:
			success = ctx.Tr("admin.dashboard.resync_all_update_hooks_success")
			err = models.RewriteRepositoryUpdateHook()
		}

		if err != nil {
			ctx.Flash.Error(err.Error())
		} else {
			ctx.Flash.Success(success)
		}
		ctx.Redirect(setting.AppSubUrl + "/admin")
		return
	}

	ctx.Data["Stats"] = models.GetStatistic()
	// FIXME: update periodically
	updateSystemStatus()
	ctx.Data["SysStatus"] = sysStatus
	ctx.HTML(200, DASHBOARD)
}