Skip to content

Commit

Permalink
计划中的 v1.3 版本内容
Browse files Browse the repository at this point in the history
1、统计数据 页面扩展显示短链接的备注信息
2、访问日志 页面扩展功能,支持导出访问日志
  • Loading branch information
barats committed Apr 28, 2022
1 parent aa732f4 commit 78f59f8
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion assets/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function sign_out_config() {
function export_accesslog() {
$('body').modal('confirm','温馨提示','确认导出访问日志?', function(choice){
if (choice) {
$("#form-export-logs-btn").click()
$("#form-export-logs").submit();
}
});
}
2 changes: 2 additions & 0 deletions controller/admin_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func AccessLogsPage(c *gin.Context) {
func AccessLogsExport(c *gin.Context) {
url := c.PostForm("url")
logs, err := service.GetAllAccessLogs(strings.TrimSpace(url))

if err != nil {
c.HTML(http.StatusOK, "access_logs.html", gin.H{
"title": "访问日志查询 - ohUrlShortener",
Expand All @@ -243,6 +244,7 @@ func AccessLogsExport(c *gin.Context) {
})
return
}

fileContent, err := export.AccessLogToExcel(logs)
if err != nil {
c.HTML(http.StatusOK, "access_logs.html", gin.H{
Expand Down
3 changes: 0 additions & 3 deletions docker/admin.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ ENV GOPROXY=https://proxy.golang.com.cn,direct
ADD . /app
WORKDIR /app
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ohurlshortener
RUN apk add upx && \
mv ohurlshortener ohurlshortener_tmp && \
upx --best -o ohurlshortener ohurlshortener_tmp

##
## Deploy
Expand Down
6 changes: 5 additions & 1 deletion docker/local_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ services:
test: [ "CMD", "psql", "-U","${PG_SUPER_USER}","-d","oh_url_shortener" ]
timeout: 10s
interval: 3s
retries: 10
retries: 10
ports:
- ${PG_LOCAL_PORT}:5432
networks:
- ohurlshortener

Expand All @@ -68,6 +70,8 @@ services:
timeout: 10s
interval: 3s
retries: 10
ports:
- ${RD_LOCAL_PORT}:6379
networks:
- ohurlshortener

Expand Down
3 changes: 0 additions & 3 deletions docker/portal.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ ENV GOPROXY=https://proxy.golang.com.cn,direct
ADD . /app
WORKDIR /app
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ohurlshortener
RUN apk add upx && \
mv ohurlshortener ohurlshortener_tmp && \
upx --best -o ohurlshortener ohurlshortener_tmp

##
## Deploy
Expand Down
6 changes: 4 additions & 2 deletions docker/vars.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

# ohUrlShortenerAdmin
OH_ADMIN_PORT=9092
OH_ADMIN_VERSION=1.2
OH_ADMIN_VERSION=1.3
OH_ADMIN_CONTAINER_NAME=ohurlshortener_admin

# ohUrlShortenerPortal
OH_PORTAL_PORT=9091
OH_PORTAL_VERSION=1.2
OH_PORTAL_VERSION=1.3
OH_PORTAL_CONTAINER_NAME=ohurlshortener_portal

# Postgresql Vars
PG_VERSION=9.6
PG_CONTAINER_NAME=ohurlshortener_pg
PG_SUPER_USER=postgres
PG_SUPER_PWD=0DePm!oG_12Cz^kd_m
PG_LOCAL_PORT=55432

#Redis Vars
RD_VERSION=6.2.6
RD_CONTAINER_NAME=ohurlshortener_redis
RD_LOCAL_PORT=56379
3 changes: 1 addition & 2 deletions templates/admin/access_logs.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
<a class="ui teal right labeled icon button" href="javascript:export_accesslog()"><i class="download icon"></i>导出</a>
</form>
<form id="form-export-logs" action="/admin/access_logs_export" method="post">
<input name="url" type="hidden" value="{{.url}}">
<button id="form-export-logs-btn" type="submit"></button>
<input name="url" type="hidden" value="{{.url}}">
</form>
</th>
</tr>
Expand Down
8 changes: 5 additions & 3 deletions templates/admin/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<table class="ui celled striped table">
<thead>
<tr>
<th colspan="13">
<th colspan="14">
<form id="form-search-url" action="/admin/stats" method="get">
<div class="ui labeled action input">
<div class="ui label">{{.prefix}}</div>
Expand All @@ -23,7 +23,8 @@
</tr>
<tr>
<th>短链接</th>
<th>生成时间</th>
<th class="center aligned">生成时间</th>
<th class="center aligned">备注</th>
<th>今日点击量</th>
<th>今日独立IP数</th>
<th>昨日点击量</th>
Expand All @@ -42,6 +43,7 @@
<tr {{if not .Valid}}class="negative"{{end}}>
<td class="collapsing"><a href="{{$.prefix}}{{.ShortUrl.ShortUrl}}" target="_blank">{{.ShortUrl.ShortUrl}}</a></td>
<td class="center aligned collapsing">{{.CreatedAt | date "2006-01-02 15:04:05"}}</td>
<td>{{if .ShortUrl.Memo.Valid}}{{.ShortUrl.Memo.String}}{{else}}--{{end}}</td>
<td>{{.TodayCount}}</td>
<td>{{.DistinctTodayCount}}</td>
<td>{{.YesterdayCount}}</td>
Expand All @@ -58,7 +60,7 @@
</tbody>
<tfoot>
<tr>
<th colspan="13" class="center aligned">
<th colspan="14" class="center aligned">
{{if not .first_page}}
<a class="ui small labeled icon button" href="/admin/stats?url={{.url}}&page={{sub .page 1}}"><i class="arrow alternate circle left outline icon"></i>上一页</a>
{{end}}
Expand Down

0 comments on commit 78f59f8

Please sign in to comment.