Skip to content

Commit

Permalink
gate out
Browse files Browse the repository at this point in the history
  • Loading branch information
Bagas Udi Sahsangka committed Sep 3, 2021
1 parent ca53017 commit 12b96c6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
5 changes: 3 additions & 2 deletions app/Http/Controllers/GateOutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function uhfReaders()
public function store(GateOutRequest $request)
{
$gateOut = GateOut::create($request->all());

shell_exec('sudo systemctl restart uhf-reader');
return ['message' => 'Data telah disimpan', 'data' => $gateOut];
}

Expand All @@ -64,7 +64,7 @@ public function show(GateOut $gateOut)
public function update(GateOutRequest $request, GateOut $gateOut)
{
$gateOut->update($request->all());

shell_exec('sudo systemctl restart uhf-reader');
return ['message' => 'Data telah disimpan', 'data' => $gateOut];
}

Expand All @@ -77,6 +77,7 @@ public function update(GateOutRequest $request, GateOut $gateOut)
public function destroy(GateOut $gateOut)
{
$gateOut->delete();
shell_exec('sudo systemctl restart uhf-reader');
return ['message' => 'Data telah dihapus'];
}

Expand Down
12 changes: 10 additions & 2 deletions frontend/components/notification/ControllerLog.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
<template>
<div class="log-container" v-html="log"></div>
<div>
<!-- TODO: kasih filter -->
<el-input autofocus placeholder="Cari log" v-model="keyword"></el-input>
<div class="log-container" v-html="log"></div>
</div>
</template>

<script>
export default {
props: ['url'],
data() {
return {
log: '',
requestInterval: null,
keyword: '',
}
},
methods: {
getLog() {
const params = { keyword: this.keyword }
this.$axios
.$get('/api/controller-log')
.$get(this.url, { params })
.then((response) => (this.log = response))
.catch((e) => console.log(e))
},
Expand Down
6 changes: 5 additions & 1 deletion frontend/pages/notification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@
</el-tab-pane>

<el-tab-pane lazy label="LOG GATE MASUK">
<NotificationControllerLog />
<NotificationControllerLog url="/api/controller-log" />
</el-tab-pane>

<el-tab-pane lazy label="LOG GATE KELUAR">
<NotificationControllerLog url="/api/uhf-log" />
</el-tab-pane>
</el-tabs>
</el-card>
Expand Down
9 changes: 7 additions & 2 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,13 @@

Route::post('takeSnapshot/{gateOut}', [GateOutController::class, 'takeSnapshot']);

Route::get('controller-log', function () {
$output = shell_exec('tail -n 250 /var/log/parking.log');
Route::get('controller-log', function (Request $request) {
$output = shell_exec("tail -n 250 /var/log/parking.log | grep {$request->keyword}");
return nl2br($output);
});

Route::get('uhf-log', function (Request $request) {
$output = shell_exec("tail -n 250 /var/log/ufh.log | grep {$request->keyword}");
return nl2br($output);
});

Expand Down
4 changes: 4 additions & 0 deletions sudoers
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
%www-data ALL=NOPASSWD: /bin/systemctl stop parking
%www-data ALL=NOPASSWD: /bin/systemctl restart parking
%www-data ALL=NOPASSWD: /bin/systemctl status parking
%www-data ALL=NOPASSWD: /bin/systemctl start uhf-reader
%www-data ALL=NOPASSWD: /bin/systemctl stop uhf-reader
%www-data ALL=NOPASSWD: /bin/systemctl restart uhf-reader
%www-data ALL=NOPASSWD: /bin/systemctl status uhf-reader

0 comments on commit 12b96c6

Please sign in to comment.