177 lines
5.2 KiB
JavaScript
Raw Normal View History

2019-11-16 10:21:14 +03:00
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('../../bootstrap');
import Vue from 'vue';
2020-01-03 12:10:07 +03:00
import DashboardPlugin from './../../plugins/dashboard-plugin';
2019-11-16 10:21:14 +03:00
import Global from '../../mixins/global';
2019-11-20 17:11:35 +03:00
import {Progress} from 'element-ui';
import AkauntingCarousel from './../../components/AkauntingCarousel';
2020-01-03 12:10:07 +03:00
// plugin setup
2020-01-14 15:55:59 +03:00
Vue.use(DashboardPlugin, Progress);
2020-01-03 12:10:07 +03:00
2019-11-16 10:21:14 +03:00
const app = new Vue({
el: '#app',
mixins: [
Global
],
2019-11-20 17:11:35 +03:00
components: {
[Progress.name]: Progress,
AkauntingCarousel
2019-11-20 17:11:35 +03:00
},
2019-11-16 10:21:14 +03:00
mounted() {
this.onReviews(1);
2019-11-16 10:21:14 +03:00
},
data: function () {
return {
reviews: {
status: false,
html: '',
pagination: {
current_page: 1,
last_page: 1
}
},
2019-11-20 17:11:35 +03:00
faq: false,
installation: {
show: false,
steps: [],
steps_total: 0,
total: 0,
path: '',
2020-12-12 14:59:58 +03:00
alias: '',
2019-11-20 17:11:35 +03:00
version: '',
status: 'success',
html: ''
},
2019-11-16 10:21:14 +03:00
}
},
methods: {
2019-11-20 17:45:19 +03:00
onChangeCategory(category) {
2020-09-07 10:57:29 +03:00
if (!category.length) {
return;
}
2019-11-20 17:45:19 +03:00
let path = document.getElementById('category_page').value;
if (category != '*') {
2019-11-20 17:45:19 +03:00
path += '/' + encodeURIComponent(category);
} else {
path = app_home;
}
location = path;
},
async onReviews(page) {
let reviews_promise = Promise.resolve(window.axios.post(url + '/apps/' + app_slug + '/reviews', {
2019-11-16 10:21:14 +03:00
page: page
2020-05-18 14:33:18 +03:00
}));
reviews_promise.then(response => {
if (response.data.success) {
this.reviews.status= true;
this.reviews.html = response.data.html;
this.reviews.pagination.current_page = page;
this.reviews.pagination.last_page = response.data.data.last_page;
}
2019-11-16 10:21:14 +03:00
})
.catch(error => {
});
},
onShowFaq() {
this.faq = true;
2019-11-20 17:11:35 +03:00
},
2020-12-12 14:59:58 +03:00
async onInstall(path, alias, name, version) {
this.installation.alias = alias;
2019-11-20 17:11:35 +03:00
this.installation.show = true;
this.installation.total = 0;
this.installation.path = path;
this.installation.version = version;
2020-05-18 14:33:18 +03:00
let steps_promise = Promise.resolve(axios.post(url + '/apps/steps', {
2019-11-20 17:11:35 +03:00
name: name,
2020-12-12 14:59:58 +03:00
alias: alias,
2019-11-20 17:11:35 +03:00
version: version
2020-05-18 14:33:18 +03:00
}));
steps_promise.then(response => {
2019-11-20 17:11:35 +03:00
if (response.data.error) {
this.installation.status = 'exception';
this.installation.html = '<div class="text-danger">' + response.data.message + '</div>';
}
// Set steps
if (response.data.data) {
this.installation.steps = response.data.data;
this.installation.steps_total = this.installation.steps.length;
this.next();
}
})
.catch(error => {
});
},
2020-05-18 14:33:18 +03:00
async next() {
2019-11-20 17:11:35 +03:00
let data = this.installation.steps.shift();
if (data) {
2020-05-18 14:33:18 +03:00
this.installation.total = parseInt((100 - ((this.installation.steps.length / this.installation.steps_total) * 100)).toFixed(0));
2019-11-20 17:11:35 +03:00
this.installation.html = '<span class="text-default"><i class="fa fa-spinner fa-spin update-spin"></i> ' + data['text'] + '</span> </br>';
2020-05-18 14:33:18 +03:00
let step_promise = Promise.resolve(axios.post(data.url, {
2020-12-12 14:59:58 +03:00
alias: this.installation.alias,
2019-11-20 17:11:35 +03:00
version: this.installation.version,
path: this.installation.path,
2020-05-18 14:33:18 +03:00
}));
step_promise.then(response => {
2019-11-20 17:11:35 +03:00
if (response.data.error) {
this.installation.status = 'exception';
this.installation.html = '<div class="text-danger"><i class="fa fa-times update-error"></i> ' + response.data.message + '</div>';
}
if (response.data.success) {
this.installation.status = 'success';
}
if (response.data.data.path) {
this.installation.path = response.data.data.path;
}
if (!response.data.error && !response.data.redirect) {
setTimeout(function() {
2020-05-18 14:33:18 +03:00
this.next();
}.bind(this), 800);
2019-11-20 17:11:35 +03:00
}
if (response.data.redirect) {
window.location = response.data.redirect;
}
})
.catch(error => {
});
}
2019-11-16 10:21:14 +03:00
}
}
});