Skip to content

Commit 82acf60

Browse files
committed
Show Nayra service info
1 parent 695df32 commit 82acf60

3 files changed

Lines changed: 69 additions & 17 deletions

File tree

‎ProcessMaker/Http/Controllers/AboutController.php‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
namespace ProcessMaker\Http\Controllers;
44

55
use Exception;
6+
use Illuminate\Support\Facades\Cache;
67
use Illuminate\Support\Facades\Http;
78
use Illuminate\Support\Facades\Log;
9+
use ProcessMaker\Facades\MessageBrokerService;
810
use ProcessMaker\Models\Setting;
911

1012
class AboutController extends Controller
@@ -70,7 +72,13 @@ public function index()
7072
$microServices = [$aiMicroService];
7173
}
7274

73-
return view('about.index',
75+
$nayraMicroService = $this->getNayraMicroServiceAbout();
76+
if ($nayraMicroService) {
77+
$microServices[] = $nayraMicroService;
78+
}
79+
80+
$view = request()->get('partial') === 'ms' ? 'about.microservices' : 'about.index';
81+
return view($view,
7482
compact(
7583
'packages',
7684
'indexedSearch',
@@ -93,4 +101,27 @@ private function getAiMicroService()
93101

94102
return null;
95103
}
104+
105+
/**
106+
* Get the Nayra microservice about information from cache or send about message to receive it.
107+
*
108+
* @return array|null
109+
*/
110+
private function getNayraMicroServiceAbout(): ?array
111+
{
112+
if (config('app.message_broker_driver') !== 'default') {
113+
$about = Cache::get('nayra.about', null);
114+
if (!$about) {
115+
// Send about message to receive about information from nayra service
116+
MessageBrokerService::sendAboutMessage();
117+
$about = [
118+
'name' => 'processmaker/nayra-service',
119+
'waiting' => true,
120+
];
121+
}
122+
return $about;
123+
}
124+
125+
return null;
126+
}
96127
}

‎resources/views/about/index.blade.php‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,9 @@
4545
</ul>
4646
@endif
4747
@if ($microServices)
48-
<h5>{{ __('Microservices') }}</h5>
49-
<ul class="list-group-flush p-0">
50-
@foreach ($microServices as $microService)
51-
<li class="list-group-item">
52-
<h6><i class="fas fa-puzzle-piece mr-2"></i>{{ ucfirst(trans($microService['name'])) }}</h6>
53-
<small>
54-
@if (isset($microService['description']))
55-
<div>{{ $microService['description'] }}</div>
56-
@endif
57-
@if (isset($microService['version']))
58-
<div><strong>Version:</strong> {{ $microService['version'] }}</div>
59-
@endif
60-
</small>
61-
</li>
62-
@endforeach
63-
</ul>
48+
<div id="ms-section">
49+
@include('about.microservices')
50+
</div>
6451
@endif
6552
<div><strong>{{ __('Indexed Search') }}</strong>: {{ $indexedSearch ? __('Enabled') : __('Disabled') }}</div>
6653
<hr>
@@ -76,12 +63,27 @@
7663
</div>
7764
</div>
7865
</div>
66+
<script>
67+
async function refreshMs() {
68+
const update = await (await fetch('?partial=ms')).text();
69+
document.getElementById('ms-section').innerHTML = update;
70+
const hasWaiting = update.indexOf('waiting') > -1;
71+
if (hasWaiting) {
72+
setTimeout(refreshMs, 1000);
73+
}
74+
}
75+
setTimeout(refreshMs, 1000);
76+
</script>
7977
@endsection
8078

8179
@section('css')
8280
<style>
8381
.about-logo {
8482
max-width: 300px;
8583
}
84+
.waiting {
85+
width: 1rem;
86+
height: 1rem;
87+
}
8688
</style>
8789
@endsection
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<h5>{{ __('Microservices') }}</h5>
2+
<ul class="list-group-flush p-0">
3+
@foreach ($microServices as $microService)
4+
<li class="list-group-item">
5+
<h6><i class="fas fa-puzzle-piece mr-2"></i>{{ ucfirst(trans($microService['name'])) }}</h6>
6+
<small>
7+
@if (isset($microService['description']))
8+
<div>{{ $microService['description'] }}</div>
9+
@endif
10+
@if (isset($microService['version']))
11+
<div><strong>Version:</strong> {{ $microService['version'] }}</div>
12+
@endif
13+
</small>
14+
@if (!empty($microService['waiting']))
15+
<i class="fas fa-sync fa-spin text-secondary waiting"></i>
16+
@endif
17+
</li>
18+
@endforeach
19+
</ul>

0 commit comments

Comments
 (0)