diff --git a/widgets/discopanel/README.md b/widgets/discopanel/README.md new file mode 100644 index 0000000..629e527 --- /dev/null +++ b/widgets/discopanel/README.md @@ -0,0 +1,68 @@ +# Discopanel Widget +Lists all servers in your Discopanel host. Server icon functionality requires using a url for the picture. These can be obtained from the curseforge or modrinth page directly. I imagine that using direct file paths would also work, you just might have to adjust how the picture file path is read in glance. I have not tested this functionality so there may be some amount of testing you would need to do. + +Discopanel v2.0.0 is here! This means that you will have to create a api token from the user page to use this functionality. The only permissions this app needs are `Read: Servers` and `Read: Server Config`. You can limit this to specific servers so you only get to see a certain selection of the servers on your Discopanel host or just add all of them! As of v2.0.1, you cannot determine the permissions of an API Token on a token by token basis, so I created a new user with only the permissions I described using the Roles Settings menu in Discopanel. Then, I made a new user with only that role and made an API Token from there. Once you have that token you can just past it into the environment variable and you are done! + +# Environment Variables +`DISCOPANEL_HOST` = URL/IP of Discopanel host. Requires http/https prefix. +`DISCOPANEL_TOKEN` = API Token used to authenticate with the Discopanel Server + +# Preview +Preview Image + +# YAML +```yaml +- type: custom-api + title: Discopanel + cache: 30s + template: | + {{ $serverList := newRequest "${DISCOPANEL_HOST}/discopanel.v1.ServerService/ListServers" + | withHeader "Content-Type" "application/json" + | withHeader "Authorization" "Bearer ${DISCOPANEL_TOKEN}" + | withStringBody `{"fullStats": true}` + | getResponse + }} + + {{ range $serverList.JSON.Array "servers" }} + {{ $mem_usage := .Int "memoryUsage" }} + {{ $mem_total := .Int "memory" }} + {{ $cpu := .Float "cpuPercent" }} + {{ $players := .Int "playersOnline" }} + {{ $max_players := .Int "maxPlayers" }} + {{ $tps := .Float "tps" }} + {{ $id := .String "id" }} + {{ $status := .String "status" }} + + {{ $serverConfig := newRequest "${DISCOPANEL_HOST}/discopanel.v1.ConfigService/GetServerConfig" + | withHeader "Content-Type" "application/json" + | withHeader "Authorization" "Bearer ${DISCOPANEL_TOKEN}" + | withStringBody (printf `{"serverId": %q}` $id) + | getResponse + }} + {{ $icon := $serverConfig.JSON.String "categories.1.properties.6.value" }} + +
+
+ no picture +
+ {{ .String "name" }} + {{ if eq "SERVER_STATUS_RUNNING" $status }} + + {{ else if eq "SERVER_STATUS_STARTING" $status }} + + {{ else }} + + {{ end }} +

{{ .String "description" }}

+
+ Memory: {{ formatNumber $mem_usage }}/{{ formatNumber $mem_total }} MB + CPU: {{ printf "%.2f" $cpu }}% + Players: {{ $players }}/{{ $max_players }} + TPS: {{ $tps }}/20 +
+
+
+
+ {{ end }} + +``` diff --git a/widgets/discopanel/meta.yml b/widgets/discopanel/meta.yml new file mode 100644 index 0000000..ae286ef --- /dev/null +++ b/widgets/discopanel/meta.yml @@ -0,0 +1,3 @@ +title: Discopanel +description: A widget to view all of your minecraft servers from Discopanel +author: PapaZ810 diff --git a/widgets/discopanel/preview.png b/widgets/discopanel/preview.png new file mode 100644 index 0000000..798e181 Binary files /dev/null and b/widgets/discopanel/preview.png differ