From 44a2538f6772adddf6c47abe7cf6288718a80165 Mon Sep 17 00:00:00 2001 From: bingoohuang Date: Mon, 5 Jul 2021 18:09:44 +0800 Subject: [PATCH] extract embed html of master/volume/filer ui to separate files --- weed/server/filer_ui/filer.html | 182 ++++++++++++++++++++ weed/server/filer_ui/templates.go | 178 +------------------- weed/server/master_ui/master.html | 110 ++++++++++++ weed/server/master_ui/templates.go | 112 +------------ weed/server/volume_server_ui/templates.go | 191 +-------------------- weed/server/volume_server_ui/volume.html | 194 ++++++++++++++++++++++ 6 files changed, 498 insertions(+), 469 deletions(-) create mode 100644 weed/server/filer_ui/filer.html create mode 100644 weed/server/master_ui/master.html create mode 100644 weed/server/volume_server_ui/volume.html diff --git a/weed/server/filer_ui/filer.html b/weed/server/filer_ui/filer.html new file mode 100644 index 000000000..84dc4d4d6 --- /dev/null +++ b/weed/server/filer_ui/filer.html @@ -0,0 +1,182 @@ + + + + SeaweedFS Filer + + + + + +
+ +
+
+ {{ range $entry := .Breadcrumbs }} + + {{ $entry.Name }} + + {{ end }} + +
+
+ +
+
+ + + + {{$path := .Path }} + {{ range $entry_index, $entry := .Entries }} + + + + + + + {{ end }} + +
+ {{if $entry.IsDirectory}} + + + {{ $entry.Name }} + + {{else}} + + {{ $entry.Name }} + + {{end}} + + {{if $entry.IsDirectory}} + {{else}} + {{ $entry.Mime }}  + {{end}} + + {{if $entry.IsDirectory}} + {{else}} + {{ $entry.Size | humanizeBytes }}  + {{end}} + + {{ $entry.Timestamp.Format "2006-01-02 15:04" }} +
+
+
+ + {{if .ShouldDisplayLoadMore}} + + +
+ + + diff --git a/weed/server/filer_ui/templates.go b/weed/server/filer_ui/templates.go index 648b97f22..f9ef064bc 100644 --- a/weed/server/filer_ui/templates.go +++ b/weed/server/filer_ui/templates.go @@ -1,6 +1,7 @@ package filer_ui import ( + _ "embed" "github.com/dustin/go-humanize" "html/template" "net/url" @@ -18,178 +19,7 @@ var funcMap = template.FuncMap{ "printpath": printpath, } -var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(` - - - SeaweedFS Filer - - - - - -
- -
-
- {{ range $entry := .Breadcrumbs }} - - {{ $entry.Name }} - - {{ end }} - -
-
- -
-
- - - - {{$path := .Path }} - {{ range $entry_index, $entry := .Entries }} - - - - - - - {{ end }} - -
- {{if $entry.IsDirectory}} - - - {{ $entry.Name }} - - {{else}} - - {{ $entry.Name }} - - {{end}} - - {{if $entry.IsDirectory}} - {{else}} - {{ $entry.Mime }}  - {{end}} - - {{if $entry.IsDirectory}} - {{else}} - {{ $entry.Size | humanizeBytes }}  - {{end}} - - {{ $entry.Timestamp.Format "2006-01-02 15:04" }} -
-
-
- - {{if .ShouldDisplayLoadMore}} - - -
- - - -`)) +var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(filerHtml)) diff --git a/weed/server/master_ui/master.html b/weed/server/master_ui/master.html new file mode 100644 index 000000000..e0241d66d --- /dev/null +++ b/weed/server/master_ui/master.html @@ -0,0 +1,110 @@ + + + + SeaweedFS {{ .Version }} + + + +
+ + +
+
+

Cluster status

+ + + + + + + + + + + + + + + {{ with .RaftServer }} + + + + + + + + + {{ end }} + +
Volume Size Limit{{ .VolumeSizeLimitMB }}MB
Free{{ .Topology.Free }}
Max{{ .Topology.Max }}
Leader{{ .Leader }}
Other Masters + +
+
+ +
+

System Stats

+ + + + + + {{ range $key, $val := .Stats }} + + + + + {{ end }} +
Concurrent Connections{{ .Counters.Connections.WeekCounter.Sum }}
{{ $key }}{{ $val }}
+
+
+ +
+

