Izveidot aplikāciju, kura ik pēc noteikta intervāla (60 sekundes) veic ierakstu datubāzē izmantojot Laravel freimworka iebūvēto funkcionalitāti.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Sergey Drozdov test :: Events</title>
<meta name="csrf_token" content="{{ csrf_token() }}" />
<!--link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.13/dist/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script-->
<link rel="stylesheet" href="css/bootstrap_4.1.3.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="js/vue_2.5.13.js"></script>
<script src="js/axios_0.19.0.min.js"></script>
</head>
<body style="padding-top: 10px">
<div style="float: right; padding: 10px 30px 0 0">Press F5 to refresh page (automatic refresh out of task scope)</div>
<div class="container">
<form action="/monitoring_status" class="form-horizontal" method="post">
<div class="row" id="toolbar">
<input type="button" value="System On" class="btn btn-primary" v-on:click="monitoringOn" />
<input type="button" value="System Off" class="btn btn-primary" v-on:click="monitoringOff" />
</div>
</form>
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Level</th>
<th>Date</th>
<th>Source</th>
<th>Information</th>
</tr>
</thead>
<tbody>
@foreach ($events as $event)
<tr>
<td>{{ $event->Id }}</td>
<td>{{ $event->Level }}</td>
<td>{{ date('d.m.Y H:i:s', strtotime($event->Date)) }}</td>
<td>{{ $event->Source }}</td>
<td>{{ $event->Information }}</td>
</tr>
@endforeach
</tbody>
</table>
{{ $events->render() }}
</div>
<script type="text/javascript">
var toolbar = new Vue({
el: '#toolbar',
data: {
},
methods: {
monitoringOn: function (event) {
axios.get('monitoring-on', { })
.then(function () {
console.log('System is ON.');
})
.catch(function (error) {
console.log(error);
});
},
monitoringOff: function (event) {
axios.get('monitoring-off', { })
.then(function () {
console.log('System is OFF.');
})
.catch(function (error) {
console.log(error);
});
}
}
})
</script>
</body>
</html>