From b3a9291d44ea75e8c27872e8ae9a5b8a5f004237 Mon Sep 17 00:00:00 2001 From: Aman upadhyay Date: Thu, 14 Nov 2019 19:40:56 +0530 Subject: [PATCH 1/7] update front changes --- resources/assets/js/plugins/en.js | 2 ++ .../assets/js/views/settings/UpdateApp.vue | 33 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/resources/assets/js/plugins/en.js b/resources/assets/js/plugins/en.js index 2ad510fb..32aff377 100644 --- a/resources/assets/js/plugins/en.js +++ b/resources/assets/js/plugins/en.js @@ -665,6 +665,8 @@ export default { update_app: { title: 'Update App', description: 'update app description', + check_update: 'Check for updates', + avail_update: 'Update available', update: 'Update' } }, diff --git a/resources/assets/js/views/settings/UpdateApp.vue b/resources/assets/js/views/settings/UpdateApp.vue index 4c3183d2..2c048103 100644 --- a/resources/assets/js/views/settings/UpdateApp.vue +++ b/resources/assets/js/views/settings/UpdateApp.vue @@ -6,9 +6,18 @@

{{ $t('settings.update_app.description') }}

- - {{ $t('settings.update_app.update') }} +

Current version: 1.0.0

+ + + {{ $t('settings.update_app.check_update') }} +
+ +

Latest version: 2.0.0