Topology

+ + + + + + + + + + + + + + {{ range $dc_index, $dc := .Topology.DataCenters }} + {{ range $rack_index, $rack := $dc.Racks }} + {{ range $dn_index, $dn := $rack.DataNodes }} + + + + + + + + + + {{ end }} + {{ end }} + {{ end }} + +
Data CenterRackRemoteAddr#VolumesVolume Ids#ErasureCodingShardsMax
{{ $dc.Id }}{{ $rack.Id }}{{ $dn.Url }} + {{ if ne $dn.PublicUrl $dn.Url }} + / {{ $dn.PublicUrl }} + {{ end }} + {{ $dn.Volumes }}{{ $dn.VolumeIds}}{{ $dn.EcShards }}{{ $dn.Max }}
+
+ +
+ + diff --git a/weed/server/master_ui/templates.go b/weed/server/master_ui/templates.go index 31b6353e9..415022b97 100644 --- a/weed/server/master_ui/templates.go +++ b/weed/server/master_ui/templates.go @@ -1,115 +1,11 @@ package master_ui import ( + _ "embed" "html/template" ) -var StatusTpl = template.Must(template.New("status").Parse(` - - - SeaweedFS {{ .Version }} - - - -
- +//go:embed master.html +var masterHtml string -
-
-

Cluster status

- - - - - - - - - - - - - - - {{ with .RaftServer }} - - - - - - - - - {{ end }} - -
Volume Size Limit{{ .VolumeSizeLimitMB }}MB
Free{{ .Topology.Free }}
Max{{ .Topology.Max }}
Leader{{ .Leader }}
Other Masters
-
- -
-

System Stats

- - - - - - {{ range $key, $val := .Stats }} - - - - - {{ end }} -
Concurrent Connections{{ .Counters.Connections.WeekCounter.Sum }}
{{ $key }}{{ $val }}
-
-
- -
-

Topology

- - - - - - - - - - - - - - {{ range $dc_index, $dc := .Topology.DataCenters }} - {{ range $rack_index, $rack := $dc.Racks }} - {{ range $dn_index, $dn := $rack.DataNodes }} - - - - - - - - - - {{ end }} - {{ end }} - {{ end }} - -
Data CenterRackRemoteAddr#VolumesVolume Ids#ErasureCodingShardsMax
{{ $dc.Id }}{{ $rack.Id }}{{ $dn.Url }} - {{ if ne $dn.PublicUrl $dn.Url }} - / {{ $dn.PublicUrl }} - {{ end }} - {{ $dn.Volumes }}{{ $dn.VolumeIds}}{{ $dn.EcShards }}{{ $dn.Max }}
-
- -
- - -`)) +var StatusTpl = template.Must(template.New("status").Parse(masterHtml)) diff --git a/weed/server/volume_server_ui/templates.go b/weed/server/volume_server_ui/templates.go index 79f1a14a0..8034d8218 100644 --- a/weed/server/volume_server_ui/templates.go +++ b/weed/server/volume_server_ui/templates.go @@ -1,6 +1,7 @@ package volume_server_ui import ( + _ "embed" "fmt" "github.com/chrislusf/seaweedfs/weed/util" "html/template" @@ -26,191 +27,7 @@ var funcMap = template.FuncMap{ "percentFrom": percentFrom, } -var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(` - - - SeaweedFS {{ .Version }} - - - - - - - -
- - -
-
-

Disk Stats

- - - - - - - - - - - - {{ range .DiskStatuses }} - - - - - - - - {{ end }} - -
PathDiskTotalFreeUsage
{{ .Dir }}{{ .DiskType }}{{ bytesToHumanReadable .All }}{{ bytesToHumanReadable .Free }}{{ percentFrom .All .Used}}%
-
- -
-

System Stats

- - - - - - - - - - - - - - - - - - - - - - {{ range $key, $val := .Stats }} - - - - - {{ end }} -
Masters{{.Masters}}
Weekly # ReadRequests{{ .Counters.ReadRequests.WeekCounter.ToList | join }}
Daily # ReadRequests{{ .Counters.ReadRequests.DayCounter.ToList | join }}
Hourly # ReadRequests{{ .Counters.ReadRequests.HourCounter.ToList | join }}
Last Minute # ReadRequests{{ .Counters.ReadRequests.MinuteCounter.ToList | join }}
{{ $key }}{{ $val }}
-
-
- -
-

Volumes

- - - - - - - - - - - - - - - {{ range .Volumes }} - - - - - - - - - - - {{ end }} - -
IdCollectionDiskData SizeFilesTrashTTLReadOnly
{{ .Id }}{{ .Collection }}{{ .DiskType }}{{ bytesToHumanReadable .Size }}{{ .FileCount }}{{ .DeleteCount }} / {{bytesToHumanReadable .DeletedByteCount}}{{ .Ttl }}{{ .ReadOnly }}
-
- -
-

Remote Volumes

- - - - - - - - - - - - - - {{ range .RemoteVolumes }} - - - - - - - - - - {{ end }} - -
IdCollectionSizeFilesTrashRemoteKey
{{ .Id }}{{ .Collection }}{{ bytesToHumanReadable .Size }}{{ .FileCount }}{{ .DeleteCount }} / {{bytesToHumanReadable .DeletedByteCount}}{{ .RemoteStorageName }}{{ .RemoteStorageKey }}
-
- -
-

Erasure Coding Shards

- - - - - - - - - - - - {{ range .EcVolumes }} - - - - - - - - {{ end }} - -
IdCollectionShard SizeShardsCreatedAt
{{ .VolumeId }}{{ .Collection }}{{ bytesToHumanReadable .ShardSize }}{{ .ShardIdList }}{{ .CreatedAt.Format "02 Jan 06 15:04 -0700" }}
-
+//go:embed volume.html +var volumeHtml string -
- - -`)) +var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(volumeHtml)) diff --git a/weed/server/volume_server_ui/volume.html b/weed/server/volume_server_ui/volume.html new file mode 100644 index 000000000..973b0bfbe --- /dev/null +++ b/weed/server/volume_server_ui/volume.html @@ -0,0 +1,194 @@ + + + + SeaweedFS {{ .Version }} + + + + + + + +
+ + +
+
+

