Skip to content

Commit

Permalink
Update progress bar added asyn
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed May 18, 2020
1 parent 790644d commit 86c06e2
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions resources/assets/js/views/install/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ const app = new Vue({
},

methods: {
onChangelog() {
axios.get(url + '/install/updates/changelog')
.then(response => {
async onChangelog() {
let changelog_promise = Promise.resolve(axios.get(url + '/install/updates/changelog'));

changelog_promise.then(response => {
this.changelog.show = true;
this.changelog.html = response.data;
})
Expand All @@ -71,14 +72,15 @@ const app = new Vue({
});
},

steps() {
async steps() {
let name = document.getElementById('name').value;

axios.post(url + '/install/updates/steps', {
let steps_promise = Promise.resolve(axios.post(url + '/install/updates/steps', {
name: name,
version: version
})
.then(response => {
}));

steps_promise.then(response => {
if (response.data.error) {
this.update.status = 'exception';
this.update.html = '<div class="text-danger">' + response.data.message + '</div>';
Expand All @@ -96,7 +98,7 @@ const app = new Vue({
});
},

next() {
async next() {
let data = this.update.steps.shift();

let name = document.getElementById('name').value;
Expand All @@ -105,18 +107,19 @@ const app = new Vue({
let installed = document.getElementById('installed').value;

if (data) {
this.update.total = (100 - ((this.update.steps.length / this.update.steps_total) * 100)).toFixed(0);
this.update.total = parseInt((100 - ((this.update.steps.length / this.update.steps_total) * 100)).toFixed(0));

this.update.html = '<span class="text-default"><i class="fa fa-spinner fa-spin update-spin"></i> ' + data['text'] + '</span> </br>';

axios.post(data.url, {
let step_promise = Promise.resolve(axios.post(data.url, {
name: name,
alias: alias,
version: version,
installed: installed,
path: this.update.path,
})
.then(response => {
}));

step_promise.then(response => {
if (response.data.error) {
this.update.status = 'exception';
this.update.html = '<div class="text-danger"><i class="fa fa-times update-error"></i> ' + response.data.message + '</div>';
Expand All @@ -131,11 +134,9 @@ const app = new Vue({
}

if (!response.data.error && !response.data.redirect) {
let self = this;

setTimeout(function() {
self.next();
}, 800);
this.next();
}.bind(this), 800);
}

if (response.data.redirect) {
Expand Down

0 comments on commit 86c06e2

Please sign in to comment.