From 86c06e27a1ba56bc6ac680f2191653f87748ba2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Mon, 18 May 2020 16:41:06 +0300 Subject: [PATCH] Update progress bar added asyn --- resources/assets/js/views/install/update.js | 33 +++++++++++---------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/resources/assets/js/views/install/update.js b/resources/assets/js/views/install/update.js index eeedeec30..c78ab6c74 100644 --- a/resources/assets/js/views/install/update.js +++ b/resources/assets/js/views/install/update.js @@ -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; }) @@ -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 = '
' + response.data.message + '
'; @@ -96,7 +98,7 @@ const app = new Vue({ }); }, - next() { + async next() { let data = this.update.steps.shift(); let name = document.getElementById('name').value; @@ -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 = ' ' + data['text'] + '
'; - 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 = '
' + response.data.message + '
'; @@ -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) {