Disk Stats

+ + + + + + + + + + + + {{ range .DiskStatuses }} + + + + + + + + {{ end }} + +
PathDiskTotalFreeUsage
{{ .Dir }}{{ .DiskType }}{{ bytesToHumanReadable .All }}{{ bytesToHumanReadable .Free }}{{ percentFrom .All .Used}}%
+
+ +
+

System Stats

+ + + + + + + + + + + + + + + + + + + + + + {{ range $key, $val := .Stats }} + + + + + {{ end }} +
Masters{{.Masters}}
Weekly # ReadRequests{{ .Counters.ReadRequests.WeekCounter.ToList | join }} +
Daily # ReadRequests{{ .Counters.ReadRequests.DayCounter.ToList | join }} +
Hourly # ReadRequests{{ .Counters.ReadRequests.HourCounter.ToList | join }} +
Last Minute # ReadRequests{{ .Counters.ReadRequests.MinuteCounter.ToList | join }} +
{{ $key }}{{ $val }}
+
+
+ +
+

Volumes

+ + + + + + + + + + + + + + + {{ range .Volumes }} + + + + + + + + + + + {{ end }} + +
IdCollectionDiskData SizeFilesTrashTTLReadOnly
{{ .Id }}{{ .Collection }}{{ .DiskType }}{{ bytesToHumanReadable .Size }}{{ .FileCount }}{{ .DeleteCount }} / {{bytesToHumanReadable .DeletedByteCount}}{{ .Ttl }}{{ .ReadOnly }}
+
+ +
+

Remote Volumes

+ + + + + + + + + + + + + + {{ range .RemoteVolumes }} + + + + + + + + + + {{ end }} + +
IdCollectionSizeFilesTrashRemoteKey
{{ .Id }}{{ .Collection }}{{ bytesToHumanReadable .Size }}{{ .FileCount }}{{ .DeleteCount }} / {{bytesToHumanReadable .DeletedByteCount}}{{ .RemoteStorageName }}{{ .RemoteStorageKey }}
+
+ +
+

Erasure Coding Shards

+ + + + + + + + + + + + {{ range .EcVolumes }} + + + + + + + + {{ end }} + +
IdCollectionShard SizeShardsCreatedAt
{{ .VolumeId }}{{ .Collection }}{{ bytesToHumanReadable .ShardSize }}{{ .ShardIdList }}{{ .CreatedAt.Format "02 Jan 06 15:04 -0700" }}
+
+ +
+ +