+ + {{ $t('settings.update_app.update') }} + +
+ + From 1051b03b007e005fcbd1946bd3429c077b50a70d Mon Sep 17 00:00:00 2001 From: jayvirsinh_gohil Date: Fri, 15 Nov 2019 13:39:57 +0530 Subject: [PATCH 2/7] refactor auto updateand invoice and estimate send --- app/Http/Controllers/EstimatesController.php | 7 +++++-- app/Http/Controllers/InvoicesController.php | 12 ++++++------ app/Http/Controllers/UpdateController.php | 2 +- app/Space/Updater.php | 8 +++++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/EstimatesController.php b/app/Http/Controllers/EstimatesController.php index ef84d541..39a69c1c 100644 --- a/app/Http/Controllers/EstimatesController.php +++ b/app/Http/Controllers/EstimatesController.php @@ -306,8 +306,6 @@ class EstimatesController extends Controller public function sendEstimate(Request $request) { $estimate = Estimate::findOrFail($request->id); - $estimate->status = Estimate::STATUS_SENT; - $estimate->save(); $data['estimate'] = $estimate->toArray(); $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)); return response()->json([ diff --git a/app/Http/Controllers/InvoicesController.php b/app/Http/Controllers/InvoicesController.php index 7eaebb7b..a91df038 100644 --- a/app/Http/Controllers/InvoicesController.php +++ b/app/Http/Controllers/InvoicesController.php @@ -371,12 +371,6 @@ class InvoicesController extends Controller { $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(); $userId = $data['invoice']['user_id']; $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)); return response()->json([ diff --git a/app/Http/Controllers/UpdateController.php b/app/Http/Controllers/UpdateController.php index 2b1049d9..736fac56 100644 --- a/app/Http/Controllers/UpdateController.php +++ b/app/Http/Controllers/UpdateController.php @@ -12,7 +12,7 @@ class UpdateController extends Controller { 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); } diff --git a/app/Space/Updater.php b/app/Space/Updater.php index b5d8b369..2368140b 100644 --- a/app/Space/Updater.php +++ b/app/Space/Updater.php @@ -13,12 +13,12 @@ class Updater { use SiteApi; - public static function update($installed, $version) + public static function update($installed, $version, $isMinor) { $data = null; $path = null; - $url = '/download/'.$version; + $url = '/download/'.$version.'?type=update'; $response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]); @@ -78,7 +78,9 @@ class Updater File::deleteDirectory($temp_path2); try { - event(new UpdateFinished($installed, $version)); + if (!$isMinor) { + event(new UpdateFinished($installed, $version)); + } return [ 'success' => true, From 22784cc23026396b2e40a3ea3c761397c73912f2 Mon Sep 17 00:00:00 2001 From: jayvirsinh_gohil Date: Fri, 15 Nov 2019 13:46:31 +0530 Subject: [PATCH 3/7] refector listener --- app/Listeners/Updates/Listener.php | 6 +++--- app/Listeners/Updates/V10/Version101.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Listeners/Updates/Listener.php b/app/Listeners/Updates/Listener.php index 6dab62a8..f0aa524d 100644 --- a/app/Listeners/Updates/Listener.php +++ b/app/Listeners/Updates/Listener.php @@ -15,9 +15,9 @@ class Listener protected function check($event) { // Do not apply to the same or newer versions - // if (version_compare($event->old, static::VERSION, '>=')) { - // return false; - // } + if (version_compare($event->old, static::VERSION, '>=')) { + return false; + } return true; } diff --git a/app/Listeners/Updates/V10/Version101.php b/app/Listeners/Updates/V10/Version101.php index 03de4a34..ff6fe22f 100644 --- a/app/Listeners/Updates/V10/Version101.php +++ b/app/Listeners/Updates/V10/Version101.php @@ -21,12 +21,12 @@ class Version101 extends Listener */ public function handle(UpdateFinished $event) { - // if (!$this->check($event)) { - // return; - // } + if (!$this->check($event)) { + return; + } Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]); - Setting::getSetting('version', self::VERSION); + Setting::setSetting('version', self::VERSION); } } From 200d7a33df78d9e7a830b6a3f0a1adefae016d34 Mon Sep 17 00:00:00 2001 From: jayvirsinh_gohil Date: Fri, 15 Nov 2019 16:26:04 +0530 Subject: [PATCH 4/7] remove temp directory --- app/Space/Updater.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Space/Updater.php b/app/Space/Updater.php index 2368140b..6dd0b165 100644 --- a/app/Space/Updater.php +++ b/app/Space/Updater.php @@ -40,8 +40,8 @@ class Updater // Create temp directory $path = 'temp-' . md5(mt_rand()); $path2 = 'temp2-' . md5(mt_rand()); - $temp_path = storage_path('app/temp') . '/' . $path; - $temp_path2 = storage_path('app/temp') . '/' . $path2; + $temp_path = storage_path('app') . '/' . $path; + $temp_path2 = storage_path('app') . '/' . $path2; if (!File::isDirectory($temp_path)) { File::makeDirectory($temp_path); From d8948af0b18d936db4775632ba6c2b093e8bbda8 Mon Sep 17 00:00:00 2001 From: Aman upadhyay Date: Fri, 15 Nov 2019 17:42:03 +0530 Subject: [PATCH 5/7] front end changes --- resources/assets/js/plugins/en.js | 9 ++- .../assets/js/views/settings/UpdateApp.vue | 70 +++++++++++-------- resources/assets/sass/pages/settings.scss | 9 +++ 3 files changed, 55 insertions(+), 33 deletions(-) diff --git a/resources/assets/js/plugins/en.js b/resources/assets/js/plugins/en.js index 33579627..6bd34c4d 100644 --- a/resources/assets/js/plugins/en.js +++ b/resources/assets/js/plugins/en.js @@ -668,10 +668,13 @@ export default { }, 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', check_update: 'Check for updates', - avail_update: 'Update available', - update: 'Update' + 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: { diff --git a/resources/assets/js/views/settings/UpdateApp.vue b/resources/assets/js/views/settings/UpdateApp.vue index 2c048103..787d066d 100644 --- a/resources/assets/js/views/settings/UpdateApp.vue +++ b/resources/assets/js/views/settings/UpdateApp.vue @@ -6,62 +6,72 @@

{{ $t('settings.update_app.description') }}

-

Current version: 1.0.0

- +
+ + {{ $t('settings.update_app.check_update') }} -
- -

Latest version: 2.0.0

+
+
+

{{ $t('settings.update_app.avail_update') }}

+
+ +

+ {{ description }} +

{{ $t('settings.update_app.update') }}
-
-
-
+