feat(oort): transform cloud storage into dedicated Mornye NAS streaming service
This commit is contained in:
@@ -538,7 +538,7 @@ h1{font-size:48px;font-weight:700;margin-bottom:8px}
|
||||
|
||||
func provisionMinIO(ak, sk, bucket string) {
|
||||
log.Printf("[MinIO] Provisioning %s", ak)
|
||||
exec.Command("mc", "alias", "set", "cosmos", "http://127.0.0.1:9000", "unityadmin", "UnityAdmin2026!").Run()
|
||||
exec.Command("mc", "alias", "set", "cosmos", "http://127.0.0.1:9010", "unityadmin", "UnityAdmin2026!").Run()
|
||||
exec.Command("mc", "admin", "user", "add", "cosmos", ak, sk).Run()
|
||||
exec.Command("mc", "mb", "--ignore-existing", "cosmos/"+bucket).Run()
|
||||
exec.Command("mc", "version", "enable", "cosmos/"+bucket).Run()
|
||||
|
||||
+490
-9
@@ -16,6 +16,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -25,7 +26,7 @@ import (
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
)
|
||||
|
||||
const minioEndpoint = "127.0.0.1:9000"
|
||||
const minioEndpoint = "127.0.0.1:9010"
|
||||
const publicMinioEndpoint = "cosmos.linuxguy.space"
|
||||
|
||||
// authS3Console validates the session and returns (accessKey, secretKey, bucket).
|
||||
@@ -134,6 +135,8 @@ func RegisterS3ConsoleRoutes(mux *http.ServeMux) {
|
||||
mux.HandleFunc("/oort/api/password", handleS3Password)
|
||||
mux.HandleFunc("/oort/api/objects/move", handleS3Move)
|
||||
mux.HandleFunc("/oort/api/buckets/rename", handleS3RenameBucket)
|
||||
mux.HandleFunc("/oort/api/nas/info", handleMornyeNASInfo)
|
||||
mux.HandleFunc("/oort/api/nas/enable-streaming", handleMornyeNASEnableStreaming)
|
||||
}
|
||||
|
||||
// ─── Console HTML page ────────────────────────────────────────────────────────
|
||||
@@ -1160,16 +1163,161 @@ var proxyTransport = &http.Transport{
|
||||
}
|
||||
|
||||
|
||||
type MornyeTrackItem struct {
|
||||
Key string `json:"key"`
|
||||
Name string `json:"name"`
|
||||
Title string `json:"title"`
|
||||
Size int64 `json:"size"`
|
||||
Format string `json:"format"`
|
||||
StreamURL string `json:"stream_url"`
|
||||
LastModified string `json:"last_modified"`
|
||||
}
|
||||
|
||||
func handleMornyeNASInfo(w http.ResponseWriter, r *http.Request) {
|
||||
ak, sk, defBucket, ok := authS3Console(r)
|
||||
if !ok {
|
||||
jsonErr(w, "unauthorized", 401)
|
||||
return
|
||||
}
|
||||
var username, name string
|
||||
scyllaSession.Query(`SELECT username, name FROM cosmos.users WHERE service='git' AND email=?`, ak).Scan(&username, &name)
|
||||
if username == "" {
|
||||
username = strings.Split(ak, "@")[0]
|
||||
}
|
||||
|
||||
var defDisp string
|
||||
scyllaSession.Query(`SELECT bucket_display_name FROM cosmos.users WHERE service='git' AND email=?`, ak).Scan(&defDisp)
|
||||
if defDisp == "" {
|
||||
defDisp = "mybucket"
|
||||
}
|
||||
|
||||
type NASBucketInfo struct {
|
||||
Name string `json:"name"`
|
||||
DisplayName string `json:"display_name"`
|
||||
IsDefault bool `json:"is_default"`
|
||||
IsPublic bool `json:"is_public"`
|
||||
NASUrl string `json:"nas_url"`
|
||||
PlaylistUrl string `json:"playlist_url"`
|
||||
TrackCount int `json:"track_count"`
|
||||
MusicBytes int64 `json:"music_bytes"`
|
||||
}
|
||||
|
||||
var bucketList []NASBucketInfo
|
||||
rawBuckets := []struct{ name, disp string }{ {defBucket, defDisp} }
|
||||
|
||||
iter := scyllaSession.Query(`SELECT bucket_name, display_name FROM cosmos.buckets WHERE owner_email = ?`, ak).Iter()
|
||||
var b, disp string
|
||||
for iter.Scan(&b, &disp) {
|
||||
if disp == "" { disp = b }
|
||||
rawBuckets = append(rawBuckets, struct{ name, disp string }{b, disp})
|
||||
}
|
||||
iter.Close()
|
||||
|
||||
mc, _ := minioClient(ak, sk)
|
||||
ctx := context.Background()
|
||||
|
||||
for i, rb := range rawBuckets {
|
||||
if rb.name == "" { continue }
|
||||
|
||||
cmd := exec.Command("mc", "anonymous", "get", "cosmos/"+rb.name)
|
||||
out, _ := cmd.CombinedOutput()
|
||||
isPub := strings.Contains(string(out), "download") || strings.Contains(string(out), "public")
|
||||
|
||||
trackCount := 0
|
||||
var musicBytes int64 = 0
|
||||
if mc != nil {
|
||||
for obj := range mc.ListObjects(ctx, rb.name, minio.ListObjectsOptions{Recursive: true}) {
|
||||
if obj.Err == nil && !strings.HasSuffix(obj.Key, "/") {
|
||||
lower := strings.ToLower(obj.Key)
|
||||
if strings.HasSuffix(lower, ".flac") || strings.HasSuffix(lower, ".mp3") ||
|
||||
strings.HasSuffix(lower, ".wav") || strings.HasSuffix(lower, ".m4a") ||
|
||||
strings.HasSuffix(lower, ".aac") || strings.HasSuffix(lower, ".ogg") ||
|
||||
strings.HasSuffix(lower, ".opus") || strings.HasSuffix(lower, ".alac") {
|
||||
trackCount++
|
||||
musicBytes += obj.Size
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bucketList = append(bucketList, NASBucketInfo{
|
||||
Name: rb.name,
|
||||
DisplayName: rb.disp,
|
||||
IsDefault: (i == 0),
|
||||
IsPublic: isPub,
|
||||
NASUrl: fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/", username, rb.disp),
|
||||
PlaylistUrl: fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/playlist.m3u", username, rb.disp),
|
||||
TrackCount: trackCount,
|
||||
MusicBytes: musicBytes,
|
||||
})
|
||||
}
|
||||
|
||||
jsonOK(w, map[string]any{
|
||||
"username": username,
|
||||
"name": name,
|
||||
"email": ak,
|
||||
"secret_key": sk,
|
||||
"s3_endpoint": "https://cosmos.linuxguy.space",
|
||||
"default_bucket": defBucket,
|
||||
"buckets": bucketList,
|
||||
})
|
||||
}
|
||||
|
||||
func handleMornyeNASEnableStreaming(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "POST" {
|
||||
jsonErr(w, "method not allowed", 405)
|
||||
return
|
||||
}
|
||||
ak, _, defBucket, ok := authS3Console(r)
|
||||
if !ok {
|
||||
jsonErr(w, "unauthorized", 401)
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
Bucket string `json:"bucket"`
|
||||
}
|
||||
json.NewDecoder(r.Body).Decode(&req)
|
||||
if req.Bucket == "" { req.Bucket = defBucket }
|
||||
|
||||
isOwner := false
|
||||
if req.Bucket == defBucket {
|
||||
isOwner = true
|
||||
} else {
|
||||
var owner string
|
||||
if err := scyllaSession.Query(`SELECT owner_email FROM cosmos.buckets WHERE bucket_name=?`, req.Bucket).Scan(&owner); err == nil && owner == ak {
|
||||
isOwner = true
|
||||
}
|
||||
}
|
||||
if !isOwner {
|
||||
jsonErr(w, "forbidden", 403)
|
||||
return
|
||||
}
|
||||
|
||||
cmd := exec.Command("mc", "anonymous", "set", "download", "cosmos/"+req.Bucket)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
log.Printf("[NAS] enable streaming error for %s: %v | %s", req.Bucket, err, string(out))
|
||||
jsonErr(w, "failed to enable streaming", 500)
|
||||
return
|
||||
}
|
||||
jsonOK(w, map[string]any{"success": true, "bucket": req.Bucket, "status": "streaming_enabled"})
|
||||
}
|
||||
|
||||
func handleS3PublicProxy(w http.ResponseWriter, r *http.Request, username, path string) {
|
||||
idx := strings.Index(path, "/")
|
||||
if idx == -1 {
|
||||
trimmed := strings.Trim(path, "/")
|
||||
var displayBucket, objectKey string
|
||||
if idx := strings.Index(trimmed, "/"); idx != -1 {
|
||||
displayBucket = trimmed[:idx]
|
||||
objectKey = trimmed[idx+1:]
|
||||
} else {
|
||||
displayBucket = trimmed
|
||||
objectKey = ""
|
||||
}
|
||||
if displayBucket == "" {
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
w.WriteHeader(404)
|
||||
w.Write([]byte("<html><body><h1>404 - Not Found</h1></body></html>"))
|
||||
return
|
||||
}
|
||||
displayBucket := path[:idx]
|
||||
objectKey := path[idx+1:]
|
||||
|
||||
cacheKey := username + ":" + displayBucket
|
||||
var actualBucket string
|
||||
@@ -1218,9 +1366,93 @@ func handleS3PublicProxy(w http.ResponseWriter, r *http.Request, username, path
|
||||
publicBucketCache.Store(cacheKey, actualBucket)
|
||||
}
|
||||
|
||||
// Check if this is a Mornye NAS root, index.json, or playlist.m3u request
|
||||
isPlaylist := objectKey == "playlist.m3u" || objectKey == "mornye.m3u" || r.URL.Query().Get("format") == "m3u"
|
||||
isJSON := objectKey == "index.json" || objectKey == "mornye.json" || r.URL.Query().Get("format") == "json" || strings.Contains(r.Header.Get("Accept"), "application/json")
|
||||
isRoot := (objectKey == "")
|
||||
|
||||
if isRoot || isPlaylist || isJSON {
|
||||
mc, err := minio.New(minioEndpoint, &minio.Options{
|
||||
Creds: credentials.NewStaticV4("unityadmin", "UnityAdmin2026!", ""),
|
||||
Secure: false,
|
||||
})
|
||||
if err != nil {
|
||||
http.Error(w, "NAS storage backend error", 500)
|
||||
return
|
||||
}
|
||||
|
||||
var tracks []MornyeTrackItem
|
||||
var totalBytes int64 = 0
|
||||
|
||||
ctx := context.Background()
|
||||
for obj := range mc.ListObjects(ctx, actualBucket, minio.ListObjectsOptions{Recursive: true}) {
|
||||
if obj.Err == nil && !strings.HasSuffix(obj.Key, "/") {
|
||||
lower := strings.ToLower(obj.Key)
|
||||
ext := strings.TrimPrefix(filepath.Ext(lower), ".")
|
||||
name := filepath.Base(obj.Key)
|
||||
title := strings.TrimSuffix(name, filepath.Ext(name))
|
||||
displayTitle := strings.ReplaceAll(title, "_", " ")
|
||||
|
||||
isAudio := ext == "flac" || ext == "mp3" || ext == "wav" || ext == "m4a" || ext == "aac" || ext == "ogg" || ext == "opus" || ext == "alac"
|
||||
if isAudio || isRoot {
|
||||
streamURL := fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/%s", username, displayBucket, url.PathEscape(obj.Key))
|
||||
tracks = append(tracks, MornyeTrackItem{
|
||||
Key: obj.Key,
|
||||
Name: name,
|
||||
Title: displayTitle,
|
||||
Size: obj.Size,
|
||||
Format: strings.ToUpper(ext),
|
||||
StreamURL: streamURL,
|
||||
LastModified: obj.LastModified.Format(time.RFC3339),
|
||||
})
|
||||
totalBytes += obj.Size
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "*")
|
||||
w.Header().Set("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS")
|
||||
|
||||
if isPlaylist {
|
||||
w.Header().Set("Content-Type", "audio/x-mpegurl; charset=utf-8")
|
||||
w.Header().Set("Content-Disposition", fmt.Sprintf("inline; filename=\"%s-mornye.m3u\"", displayBucket))
|
||||
var buf strings.Builder
|
||||
buf.WriteString("#EXTM3U\n")
|
||||
buf.WriteString(fmt.Sprintf("#PLAYLIST:Mornye NAS - %s - %s\n\n", username, displayBucket))
|
||||
for _, t := range tracks {
|
||||
buf.WriteString(fmt.Sprintf("#EXTINF:-1,%s\n%s\n", t.Title, t.StreamURL))
|
||||
}
|
||||
w.Write([]byte(buf.String()))
|
||||
return
|
||||
}
|
||||
|
||||
if isJSON {
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
json.NewEncoder(w).Encode(map[string]any{
|
||||
"service": "Mornye NAS",
|
||||
"version": "2.0",
|
||||
"status": "online",
|
||||
"account": username,
|
||||
"bucket": displayBucket,
|
||||
"nas_url": fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/", username, displayBucket),
|
||||
"playlist_url": fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/playlist.m3u", username, displayBucket),
|
||||
"s3_endpoint": "https://cosmos.linuxguy.space",
|
||||
"tracks_count": len(tracks),
|
||||
"total_bytes": totalBytes,
|
||||
"tracks": tracks,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Web player page
|
||||
renderMornyeNASWebPlayer(w, username, displayBucket, tracks, totalBytes)
|
||||
return
|
||||
}
|
||||
|
||||
targetPath := fmt.Sprintf("/%s/%s", actualBucket, objectKey)
|
||||
|
||||
targetUrl, _ := url.Parse("http://127.0.0.1:9000")
|
||||
targetUrl, _ := url.Parse("http://127.0.0.1:9010")
|
||||
proxy := httputil.NewSingleHostReverseProxy(targetUrl)
|
||||
proxy.Transport = proxyTransport
|
||||
|
||||
@@ -1230,9 +1462,35 @@ func handleS3PublicProxy(w http.ResponseWriter, r *http.Request, username, path
|
||||
proxy.ModifyResponse = func(resp *http.Response) error {
|
||||
if resp.StatusCode == 403 {
|
||||
resp.StatusCode = 403
|
||||
resp.Body = io.NopCloser(strings.NewReader("<html><body><h1>403 - Access Denied</h1><p>Public access is not enabled for this bucket.</p></body></html>"))
|
||||
resp.Header.Set("Content-Length", fmt.Sprintf("%d", len("<html><body><h1>403 - Access Denied</h1><p>Public access is not enabled for this bucket.</p></body></html>")))
|
||||
resp.Body = io.NopCloser(strings.NewReader("<html><body><h1>403 - Access Denied</h1><p>Public streaming access is not enabled for this Mornye NAS bucket. Enable public streaming in Oort NAS Console.</p></body></html>"))
|
||||
resp.Header.Set("Content-Length", fmt.Sprintf("%d", len("<html><body><h1>403 - Access Denied</h1><p>Public streaming access is not enabled for this Mornye NAS bucket. Enable public streaming in Oort NAS Console.</p></body></html>")))
|
||||
resp.Header.Set("Content-Type", "text/html")
|
||||
return nil
|
||||
}
|
||||
resp.Header.Set("Access-Control-Allow-Origin", "*")
|
||||
resp.Header.Set("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS")
|
||||
resp.Header.Set("Access-Control-Allow-Headers", "Range, Authorization, Content-Type")
|
||||
resp.Header.Set("Access-Control-Expose-Headers", "Content-Range, Content-Length, Accept-Ranges")
|
||||
resp.Header.Set("Accept-Ranges", "bytes")
|
||||
|
||||
lowerKey := strings.ToLower(objectKey)
|
||||
switch {
|
||||
case strings.HasSuffix(lowerKey, ".flac"):
|
||||
resp.Header.Set("Content-Type", "audio/flac")
|
||||
case strings.HasSuffix(lowerKey, ".mp3"):
|
||||
resp.Header.Set("Content-Type", "audio/mpeg")
|
||||
case strings.HasSuffix(lowerKey, ".wav"):
|
||||
resp.Header.Set("Content-Type", "audio/wav")
|
||||
case strings.HasSuffix(lowerKey, ".m4a"):
|
||||
resp.Header.Set("Content-Type", "audio/mp4")
|
||||
case strings.HasSuffix(lowerKey, ".aac"):
|
||||
resp.Header.Set("Content-Type", "audio/aac")
|
||||
case strings.HasSuffix(lowerKey, ".ogg"):
|
||||
resp.Header.Set("Content-Type", "audio/ogg")
|
||||
case strings.HasSuffix(lowerKey, ".opus"):
|
||||
resp.Header.Set("Content-Type", "audio/opus")
|
||||
case strings.HasSuffix(lowerKey, ".lrc"):
|
||||
resp.Header.Set("Content-Type", "text/plain; charset=utf-8")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1242,6 +1500,229 @@ func handleS3PublicProxy(w http.ResponseWriter, r *http.Request, username, path
|
||||
recordHit(actualBucket, tw.statusCode, tw.bytes, false, r.Header.Get("CF-IPCountry"), "read")
|
||||
}
|
||||
|
||||
func renderMornyeNASWebPlayer(w http.ResponseWriter, username, displayBucket string, tracks []MornyeTrackItem, totalBytes int64) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
nasURL := fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/", username, displayBucket)
|
||||
playlistURL := fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/playlist.m3u", username, displayBucket)
|
||||
jsonURL := fmt.Sprintf("https://cosmos.linuxguy.space/oort/%s/%s/index.json", username, displayBucket)
|
||||
|
||||
var sizeStr string
|
||||
tb := float64(totalBytes)
|
||||
if tb > 1024*1024*1024 {
|
||||
sizeStr = fmt.Sprintf("%.2f GB", tb/(1024*1024*1024))
|
||||
} else {
|
||||
sizeStr = fmt.Sprintf("%.1f MB", tb/(1024*1024))
|
||||
}
|
||||
|
||||
tracksJSON, _ := json.Marshal(tracks)
|
||||
|
||||
html := fmt.Sprintf(`<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Mornye NAS · @%s / %s</title>
|
||||
<link rel="icon" href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%%23a855f7" d="M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z"/></svg>'>
|
||||
<style>
|
||||
:root{--bg:#030712;--surface:rgba(255,255,255,0.035);--border:rgba(255,255,255,0.09);--accent:#a855f7;--accent-cyan:#38bdf8;--text:#f3f4f6;--dim:#9ca3af;--mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;}
|
||||
*{box-sizing:border-box;margin:0;padding:0;}
|
||||
body{background:var(--bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;min-height:100vh;padding:24px 16px 120px;}
|
||||
.container{max-width:980px;margin:0 auto;}
|
||||
.glass{background:var(--surface);border:1px solid var(--border);border-radius:16px;backdrop-filter:blur(16px);padding:24px;margin-bottom:20px;}
|
||||
.header{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:16px;padding-bottom:16px;border-bottom:1px solid var(--border);margin-bottom:20px;}
|
||||
.brand{display:flex;align-items:center;gap:12px;}
|
||||
.icon-box{width:42px;height:42px;border-radius:12px;background:linear-gradient(135deg,#a855f7,#4f46e5);display:flex;align-items:center;justify-content:center;box-shadow:0 0 20px rgba(168,85,247,0.35);}
|
||||
.title{font-size:20px;font-weight:700;letter-spacing:-0.5px;}
|
||||
.badge{display:inline-flex;align-items:center;gap:6px;font-size:11px;font-family:var(--mono);text-transform:uppercase;padding:4px 10px;border-radius:99px;background:rgba(56,189,248,0.1);color:var(--accent-cyan);border:1px solid rgba(56,189,248,0.25);}
|
||||
.dot{width:6px;height:6px;border-radius:50%%;background:#22c55e;box-shadow:0 0 8px #22c55e;}
|
||||
.nas-box{background:rgba(0,0,0,0.5);border:1px solid rgba(168,85,247,0.3);border-radius:12px;padding:16px;display:flex;align-items:center;gap:12px;flex-wrap:wrap;}
|
||||
.url-val{font-family:var(--mono);font-size:13px;color:#e9d5ff;flex:1;min-width:240px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
||||
.btn{cursor:pointer;background:linear-gradient(135deg,#a855f7,#6366f1);color:#fff;border:none;padding:9px 18px;border-radius:10px;font-size:13px;font-weight:600;display:inline-flex;align-items:center;gap:6px;transition:0.2s;}
|
||||
.btn:hover{filter:brightness(1.15);transform:translateY(-1px);}
|
||||
.btn-ghost{background:rgba(255,255,255,0.06);border:1px solid var(--border);color:var(--text);}
|
||||
.btn-ghost:hover{background:rgba(255,255,255,0.12);}
|
||||
.player-card{position:fixed;bottom:16px;left:50%%;transform:translateX(-50%%);width:calc(100%% - 32px);max-width:980px;background:rgba(15,23,42,0.95);border:1px solid rgba(168,85,247,0.4);border-radius:16px;box-shadow:0 20px 50px rgba(0,0,0,0.7);padding:14px 20px;z-index:9999;backdrop-filter:blur(20px);display:flex;align-items:center;gap:16px;flex-wrap:wrap;}
|
||||
.track-table{width:100%%;border-collapse:collapse;margin-top:12px;font-size:13px;}
|
||||
.track-table th{text-align:left;color:var(--dim);font-size:11px;text-transform:uppercase;letter-spacing:1px;padding:12px 14px;border-bottom:1px solid var(--border);}
|
||||
.track-table td{padding:14px;border-bottom:1px solid rgba(255,255,255,0.04);vertical-align:middle;}
|
||||
.track-row:hover td{background:rgba(255,255,255,0.02);}
|
||||
.pill-format{font-size:10px;font-family:var(--mono);padding:2px 8px;border-radius:4px;font-weight:700;}
|
||||
.pill-FLAC{background:rgba(168,85,247,0.2);color:#d8b4fe;border:1px solid rgba(168,85,247,0.4);}
|
||||
.pill-MP3{background:rgba(34,197,94,0.2);color:#86efac;border:1px solid rgba(34,197,94,0.4);}
|
||||
.pill-WAV{background:rgba(56,189,248,0.2);color:#7dd3fc;border:1px solid rgba(56,189,248,0.4);}
|
||||
.pill-OTHER{background:rgba(255,255,255,0.1);color:#e2e8f0;border:1px solid rgba(255,255,255,0.2);}
|
||||
.vinyl{width:36px;height:36px;border-radius:50%%;background:#18181b;border:2px solid #3f3f46;display:flex;align-items:center;justify-content:center;position:relative;}
|
||||
.spinning{animation:spin 3s linear infinite;}
|
||||
@keyframes spin{100%%{transform:rotate(360deg);}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="glass">
|
||||
<div class="header">
|
||||
<div class="brand">
|
||||
<div class="icon-box">
|
||||
<svg width="22" height="22" fill="none" stroke="#fff" stroke-width="2" viewBox="0 0 24 24"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>
|
||||
</div>
|
||||
<div>
|
||||
<div class="title">Mornye NAS · Audio Stream Gateway</div>
|
||||
<div style="font-size:13px;color:var(--dim);margin-top:2px;">Account: <strong style="color:#fff">@%s</strong> · Space: <strong style="color:var(--accent-cyan)">%s</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex;gap:10px;align-items:center;">
|
||||
<span class="badge"><span class="dot"></span>NAS Storage Online</span>
|
||||
<a href="/oort/console" class="btn btn-ghost" style="text-decoration:none;">Oort Console →</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-bottom:16px;font-size:13px;color:var(--dim);">
|
||||
Configure this dedicated URL into your <strong>Mornye Music Streaming App</strong> to access your network-attached library with lossless byte-range playback:
|
||||
</div>
|
||||
|
||||
<div class="nas-box">
|
||||
<div class="url-val" id="nasUrlVal">%s</div>
|
||||
<button class="btn" onclick="copyText('%s','Mornye NAS URL copied!')">📋 Copy Mornye NAS URL</button>
|
||||
<a href="%s" class="btn btn-ghost" style="text-decoration:none;" download>🎵 Playlist (.m3u)</a>
|
||||
<a href="%s" class="btn btn-ghost" style="text-decoration:none;" target="_blank">JSON Metadata</a>
|
||||
</div>
|
||||
|
||||
<div style="display:flex;gap:20px;margin-top:20px;padding-top:16px;border-top:1px solid var(--border);font-size:13px;color:var(--dim);flex-wrap:wrap;">
|
||||
<div>Tracks: <strong style="color:#fff">%d audio file(s)</strong></div>
|
||||
<div>Library Size: <strong style="color:#fff">%s</strong></div>
|
||||
<div>Protocol: <strong style="color:#38bdf8">RFC 7233 Byte-Range Streaming</strong></div>
|
||||
<div>DAC / Hi-Res: <strong style="color:#a855f7">Bit-Perfect 24-bit/192kHz Ready</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="glass">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;">
|
||||
<h3 style="font-size:16px;font-weight:600;">Music Library</h3>
|
||||
<button class="btn btn-ghost" onclick="playAll()">▶ Play All</button>
|
||||
</div>
|
||||
|
||||
<div style="overflow-x:auto;">
|
||||
<table class="track-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:50px;">#</th>
|
||||
<th>Track Name</th>
|
||||
<th style="width:100px;">Format</th>
|
||||
<th style="width:110px;">Size</th>
|
||||
<th style="width:200px;text-align:right;">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="trackList">
|
||||
<!-- Injected by JS -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="player-card" id="playerBar" style="display:none;">
|
||||
<div class="vinyl spinning" id="disc">
|
||||
<div style="width:10px;height:10px;border-radius:50%%;background:#a855f7;"></div>
|
||||
</div>
|
||||
<div style="flex:1;min-width:200px;">
|
||||
<div id="nowPlayingTitle" style="font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">No track playing</div>
|
||||
<div id="nowPlayingSub" style="font-size:11px;color:var(--dim);font-family:var(--mono);margin-top:2px;">Select a track to stream</div>
|
||||
</div>
|
||||
<audio id="audioEl" controls style="flex:2;min-width:260px;height:36px;outline:none;border-radius:8px;"></audio>
|
||||
<button class="btn btn-ghost" onclick="playNext()" title="Next Track">⏭</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const tracks = %s;
|
||||
let currentIndex = -1;
|
||||
const audio = document.getElementById('audioEl');
|
||||
const bar = document.getElementById('playerBar');
|
||||
const disc = document.getElementById('disc');
|
||||
const nowTitle = document.getElementById('nowPlayingTitle');
|
||||
const nowSub = document.getElementById('nowPlayingSub');
|
||||
|
||||
function fmtBytes(b){
|
||||
if(!b) return '0 B';
|
||||
const u = ['B','KB','MB','GB'];
|
||||
let i=0; while(b>=1024 && i<u.length-1){b/=1024; i++;}
|
||||
return b.toFixed(1) + ' ' + u[i];
|
||||
}
|
||||
|
||||
function renderTracks(){
|
||||
const tb = document.getElementById('trackList');
|
||||
if(!tracks || !tracks.length){
|
||||
tb.innerHTML = '<tr><td colspan="5" style="text-align:center;padding:40px;color:var(--dim);">No audio tracks uploaded yet. Open Oort Console to upload FLAC, MP3, or WAV files.</td></tr>';
|
||||
return;
|
||||
}
|
||||
tb.innerHTML = tracks.map((t, idx) => {
|
||||
const fmt = t.format || 'AUDIO';
|
||||
const pillClass = 'pill-' + (['FLAC','MP3','WAV'].includes(fmt) ? fmt : 'OTHER');
|
||||
return '<tr class="track-row">' +
|
||||
'<td style="color:var(--dim);font-family:var(--mono);">' + (idx + 1) + '</td>' +
|
||||
'<td><strong style="color:#fff;">' + escapeHtml(t.title) + '</strong><div style="font-size:11px;color:var(--dim);font-family:var(--mono);margin-top:2px;">' + escapeHtml(t.name) + '</div></td>' +
|
||||
'<td><span class="pill-format ' + pillClass + '">' + fmt + '</span></td>' +
|
||||
'<td style="color:var(--dim);font-family:var(--mono);">' + fmtBytes(t.size) + '</td>' +
|
||||
'<td style="text-align:right;">' +
|
||||
'<button class="btn" style="padding:6px 12px;margin-right:6px;font-size:12px;" onclick="playTrack(' + idx + ')">▶ Play</button>' +
|
||||
'<a href="' + t.stream_url + '" download class="btn btn-ghost" style="padding:6px 10px;font-size:12px;text-decoration:none;margin-right:6px;">⬇</a>' +
|
||||
'<button class="btn btn-ghost" style="padding:6px 10px;font-size:12px;" onclick="copyText(\'' + t.stream_url + '\',\'Direct stream URL copied!\')" title="Copy Link">🔗</button>' +
|
||||
'</td>' +
|
||||
'</tr>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function escapeHtml(s){
|
||||
if(!s) return '';
|
||||
return s.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
|
||||
}
|
||||
|
||||
function playTrack(idx){
|
||||
if(idx < 0 || idx >= tracks.length) return;
|
||||
currentIndex = idx;
|
||||
const t = tracks[idx];
|
||||
nowTitle.textContent = t.title || t.name;
|
||||
nowSub.textContent = (t.format || 'AUDIO') + ' · ' + fmtBytes(t.size) + ' · Zero-Delay Stream';
|
||||
audio.src = t.stream_url;
|
||||
bar.style.display = 'flex';
|
||||
audio.play();
|
||||
disc.classList.add('spinning');
|
||||
}
|
||||
|
||||
function playNext(){
|
||||
if(tracks.length === 0) return;
|
||||
const next = (currentIndex + 1) %% tracks.length;
|
||||
playTrack(next);
|
||||
}
|
||||
|
||||
function playAll(){
|
||||
if(tracks.length > 0) playTrack(0);
|
||||
}
|
||||
|
||||
audio.onended = () => { playNext(); };
|
||||
audio.onpause = () => { disc.classList.remove('spinning'); };
|
||||
audio.onplay = () => { disc.classList.add('spinning'); };
|
||||
|
||||
function copyText(txt, msg){
|
||||
navigator.clipboard.writeText(txt).then(() => {
|
||||
alert(msg || 'Copied to clipboard!');
|
||||
}).catch(() => {
|
||||
prompt('Copy this URL:', txt);
|
||||
});
|
||||
}
|
||||
|
||||
renderTracks();
|
||||
</script>
|
||||
</body>
|
||||
</html>`,
|
||||
username, displayBucket,
|
||||
username, displayBucket,
|
||||
nasURL, nasURL, playlistURL, jsonURL,
|
||||
len(tracks), sizeStr,
|
||||
string(tracksJSON),
|
||||
)
|
||||
w.Write([]byte(html))
|
||||
}
|
||||
|
||||
|
||||
func handleS3BucketSettings(w http.ResponseWriter, r *http.Request) {
|
||||
ak, _, defBucket, ok := authS3Console(r)
|
||||
if !ok {
|
||||
@@ -1713,7 +2194,7 @@ func handleS3CDNProxy(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
targetPath := "/" + bucket + "/" + key
|
||||
|
||||
targetUrl, _ := url.Parse("http://127.0.0.1:9000")
|
||||
targetUrl, _ := url.Parse("http://127.0.0.1:9010")
|
||||
proxy := httputil.NewSingleHostReverseProxy(targetUrl)
|
||||
proxy.Director = func(req *http.Request) {
|
||||
req.URL.Scheme = targetUrl.Scheme
|
||||
|
||||
+10
-10
@@ -636,34 +636,34 @@ footer.show{transform:translateY(0)}
|
||||
</div>
|
||||
|
||||
<!-- ★ STATION 3 — OORT (Z = -8400) -->
|
||||
<div class="station" id="st3" data-label="02 — OORT">
|
||||
<div class="station" id="st3" data-label="02 — MORNYE NAS">
|
||||
<div class="st-inner">
|
||||
<div class="prod-wrap rev">
|
||||
<div class="prod-copy">
|
||||
<span class="ch-tag">02 — Oort</span>
|
||||
<h2 class="prod-h">S3 storage.<br><em class="oort-em">Your hardware.</em></h2>
|
||||
<span class="ch-tag">02 — Oort NAS for Mornye</span>
|
||||
<h2 class="prod-h">Mornye NAS.<br><em class="oort-em">Your music hardware.</em></h2>
|
||||
<p class="prod-p">
|
||||
S3-compatible object storage built on MinIO.
|
||||
Versioning, lifecycle policies, multipart uploads —
|
||||
every S3 API call, zero cloud bills.
|
||||
High-performance Network Attached Storage built for Mornye music streaming
|
||||
and sovereign S3 object cloud. Unique isolated streaming URLs for every account,
|
||||
lossless FLAC byte-range delivery, zero cloud bills.
|
||||
</p>
|
||||
<div class="prod-stats">
|
||||
<div><div class="pstat-v"><em id="oRps" style="color:var(--ac)">34,210</em></div><div class="pstat-l">Req / second</div></div>
|
||||
<div><div class="pstat-v"><em id="oLat" style="color:var(--ac)">3.8</em>ms</div><div class="pstat-l">p99 latency</div></div>
|
||||
<div><div class="pstat-v"><em id="oStore" style="color:var(--ac)">4.7</em>TB</div><div class="pstat-l">Data stored</div></div>
|
||||
</div>
|
||||
<a href="/oort" class="btn btn-w" style="transform:translateZ(60px)">Open Oort ↗</a>
|
||||
<a href="/oort" class="btn btn-w" style="transform:translateZ(60px)">Open Mornye NAS ↗</a>
|
||||
</div>
|
||||
<div class="panel-3d oort-panel">
|
||||
<div class="panel-top"><span class="panel-chip">oort · live</span><span class="panel-status">Nominal</span></div>
|
||||
<div class="panel-top"><span class="panel-chip">oort · nas live</span><span class="panel-status">Nominal</span></div>
|
||||
<div class="panel-bars" id="oort-bars"></div>
|
||||
<div class="panel-metrics">
|
||||
<div class="metric oort-m"><div class="metric-v" id="oR2">34,210</div><div class="metric-l">Req / s</div></div>
|
||||
<div class="metric oort-m"><div class="metric-v" id="oL2">3.8ms</div><div class="metric-l">p99 latency</div></div>
|
||||
<div class="metric oort-m"><div class="metric-v" id="oS2">4.7TB</div><div class="metric-l">Stored</div></div>
|
||||
<div class="metric oort-m"><div class="metric-v">AES-256</div><div class="metric-l">Encryption</div></div>
|
||||
<div class="metric oort-m"><div class="metric-v">FLAC/24b</div><div class="metric-l">Hi-Res Ready</div></div>
|
||||
</div>
|
||||
<div class="panel-cta"><span>S3-compatible · MinIO-powered</span><a href="/oort" class="panel-link">Open Oort →</a></div>
|
||||
<div class="panel-cta"><span>Mornye NAS · MinIO-powered</span><a href="/oort" class="panel-link">Open NAS →</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+9
-9
@@ -3,8 +3,8 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Oort — Sovereign S3 Object Storage · Cosmos</title>
|
||||
<meta name="description" content="S3-compatible object storage engineered for infinite scale and zero exposure. Buckets, versioning, real-time analytics, custom domains.">
|
||||
<title>Oort — High-Performance NAS for Mornye & Sovereign Storage · Cosmos</title>
|
||||
<meta name="description" content="Dedicated high-performance Network Attached Storage (NAS) engineered for Mornye music streaming and sovereign S3 object cloud. Unique streaming URLs for every account, lossless FLAC byte-range streaming, zero cloud bills.">
|
||||
<link rel="icon" href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><circle cx="16" cy="16" r="6" fill="%23eef3f8"/><ellipse cx="16" cy="16" rx="14" ry="5.5" fill="none" stroke="%238fd9ff" stroke-width="1.5" transform="rotate(-24 16 16)"/></svg>'>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
@@ -867,8 +867,8 @@ footer {
|
||||
</div>
|
||||
|
||||
<div class="hud hud-bl">
|
||||
<span>OORT CLOUD · CELESTIAL STORAGE</span>
|
||||
<span>AWS S3 PROTOCOL · SIGNATURE V4</span>
|
||||
<span>OORT NAS FOR MORNYE · CELESTIAL STORAGE</span>
|
||||
<span>LOSSLESS FLAC STREAMING · S3 PROTOCOL</span>
|
||||
</div>
|
||||
<div class="hud hud-br">
|
||||
<span id="utc">00:00:00 UTC</span>
|
||||
@@ -879,16 +879,16 @@ footer {
|
||||
<div class="hero-inner">
|
||||
<div class="tag">
|
||||
<span class="dot"></span>
|
||||
<span data-scr>OBJECT STORAGE · S3 COMPATIBLE</span>
|
||||
<span data-scr>MORNYE NAS · ZERO-DELAY AUDIO STREAMING</span>
|
||||
</div>
|
||||
<h1 class="title">
|
||||
<span class="msk"><span class="msk-in">Storage for</span></span>
|
||||
<span class="msk"><span class="msk-in"><em>the infinite.</em></span></span>
|
||||
<span class="msk"><span class="msk-in"><em>Mornye streaming.</em></span></span>
|
||||
</h1>
|
||||
<p class="sub">S3-compatible object storage engineered for infinite scale and zero exposure. Complete AWS SDK compatibility, versioned buckets, custom domains, and live global analytics.</p>
|
||||
<p class="sub">High-performance Network Attached Storage (NAS) engineered for Mornye music streaming and sovereign object cloud. Unique streaming URLs for every account, lossless FLAC byte-range delivery, and infinite hardware capacity.</p>
|
||||
<div class="ctas">
|
||||
<a class="btn btn-p mag" href="/oort/login">Open Storage Console</a>
|
||||
<a class="btn btn-g mag" href="/oort/signup">Create Bucket Account</a>
|
||||
<a class="btn btn-p mag" href="/oort/login">Open Mornye NAS Console</a>
|
||||
<a class="btn btn-g mag" href="/oort/signup">Create NAS Account</a>
|
||||
</div>
|
||||
|
||||
<div class="stats-row">
|
||||
|
||||
+540
-13
@@ -845,6 +845,10 @@ input:checked + .slider:before { transform: translateX(16px); }
|
||||
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>
|
||||
Dashboard
|
||||
</div>
|
||||
<div class="nav-item" id="nav-nas" onclick="switchView('nas')">
|
||||
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>
|
||||
Mornye NAS
|
||||
</div>
|
||||
<div class="nav-item" id="nav-analytics" onclick="switchView('analytics')">
|
||||
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/></svg>
|
||||
Analytics
|
||||
@@ -907,8 +911,8 @@ input:checked + .slider:before { transform: translateX(16px); }
|
||||
<div style="display:flex; align-items:center; gap:0; background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.12); border-radius:999px; padding:4px; margin-right:16px; border-right:none;">
|
||||
<button id="pill-drive" onclick="setMode('drive')"
|
||||
style="display:flex;align-items:center;gap:6px;padding:7px 16px;border-radius:999px;border:none;cursor:pointer;font-size:13px;font-weight:700;transition:all 0.3s cubic-bezier(0.16,1,0.3,1);background:linear-gradient(135deg,#7c3aed,#4f46e5);color:white;box-shadow:0 2px 8px rgba(124,58,237,0.4);">
|
||||
<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/></svg>
|
||||
Cloud Drive
|
||||
<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>
|
||||
Mornye NAS
|
||||
</button>
|
||||
<button id="pill-s3" onclick="setMode('s3')"
|
||||
style="display:flex;align-items:center;gap:6px;padding:7px 16px;border-radius:999px;border:none;cursor:pointer;font-size:13px;font-weight:700;transition:all 0.3s cubic-bezier(0.16,1,0.3,1);background:transparent;color:rgba(255,255,255,0.55);">
|
||||
@@ -1205,6 +1209,223 @@ input:checked + .slider:before { transform: translateX(16px); }
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ─── MORNYE NAS VIEW ─── -->
|
||||
<div class="view" id="view-nas">
|
||||
<div class="content" style="overflow-y:auto; padding-bottom: 120px;">
|
||||
<!-- Page Header -->
|
||||
<div class="page-header" style="padding-top:24px;">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;">
|
||||
<div>
|
||||
<div style="display:flex;align-items:center;gap:10px;">
|
||||
<div class="page-title" style="margin:0;">Mornye NAS Management</div>
|
||||
<span class="badge" style="background:rgba(168,85,247,0.15);color:#d8b4fe;border:1px solid rgba(168,85,247,0.3);padding:4px 10px;border-radius:99px;font-size:11px;font-weight:700;">NETWORK STORAGE</span>
|
||||
</div>
|
||||
<div class="page-subtitle" style="margin-top:4px;">
|
||||
Dedicated high-performance audio streaming storage for your Mornye app. Every account has its own isolated NAS space and unique stream URL.
|
||||
</div>
|
||||
</div>
|
||||
<div style="display:flex;align-items:center;gap:8px;">
|
||||
<button class="btn btn-ghost btn-sm" onclick="loadMornyeNASView()">
|
||||
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 11-2.12-9.36L23 10"/></svg>
|
||||
Refresh
|
||||
</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="openModal('modal-create-bucket')">
|
||||
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
|
||||
New NAS Space
|
||||
</button>
|
||||
<button class="btn btn-primary btn-sm" onclick="triggerNASMusicUpload()" style="background:linear-gradient(135deg,#a855f7,#6366f1);border:none;">
|
||||
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
|
||||
Upload Music
|
||||
</button>
|
||||
<input type="file" id="nas-music-input" multiple accept=".flac,.mp3,.wav,.m4a,.aac,.ogg,.opus,.alac,.lrc" onchange="uploadNASMusicFiles(this.files)" style="display:none">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hero Mornye Connection Card -->
|
||||
<div style="background:linear-gradient(135deg,rgba(168,85,247,0.08),rgba(56,189,248,0.05));border:1px solid rgba(168,85,247,0.3);border-radius:16px;padding:22px;margin-bottom:24px;position:relative;overflow:hidden;box-shadow:0 8px 32px rgba(0,0,0,0.3);">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;margin-bottom:16px;">
|
||||
<div style="display:flex;align-items:center;gap:12px;">
|
||||
<div style="width:40px;height:40px;border-radius:12px;background:linear-gradient(135deg,#9333ea,#4f46e5);display:flex;align-items:center;justify-content:center;box-shadow:0 0 16px rgba(147,51,234,0.4);">
|
||||
<svg width="20" height="20" fill="none" stroke="#fff" stroke-width="2" viewBox="0 0 24 24"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>
|
||||
</div>
|
||||
<div>
|
||||
<div style="font-size:16px;font-weight:700;color:#fff;">Your Unique Mornye NAS Storage Space</div>
|
||||
<div style="font-size:12px;color:rgba(255,255,255,0.6);margin-top:2px;">
|
||||
Account: <span id="nas-user-pill" style="color:#e9d5ff;font-weight:600;">@loading</span> · Space:
|
||||
<select id="nas-space-selector" onchange="onNASSpaceChanged(this.value)" style="background:rgba(0,0,0,0.6);color:#38bdf8;border:1px solid rgba(56,189,248,0.3);border-radius:6px;padding:2px 8px;font-size:12px;font-weight:600;outline:none;cursor:pointer;">
|
||||
<option value="">Loading spaces…</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="nas-streaming-badge" style="display:flex;align-items:center;gap:8px;">
|
||||
<span class="badge" style="background:rgba(34,197,94,0.12);color:#4ade80;border:1px solid rgba(34,197,94,0.3);padding:6px 12px;border-radius:99px;font-size:12px;font-weight:600;display:flex;align-items:center;gap:6px;">
|
||||
<span class="dot" style="background:#22c55e;box-shadow:0 0 8px #22c55e;"></span>
|
||||
Streaming Ready
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- NAS URL Bar -->
|
||||
<div style="background:rgba(0,0,0,0.65);border:1px solid rgba(255,255,255,0.12);border-radius:12px;padding:12px 16px;display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:16px;">
|
||||
<div style="font-size:11px;font-weight:700;color:var(--text3);text-transform:uppercase;letter-spacing:0.8px;">Mornye NAS URL:</div>
|
||||
<div id="nas-primary-url" style="flex:1;min-width:240px;font-family:var(--mono);font-size:13.5px;color:#f3f4f6;word-break:break-all;">
|
||||
https://cosmos.linuxguy.space/oort/…/
|
||||
</div>
|
||||
<div style="display:flex;gap:8px;flex-wrap:wrap;">
|
||||
<button class="btn btn-sm" onclick="copyNASPrimaryURL()" style="background:linear-gradient(135deg,#9333ea,#4f46e5);border:none;display:flex;align-items:center;gap:6px;">
|
||||
<svg width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
|
||||
Copy Mornye NAS URL
|
||||
</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="copyNASPlaylistURL()" style="display:flex;align-items:center;gap:6px;">
|
||||
<svg width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>
|
||||
Copy M3U Link
|
||||
</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="openNASWebPlayer()" style="display:flex;align-items:center;gap:6px;">
|
||||
<svg width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>
|
||||
Web Player ↗
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Connection Parameters Grid -->
|
||||
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:12px;font-size:12px;">
|
||||
<div style="background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.06);border-radius:10px;padding:10px 14px;">
|
||||
<div style="color:var(--text3);font-size:11px;font-weight:600;text-transform:uppercase;">Network Storage Endpoint</div>
|
||||
<div style="font-family:var(--mono);color:#38bdf8;font-size:12.5px;margin-top:3px;word-break:break-all;">https://cosmos.linuxguy.space</div>
|
||||
</div>
|
||||
<div style="background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.06);border-radius:10px;padding:10px 14px;">
|
||||
<div style="color:var(--text3);font-size:11px;font-weight:600;text-transform:uppercase;">NAS Space / Bucket</div>
|
||||
<div id="nas-active-bucket-name" style="font-family:var(--mono);color:#fff;font-size:12.5px;margin-top:3px;">—</div>
|
||||
</div>
|
||||
<div style="background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.06);border-radius:10px;padding:10px 14px;">
|
||||
<div style="color:var(--text3);font-size:11px;font-weight:600;text-transform:uppercase;">Access Key (Email)</div>
|
||||
<div id="nas-access-key-val" style="font-family:var(--mono);color:#fff;font-size:12.5px;margin-top:3px;overflow:hidden;text-overflow:ellipsis;">—</div>
|
||||
</div>
|
||||
<div style="background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.06);border-radius:10px;padding:10px 14px;">
|
||||
<div style="color:var(--text3);font-size:11px;font-weight:600;text-transform:uppercase;display:flex;justify-content:space-between;">
|
||||
<span>S3 Secret Key</span>
|
||||
<a href="javascript:void(0)" onclick="toggleNASSecretKey()" style="color:#a855f7;text-decoration:none;">Show</a>
|
||||
</div>
|
||||
<div id="nas-secret-key-val" style="font-family:var(--mono);color:#fff;font-size:12.5px;margin-top:3px;">••••••••••••••••</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- NAS Telemetry Stats -->
|
||||
<div class="stats-grid" style="margin-bottom:24px;">
|
||||
<div class="stat-card">
|
||||
<div class="stat-card-header">
|
||||
<div class="stat-card-label">Music Tracks</div>
|
||||
<div class="stat-card-icon" style="background:rgba(168,85,247,0.15)">
|
||||
<svg fill="none" stroke="#c084fc" stroke-width="2" viewBox="0 0 24 24" width="16" height="16"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card-value" id="nas-stat-tracks">0</div>
|
||||
<div class="stat-card-meta">In this Mornye space</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card">
|
||||
<div class="stat-card-header">
|
||||
<div class="stat-card-label">Audio Storage</div>
|
||||
<div class="stat-card-icon" style="background:rgba(56,189,248,0.15)">
|
||||
<svg fill="none" stroke="#38bdf8" stroke-width="2" viewBox="0 0 24 24" width="16" height="16"><path d="M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card-value" id="nas-stat-size">0 B</div>
|
||||
<div class="stat-card-meta">FLAC & MP3 library size</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card">
|
||||
<div class="stat-card-header">
|
||||
<div class="stat-card-label">Streaming Protocol</div>
|
||||
<div class="stat-card-icon" style="background:rgba(34,197,94,0.15)">
|
||||
<svg fill="none" stroke="#4ade80" stroke-width="2" viewBox="0 0 24 24" width="16" height="16"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card-value" style="font-size:20px;margin-top:4px;color:#4ade80;">HTTP 206 Partial</div>
|
||||
<div class="stat-card-meta">Instant seek & zero delay</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-card">
|
||||
<div class="stat-card-header">
|
||||
<div class="stat-card-label">Hi-Res Audio Engine</div>
|
||||
<div class="stat-card-icon" style="background:rgba(234,179,8,0.15)">
|
||||
<svg fill="none" stroke="#facc15" stroke-width="2" viewBox="0 0 24 24" width="16" height="16"><circle cx="12" cy="12" r="10"/><polygon points="10 8 16 12 10 16 10 8"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card-value" style="font-size:20px;margin-top:4px;color:#facc15;">24b / 192kHz</div>
|
||||
<div class="stat-card-meta">Lossless studio pass-through</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Music Drag & Drop Upload Zone -->
|
||||
<div id="nas-dropzone" ondragover="onNASDragOver(event)" ondragleave="onNASDragLeave(event)" ondrop="onNASDrop(event)" onclick="triggerNASMusicUpload()"
|
||||
style="background:rgba(255,255,255,0.015);border:2px dashed rgba(168,85,247,0.3);border-radius:16px;padding:32px 24px;text-align:center;cursor:pointer;transition:all 0.3s;margin-bottom:24px;">
|
||||
<div style="width:48px;height:48px;border-radius:12px;background:rgba(168,85,247,0.12);display:inline-flex;align-items:center;justify-content:center;color:#c084fc;margin-bottom:12px;">
|
||||
<svg width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/><line x1="12" y1="12" x2="12" y2="12"/></svg>
|
||||
</div>
|
||||
<div style="font-size:15px;font-weight:700;color:#fff;">Drop Music Files Here or Click to Upload</div>
|
||||
<div style="font-size:12.5px;color:var(--text3);margin-top:4px;">Supports FLAC (16/24-bit), MP3, WAV, AAC, M4A, OGG, and LRC lyrics. Streamed directly to Mornye.</div>
|
||||
</div>
|
||||
|
||||
<!-- Music Tracks Table Card -->
|
||||
<div style="background:var(--bg2);border:1px solid var(--border);border-radius:16px;overflow:hidden;box-shadow:0 8px 24px rgba(0,0,0,0.2);">
|
||||
<div style="padding:16px 20px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;">
|
||||
<div style="display:flex;align-items:center;gap:10px;">
|
||||
<div style="font-size:15px;font-weight:700;">NAS Audio Library</div>
|
||||
<span id="nas-track-count-badge" class="badge" style="background:rgba(255,255,255,0.06);color:#fff;">0 tracks</span>
|
||||
</div>
|
||||
<div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap;">
|
||||
<div style="display:flex;align-items:center;background:rgba(255,255,255,0.04);border:1px solid var(--border);border-radius:8px;padding:4px 10px;">
|
||||
<svg width="14" height="14" fill="none" stroke="var(--text3)" stroke-width="2" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
|
||||
<input type="text" id="nas-search-input" oninput="filterNASTracks(this.value)" placeholder="Filter tracks..." style="background:transparent;border:none;color:#fff;outline:none;font-size:13px;padding-left:8px;width:150px;">
|
||||
</div>
|
||||
<button class="btn btn-ghost btn-sm" onclick="playAllNASTracks()">
|
||||
<svg width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg>
|
||||
Play All
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="overflow-x:auto;">
|
||||
<table style="width:100%;border-collapse:collapse;font-size:13.5px;text-align:left;">
|
||||
<thead>
|
||||
<tr style="border-bottom:1px solid var(--border);background:rgba(255,255,255,0.02);color:var(--text3);font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.6px;">
|
||||
<th style="padding:12px 16px;width:60px;">#</th>
|
||||
<th style="padding:12px 16px;">Track Title & Filename</th>
|
||||
<th style="padding:12px 16px;width:110px;">Format</th>
|
||||
<th style="padding:12px 16px;width:110px;">Size</th>
|
||||
<th style="padding:12px 16px;width:140px;">Modified</th>
|
||||
<th style="padding:12px 16px;width:200px;text-align:right;">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="nas-tracks-tbody">
|
||||
<tr><td colspan="6" style="text-align:center;padding:40px;color:var(--text3);">Loading audio tracks…</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Persistent Mornye Floating Audio Player -->
|
||||
<div id="nas-audio-player-bar" style="display:none;position:fixed;bottom:20px;left:50%;transform:translateX(-50%);width:calc(100% - 32px);max-width:980px;background:rgba(15,23,42,0.95);border:1px solid rgba(168,85,247,0.4);border-radius:16px;box-shadow:0 20px 50px rgba(0,0,0,0.8);padding:12px 20px;z-index:99999;backdrop-filter:blur(24px);align-items:center;gap:16px;flex-wrap:wrap;">
|
||||
<div id="nas-vinyl" style="width:36px;height:36px;border-radius:50%;background:#18181b;border:2px solid #a855f7;display:flex;align-items:center;justify-content:center;box-shadow:0 0 12px rgba(168,85,247,0.4);animation:spin 3s linear infinite;">
|
||||
<div style="width:10px;height:10px;border-radius:50%;background:#a855f7;"></div>
|
||||
</div>
|
||||
<div style="flex:1;min-width:180px;">
|
||||
<div id="nas-player-title" style="font-size:13.5px;font-weight:700;color:#fff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">Now Playing</div>
|
||||
<div id="nas-player-sub" style="font-size:11px;font-family:var(--mono);color:rgba(255,255,255,0.55);margin-top:2px;">FLAC · Zero-Delay Stream</div>
|
||||
</div>
|
||||
<audio id="nas-global-audio" controls autoplay style="flex:2;min-width:260px;height:36px;outline:none;border-radius:8px;"></audio>
|
||||
<div style="display:flex;gap:6px;">
|
||||
<button class="btn btn-ghost btn-sm" onclick="playNextNASTrack()" title="Next Track">⏭</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="closeNASAudioPlayer()" title="Close Player">✕</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ─── BROWSER VIEW ─── -->
|
||||
<div class="view" id="view-browser">
|
||||
<!-- Top Action Header -->
|
||||
@@ -1942,6 +2163,7 @@ function switchView(name, bucket, prefix) {
|
||||
loadObjects();
|
||||
}
|
||||
if (name === 'dashboard') loadDashboard();
|
||||
if (name === 'nas') loadMornyeNASView();
|
||||
if (name === 'analytics') loadAnalytics();
|
||||
if (name === 'account') populateAccount();
|
||||
if (name === 'security') populateSecurity();
|
||||
@@ -1959,9 +2181,10 @@ function updateTopbar(view) {
|
||||
const bc = document.getElementById('topbarBreadcrumb');
|
||||
const labels = {
|
||||
dashboard: 'Dashboard',
|
||||
nas: 'Mornye NAS Management',
|
||||
account: 'Profile & API Keys',
|
||||
security: 'Security Settings',
|
||||
browser: (typeof uiMode !== 'undefined' && uiMode === 's3' ? 'Bucket: ' : 'Drive: ') + getBucketDisplayName(state.bucket),
|
||||
browser: (typeof uiMode !== 'undefined' && uiMode === 's3' ? 'Bucket: ' : 'NAS Space: ') + getBucketDisplayName(state.bucket),
|
||||
};
|
||||
const label = labels[view] || view;
|
||||
bc.innerHTML = `<span class="bc-item active">${label}</span>`;
|
||||
@@ -2950,7 +3173,7 @@ function setMode(mode, skipAnim = false) {
|
||||
if (!skipAnim && layer && txt) {
|
||||
txt.textContent = isS3
|
||||
? 'Switching to S3 Object Storage…'
|
||||
: 'Switching to Cloud Drive…';
|
||||
: 'Switching to Mornye NAS…';
|
||||
layer.style.pointerEvents = 'all';
|
||||
layer.style.opacity = '1';
|
||||
}
|
||||
@@ -2961,18 +3184,18 @@ function setMode(mode, skipAnim = false) {
|
||||
// Sidebar section label (first one is the buckets section)
|
||||
const sectionLabels = document.querySelectorAll('.sidebar-section-label');
|
||||
if (sectionLabels[0]) {
|
||||
sectionLabels[0].textContent = isS3 ? 'Buckets' : 'Drives';
|
||||
sectionLabels[0].textContent = isS3 ? 'Buckets' : 'Music NAS Spaces';
|
||||
}
|
||||
|
||||
// "Create bucket" link in sidebar
|
||||
const createBucketLink = document.querySelector('.sidebar-create-bucket span');
|
||||
if (createBucketLink) {
|
||||
createBucketLink.textContent = isS3 ? 'Create bucket' : 'Create drive';
|
||||
createBucketLink.textContent = isS3 ? 'Create bucket' : 'New NAS Space';
|
||||
}
|
||||
|
||||
// "Create bucket" modal title
|
||||
const cbTitle = document.querySelector('#modal-create-bucket .modal-title');
|
||||
if (cbTitle) cbTitle.textContent = isS3 ? 'Create Bucket' : 'Create Drive';
|
||||
if (cbTitle) cbTitle.textContent = isS3 ? 'Create Bucket' : 'Create Mornye NAS Space';
|
||||
|
||||
// Stat card labels
|
||||
const bucketsLabel = document.querySelector('[id="dash-buckets"] + .stat-card-meta, .stat-card-label');
|
||||
@@ -2982,9 +3205,9 @@ function setMode(mode, skipAnim = false) {
|
||||
const card = dashBuckets.closest('.stat-card');
|
||||
if (card) {
|
||||
const label = card.querySelector('.stat-card-label');
|
||||
if (label) label.textContent = isS3 ? 'Buckets' : 'Drives';
|
||||
if (label) label.textContent = isS3 ? 'Buckets' : 'NAS Spaces';
|
||||
const meta = card.querySelector('.stat-card-meta');
|
||||
if (meta) meta.textContent = isS3 ? 'Active buckets' : 'Active drives';
|
||||
if (meta) meta.textContent = isS3 ? 'Active buckets' : 'Active NAS spaces';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2993,8 +3216,8 @@ function setMode(mode, skipAnim = false) {
|
||||
if (dbl) {
|
||||
const cardTitle = dbl.closest('.chart-card')?.querySelector('.chart-card-title');
|
||||
const cardSub = dbl.closest('.chart-card')?.querySelector('.chart-card-sub');
|
||||
if (cardTitle) cardTitle.textContent = isS3 ? 'Buckets' : 'Drives';
|
||||
if (cardSub) cardSub.textContent = isS3 ? 'Your storage buckets' : 'Your cloud drives';
|
||||
if (cardTitle) cardTitle.textContent = isS3 ? 'Buckets' : 'Mornye NAS Spaces';
|
||||
if (cardSub) cardSub.textContent = isS3 ? 'Your storage buckets' : 'Your network audio storage spaces';
|
||||
}
|
||||
|
||||
// Dashboard page title subtitle
|
||||
@@ -3002,12 +3225,12 @@ function setMode(mode, skipAnim = false) {
|
||||
if (pageSub) {
|
||||
pageSub.textContent = isS3
|
||||
? 'S3-compatible object storage overview'
|
||||
: 'Cloud drive storage overview';
|
||||
: 'Mornye NAS & high-resolution music streaming overview';
|
||||
}
|
||||
|
||||
// User role in sidebar
|
||||
const roleLabel = document.querySelector('.user-role');
|
||||
if (roleLabel) roleLabel.textContent = isS3 ? 'S3 Object Storage' : 'Cloud Drive';
|
||||
if (roleLabel) roleLabel.textContent = isS3 ? 'S3 Object Storage' : 'Mornye NAS Storage';
|
||||
|
||||
// Browser "New Folder" button — only show in Drive mode
|
||||
const mkdirBtn = document.querySelector('[onclick="openModal(\'modal-mkdir\')"]');
|
||||
@@ -4388,6 +4611,310 @@ async function executeRenameBucket() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ══════════════════════════════════════════════════════════════
|
||||
MORNYE NAS MANAGEMENT & STREAMING CONTROLLER
|
||||
══════════════════════════════════════════════════════════════ */
|
||||
let mornyeNASData = null;
|
||||
let currentNASTracks = [];
|
||||
let allNASTracksUnfiltered = [];
|
||||
let currentNASBucket = null;
|
||||
let currentNASTrackIdx = -1;
|
||||
|
||||
function escapeHtml(s) {
|
||||
if (!s) return '';
|
||||
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
|
||||
async function loadMornyeNASView() {
|
||||
const r = await api('/oort/api/nas/info');
|
||||
if (!r) return;
|
||||
mornyeNASData = r;
|
||||
|
||||
const userPill = document.getElementById('nas-user-pill');
|
||||
if (userPill) userPill.textContent = '@' + (r.username || 'user');
|
||||
|
||||
const akVal = document.getElementById('nas-access-key-val');
|
||||
if (akVal) akVal.textContent = r.email || '';
|
||||
|
||||
const skVal = document.getElementById('nas-secret-key-val');
|
||||
if (skVal) {
|
||||
skVal.dataset.secret = r.secret_key || '';
|
||||
skVal.textContent = '••••••••••••••••';
|
||||
}
|
||||
|
||||
const sel = document.getElementById('nas-space-selector');
|
||||
if (sel) {
|
||||
sel.innerHTML = '';
|
||||
(r.buckets || []).forEach(b => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = b.name;
|
||||
opt.textContent = `${b.display_name} (${b.track_count} tracks)`;
|
||||
if (state.bucket && b.name === state.bucket) opt.selected = true;
|
||||
sel.appendChild(opt);
|
||||
});
|
||||
}
|
||||
|
||||
const activeBucket = (sel && sel.value) || (r.buckets && r.buckets[0]?.name);
|
||||
if (activeBucket) {
|
||||
onNASSpaceChanged(activeBucket);
|
||||
}
|
||||
}
|
||||
|
||||
function onNASSpaceChanged(bucketName) {
|
||||
if (!mornyeNASData) return;
|
||||
const b = (mornyeNASData.buckets || []).find(x => x.name === bucketName) || (mornyeNASData.buckets && mornyeNASData.buckets[0]);
|
||||
if (!b) return;
|
||||
currentNASBucket = b;
|
||||
state.bucket = b.name;
|
||||
|
||||
const primaryUrlEl = document.getElementById('nas-primary-url');
|
||||
if (primaryUrlEl) primaryUrlEl.textContent = b.nas_url;
|
||||
|
||||
const activeBucketEl = document.getElementById('nas-active-bucket-name');
|
||||
if (activeBucketEl) activeBucketEl.textContent = b.name;
|
||||
|
||||
const badgeWrap = document.getElementById('nas-streaming-badge');
|
||||
if (badgeWrap) {
|
||||
if (b.is_public) {
|
||||
badgeWrap.innerHTML = `
|
||||
<span class="badge" style="background:rgba(34,197,94,0.12);color:#4ade80;border:1px solid rgba(34,197,94,0.3);padding:6px 12px;border-radius:99px;font-size:12px;font-weight:600;display:flex;align-items:center;gap:6px;">
|
||||
<span class="dot" style="background:#22c55e;box-shadow:0 0 8px #22c55e;"></span>
|
||||
Streaming Ready
|
||||
</span>`;
|
||||
} else {
|
||||
badgeWrap.innerHTML = `
|
||||
<button class="btn btn-sm" onclick="enableNASPublicStreaming('${b.name}')" style="background:#eab308;color:#000;font-weight:700;border:none;border-radius:8px;padding:6px 12px;cursor:pointer;">
|
||||
⚡ Enable Streaming for Mornye
|
||||
</button>`;
|
||||
}
|
||||
}
|
||||
|
||||
loadNASTracks(b.name);
|
||||
}
|
||||
|
||||
async function loadNASTracks(bucketName) {
|
||||
const tbody = document.getElementById('nas-tracks-tbody');
|
||||
if (tbody) {
|
||||
tbody.innerHTML = `<tr><td colspan="6" style="text-align:center;padding:40px;color:var(--text3);">Loading audio tracks…</td></tr>`;
|
||||
}
|
||||
|
||||
const r = await api(`/oort/api/objects?bucket=${bucketName}&prefix=`);
|
||||
if (!r) {
|
||||
if (tbody) tbody.innerHTML = `<tr><td colspan="6" style="text-align:center;padding:40px;color:#f87171;">Failed to load tracks.</td></tr>`;
|
||||
return;
|
||||
}
|
||||
|
||||
const audioExts = ['flac', 'mp3', 'wav', 'm4a', 'aac', 'ogg', 'opus', 'alac'];
|
||||
const allObjects = r.objects || [];
|
||||
allNASTracksUnfiltered = allObjects.filter(o => {
|
||||
if (o.is_dir) return false;
|
||||
const ext = o.name.split('.').pop().toLowerCase();
|
||||
return audioExts.includes(ext);
|
||||
});
|
||||
currentNASTracks = [...allNASTracksUnfiltered];
|
||||
|
||||
let totalBytes = 0;
|
||||
currentNASTracks.forEach(t => { totalBytes += (t.size || 0); });
|
||||
|
||||
const statTracks = document.getElementById('nas-stat-tracks');
|
||||
if (statTracks) statTracks.textContent = currentNASTracks.length;
|
||||
|
||||
const statSize = document.getElementById('nas-stat-size');
|
||||
if (statSize) statSize.textContent = fmtBytes(totalBytes);
|
||||
|
||||
const countBadge = document.getElementById('nas-track-count-badge');
|
||||
if (countBadge) countBadge.textContent = `${currentNASTracks.length} track${currentNASTracks.length === 1 ? '' : 's'}`;
|
||||
|
||||
renderNASTrackRows(currentNASTracks);
|
||||
}
|
||||
|
||||
function filterNASTracks(query) {
|
||||
const q = (query || '').toLowerCase().trim();
|
||||
if (!q) {
|
||||
currentNASTracks = [...allNASTracksUnfiltered];
|
||||
} else {
|
||||
currentNASTracks = allNASTracksUnfiltered.filter(t => t.name.toLowerCase().includes(q));
|
||||
}
|
||||
renderNASTrackRows(currentNASTracks);
|
||||
}
|
||||
|
||||
function renderNASTrackRows(tracks) {
|
||||
const tbody = document.getElementById('nas-tracks-tbody');
|
||||
if (!tbody) return;
|
||||
|
||||
if (!tracks.length) {
|
||||
tbody.innerHTML = `<tr><td colspan="6" style="text-align:center;padding:48px;color:var(--text3);">
|
||||
<div style="font-size:36px;margin-bottom:8px;">🎵</div>
|
||||
<div style="font-size:15px;font-weight:600;color:#fff;">No music tracks in this NAS space yet</div>
|
||||
<div style="font-size:12.5px;color:var(--text3);margin-top:4px;">Drag and drop audio files above or click Upload Music to start streaming to Mornye.</div>
|
||||
</td></tr>`;
|
||||
return;
|
||||
}
|
||||
|
||||
tbody.innerHTML = tracks.map((t, idx) => {
|
||||
const ext = t.name.split('.').pop().toUpperCase();
|
||||
const pillClass = ['FLAC', 'MP3', 'WAV'].includes(ext) ? `pill-${ext}` : 'pill-OTHER';
|
||||
const streamUrl = `${currentNASBucket ? currentNASBucket.nas_url : ''}${encodeURIComponent(t.key)}`;
|
||||
const dateStr = t.last_modified ? new Date(t.last_modified).toLocaleDateString('en-US', {month:'short', day:'numeric', year:'numeric'}) : '—';
|
||||
const escKey = t.key.replace(/'/g, "\\'");
|
||||
|
||||
return `
|
||||
<tr class="track-row" style="border-bottom:1px solid rgba(255,255,255,0.04);">
|
||||
<td style="padding:14px 16px;color:var(--text3);font-family:var(--mono);">${idx + 1}</td>
|
||||
<td style="padding:14px 16px;">
|
||||
<div style="font-weight:600;color:#fff;font-size:14px;">${escapeHtml(t.name.replace(/\.[^/.]+$/, '').replace(/_/g, ' '))}</div>
|
||||
<div style="font-size:11px;color:var(--text3);font-family:var(--mono);margin-top:2px;">${escapeHtml(t.name)}</div>
|
||||
</td>
|
||||
<td style="padding:14px 16px;"><span class="pill-format ${pillClass}">${ext}</span></td>
|
||||
<td style="padding:14px 16px;color:var(--text3);font-family:var(--mono);">${fmtBytes(t.size)}</td>
|
||||
<td style="padding:14px 16px;color:var(--text3);font-size:12px;">${dateStr}</td>
|
||||
<td style="padding:14px 16px;text-align:right;">
|
||||
<button class="btn btn-sm" onclick="playNASTrack(${idx})" style="background:linear-gradient(135deg,#9333ea,#4f46e5);border:none;padding:5px 12px;font-size:12px;margin-right:6px;cursor:pointer;">▶ Play</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="downloadFile('${escKey}')" style="padding:5px 8px;font-size:12px;margin-right:4px;cursor:pointer;" title="Download">⬇</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="copyStreamURL('${streamUrl}')" style="padding:5px 8px;font-size:12px;margin-right:4px;cursor:pointer;" title="Copy Stream Link">🔗</button>
|
||||
<button class="btn btn-ghost btn-sm" onclick="deleteObject('${escKey}'); setTimeout(() => loadNASTracks(currentNASBucket.name), 600);" style="padding:5px 8px;font-size:12px;color:#f87171;cursor:pointer;" title="Delete">🗑</button>
|
||||
</td>
|
||||
</tr>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function playNASTrack(idx) {
|
||||
if (idx < 0 || idx >= currentNASTracks.length) return;
|
||||
currentNASTrackIdx = idx;
|
||||
const t = currentNASTracks[idx];
|
||||
const bar = document.getElementById('nas-audio-player-bar');
|
||||
const audio = document.getElementById('nas-global-audio');
|
||||
const title = document.getElementById('nas-player-title');
|
||||
const sub = document.getElementById('nas-player-sub');
|
||||
const ext = t.name.split('.').pop().toUpperCase();
|
||||
|
||||
const streamUrl = `${currentNASBucket.nas_url}${encodeURIComponent(t.key)}`;
|
||||
if (title) title.textContent = t.name.replace(/\.[^/.]+$/, '').replace(/_/g, ' ');
|
||||
if (sub) sub.textContent = `${ext} · ${fmtBytes(t.size)} · Zero-Delay Stream`;
|
||||
|
||||
if (bar) bar.style.display = 'flex';
|
||||
if (audio) {
|
||||
audio.src = streamUrl;
|
||||
audio.play();
|
||||
audio.onended = () => { playNextNASTrack(); };
|
||||
}
|
||||
}
|
||||
|
||||
function playNextNASTrack() {
|
||||
if (!currentNASTracks.length) return;
|
||||
const next = (currentNASTrackIdx + 1) % currentNASTracks.length;
|
||||
playNASTrack(next);
|
||||
}
|
||||
|
||||
function playAllNASTracks() {
|
||||
if (currentNASTracks.length > 0) playNASTrack(0);
|
||||
}
|
||||
|
||||
function closeNASAudioPlayer() {
|
||||
const bar = document.getElementById('nas-audio-player-bar');
|
||||
const audio = document.getElementById('nas-global-audio');
|
||||
if (audio) { audio.pause(); audio.src = ''; }
|
||||
if (bar) bar.style.display = 'none';
|
||||
}
|
||||
|
||||
function copyNASPrimaryURL() {
|
||||
if (!currentNASBucket) return;
|
||||
copyText(currentNASBucket.nas_url, 'Unique Mornye NAS URL copied! Paste this in your Mornye App settings.');
|
||||
}
|
||||
|
||||
function copyNASPlaylistURL() {
|
||||
if (!currentNASBucket) return;
|
||||
copyText(currentNASBucket.playlist_url, 'Mornye M3U Playlist stream URL copied!');
|
||||
}
|
||||
|
||||
function openNASWebPlayer() {
|
||||
if (!currentNASBucket) return;
|
||||
window.open(currentNASBucket.nas_url, '_blank');
|
||||
}
|
||||
|
||||
function copyStreamURL(url) {
|
||||
copyText(url, 'Track direct stream URL copied!');
|
||||
}
|
||||
|
||||
function toggleNASSecretKey() {
|
||||
const el = document.getElementById('nas-secret-key-val');
|
||||
if (!el) return;
|
||||
if (el.textContent === '••••••••••••••••') {
|
||||
el.textContent = el.dataset.secret || '—';
|
||||
} else {
|
||||
el.textContent = '••••••••••••••••';
|
||||
}
|
||||
}
|
||||
|
||||
async function enableNASPublicStreaming(bucketName) {
|
||||
toast('Configuring public streaming for Mornye…', 'info');
|
||||
const r = await api('/oort/api/nas/enable-streaming', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ bucket: bucketName })
|
||||
});
|
||||
if (r && r.success) {
|
||||
toast('Public streaming active! Mornye can now stream from this space.', 'success');
|
||||
if (mornyeNASData) {
|
||||
const b = mornyeNASData.buckets.find(x => x.name === bucketName);
|
||||
if (b) b.is_public = true;
|
||||
}
|
||||
onNASSpaceChanged(bucketName);
|
||||
} else {
|
||||
toast('Failed to enable streaming', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function triggerNASMusicUpload() {
|
||||
const inp = document.getElementById('nas-music-input');
|
||||
if (inp) inp.click();
|
||||
}
|
||||
|
||||
function uploadNASMusicFiles(files) {
|
||||
if (!files || !files.length) return;
|
||||
if (!currentNASBucket) { toast('Select a NAS space first', 'error'); return; }
|
||||
state.bucket = currentNASBucket.name;
|
||||
queueFiles(files);
|
||||
setTimeout(() => { loadNASTracks(currentNASBucket.name); }, 2500);
|
||||
}
|
||||
|
||||
function onNASDragOver(e) {
|
||||
e.preventDefault();
|
||||
const dz = document.getElementById('nas-dropzone');
|
||||
if (dz) {
|
||||
dz.style.borderColor = '#a855f7';
|
||||
dz.style.background = 'rgba(168,85,247,0.06)';
|
||||
}
|
||||
}
|
||||
|
||||
function onNASDragLeave(e) {
|
||||
e.preventDefault();
|
||||
const dz = document.getElementById('nas-dropzone');
|
||||
if (dz) {
|
||||
dz.style.borderColor = 'rgba(168,85,247,0.3)';
|
||||
dz.style.background = 'rgba(255,255,255,0.015)';
|
||||
}
|
||||
}
|
||||
|
||||
function onNASDrop(e) {
|
||||
e.preventDefault();
|
||||
onNASDragLeave(e);
|
||||
if (e.dataTransfer && e.dataTransfer.files) {
|
||||
uploadNASMusicFiles(e.dataTransfer.files);
|
||||
}
|
||||
}
|
||||
|
||||
function copyText(txt, msg) {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(txt).then(() => {
|
||||
toast(msg || 'Copied to clipboard!');
|
||||
}).catch(() => {
|
||||
prompt('Copy this URL:', txt);
|
||||
});
|
||||
} else {
|
||||
prompt('Copy this URL:', txt);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user