diff --git a/app/Http/Controllers/Install/Updates.php b/app/Http/Controllers/Install/Updates.php
index 29c71f1d3..aee0b55bb 100644
--- a/app/Http/Controllers/Install/Updates.php
+++ b/app/Http/Controllers/Install/Updates.php
@@ -104,43 +104,46 @@ class Updates extends Controller
*/
public function steps(Request $request)
{
- $json = [];
- $json['step'] = [];
+ $steps = [];
$name = $request['name'];
- $version = $request['version'];
// Download
- $json['step'][] = [
+ $steps[] = [
'text' => trans('modules.installation.download', ['module' => $name]),
'url' => url('install/updates/download')
];
// Unzip
- $json['step'][] = [
+ $steps[] = [
'text' => trans('modules.installation.unzip', ['module' => $name]),
'url' => url('install/updates/unzip')
];
// File Copy
- $json['step'][] = [
+ $steps[] = [
'text' => trans('modules.installation.file_copy', ['module' => $name]),
'url' => url('install/updates/file-copy')
];
// Finish installation
- $json['step'][] = [
+ $steps[] = [
'text' => trans('modules.installation.finish', ['module' => $name]),
'url' => url('install/updates/finish')
];
// Redirect
- $json['step'][] = [
+ $steps[] = [
'text' => trans('modules.installation.redirect', ['module' => $name]),
'url' => url('install/updates/redirect')
];
- return response()->json($json);
+ return response()->json([
+ 'success' => true,
+ 'error' => false,
+ 'data' => $steps,
+ 'message' => null
+ ]);
}
/**
diff --git a/app/Utilities/Updater.php b/app/Utilities/Updater.php
index ad1309f14..7eeb028b7 100644
--- a/app/Utilities/Updater.php
+++ b/app/Utilities/Updater.php
@@ -43,7 +43,8 @@ class Updater
if ($response instanceof RequestException) {
return [
'success' => false,
- 'errors' => trans('modules.errors.download', ['module' => $name]),
+ 'error' => true,
+ 'message' => trans('modules.errors.download', ['module' => $alias]),
'data' => [
'path' => $path
]
@@ -69,7 +70,8 @@ class Updater
if (!$uploaded) {
return [
'success' => false,
- 'errors' => trans('modules.errors.zip', ['module' => $alias]),
+ 'error' => true,
+ 'message' => trans('modules.errors.zip', ['module' => $alias]),
'data' => [
'path' => $path
]
@@ -81,7 +83,8 @@ class Updater
return [
'success' => true,
- 'errors' => false,
+ 'error' => false,
+ 'message' => null,
'data' => [
'path' => $path
]
@@ -89,7 +92,8 @@ class Updater
} catch (\Exception $e) {
return [
'success' => false,
- 'errors' => trans('modules.errors.download', ['module' => $alias]),
+ 'error' => true,
+ 'message' => trans('modules.errors.download', ['module' => $alias]),
'data' => []
];
}
@@ -97,7 +101,8 @@ class Updater
return [
'success' => false,
- 'errors' => trans('modules.errors.download', ['module' => $alias]),
+ 'error' => true,
+ 'message' => trans('modules.errors.download', ['module' => $alias]),
'data' => [
'path' => $path
]
@@ -116,7 +121,8 @@ class Updater
if (($zip->open($file) !== true) || !$zip->extractTo($temp_path)) {
return [
'success' => false,
- 'errors' => trans('modules.errors.unzip', ['module' => $alias]),
+ 'error' => true,
+ 'message' => trans('modules.errors.unzip', ['module' => $alias]),
'data' => [
'path' => $path
]
@@ -133,7 +139,8 @@ class Updater
return [
'success' => true,
- 'errors' => false,
+ 'error' => false,
+ 'message' => null,
'data' => [
'path' => $path
]
@@ -141,7 +148,8 @@ class Updater
} catch (\Exception $e) {
return [
'success' => false,
- 'errors' => trans('modules.errors.unzip', ['module' => $alias]),
+ 'error' => true,
+ 'message' => trans('modules.errors.unzip', ['module' => $alias]),
'data' => []
];
}
@@ -156,7 +164,8 @@ class Updater
if (!File::copyDirectory($temp_path, base_path())) {
return [
'success' => false,
- 'errors' => trans('modules.errors.file_copy', ['module' => $alias]),
+ 'error' => true,
+ 'message' => trans('modules.errors.file_copy', ['module' => $alias]),
'data' => [
'path' => $path
]
@@ -177,7 +186,8 @@ class Updater
if (!File::copyDirectory($temp_path, $module_path)) {
return [
'success' => false,
- 'errors' => trans('modules.errors.file_copy', ['module' => $alias]),
+ 'error' => true,
+ 'message' => trans('modules.errors.file_copy', ['module' => $alias]),
'data' => [
'path' => $path
]
@@ -208,7 +218,8 @@ class Updater
return [
'success' => true,
- 'errors' => false,
+ 'error' => false,
+ 'message' => null,
'data' => [
'path' => $path
]
@@ -216,7 +227,8 @@ class Updater
} catch (\Exception $e) {
return [
'success' => false,
- 'errors' => trans('modules.errors.file_copy', ['module' => $alias]),
+ 'error' => true,
+ 'message' => trans('modules.errors.file_copy', ['module' => $alias]),
'data' => []
];
}
@@ -228,7 +240,8 @@ class Updater
if (($alias == 'core') && (version('short') != $version)) {
return [
'success' => false,
- 'errors' => trans('modules.errors.file_copy', ['module' => $alias]),
+ 'error' => true,
+ 'message' => trans('modules.errors.file_copy', ['module' => $alias]),
'data' => []
];
}
@@ -241,13 +254,15 @@ class Updater
return [
'success' => true,
- 'errors' => false,
+ 'error' => false,
+ 'message' => null,
'data' => []
];
} catch (\Exception $e) {
return [
'success' => false,
- 'errors' => trans('modules.errors.finish', ['module' => $alias]),
+ 'error' => true,
+ 'message' => trans('modules.errors.finish', ['module' => $alias]),
'data' => []
];
}
diff --git a/app/Utilities/Versions.php b/app/Utilities/Versions.php
index 03aecf414..71e71468b 100644
--- a/app/Utilities/Versions.php
+++ b/app/Utilities/Versions.php
@@ -43,7 +43,7 @@ class Versions
continue;
}
- $output .= '
'.$release->tag_name.'
';
+ $output .= '' . $release->tag_name . '
';
$output .= $parsedown->text($release->body);
diff --git a/resources/assets/js/views/install/update.js b/resources/assets/js/views/install/update.js
new file mode 100644
index 000000000..8e1309945
--- /dev/null
+++ b/resources/assets/js/views/install/update.js
@@ -0,0 +1,145 @@
+/**
+ * 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';
+
+import Global from './../../mixins/global';
+
+import {Progress} from 'element-ui';
+
+Vue.use(Progress);
+
+const app = new Vue({
+ el: '#app',
+
+ mixins: [
+ Global
+ ],
+
+ components: {
+ [Progress.name]: Progress,
+ },
+
+ data: function () {
+ return {
+ changelog: {
+ show:false,
+ html: null
+ },
+ update: {
+ steps: [],
+ steps_total: 0,
+ total: 0,
+ path: '',
+ status: 'success',
+ html: ''
+ },
+ page: 'check',
+ name: null,
+ version: null
+ }
+ },
+
+ mounted() {
+ if (document.getElementById('page') != null && document.getElementById('page').value == 'update') {
+ this.steps();
+ }
+ },
+
+ methods: {
+ onChangelog() {
+ axios.get(url + '/install/updates/changelog')
+ .then(response => {
+ this.changelog.show = true;
+ this.changelog.html = response.data;
+ })
+ .catch(e => {
+ this.errors.push(e)
+ })
+ .finally(function () {
+ // always executed
+ });
+ },
+
+ steps() {
+ let name = document.getElementById('name').value;
+
+ axios.post(url + '/install/updates/steps', {
+ name: name,
+ version: version
+ })
+ .then(response => {
+ if (response.data.error) {
+ this.update.status = 'exception';
+ this.update.html = '' + response.data.message + '
';
+ }
+
+ // Set steps
+ if (response.data.data) {
+ this.update.steps = response.data.data;
+ this.update.steps_total = this.update.steps.length;
+
+ this.next();
+ }
+ })
+ .catch(error => {
+ });
+ },
+
+ next() {
+ let data = this.update.steps.shift();
+
+ let name = document.getElementById('name').value;
+ let alias = document.getElementById('alias').value;
+ let version = document.getElementById('version').value;
+ let installed = document.getElementById('installed').value;
+
+ if (data) {
+ this.update.total = (100 - ((this.update.steps.length / this.update.steps_total) * 100));
+
+ this.update.html = ' ' + data['text'] + ' ';
+
+ axios.post(data.url, {
+ name: name,
+ alias: alias,
+ version: version,
+ installed: installed,
+ path: this.update.path,
+ })
+ .then(response => {
+ if (response.data.error) {
+ this.update.status = 'exception';
+ this.update.html = ' ' + response.data.message + '
';
+ }
+
+ if (response.data.success) {
+ this.update.status = 'success';
+ }
+
+ if (response.data.data.path) {
+ this.update.path = response.data.data.path;
+ }
+
+ if (!response.data.error && !response.data.redirect) {
+ let self = this;
+
+ setTimeout(function() {
+ self.next();
+ }, 800);
+ }
+
+ if (response.data.redirect) {
+ window.location = response.data.redirect;
+ }
+ })
+ .catch(error => {
+ });
+ }
+ }
+ }
+});
diff --git a/resources/views/install/updates/edit.blade.php b/resources/views/install/updates/edit.blade.php
index e65555235..83489a0c3 100644
--- a/resources/views/install/updates/edit.blade.php
+++ b/resources/views/install/updates/edit.blade.php
@@ -3,7 +3,11 @@
@section('title', trans_choice('general.updates', 2))
@section('new_button')
- {{ trans('updates.check') }}
+
+
+ {{ trans('updates.check') }}
+
+
@endsection
@section('content')
@@ -14,100 +18,20 @@
-
-
- {{ trans('modules.installation.start', ['module' => $name]) }}
-
-
+
-
+
+
+ {{ Form::hidden('page', 'update', ['id' => 'page']) }}
+ {{ Form::hidden('name', $name, ['id' => 'name']) }}
+ {{ Form::hidden('version', $version, ['id' => 'version']) }}
+ {{ Form::hidden('alias', $alias, ['id' => 'alias']) }}
+ {{ Form::hidden('installed', $installed, ['id' => 'installed']) }}
@endsection
-@push('scripts')
-
+@push('scripts_start')
+
@endpush
diff --git a/resources/views/install/updates/index.blade.php b/resources/views/install/updates/index.blade.php
index f805c5d1e..b24a90e33 100644
--- a/resources/views/install/updates/index.blade.php
+++ b/resources/views/install/updates/index.blade.php
@@ -23,8 +23,13 @@
{{ trans('updates.new_core') }}
-
-
+
+
@endif
@@ -56,7 +61,9 @@
{{ $module->installed }} |
{{ $module->latest }} |
- {{ trans_choice('general.updates', 1) }}
+
+ {{ trans_choice('general.updates', 1) }}
+
|
@endforeach
@@ -73,4 +80,18 @@
+
+
+
+
+
+
@endsection
+
+@push('scripts_start')
+
+@endpush
diff --git a/routes/admin.php b/routes/admin.php
index df58fa116..3a0685d70 100644
--- a/routes/admin.php
+++ b/routes/admin.php
@@ -199,6 +199,7 @@ Route::group(['prefix' => 'install'], function () {
Route::post('updates/file-copy', 'Install\Updates@fileCopy')->middleware('api.key')->name('updates.copy');
Route::post('updates/migrate', 'Install\Updates@migrate')->name('updates.migrate');
Route::post('updates/finish', 'Install\Updates@finish')->name('updates.finish');
+ Route::post('updates/redirect', 'Install\Updates@redirect')->name('updates.redirect');
Route::resource('updates', 'Install\Updates');
});
diff --git a/webpack.mix.js b/webpack.mix.js
index 684dcf31d..aba132fbc 100644
--- a/webpack.mix.js
+++ b/webpack.mix.js
@@ -47,6 +47,7 @@ mix
// Install
.js('resources/assets/js/install.js', 'public/js')
+ .js('resources/assets/js/views/install/update.js', 'public/js/install')
// Modules
.js('resources/assets/js/views/modules/item.js', 'public/js/modules')