Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
Adapted to new API
Browse files Browse the repository at this point in the history
  • Loading branch information
zziger committed Oct 1, 2023
1 parent 2a008c3 commit bf34f62
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/components/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
},
methods: {
async fetchPlayers() {
const data = await getRequest('https://api.altv.mp/servers/');
const data = await getRequest('https://api.alt-mp.com/servers/info');
if (!data) {
return;
Expand Down
27 changes: 11 additions & 16 deletions src/components/server/server-modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,23 @@
<tbody>
<tr>
<td>Players</td>
<td><b>{{ server.players }}</b> / {{ server.maxPlayers }}</td>
<td><b>{{ server.playersCount }}</b> / {{ server.maxPlayersCount }}</td>
</tr>
<tr>
<td>Language</td>
<td>{{ this.getLanguage(server.language) }}</td>
</tr>
<tr v-if="!server.useCdn">
<td>IP</td>
<td>{{ server.host }}</td>
</tr>
<tr v-if="!server.useCdn">
<td>Port</td>
<td>{{ server.port }}</td>
</tr>
<tr v-if="server.useCdn">
<td>Host</td>
<td>{{ server.cdnUrl }}</td>
<tr>
<td>Address</td>
<td>{{ server.address }}</td>
</tr>
<tr>
<td>Gamemode</td>
<td>{{ server.gameMode }}</td>
</tr>
<tr>
<td>Website</td>
<td>{{ server.website }}</td>
<a :href="server.website">{{ server.website }}</a>
</tr>
<tr>
<td>Description</td>
Expand Down Expand Up @@ -92,8 +84,7 @@
</div>
</div>
<div class="connect" colspan="2">
<a v-if="server.useCdn" :href="'altv://connect/' + server.cdnUrl">Connect</a>
<a v-else :href="'altv://connect/' + server.host + ':' + server.port">Connect</a>
<a :href="`altv://connect/${encodeURIComponent(server.address)}?name=${server.name}&id=${server.publicId}`">Connect</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -211,7 +202,7 @@ export default {
getPlayerData: async function () {
this.playerData = null;
const playerData = await getRequest(`https://api.alt-mp.com/${this.type}/${this.server.id}/${this.period}`);
const playerData = await getRequest(`https://api.alt-mp.com/servers/${this.server.publicId}/${this.type}/${this.period}`);
if (!playerData) {
return;
Expand Down Expand Up @@ -513,6 +504,10 @@ div.connect a:active {
border-spacing: 10px;
}
.modal-container .information table a {
color: white !important;
}
.modal-container .information table tr td:first-child {
/* display: block; */
text-transform: uppercase;
Expand Down
15 changes: 7 additions & 8 deletions src/components/server/servers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<div class="stats">
<!-- <a class="stats" href="https://altstats.net/" target="_blank"> -->
<span class="players">
Players online: <i>{{ servers.reduce((a, b) => a + (b.players || 0), 0) }}</i>
Players online: <i>{{ servers.reduce((a, b) => a + (b.playersCount || 0), 0) }}</i>
</span>
<span class="servers">
Servers online: <i>{{ servers.length }}</i>
Expand Down Expand Up @@ -68,18 +68,17 @@
<div class="icons">
<i v-if="server.verified" class="fa fa-check" title="Verified server"></i>
<i v-if="server.promoted" class="fa fa-bolt" title="Promoted server"></i>
<i v-if="server.locked" class="fa fa-lock" title="Locked server"></i>
<i v-if="server.passworded" class="fa fa-lock" title="Locked server"></i>
</div>
</td>
<td class="center players"><b>{{ server.players }}</b> <span class="optional">/
{{ server.maxPlayers }}</span></td>
<td class="center players"><b>{{ server.playersCount }}</b> <span class="optional">/
{{ server.maxPlayersCount }}</span></td>
<td class="center optional">{{ server.gameMode }}</td>
<td class="center optional">{{ getLanguage(server.language) }}
<!-- <img :src="getFlagImage(server.language)" /> -->
</td>
<td class="center optional connect">
<a v-if="server.useCdn" :href="'altv://connect/' + server.cdnUrl">Connect</a>
<a v-else :href="'altv://connect/' + server.host + ':' + server.port">Connect</a>
<a :href="'altv://connect/' + server.address">Connect</a>
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -139,7 +138,7 @@
getLanguage: getLanguage,
fetchServers: async function () {
console.log("Fetch servers from the API...");
const data = await getRequest('https://api.alt-mp.com/servers/list');
const data = await getRequest('https://api.alt-mp.com/servers');
if (!data) {
return;
Expand Down Expand Up @@ -234,7 +233,7 @@
return this.servers.filter(server => {
if (!server.players && this.filter.empty) return false;
if ((server.players === server.maxPlayers) && this.filter.full) return false;
if (server.locked && this.filter.locked) return false;
if (server.passworded && this.filter.locked) return false;
if (!this.filter.name) return true;
var filter = this.filter.name.toLowerCase();
Expand Down

0 comments on commit bf34f62

Please sign in to comment.