Files
mixtape/zero.Backoffice.UI/_notimplemented/setup/Steps/step-install.vue
T

179 lines
3.5 KiB
Vue
Raw Normal View History

2020-04-03 14:27:39 +02:00
<template>
<div class="setup-step setup-step-install">
2020-04-03 16:45:47 +02:00
<div v-if="!errorMessage" class="setup-step-install-inner">
<div class="setup-step-install-progress"><i :style="{ width: progress + '%' }"></i></div>
2020-04-03 14:27:39 +02:00
<h2>Installing</h2>
</div>
2020-04-03 16:45:47 +02:00
<div v-if="errorMessage" class="setup-step-install-error">
<div class="setup-step-install-error-main">
<h2>Oh no!</h2>
<p>The setup of <b>zero</b> failed with following error(s):</p>
<pre class="setup-step-install-error-code"><code v-html="errorMessage"></code></pre>
</div>
<div class="setup-buttons">
2020-04-15 01:42:06 +02:00
<ui-button type="outline" @click="onBack" label="Go back" caret="left" caret-position="left" />
<ui-button label="Retry" @click="install" />
2020-04-03 16:45:47 +02:00
</div>
</div>
2020-04-03 14:27:39 +02:00
</div>
</template>
<script>
2020-04-03 16:45:47 +02:00
import Axios from 'axios'
2020-04-03 14:27:39 +02:00
export default {
name: 'setupStepInstall',
2020-04-03 16:45:47 +02:00
props: {
value: Object,
onBack: {
type: Function,
required: true
},
onNext: {
type: Function,
required: true
}
},
data: () => ({
errorMessage: null,
progress: 0
}),
mounted()
2020-04-03 14:27:39 +02:00
{
2020-04-03 16:45:47 +02:00
this.install();
2020-04-03 14:27:39 +02:00
},
methods: {
2020-04-03 16:45:47 +02:00
install()
{
this.errorMessage = null;
2020-04-03 14:27:39 +02:00
2020-04-03 16:45:47 +02:00
let interval = setInterval(() =>
{
if (++this.progress >= 100)
{
this.onNext();
clearInterval(interval);
}
2020-04-03 18:03:36 +02:00
}, 50);
2020-04-03 16:45:47 +02:00
2020-04-06 11:03:55 +02:00
Axios.post(zero.path + 'api/setup/install', this.value)
2020-04-03 16:45:47 +02:00
.then(response =>
{
2020-04-15 01:42:06 +02:00
if (!response.success)
{
throw response;
}
2020-04-03 16:45:47 +02:00
})
.catch((error) =>
{
2020-04-03 18:03:36 +02:00
clearInterval(interval);
2020-04-03 16:45:47 +02:00
// The request was made and the server responded with a status code that falls out of the range of 2xx
if (error.response)
{
this.error(error.response.data);
}
// The request was made but no response was received
else if (error.request)
{
this.error(error.request);
}
else
{
this.error(error.message);
}
});
},
error(error)
{
this.errorMessage = error;
}
2020-04-03 14:27:39 +02:00
}
}
</script>
<style lang="scss">
.setup-step-install
{
display: grid;
grid-template-rows: 1fr auto;
align-items: center;
2020-04-03 16:45:47 +02:00
justify-content: stretch;
}
.setup-step-install-inner
{
2020-04-03 14:27:39 +02:00
text-align: center;
2020-04-03 16:45:47 +02:00
h2
2020-04-03 14:27:39 +02:00
{
2020-04-03 16:45:47 +02:00
margin: 30px 0 0;
2020-04-03 14:27:39 +02:00
}
}
2020-04-03 16:45:47 +02:00
.setup-step-install-progress
{
position: relative;
margin: 0 auto;
width: 80%;
height: 12px;
border-radius: 6px;
background: var(--color-bg-light);
overflow: hidden;
i
{
2020-08-16 15:51:12 +02:00
background: var(--color-primary);
2020-04-03 16:45:47 +02:00
transition: width 0.1s ease;
display: block;
height: 100%;
}
}
.setup-step-install-error
{
display: grid;
grid-template-rows: 1fr auto;
align-items: stretch;
width: 100%;
height: 100%;
h2
{
color: var(--color-negative);
}
div
{
width: 100%;
}
}
.setup-step-install-error-code
{
background: var(--color-bg-light);
padding: 20px;
font-size: 14px;
line-height: 20px;
width: 440px;
max-height: 50vh;
overflow: scroll;
font-family: 'Lucida Console', Consolas, sans-serif;
margin: 0;
}
.setup-step-install-error-main
{
display: grid;
grid-template-rows: auto auto 1fr;
margin-bottom: 30px;
}
2020-04-03 14:27:39 +02:00
</style>