M analytics/routes.go => analytics/routes.go +9 -2
@@ 36,8 36,10 @@ func (s *Service) Detail(c echo.Context) error {
if err != nil {
return echo.NotFoundHandler(c)
}
-
- orgSlug := links.PullOrgSlug(c)
+ orgSlug := c.Param("slug")
+ if orgSlug == "" {
+ return echo.NotFoundHandler(c)
+ }
opts := &database.FilterOptions{
Filter: sq.And{
sq.Eq{"o.slug": orgSlug},
@@ 61,6 63,7 @@ func (s *Service) Detail(c echo.Context) error {
showQRList bool
isQRDetail bool
isLinksDetail bool
+ back string
)
switch aType {
@@ 68,9 71,11 @@ func (s *Service) Detail(c echo.Context) error {
isLinksDetail = true
case "shorts":
showQRList = true
+ back = c.Echo().Reverse("short:link_short_list", org.Slug)
case "lists":
showListingLinksList = true
showQRList = true
+ back = c.Echo().Reverse("list:listing_list", org.Slug)
case "qr":
isQRDetail = true
@@ 196,6 201,7 @@ func (s *Service) Detail(c echo.Context) error {
pd.Data["qr_scans"] = lt.Translate("QR Scans")
pd.Data["links"] = lt.Translate("Links")
pd.Data["no_data"] = lt.Translate("No Data")
+ pd.Data["back"] = lt.Translate("Back")
chart := make(map[string]int)
sortedChart := make(map[string]int)
chartKey := make([]string, 0)
@@ 225,6 231,7 @@ func (s *Service) Detail(c echo.Context) error {
"chart": sortedChart,
"title": result.Data.Title,
"org": org,
+ "back": back,
}
return gctx.Render(http.StatusOK, "analytics_detail.html", gmap)
}
M cmd/links/main.go => cmd/links/main.go +1 -1
@@ 259,7 259,7 @@ func run() error {
list.NewService(listService)
adminService := e.Group("/admin")
admin.NewService(adminService)
- analyticsService := e.Group("/analytics")
+ analyticsService := e.Group("/:slug/analytics")
analytics.NewService(analyticsService)
billingService := e.Group("/billing")
billing.NewService(billingService)
M templates/analytics_detail.html => templates/analytics_detail.html +5 -2
@@ 1,6 1,9 @@
{{template "base" .}}
<section class="app-header">
<h1 class="app-header__title">{{.pd.Title}} | {{.title}}</h1>
+ {{if .back}}
+ <a class="button primary is-small" href="{{.back}}">{{.pd.Data.back}}</a>
+ {{end}}
</section>
<section class="card shadow-card">
{{if and .isRestricted (or .isQRDetail .isLinksDetail) }}
@@ 65,7 68,7 @@
{{if .data.QrList}}
{{range .data.QrList}}
<tr>
- <td><a href="{{reverse "analytics:detail" "qr" .ID}}">{{.Title}}</a></td>
+ <td><a href="{{reverse "analytics:detail" $.org.Slug "qr" .ID}}">{{.Title}}</a></td>
<td>{{.Clicks}}</td>
</tr>
{{end}}
@@ 84,7 87,7 @@
{{if .data.ListingLink}}
{{range .data.ListingLink}}
<tr>
- <td><a href="{{reverse "analytics:detail" "links" .ID}}">{{.Title}}</a></td>
+ <td><a href="{{reverse "analytics:detail" $.org.Slug "links" .ID}}">{{.Title}}</a></td>
<td>{{.Clicks}}</td>
</tr>
{{end}}
M templates/link_short_list.html => templates/link_short_list.html +1 -1
@@ 42,7 42,7 @@
{{if eq .UserID $.currentUserID}}
<p><a class="mr-1" href="{{reverse "short:link_short_edit" $.org.Slug .ID}}">{{$.pd.Data.edit}}</a></p>
<p><a class="mr-1" href="{{reverse "short:link_short_delete" $.org.Slug .ID}}">{{$.pd.Data.delete}}</a></p>
- <p><a class="mr-1" href="{{reverse "analytics:detail" "shorts" .ID}}">{{$.pd.Data.analytics}}</a></p>
+ <p><a class="mr-1" href="{{reverse "analytics:detail" $.org.Slug "shorts" .ID}}">{{$.pd.Data.analytics}}</a></p>
{{end}}
</div>
</details>
M templates/listing_list.html => templates/listing_list.html +1 -1
@@ 43,7 43,7 @@
<p><a class="mr-1" href="{{reverse "list:listing_links" $.org.Slug .ID}}">{{$.pd.Data.manage_links}}</a></p>
<p><a class="mr-1" href="{{reverse "list:listing_update" $.org.Slug .ID}}">{{$.pd.Data.edit}}</a></p>
<p><a class="mr-1" href="{{reverse "list:listing_delete" $.org.Slug .ID}}">{{$.pd.Data.delete}}</a></p>
- <p><a class="mr-1" href="{{reverse "analytics:detail" "lists" .ID}}">{{$.pd.Data.analytics}}</a></p>
+ <p><a class="mr-1" href="{{reverse "analytics:detail" $.org.Slug "lists" .ID}}">{{$.pd.Data.analytics}}</a></p>
{{end}}
</div>
</details>