mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 12:11:08 -04:00
Merge branch 'auto-update' into 'master'
Auto update See merge request mohit.panjvani/crater-web!29
This commit is contained in:
@ -306,8 +306,6 @@ class EstimatesController extends Controller
|
|||||||
public function sendEstimate(Request $request)
|
public function sendEstimate(Request $request)
|
||||||
{
|
{
|
||||||
$estimate = Estimate::findOrFail($request->id);
|
$estimate = Estimate::findOrFail($request->id);
|
||||||
$estimate->status = Estimate::STATUS_SENT;
|
|
||||||
$estimate->save();
|
|
||||||
|
|
||||||
$data['estimate'] = $estimate->toArray();
|
$data['estimate'] = $estimate->toArray();
|
||||||
$userId = $data['estimate']['user_id'];
|
$userId = $data['estimate']['user_id'];
|
||||||
@ -330,6 +328,11 @@ class EstimatesController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($estimate->status == Estimate::STATUS_DRAFT) {
|
||||||
|
$estimate->status = Estimate::STATUS_SENT;
|
||||||
|
$estimate->save();
|
||||||
|
}
|
||||||
|
|
||||||
\Mail::to($email)->send(new EstimatePdf($data, $notificationEmail));
|
\Mail::to($email)->send(new EstimatePdf($data, $notificationEmail));
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|||||||
@ -371,12 +371,6 @@ class InvoicesController extends Controller
|
|||||||
{
|
{
|
||||||
$invoice = Invoice::findOrFail($request->id);
|
$invoice = Invoice::findOrFail($request->id);
|
||||||
|
|
||||||
if ($invoice->status == Invoice::STATUS_DRAFT) {
|
|
||||||
$invoice->status = Invoice::STATUS_SENT;
|
|
||||||
$invoice->sent = true;
|
|
||||||
$invoice->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
$data['invoice'] = $invoice->toArray();
|
$data['invoice'] = $invoice->toArray();
|
||||||
$userId = $data['invoice']['user_id'];
|
$userId = $data['invoice']['user_id'];
|
||||||
$data['user'] = User::find($userId)->toArray();
|
$data['user'] = User::find($userId)->toArray();
|
||||||
@ -398,6 +392,12 @@ class InvoicesController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($invoice->status == Invoice::STATUS_DRAFT) {
|
||||||
|
$invoice->status = Invoice::STATUS_SENT;
|
||||||
|
$invoice->sent = true;
|
||||||
|
$invoice->save();
|
||||||
|
}
|
||||||
|
|
||||||
\Mail::to($email)->send(new invoicePdf($data, $notificationEmail));
|
\Mail::to($email)->send(new invoicePdf($data, $notificationEmail));
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|||||||
@ -12,7 +12,7 @@ class UpdateController extends Controller
|
|||||||
{
|
{
|
||||||
set_time_limit(600); // 10 minutes
|
set_time_limit(600); // 10 minutes
|
||||||
|
|
||||||
$json = Updater::update($request->installed, $request->version);
|
$json = Updater::update($request->installed, $request->version, $request->isMinor);
|
||||||
|
|
||||||
return response()->json($json);
|
return response()->json($json);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,9 +15,9 @@ class Listener
|
|||||||
protected function check($event)
|
protected function check($event)
|
||||||
{
|
{
|
||||||
// Do not apply to the same or newer versions
|
// Do not apply to the same or newer versions
|
||||||
// if (version_compare($event->old, static::VERSION, '>=')) {
|
if (version_compare($event->old, static::VERSION, '>=')) {
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,12 +21,12 @@ class Version101 extends Listener
|
|||||||
*/
|
*/
|
||||||
public function handle(UpdateFinished $event)
|
public function handle(UpdateFinished $event)
|
||||||
{
|
{
|
||||||
// if (!$this->check($event)) {
|
if (!$this->check($event)) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
|
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
|
||||||
|
|
||||||
Setting::getSetting('version', self::VERSION);
|
Setting::setSetting('version', self::VERSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,12 +13,12 @@ class Updater
|
|||||||
{
|
{
|
||||||
use SiteApi;
|
use SiteApi;
|
||||||
|
|
||||||
public static function update($installed, $version)
|
public static function update($installed, $version, $isMinor)
|
||||||
{
|
{
|
||||||
$data = null;
|
$data = null;
|
||||||
$path = null;
|
$path = null;
|
||||||
|
|
||||||
$url = '/download/'.$version;
|
$url = '/download/'.$version.'?type=update';
|
||||||
|
|
||||||
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]);
|
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]);
|
||||||
|
|
||||||
@ -40,8 +40,8 @@ class Updater
|
|||||||
// Create temp directory
|
// Create temp directory
|
||||||
$path = 'temp-' . md5(mt_rand());
|
$path = 'temp-' . md5(mt_rand());
|
||||||
$path2 = 'temp2-' . md5(mt_rand());
|
$path2 = 'temp2-' . md5(mt_rand());
|
||||||
$temp_path = storage_path('app/temp') . '/' . $path;
|
$temp_path = storage_path('app') . '/' . $path;
|
||||||
$temp_path2 = storage_path('app/temp') . '/' . $path2;
|
$temp_path2 = storage_path('app') . '/' . $path2;
|
||||||
|
|
||||||
if (!File::isDirectory($temp_path)) {
|
if (!File::isDirectory($temp_path)) {
|
||||||
File::makeDirectory($temp_path);
|
File::makeDirectory($temp_path);
|
||||||
@ -78,7 +78,9 @@ class Updater
|
|||||||
File::deleteDirectory($temp_path2);
|
File::deleteDirectory($temp_path2);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
event(new UpdateFinished($installed, $version));
|
if (!$isMinor) {
|
||||||
|
event(new UpdateFinished($installed, $version));
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'success' => true,
|
'success' => true,
|
||||||
|
|||||||
@ -668,8 +668,13 @@ export default {
|
|||||||
},
|
},
|
||||||
update_app: {
|
update_app: {
|
||||||
title: 'Update App',
|
title: 'Update App',
|
||||||
description: 'update app description',
|
description: 'You can easily update Crater by checking for a new update by clicking the button below',
|
||||||
update: 'Update'
|
check_update: 'Check for updates',
|
||||||
|
avail_update: 'New Update available',
|
||||||
|
next_version: 'Next version',
|
||||||
|
update: 'Update',
|
||||||
|
update_progress: 'Update in progress...',
|
||||||
|
progress_text: 'It will just take a few minutes. Please do not refresh the screen or close the window before the update finishes'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
wizard: {
|
wizard: {
|
||||||
|
|||||||
@ -6,50 +6,89 @@
|
|||||||
<p class="page-sub-title">
|
<p class="page-sub-title">
|
||||||
{{ $t('settings.update_app.description') }}
|
{{ $t('settings.update_app.description') }}
|
||||||
</p>
|
</p>
|
||||||
<base-button size="large" icon="sync-alt" color="theme" @click="onUpdateApp">
|
<label class="input-label">Current version</label><br>
|
||||||
{{ $t('settings.update_app.update') }}
|
<label class="version">1.0.0</label>
|
||||||
|
<base-button :outline="true" size="large" color="theme" @click="checkUpdate">
|
||||||
|
<font-awesome-icon :class="{'update': isUpdateAvail}" style="margin-right: 5px;" icon="sync-alt" />
|
||||||
|
{{ $t('settings.update_app.check_update') }}
|
||||||
</base-button>
|
</base-button>
|
||||||
<div v-if="isShowProgressBar" class="progress mt-4">
|
<hr>
|
||||||
<div
|
<div class="mt-4 content">
|
||||||
:style="[{'width': progress+'%'}]"
|
<h3 class="page-title">{{ $t('settings.update_app.avail_update') }}</h3>
|
||||||
class="progress-bar progress-bar-striped progress-bar-animated"
|
<label class="input-label">{{ $t('settings.update_app.next_version') }}</label><br>
|
||||||
role="progressbar"
|
<label class="version">{{ updateData.version }}</label>
|
||||||
aria-valuenow="0"
|
<p class="page-sub-title">
|
||||||
aria-valuemin="0"
|
{{ description }}
|
||||||
aria-valuemax="100"
|
</p>
|
||||||
/>
|
<base-button size="large" color="theme" @click="onUpdateApp">
|
||||||
|
{{ $t('settings.update_app.update') }}
|
||||||
|
</base-button>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- <div>
|
||||||
|
<h3 class="page-title">{{ $t('settings.update_app.update_progress') }}</h3>
|
||||||
|
<p class="page-sub-title">
|
||||||
|
{{ $t('settings.update_app.progress_text') }}
|
||||||
|
</p>
|
||||||
|
<font-awesome-icon icon="spinner" class="fa-spin"/>
|
||||||
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import { mapActions, mapGetters } from 'vuex'
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
isShowProgressBar: false,
|
isShowProgressBar: false,
|
||||||
|
isUpdateAvail: false,
|
||||||
progress: 10,
|
progress: 10,
|
||||||
interval: null
|
interval: null,
|
||||||
|
description: '',
|
||||||
|
updateData: {
|
||||||
|
isMinor: Boolean,
|
||||||
|
installed: '',
|
||||||
|
version: ''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onUpdateApp () {
|
async onUpdateApp () {
|
||||||
this.isShowProgressBar = true
|
const data = this.updateData
|
||||||
this.interval = setInterval(() => {
|
let response = await axios.post('/api/update', data)
|
||||||
if (this.progress >= 100) {
|
console.log(response.data)
|
||||||
clearInterval(this.interval)
|
},
|
||||||
setTimeout(() => {
|
async checkUpdate () {
|
||||||
this.isShowProgressBar = false
|
let response = await axios.get('/api/check/update')
|
||||||
}, 1000)
|
console.log(response.data)
|
||||||
}
|
if (response.data) {
|
||||||
this.progress += 10
|
this.updateData.isMinor = response.data.is_minor
|
||||||
}, 250)
|
this.updateData.version = response.data.version.version
|
||||||
|
this.updateData.description = response.data.version.description
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.update {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
animation: rotating 1s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes rotating {
|
||||||
|
0% {
|
||||||
|
transform: rotate(0);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
9
resources/assets/sass/pages/settings.scss
vendored
9
resources/assets/sass/pages/settings.scss
vendored
@ -150,6 +150,15 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.version {
|
||||||
|
background: #EAF1FB;
|
||||||
|
border: 1px solid #EAF1FB;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 10px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media(max-width: $x-small-breakpoint ) {
|
@media(max-width: $x-small-breakpoint ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user