-
Notifications
You must be signed in to change notification settings - Fork 2
/
updates.blade.php
127 lines (120 loc) · 5.75 KB
/
updates.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@extends(AdminTheme::wrapper(), ['title' => 'Updates', 'keywords' => 'WemX Updates, WemX Panel'])
@section('container')
<div class="card mb-6">
@if(Cache::has('app_updating'))
<div class="card-body">
<div class="empty-state" data-height="400" style="height: 400px;">
<div class="empty-state-icon" style="background-color: #059669; display: flex; justify-content: center; align-items: center">
<img src="/assets/src/spinners/blocks.svg" style="width: 50px;">
</div>
<h2>{{ __('admin.installing') }} {{ Cache::get('app_updating')['type'] }} {{ Cache::get('app_updating')['version'] }}</h2>
<p class="lead">
<span id="progress">{{ Cache::get('app_updating')['progress'] }}</span><span id="loading">...</span>
</p>
<a href="https://wemx.net/news" target="_blank" class="mt-4 bb">{{ __('admin.update_manually') }}</a>
</div>
</div>
<script>
let count = 0;
const loadingElement = document.getElementById('loading');
setInterval(() => {
count++;
loadingElement.textContent = '.'.repeat(count % 4);
}, 500);
const progressElement = document.getElementById('progress');
setInterval(async () => {
try {
let response = await fetch('{{ route("updates.progress") }}');
// Check if the response is successful
if (!response.ok) {
throw new Error(`Failed to load update progress, please wait 2 min or perform a manual update.`);
}
let data = await response.json();
if(data.updating) {
progressElement.innerHTML = data.progress;
}
} catch (error) {
progressElement.innerHTML = error;
console.error("There was an error fetching the data:", error);
}
}, 1500);
</script>
@else
@if(config('app.version') >= $latest_version->version)
<div class="card-body">
<div class="empty-state" data-height="400" style="height: 400px;">
<div class="empty-state-icon" style="background-color: #059669;">
<i class="fas fa-check"></i>
</div>
<h2>{{ __('admin.running_latest_version') }} ({{config('app.version')}})</h2>
<p class="lead">
{{ __('admin.running_latest_version_desc') }}
</p>
<a href="https://wemx.net/news" target="_blank" class="btn btn-success mt-4">{{ __('client.latest_news') }}</a>
@if(config('app.version') == 'dev')
<a href="{{ route('updates.install', ['version' => 'latest', 'type' => 'dev']) }}" class="btn btn-success mt-4">{{ __('admin.install_dev_version') }}</a>
@endif
<a href="{{ route('updates.index') }}" class="mt-4 bb">{{ __('admin.refresh') }}</a>
</div>
</div>
@else
<div class="card-body">
<div class="empty-state" data-height="400" style="height: 400px;">
<div class="empty-state-icon" style="background-color: #059669; display: flex; justify-content: center; align-items: center">
<i class="fas fa-download"></i>
{{-- <img src="/assets/src/spinners/blocks.svg" style="width: 50px;"> --}}
</div>
<h2>{{ __('admin.update_available') }}</h2>
<p class="lead">
{{ __('admin.update_available_desc') }}
</p>
<button type="button" data-toggle="modal" data-target="#installUpdateModal" class="btn btn-success mt-4">{{ __('admin.install') }} v{{ $latest_version->version }}</button>
<a href="https://wemx.net/news" target="_blank" class="mt-4 bb">{{ __('admin.view_changelog') }}</a>
</div>
</div>
@endif
@endif
</div>
<div class="card">
<div class="card-body">
@foreach($versions as $version)
<div class="media mb-4">
<img class="mr-3" src="/assets/core/img/logo.png" alt="wemx logo" style="width: 46px; height: 46px; border-radius: 10px">
<div class="media-body">
<h5 class="mt-0">{{ __('admin.version') }} {{ $version->version }} ({{ $version->type }})</h5>
<p class="mb-0">
{!! $version->changelog ?? __('admin.no_changelog_provided') !!}
</p>
<small>{{ Carbon::parse($version->created_at)->diffForHumans() }} ({{ Carbon::parse($version->created_at)->translatedFormat('d M Y') }})</small>
</div>
@if(config('app.version') == $version->version)
<a href="#" class="btn btn-success mt-4 disabled">{{ __('admin.installed') }}</a>
@endif
</div>
@endforeach
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="installUpdateModal" tabindex="-1" role="dialog" aria-labelledby="installUpdateModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="installUpdateModalLabel">{{ __('admin.installing_update') }} {{ $latest_version->version }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="{{ __('admin.close') }}">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="alert alert-info" role="alert">
{{ __('admin.installing_update_warn') }}
</div>
{!! $latest_version->changelog !!}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">{!! __('admin.cancel') !!}</button>
<a href="{{ route('updates.install', ['version' => $latest_version->version, 'type' => 'stable']) }}" class="btn btn-success">{{ __('admin.install') }} {{ $latest_version->version }}</a>
</div>
</div>
</div>
</div>
@endsection