rudeshark.net/src/client/app/common/views/components/connect-failed.troubleshooter.vue

149 lines
3.5 KiB
Vue
Raw Normal View History

2018-02-21 13:34:49 +01:00
<template>
<div class="troubleshooter">
2018-04-16 08:59:43 +02:00
<div class="body">
<h1><fa icon="wrench"/>{{ $t('title') }}</h1>
2018-04-16 08:59:43 +02:00
<div>
<p :data-wip="network == null">
<template v-if="network != null">
<template v-if="network"><fa icon="check"/></template>
<template v-if="!network"><fa icon="times"/></template>
2018-04-16 08:59:43 +02:00
</template>
{{ network == null ? this.$t('checking-network') : this.$t('network') }}<mk-ellipsis v-if="network == null"/>
2018-04-16 08:59:43 +02:00
</p>
<p v-if="network == true" :data-wip="internet == null">
<template v-if="internet != null">
<template v-if="internet"><fa icon="check"/></template>
<template v-if="!internet"><fa icon="times"/></template>
2018-04-16 08:59:43 +02:00
</template>
{{ internet == null ? this.$t('checking-internet') : this.$t('internet') }}<mk-ellipsis v-if="internet == null"/>
2018-04-16 08:59:43 +02:00
</p>
<p v-if="internet == true" :data-wip="server == null">
<template v-if="server != null">
<template v-if="server"><fa icon="check"/></template>
<template v-if="!server"><fa icon="times"/></template>
2018-04-16 08:59:43 +02:00
</template>
{{ server == null ? this.$t('checking-server') : this.$t('server') }}<mk-ellipsis v-if="server == null"/>
2018-04-16 08:59:43 +02:00
</p>
</div>
<p v-if="!end">{{ $t('finding') }}<mk-ellipsis/></p>
<p v-if="network === false"><b><fa icon="exclamation-triangle"/>{{ $t('no-network') }}</b><br>{{ $t('no-network-desc') }}</p>
<p v-if="internet === false"><b><fa icon="exclamation-triangle"/>{{ $t('no-internet') }}</b><br>{{ $t('no-internet-desc') }}</p>
<p v-if="server === false"><b><fa icon="exclamation-triangle"/>{{ $t('no-server') }}</b><br>{{ $t('no-server-desc') }}</p>
<p v-if="server === true" class="success"><b><fa icon="info-circle"/>{{ $t('success') }}</b><br>{{ $t('success-desc') }}</p>
2018-02-21 13:34:49 +01:00
</div>
2018-04-16 08:59:43 +02:00
<footer>
<a href="/assets/flush.html">{{ $t('flush') }}</a> | <a href="/assets/version.html">{{ $t('set-version') }}</a>
2018-04-16 08:59:43 +02:00
</footer>
2018-02-21 13:34:49 +01:00
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../i18n';
2018-02-21 13:34:49 +01:00
import { apiUrl } from '../../../config';
export default Vue.extend({
i18n: i18n('common/views/components/connect-failed.troubleshooter.vue'),
2018-02-21 13:34:49 +01:00
data() {
return {
network: navigator.onLine,
end: false,
2018-02-21 21:05:19 +01:00
internet: null,
server: null
2018-02-21 13:34:49 +01:00
};
},
mounted() {
if (!this.network) {
this.end = true;
return;
}
// Check internet connection
2018-09-01 16:12:51 +02:00
fetch(`https://google.com?rand=${Math.random()}`, {
2018-02-21 13:34:49 +01:00
mode: 'no-cors'
}).then(() => {
this.internet = true;
// Check misskey server is available
fetch(`${apiUrl}/meta`).then(() => {
this.end = true;
this.server = true;
})
.catch(() => {
this.end = true;
this.server = false;
});
})
.catch(() => {
this.end = true;
this.internet = false;
});
}
});
</script>
<style lang="stylus" scoped>
.troubleshooter
2018-04-17 00:42:38 +02:00
margin-top 1em
2018-04-16 08:59:43 +02:00
> .body
width 100%
max-width 500px
2018-04-17 00:42:38 +02:00
margin 0 auto
2018-04-16 08:59:43 +02:00
text-align left
background #fff
border-radius 8px
border solid 1px #ddd
> h1
margin 0
padding 0.6em 1.2em
font-size 1em
2018-02-21 13:34:49 +01:00
color #444
2018-04-16 08:59:43 +02:00
border-bottom solid 1px #eee
2018-02-21 13:34:49 +01:00
> [data-icon]
2018-02-21 13:34:49 +01:00
margin-right 0.25em
2018-04-16 08:59:43 +02:00
> div
overflow hidden
padding 0.6em 1.2em
2018-02-21 13:34:49 +01:00
2018-04-16 08:59:43 +02:00
> p
margin 0.5em 0
font-size 0.9em
color #444
2018-02-21 13:34:49 +01:00
2018-04-16 08:59:43 +02:00
&[data-wip]
color #888
2018-02-21 13:34:49 +01:00
> [data-icon]
2018-04-16 08:59:43 +02:00
margin-right 0.25em
2018-02-21 13:34:49 +01:00
2018-04-16 08:59:43 +02:00
&.times
color #e03524
&.check
color #84c32f
> p
margin 0
padding 0.7em 1.2em
font-size 1em
color #444
border-top solid 1px #eee
2018-02-21 13:34:49 +01:00
> b
> [data-icon]
2018-04-16 08:59:43 +02:00
margin-right 0.25em
&.success
> b
color #39adad
&:not(.success)
> b
color #ad4339
2018-02-21 13:34:49 +01:00
</style>