show scan status in ui
This commit is contained in:
@@ -73,10 +73,8 @@ func (c *Controller) ServeHome(w http.ResponseWriter, r *http.Request) {
|
||||
)
|
||||
data.RequestRoot = fmt.Sprintf("%s://%s", scheme, host)
|
||||
data.CurrentLastFMAPIKey = c.DB.GetSetting("lastfm_api_key")
|
||||
if tStr := c.DB.GetSetting("last_scan_time"); tStr != "" {
|
||||
i, _ := strconv.ParseInt(tStr, 10, 64)
|
||||
data.LastScanTime = time.Unix(i, 0)
|
||||
}
|
||||
//
|
||||
// users box
|
||||
c.DB.Find(&data.AllUsers)
|
||||
//
|
||||
// recent folders box
|
||||
@@ -85,6 +83,11 @@ func (c *Controller) ServeHome(w http.ResponseWriter, r *http.Request) {
|
||||
Order("updated_at DESC").
|
||||
Limit(8).
|
||||
Find(&data.RecentFolders)
|
||||
data.IsScanning = scanner.IsScanning()
|
||||
if tStr := c.DB.GetSetting("last_scan_time"); tStr != "" {
|
||||
i, _ := strconv.ParseInt(tStr, 10, 64)
|
||||
data.LastScanTime = time.Unix(i, 0)
|
||||
}
|
||||
//
|
||||
renderTemplate(w, r, c.Templates["home.tmpl"], data)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
@@ -175,7 +174,7 @@ func (c *Controller) GetScanStatus(w http.ResponseWriter, r *http.Request) {
|
||||
Count(&trackCount)
|
||||
sub := subsonic.NewResponse()
|
||||
sub.ScanStatus = &subsonic.ScanStatus{
|
||||
Scanning: atomic.LoadInt32(&scanner.IsScanning) == 1,
|
||||
Scanning: scanner.IsScanning(),
|
||||
Count: trackCount,
|
||||
}
|
||||
respond(w, r, sub)
|
||||
|
||||
@@ -23,6 +23,7 @@ type templateData struct {
|
||||
RecentFolders []*model.Album
|
||||
AllUsers []*model.User
|
||||
LastScanTime time.Time
|
||||
IsScanning bool
|
||||
//
|
||||
CurrentLastFMAPIKey string
|
||||
CurrentLastFMAPISecret string
|
||||
|
||||
Reference in New Issue
Block a user