mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Fetch instances using Instances API. (#854)
This commit is contained in:
parent
9a1aca925b
commit
6b4bd1a034
2 changed files with 21 additions and 30 deletions
|
@ -158,6 +158,9 @@
|
||||||
<th v-t="'preferences.instance_name'" />
|
<th v-t="'preferences.instance_name'" />
|
||||||
<th v-t="'preferences.instance_locations'" />
|
<th v-t="'preferences.instance_locations'" />
|
||||||
<th v-t="'preferences.has_cdn'" />
|
<th v-t="'preferences.has_cdn'" />
|
||||||
|
<th v-t="'preferences.registered_users'" />
|
||||||
|
<th v-t="'preferences.version'" />
|
||||||
|
<th v-t="'preferences.up_to_date'" />
|
||||||
<th v-t="'preferences.ssl_score'" />
|
<th v-t="'preferences.ssl_score'" />
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -165,9 +168,12 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td v-text="instance.name" />
|
<td v-text="instance.name" />
|
||||||
<td v-text="instance.locations" />
|
<td v-text="instance.locations" />
|
||||||
<td v-t="`actions.${instance.cdn === 'Yes' ? 'yes' : 'no'}`" />
|
<td v-t="`actions.${instance.cdn ? 'yes' : 'no'}`" />
|
||||||
|
<td v-text="instance.registered" />
|
||||||
|
<td v-text="instance.version" />
|
||||||
|
<td v-t="`actions.${instance.up_to_date ? 'yes' : 'no'}`" />
|
||||||
<td>
|
<td>
|
||||||
<a :href="sslScore(instance.apiurl)" target="_blank" v-t="'actions.view_ssl_score'" />
|
<a :href="sslScore(instance.api_url)" target="_blank" v-t="'actions.view_ssl_score'" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -178,7 +184,7 @@
|
||||||
<label for="ddlInstanceSelection"><strong v-text="`${$t('actions.instance_selection')}:`" /></label>
|
<label for="ddlInstanceSelection"><strong v-text="`${$t('actions.instance_selection')}:`" /></label>
|
||||||
<br />
|
<br />
|
||||||
<select id="ddlInstanceSelection" v-model="selectedInstance" class="select w-auto" @change="onChange($event)">
|
<select id="ddlInstanceSelection" v-model="selectedInstance" class="select w-auto" @change="onChange($event)">
|
||||||
<option v-for="instance in instances" :key="instance.name" :value="instance.apiurl" v-text="instance.name" />
|
<option v-for="instance in instances" :key="instance.name" :value="instance.api_url" v-text="instance.name" />
|
||||||
</select>
|
</select>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -257,34 +263,16 @@ export default {
|
||||||
async mounted() {
|
async mounted() {
|
||||||
if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} });
|
if (Object.keys(this.$route.query).length > 0) this.$router.replace({ query: {} });
|
||||||
|
|
||||||
fetch("https://raw.githubusercontent.com/wiki/TeamPiped/Piped-Frontend/Instances.md")
|
this.fetchJson("https://piped-instances.kavin.rocks/").then(resp => {
|
||||||
.then(resp => resp.text())
|
this.instances = resp;
|
||||||
.then(body => {
|
if (this.instances.filter(instance => instance.api_url == this.apiUrl()).length == 0)
|
||||||
var skipped = 0;
|
this.instances.push({
|
||||||
const lines = body.split("\n");
|
name: "Custom Instance",
|
||||||
lines.map(line => {
|
api_url: this.apiUrl(),
|
||||||
const split = line.split("|");
|
locations: "Unknown",
|
||||||
if (split.length == 5) {
|
cdn: false,
|
||||||
if (skipped < 2) {
|
|
||||||
skipped++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.instances.push({
|
|
||||||
name: split[0].trim(),
|
|
||||||
apiurl: split[1].trim(),
|
|
||||||
locations: split[2].trim(),
|
|
||||||
cdn: split[3].trim(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
if (this.instances.filter(instance => instance.apiurl == this.apiUrl()).length == 0)
|
});
|
||||||
this.instances.push({
|
|
||||||
name: "Custom Instance",
|
|
||||||
apiurl: this.apiUrl(),
|
|
||||||
locations: "Unknown",
|
|
||||||
cdn: "Unknown",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (this.testLocalStorage) {
|
if (this.testLocalStorage) {
|
||||||
this.selectedInstance = this.getPreferenceString("instance", "https://pipedapi.kavin.rocks");
|
this.selectedInstance = this.getPreferenceString("instance", "https://pipedapi.kavin.rocks");
|
||||||
|
|
|
@ -79,6 +79,9 @@
|
||||||
"instance_name": "Instance Name",
|
"instance_name": "Instance Name",
|
||||||
"instance_locations": "Instance Locations",
|
"instance_locations": "Instance Locations",
|
||||||
"has_cdn": "Has CDN?",
|
"has_cdn": "Has CDN?",
|
||||||
|
"registered_users": "Registered Users",
|
||||||
|
"version": "Version",
|
||||||
|
"up_to_date": "Up to Date?",
|
||||||
"ssl_score": "SSL Score"
|
"ssl_score": "SSL Score"
|
||||||
},
|
},
|
||||||
"login": {
|
"login": {
|
||||||
|
|
Loading…
Reference in a new issue