mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-18 02:34:08 +00:00
Add support for release channels (insider release channel) in Updater
This commit is contained in:
@@ -10,14 +10,21 @@ class AppVersionController extends Controller
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
$version = Setting::getSetting('version');
|
||||
|
||||
$channel = Setting::getSetting('updater_channel');
|
||||
if (is_null($channel)) {
|
||||
$channel = 'stable';
|
||||
Setting::setSetting('updater_channel', 'stable'); // default.
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'version' => $version,
|
||||
'channel' => $channel,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,9 @@ class CheckVersionController extends Controller
|
||||
|
||||
set_time_limit(600); // 10 minutes
|
||||
|
||||
$json = Updater::checkForUpdate(Setting::getSetting('version'));
|
||||
$channel = $request->get('channel', 'stable');
|
||||
$response = Updater::checkForUpdate(Setting::getSetting('version'), $channel);
|
||||
|
||||
return response()->json($json);
|
||||
return response()->json($response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,19 @@ class Updater
|
||||
{
|
||||
use SiteApi;
|
||||
|
||||
public static function checkForUpdate($installed_version)
|
||||
public static function checkForUpdate($installed_version, $updater_channel = 'stable')
|
||||
{
|
||||
$data = null;
|
||||
$url = 'releases/update-check/'.$installed_version;
|
||||
$url = sprintf('releases/update-check/%s?channel=%s', $installed_version, $updater_channel);
|
||||
|
||||
$response = static::getRemote($url, ['timeout' => 100, 'track_redirects' => true]);
|
||||
|
||||
$data = (object) ['success' => false, 'release' => null];
|
||||
if ($response && ($response->getStatusCode() == 200)) {
|
||||
$data = $response->getBody()->getContents();
|
||||
$data = json_decode($data);
|
||||
}
|
||||
|
||||
$data = json_decode($data);
|
||||
|
||||
if ($data->success && $data->release && property_exists($data->release, 'extensions')) {
|
||||
$extensions = [];
|
||||
foreach ($data->release->extensions as $extension) {
|
||||
|
||||
@@ -1272,6 +1272,7 @@
|
||||
"title": "Update App",
|
||||
"description": "You can easily update InvoiceShelf by checking for a new update by clicking the button below",
|
||||
"check_update": "Check for updates",
|
||||
"insider_consent" : "Opt-in for Insider releases. Recommended for testing purposes only.",
|
||||
"avail_update": "New Update available",
|
||||
"next_version": "Next version",
|
||||
"requirements": "Requirements",
|
||||
|
||||
@@ -8,11 +8,12 @@
|
||||
{{ $t('settings.update_app.current_version') }}
|
||||
</label>
|
||||
|
||||
<div
|
||||
class="
|
||||
<div class="w-full border-b-2 border-gray-100 border-solid pb-4">
|
||||
<div
|
||||
class="
|
||||
box-border
|
||||
flex
|
||||
w-16
|
||||
inline-block
|
||||
w-auto
|
||||
p-3
|
||||
my-2
|
||||
text-sm text-gray-600
|
||||
@@ -21,8 +22,13 @@
|
||||
rounded-md
|
||||
version
|
||||
"
|
||||
>
|
||||
{{ currentVersion }}
|
||||
>
|
||||
{{ currentVersion }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="w-full pt-4">
|
||||
<BaseCheckbox v-model="insiderChannel" :label="$t('settings.update_app.insider_consent')"/>
|
||||
</div>
|
||||
|
||||
<BaseButton
|
||||
@@ -71,8 +77,8 @@
|
||||
<div
|
||||
class="
|
||||
box-border
|
||||
flex
|
||||
w-16
|
||||
inline-block
|
||||
w-auto
|
||||
p-3
|
||||
my-2
|
||||
text-sm text-gray-600
|
||||
@@ -204,6 +210,7 @@ import { handleError } from '@/scripts/helpers/error-handling'
|
||||
import { useCompanyStore } from '@/scripts/admin/stores/company'
|
||||
import { useExchangeRateStore } from '@/scripts/admin/stores/exchange-rate'
|
||||
import { useDialogStore } from '@/scripts/stores/dialog'
|
||||
import BaseCheckbox from "@/scripts/components/base/BaseCheckbox.vue";
|
||||
|
||||
const notificationStore = useNotificationStore()
|
||||
const dialogStore = useDialogStore()
|
||||
@@ -216,6 +223,7 @@ let isCheckingforUpdate = ref(false)
|
||||
let description = ref('')
|
||||
let changelog = ref('');
|
||||
let currentVersion = ref('')
|
||||
let insiderChannel = ref('')
|
||||
let requiredExtentions = ref(null)
|
||||
let deletedFiles = ref(null)
|
||||
let isUpdating = ref(false)
|
||||
@@ -283,6 +291,7 @@ window.addEventListener('beforeunload', (event) => {
|
||||
|
||||
axios.get('/api/v1/app/version').then((res) => {
|
||||
currentVersion.value = res.data.version
|
||||
insiderChannel.value = res.data.channel === 'insider'
|
||||
})
|
||||
|
||||
// comapnyStore
|
||||
@@ -323,7 +332,11 @@ function statusClass(step) {
|
||||
async function checkUpdate() {
|
||||
try {
|
||||
isCheckingforUpdate.value = true
|
||||
let response = await axios.get('/api/v1/check/update')
|
||||
let response = await axios.get('/api/v1/check/update', {
|
||||
params: {
|
||||
channel: insiderChannel ? 'insider' : ''
|
||||
}
|
||||
});
|
||||
isCheckingforUpdate.value = false
|
||||
if (!response.data.release) {
|
||||
notificationStore.showNotification({
|
||||
@@ -342,6 +355,7 @@ async function checkUpdate() {
|
||||
requiredExtentions.value = response.data.release.extensions
|
||||
isUpdateAvailable.value = true
|
||||
minPhpVesrion.value = response.data.release.min_php_version
|
||||
deletedFiles.value = response.data.release.deleted_files
|
||||
}
|
||||
} catch (e) {
|
||||
isUpdateAvailable.value = false
|
||||
|
||||
Reference in New Issue
Block a user