mirror of
https://github.com/aclist/dztui.git
synced 2024-12-28 21:32:36 +01:00
Hotfix for API pagination
This commit is contained in:
parent
9e1d2e8522
commit
f49f9e4358
2 changed files with 30 additions and 10 deletions
|
@ -4,6 +4,10 @@
|
||||||
- Clean up logging
|
- Clean up logging
|
||||||
- Custom query API
|
- Custom query API
|
||||||
|
|
||||||
|
## [2.4.2-rc.1] 2022-08-10
|
||||||
|
### Fixed
|
||||||
|
- Page though API results to list >10 servers
|
||||||
|
|
||||||
## [2.4.1-testing] 2022-08-09
|
## [2.4.1-testing] 2022-08-09
|
||||||
### Fixed
|
### Fixed
|
||||||
- Hotfix for progress bar breaking table when >9 servers in list
|
- Hotfix for progress bar breaking table when >9 servers in list
|
||||||
|
|
36
dzgui.sh
36
dzgui.sh
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
version=2.4.1-testing
|
version=2.4.2-rc.1
|
||||||
aid=221100
|
aid=221100
|
||||||
game="dayz"
|
game="dayz"
|
||||||
workshop="steam://url/CommunityFilePage/"
|
workshop="steam://url/CommunityFilePage/"
|
||||||
|
@ -80,10 +80,8 @@ items=(
|
||||||
"View changelog"
|
"View changelog"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
exit_and_cleanup(){
|
cleanup(){
|
||||||
#TODO: this is currently unused
|
|
||||||
rm $tmp
|
rm $tmp
|
||||||
rm $link_file
|
|
||||||
}
|
}
|
||||||
warn_and_exit(){
|
warn_and_exit(){
|
||||||
zenity --info --title="DZGUI" --text="$1" --icon-name="dialog-warning" 2>/dev/null
|
zenity --info --title="DZGUI" --text="$1" --icon-name="dialog-warning" 2>/dev/null
|
||||||
|
@ -96,6 +94,10 @@ warn(){
|
||||||
info(){
|
info(){
|
||||||
zenity --info --title="DZGUI" --text="$1" 2>/dev/null
|
zenity --info --title="DZGUI" --text="$1" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
set_api_params(){
|
||||||
|
response=$(curl -s "$api" -H "Authorization: Bearer "$api_key"" -G -d "sort=-players" \
|
||||||
|
-d "filter[game]=$game" -d "filter[ids][whitelist]=$list_of_ids")
|
||||||
|
}
|
||||||
query_api(){
|
query_api(){
|
||||||
#TODO: prevent drawing list if null values returned without API error
|
#TODO: prevent drawing list if null values returned without API error
|
||||||
if [[ $one_shot_launch -eq 1 ]]; then
|
if [[ $one_shot_launch -eq 1 ]]; then
|
||||||
|
@ -107,8 +109,7 @@ query_api(){
|
||||||
list_of_ids="$whitelist"
|
list_of_ids="$whitelist"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
response=$(curl -s "$api" -H "Authorization: Bearer "$api_key"" -G -d "sort=-players" \
|
set_api_params
|
||||||
-d "filter[game]=$game" -d "filter[ids][whitelist]=$list_of_ids")
|
|
||||||
if [[ "$(jq -r 'keys[]' <<< "$response")" == "errors" ]]; then
|
if [[ "$(jq -r 'keys[]' <<< "$response")" == "errors" ]]; then
|
||||||
code=$(jq -r '.errors[] .status' <<< $response)
|
code=$(jq -r '.errors[] .status' <<< $response)
|
||||||
#TODO: fix granular api codes
|
#TODO: fix granular api codes
|
||||||
|
@ -638,7 +639,7 @@ debug_menu(){
|
||||||
}
|
}
|
||||||
query_and_connect(){
|
query_and_connect(){
|
||||||
query_api
|
query_api
|
||||||
parse_json <<< "$response"
|
parse_json
|
||||||
#TODO: create logger function
|
#TODO: create logger function
|
||||||
echo "[DZGUI] Checking response time of servers"
|
echo "[DZGUI] Checking response time of servers"
|
||||||
create_array | zenity --width 500 --progress --pulsate --title="DZGUI" --auto-close 2>/dev/null
|
create_array | zenity --width 500 --progress --pulsate --title="DZGUI" --auto-close 2>/dev/null
|
||||||
|
@ -698,10 +699,24 @@ main_menu(){
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
page_through(){
|
||||||
|
response=$(curl -s "$page")
|
||||||
|
list=$(echo "$response" | jq -r '.data[] .attributes | "\(.name)\t\(.ip):\(.port)\t\(.players)/\(.maxPlayers)\t\(.details.time)\t\(.status)\t\(.id)"')
|
||||||
|
idarr+=("$list")
|
||||||
|
echo "${idarr[@]}" | wc -l
|
||||||
|
parse_json
|
||||||
|
}
|
||||||
parse_json(){
|
parse_json(){
|
||||||
list=$(jq -r '.data[] .attributes | "\(.name)\t\(.ip):\(.port)\t\(.players)/\(.maxPlayers)\t\(.details.time)\t\(.status)\t\(.id)"')
|
page=$(echo "$response" | jq -r '.links.next?')
|
||||||
fetch_query_ports
|
if [[ "$page" != "null" ]]; then
|
||||||
echo -e "$list" > $tmp
|
list=$(echo "$response" | jq -r '.data[] .attributes | "\(.name)\t\(.ip):\(.port)\t\(.players)/\(.maxPlayers)\t\(.details.time)\t\(.status)\t\(.id)"')
|
||||||
|
idarr+=("$list")
|
||||||
|
page_through
|
||||||
|
else
|
||||||
|
printf "%s\n" "${idarr[@]}" > $tmp
|
||||||
|
idarr=()
|
||||||
|
fetch_query_ports
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
check_ping(){
|
check_ping(){
|
||||||
ping_ip=$(echo "$1" | awk -F'\t' '{print $2}' | awk -F: '{print $1}')
|
ping_ip=$(echo "$1" | awk -F'\t' '{print $2}' | awk -F: '{print $1}')
|
||||||
|
@ -942,3 +957,4 @@ main(){
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
Loading…
Reference in a new issue