dashboard: use last path item to handle TP number selection
This commit is contained in:
parent
6086b82181
commit
8d55ecc3af
@ -38,7 +38,13 @@ angular.module("AdLinApp", ["ngResource", "ngSanitize"])
|
|||||||
|
|
||||||
angular.module("AdLinApp")
|
angular.module("AdLinApp")
|
||||||
.run(function($rootScope, $location) {
|
.run(function($rootScope, $location) {
|
||||||
$rootScope.tutoid = 0;
|
if (window.location.pathname.split("/").length >= 3) {
|
||||||
|
$rootScope.tutoid = parseInt(window.location.pathname.split("/")[2], 10);
|
||||||
|
}
|
||||||
|
if (!$rootScope.tutoid || isNaN($rootScope.tutoid)) {
|
||||||
|
$rootScope.tutoid = 1;
|
||||||
|
}
|
||||||
|
$rootScope.tutoid--;
|
||||||
})
|
})
|
||||||
.controller("StudentsController", function($scope, $interval, Student) {
|
.controller("StudentsController", function($scope, $interval, Student) {
|
||||||
$scope.students = Student.query();
|
$scope.students = Student.query();
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
@ -38,11 +39,14 @@ func init() {
|
|||||||
Router().GET("/dashboard/", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
Router().GET("/dashboard/", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
http.ServeFile(w, r, path.Join(StaticDir, "dashboard.html"))
|
http.ServeFile(w, r, path.Join(StaticDir, "dashboard.html"))
|
||||||
})
|
})
|
||||||
Router().GET("/dashboard/css/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
Router().GET("/dashboard/:where", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/dashboard")
|
if _, err := strconv.ParseInt(string(ps.ByName("where")), 10, 64); err != nil {
|
||||||
serveStaticAsset(w, r)
|
http.NotFound(w, r)
|
||||||
|
} else {
|
||||||
|
http.ServeFile(w, r, path.Join(StaticDir, "dashboard.html"))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
Router().GET("/dashboard/js/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
Router().GET("/dashboard/:where/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/dashboard")
|
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/dashboard")
|
||||||
serveStaticAsset(w, r)
|
serveStaticAsset(w, r)
|
||||||
})
|
})
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
)
|
)
|
||||||
@ -61,21 +62,35 @@ func init() {
|
|||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Router().GET("/dashboard/css/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
Router().GET("/dashboard/:where", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
|
if _, err := strconv.ParseInt(string(ps.ByName("where")), 10, 64); err != nil {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
} else {
|
||||||
|
if data, err := Asset("htdocs/dashboard.html"); err != nil {
|
||||||
|
fmt.Fprintf(w, "{\"errmsg\":%q}", err)
|
||||||
|
} else {
|
||||||
|
w.Write(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Router().GET("/dashboard/:where/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
|
if ps.ByName("where") == "css" {
|
||||||
w.Header().Set("Content-Type", "text/css")
|
w.Header().Set("Content-Type", "text/css")
|
||||||
if data, err := Asset(path.Join("htdocs", strings.TrimPrefix(r.URL.Path, "/dashboard"))); err != nil {
|
if data, err := Asset(path.Join("htdocs", strings.TrimPrefix(r.URL.Path, "/dashboard"))); err != nil {
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
} else {
|
} else {
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
})
|
} else if ps.ByName("where") == "js" {
|
||||||
Router().GET("/dashboard/js/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
||||||
w.Header().Set("Content-Type", "text/javascript")
|
w.Header().Set("Content-Type", "text/javascript")
|
||||||
if data, err := Asset(path.Join("htdocs", strings.TrimPrefix(r.URL.Path, "/dashboard"))); err != nil {
|
if data, err := Asset(path.Join("htdocs", strings.TrimPrefix(r.URL.Path, "/dashboard"))); err != nil {
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
} else {
|
} else {
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
Router().GET("/maatma/", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
Router().GET("/maatma/", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
|
Reference in New Issue
Block a user