App store install purchase app

This commit is contained in:
Cüneyt Şentürk 2019-11-20 17:11:35 +03:00
parent 8d50c8cedb
commit 771d73f0d1
7 changed files with 143 additions and 21 deletions

View File

@ -78,31 +78,34 @@ class Item extends Controller
*/ */
public function steps(Request $request) public function steps(Request $request)
{ {
$json = []; $steps = [];
$json['step'] = [];
$name = $request['name']; $name = $request['name'];
$version = $request['version'];
// Download // Download
$json['step'][] = [ $steps[] = [
'text' => trans('modules.installation.download', ['module' => $name]), 'text' => trans('modules.installation.download', ['module' => $name]),
'url' => url('apps/download') 'url' => url('apps/download')
]; ];
// Unzip // Unzip
$json['step'][] = [ $steps[] = [
'text' => trans('modules.installation.unzip', ['module' => $name]), 'text' => trans('modules.installation.unzip', ['module' => $name]),
'url' => url('apps/unzip') 'url' => url('apps/unzip')
]; ];
// Download // Download
$json['step'][] = [ $steps[] = [
'text' => trans('modules.installation.install', ['module' => $name]), 'text' => trans('modules.installation.install', ['module' => $name]),
'url' => url('apps/install') 'url' => url('apps/install')
]; ];
return response()->json($json); return response()->json([
'success' => true,
'error' => false,
'data' => $steps,
'message' => null
]);
} }
/** /**

View File

@ -335,14 +335,16 @@ trait Modules
return [ return [
'success' => true, 'success' => true,
'errors' => false, 'error' => false,
'message' => null,
'data' => $data, 'data' => $data,
]; ];
} }
return [ return [
'success' => false, 'success' => false,
'errors' => true, 'error' => true,
'message' => null,
'data' => null, 'data' => null,
]; ];
} }
@ -359,7 +361,8 @@ trait Modules
if (!$zip->open($file) || !$zip->extractTo($temp_path)) { if (!$zip->open($file) || !$zip->extractTo($temp_path)) {
return [ return [
'success' => false, 'success' => false,
'errors' => true, 'error' => true,
'message' => null,
'data' => null, 'data' => null,
]; ];
} }
@ -375,7 +378,8 @@ trait Modules
return [ return [
'success' => true, 'success' => true,
'errors' => false, 'error' => false,
'message' => null,
'data' => $data, 'data' => $data,
]; ];
} }
@ -414,8 +418,9 @@ trait Modules
return [ return [
'success' => true, 'success' => true,
'installed' => url("apps/post/" . $module->alias), 'redirect' => url("apps/post/" . $module->alias),
'errors' => false, 'error' => false,
'message' => null,
'data' => $data, 'data' => $data,
]; ];
} }
@ -439,7 +444,8 @@ trait Modules
return [ return [
'success' => true, 'success' => true,
'errors' => false, 'error' => false,
'message' => null,
'data' => $data 'data' => $data
]; ];
} }
@ -460,7 +466,8 @@ trait Modules
return [ return [
'success' => true, 'success' => true,
'errors' => false, 'error' => false,
'message' => null,
'data' => $data 'data' => $data
]; ];
} }
@ -481,7 +488,8 @@ trait Modules
return [ return [
'success' => true, 'success' => true,
'errors' => false, 'error' => false,
'message' => null,
'data' => $data 'data' => $data
]; ];
} }

View File

@ -100,7 +100,7 @@ const app = new Vue({
let installed = document.getElementById('installed').value; let installed = document.getElementById('installed').value;
if (data) { if (data) {
this.update.total = (100 - ((this.update.steps.length / this.update.steps_total) * 100)); this.update.total = (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>'; this.update.html = '<span class="text-default"><i class="fa fa-spinner fa-spin update-spin"></i> ' + data['text'] + '</span> </br>';

View File

@ -10,6 +10,10 @@ import Vue from 'vue';
import Global from '../../mixins/global'; import Global from '../../mixins/global';
import {Progress} from 'element-ui';
Vue.use(Progress);
const app = new Vue({ const app = new Vue({
el: '#app', el: '#app',
@ -17,6 +21,10 @@ const app = new Vue({
Global Global
], ],
components: {
[Progress.name]: Progress,
},
mounted() { mounted() {
this.onGetReviews('', 1); this.onGetReviews('', 1);
}, },
@ -24,7 +32,17 @@ const app = new Vue({
data: function () { data: function () {
return { return {
reviews: '', reviews: '',
faq: false faq: false,
installation: {
show: false,
steps: [],
steps_total: 0,
total: 0,
path: '',
version: '',
status: 'success',
html: ''
},
} }
}, },
@ -43,6 +61,77 @@ const app = new Vue({
onShowFaq() { onShowFaq() {
this.faq = true; this.faq = true;
},
onInstall(path, name, version) {
this.installation.show = true;
this.installation.total = 0;
this.installation.path = path;
this.installation.version = version;
axios.post(url + '/apps/steps', {
name: name,
version: version
})
.then(response => {
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 => {
});
},
next() {
let data = this.installation.steps.shift();
if (data) {
this.installation.total = (100 - ((this.installation.steps.length / this.installation.steps_total) * 100)).toFixed(0);
this.installation.html = '<span class="text-default"><i class="fa fa-spinner fa-spin update-spin"></i> ' + data['text'] + '</span> </br>';
axios.post(data.url, {
version: this.installation.version,
path: this.installation.path,
})
.then(response => {
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) {
let self = this;
setTimeout(function() {
self.next();
}, 800);
}
if (response.data.redirect) {
window.location = response.data.redirect;
}
})
.catch(error => {
});
}
} }
} }
}); });

View File

@ -61,3 +61,7 @@
</div> </div>
@endif @endif
@endsection @endsection
@push('scripts_start')
<script src="{{ asset('public/js/modules/apps.js?v=' . version('short')) }}"></script>
@endpush

View File

@ -210,16 +210,16 @@
@else @else
@permission('create-modules-item') @permission('create-modules-item')
@if ($module->install) @if ($module->install)
<a href="{{ $module->action_url }}" class="btn btn-success btn-block" id="install-module"> <button type="button" @click="onInstall('{{ $module->action_url }}', '{{ $module->name }}', '{{ $module->version }}')" class="btn btn-success btn-block" id="install-module">
{{ trans('modules.install') }} {{ trans('modules.install') }}
</a> </button>
@else @else
<a href="{{ $module->action_url }}" class="btn btn-success btn-block" target="_blank"> <a href="{{ $module->action_url }}" class="btn btn-success btn-block" target="_blank">
{{ trans('modules.buy_now') }} {{ trans('modules.buy_now') }}
</a> </a>
@endif @endif
@endpermission @endpermission
@endif @endif
@if ($module->purchase_faq) @if ($module->purchase_faq)
<div class="text-center mt-3"> <div class="text-center mt-3">
@ -293,6 +293,23 @@
</template> </template>
</akaunting-modal> </akaunting-modal>
@endif @endif
@if ($module->install)
<akaunting-modal :show="installation.show"
:title="'{{ trans('modules.installation.header') }}'"
@cancel="installation.show = false">
<template #modal-body>
<div class="modal-body">
<el-progress :text-inside="true" :stroke-width="24" :percentage="installation.total" :status="installation.status"></el-progress>
<div id="progress-text" v-html="installation.html"></div>
</div>
</template>
<template #card-footer>
<span></span>
</template>
</akaunting-modal>
@endif
@endsection @endsection
@push('scripts_start') @push('scripts_start')

View File

@ -5,6 +5,7 @@
<div class="row"> <div class="row">
<div class="col-9"> <div class="col-9">
{!! Form::select('category', $categories, request('category'), ['class' => 'form-control form-control-sm table-header-search mt-0']) !!} {!! Form::select('category', $categories, request('category'), ['class' => 'form-control form-control-sm table-header-search mt-0']) !!}
<a href="{{ route('apps.paid') }}" class="btn btn-sm btn-white card-buttons filter-button ml-2">{{ trans('modules.top_paid') }}</a> <a href="{{ route('apps.paid') }}" class="btn btn-sm btn-white card-buttons filter-button ml-2">{{ trans('modules.top_paid') }}</a>
<a href="{{ route('apps.new') }}" class="btn btn-sm btn-white card-buttons filter-button">{{ trans('modules.new') }}</a> <a href="{{ route('apps.new') }}" class="btn btn-sm btn-white card-buttons filter-button">{{ trans('modules.new') }}</a>
<a href="{{ route('apps.free') }}" class="btn btn-sm btn-white card-buttons filter-button">{{ trans('modules.top_free') }}</a> <a href="{{ route('apps.free') }}" class="btn btn-sm btn-white card-buttons filter-button">{{ trans('modules.top_free') }}</a>