Migracia a male opravy

- csrf ocharana, vypnutie pre /log
- oprava loggovania pamate
- pridanie vue skriptov
This commit is contained in:
Jaroslav Drzik
2020-03-26 07:52:02 +01:00
parent 575b55bdc2
commit a4b7483048
50 changed files with 23176 additions and 4 deletions

78
README.md Executable file
View File

@@ -0,0 +1,78 @@
<p align="center"><img src="https://res.cloudinary.com/dtfbvvkyp/image/upload/v1566331377/laravel-logolockup-cmyk-red.svg" width="400"></p>
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[British Software Development](https://www.britishsoftware.co)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- [UserInsights](https://userinsights.com)
- [Fragrantica](https://www.fragrantica.com)
- [SOFTonSOFA](https://softonsofa.com/)
- [User10](https://user10.com)
- [Soumettre.fr](https://soumettre.fr/)
- [CodeBrisk](https://codebrisk.com)
- [1Forge](https://1forge.com)
- [TECPRESSO](https://tecpresso.co.jp/)
- [Runtime Converter](http://runtimeconverter.com/)
- [WebL'Agence](https://weblagence.com/)
- [Invoice Ninja](https://www.invoiceninja.com)
- [iMi digital](https://www.imi-digital.de/)
- [Earthlink](https://www.earthlink.ro/)
- [Steadfast Collective](https://steadfastcollective.com/)
- [We Are The Robots Inc.](https://watr.mx/)
- [Understand.io](https://www.understand.io/)
- [Abdel Elrafa](https://abdelelrafa.com)
- [Hyper Host](https://hyper.host)
- [Appoly](https://www.appoly.co.uk)
- [OP.GG](https://op.gg)
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ConfirmsPasswords;
class ConfirmPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Confirm Password Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password confirmations and
| uses a simple trait to include the behavior. You're free to explore
| this trait and override any functions that require customization.
|
*/
use ConfirmsPasswords;
/**
* Where to redirect users when the intended url fails.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Http\Controllers;
use App\User;
use Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
class DataController extends Controller
{
/**
* Show the profile for the given user.
*
* @param int $computer_id
*/
public function get($id=null)
{
$where = [];
$computer_id = Request::input('computer_id');
$from = Request::input('from');
$to = Request::input('to');
$where[] = ["computer_id", '=', $computer_id];
if ($from) $where[] = ["created_at", '>=', $from];
if ($to) $where[] = ["created_at", '<=', $to];
$queries = DB::table('values')->where($where)->get();
return response()->json($queries);
}
}

View File

@@ -8,7 +8,7 @@ use Illuminate\Support\Facades\DB;
class Logging extends Controller
{
public static $_items = [ 'netstat_sent' => 'i', 'netstat_recv' => 'i', 'memory_free' => 'f', 'memory_total' => 'f', 'memory_used' => 'f', 'disk_free' => 'B', 'disk_percent' => 'f', 'disk_used' => 'B', 'disk_total' => 'B', 'processes' => 'i', 'temp' => 'i', 'load' => 'f', 'username' =>'s', 'computer' => 's'];
public static $_items = [ 'netstat_sent' => 'i', 'netstat_recv' => 'i', 'memory_free' => 'B', 'memory_total' => 'B', 'memory_used' => 'B', 'disk_free' => 'B', 'disk_percent' => 'f', 'disk_used' => 'B', 'disk_total' => 'B', 'processes' => 'i', 'temp' => 'i', 'load' => 'f', 'username' =>'s', 'computer' => 's'];
private $_values = [];
private $_ucache = [];
@@ -32,7 +32,7 @@ class Logging extends Controller
if ($ret == false ) {
$q = DB::table('computers')->select('id', 'computer')->get();
foreach ($q as $v) {
$this->_ucache[$v->computer] = $v->id;
$this->_ccache[$v->computer] = $v->id;
}
\apcu_store('computers',$this->_ccache);
}
@@ -67,7 +67,7 @@ class Logging extends Controller
$units = explode(' ', ' K M G T P E Z Y');
preg_match('/([0-9]+)([GKMTgkmT])?B/',$v,$vu);
preg_match('/([0-9\.]+)([GKMTgkmT])?B/',$v,$vu);
$v1 = $vu[1];
if (count($vu) == 3)

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
class CheckForMaintenanceMode extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class ValuesResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

10
app/Values.php Executable file
View File

@@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Values extends Model
{
//
}

52
config/hashing.php Executable file
View File

@@ -0,0 +1,52 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon", "argon2id"
|
*/
'driver' => 'bcrypt',
/*
|--------------------------------------------------------------------------
| Bcrypt Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Bcrypt algorithm. This will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'bcrypt' => [
'rounds' => env('BCRYPT_ROUNDS', 10),
],
/*
|--------------------------------------------------------------------------
| Argon Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Argon algorithm. These will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'argon' => [
'memory' => 1024,
'threads' => 2,
'time' => 2,
],
];

104
config/logging.php Executable file
View File

@@ -0,0 +1,104 @@
<?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
'ignore_exceptions' => false,
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'days' => 14,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => 'critical',
],
'papertrail' => [
'driver' => 'monolog',
'level' => 'debug',
'handler' => SyslogUdpHandler::class,
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
],
],
'stderr' => [
'driver' => 'monolog',
'handler' => StreamHandler::class,
'formatter' => env('LOG_STDERR_FORMATTER'),
'with' => [
'stream' => 'php://stderr',
],
],
'syslog' => [
'driver' => 'syslog',
'level' => 'debug',
],
'errorlog' => [
'driver' => 'errorlog',
'level' => 'debug',
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
],
];

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failed_jobs');
}
}

15
graph/.editorconfig Executable file
View File

@@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2

46
graph/.env.example Executable file
View File

@@ -0,0 +1,46 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

5
graph/.gitattributes vendored Executable file
View File

@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore

12
graph/.gitignore vendored Executable file
View File

@@ -0,0 +1,12 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

13
graph/.styleci.yml Executable file
View File

@@ -0,0 +1,13 @@
php:
preset: laravel
disabled:
- unused_use
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true

10242
package-lock.json generated Executable file

File diff suppressed because it is too large Load Diff

1532
public/0.js vendored Executable file

File diff suppressed because it is too large Load Diff

14
public/1.js vendored Executable file

File diff suppressed because one or more lines are too long

7
public/1.js.LICENSE.txt Executable file
View File

@@ -0,0 +1,7 @@
/*!
* wordcloud2.js
* http://timdream.org/wordcloud2.js/
*
* Copyright 2011 - 2013 Tim Chien
* Released under the MIT license
*/

14
public/2.js vendored Executable file

File diff suppressed because one or more lines are too long

1
public/3.js vendored Executable file

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

14
public/js/app.js.LICENSE.txt Executable file
View File

@@ -0,0 +1,14 @@
/*!
* Vue.js v2.6.11
* (c) 2014-2019 Evan You
* Released under the MIT License.
*/
/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/

4
public/mix-manifest.json Executable file
View File

@@ -0,0 +1,4 @@
{
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css"
}

41
resources/js/app.js vendored Executable file
View File

@@ -0,0 +1,41 @@
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap');
window.Vue = require('vue');
window.moment = require('moment');
/**
* The following block of code may be used to automatically register your
* Vue components. It will recursively scan this directory for the Vue
* components and automatically register them with their "basename".
*
* Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
*/
// const files = require.context('./', true, /\.vue$/i)
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
import { Datetime } from 'vue-datetime';
Vue.component('datetime', Datetime);
Vue.component('example-component', require('./components/ExampleComponent.vue').default);
Vue.component('network-graph', require('./components/NetworkGraph.vue').default);
Vue.component('temp-graph', require('./components/TempGraph.vue').default);
Vue.component('memory-graph', require('./components/MemoryGraph.vue').default);
Vue.component('load-graph', require('./components/LoadGraph.vue').default);
Vue.component('processes-graph', require('./components/ProcessesGraph.vue').default);
Vue.component('disk-graph', require('./components/DiskGraph.vue').default);
Vue.component('search-input', require('./components/SearchInput.vue').default);
/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you manwy begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
const app = new Vue({
el: '#app',
});

48
resources/js/bootstrap.js vendored Executable file
View File

@@ -0,0 +1,48 @@
window._ = require('lodash');
/**
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
* for JavaScript based Bootstrap features such as modals and tabs. This
* code may be modified to fit the specific needs of your application.
*/
try {
window.Popper = require('popper.js').default;
window.$ = window.jQuery = require('jquery');
require('bootstrap');
} catch (e) {}
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
window.axios = require('axios');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/
import Vue from 'vue';
import VueDygraphs from 'vue-dygraphs';
import VueSuggestion from 'vue-suggestion';
Vue.use(VueSuggestion);
Vue.use(VueDygraphs);
// import Echo from 'laravel-echo';
// window.Pusher = require('pusher-js');
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: process.env.MIX_PUSHER_APP_KEY,
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
// encrypted: true
// });

View File

@@ -0,0 +1,48 @@
<template>
<div class="chart">
<line-chart
:data="data"
area
/>
</div>
</template>
<script>
export default {
name: "LineBase",
data() {
return {
data: [
{
name: "Test",
data: [
{
label: "2016",
value: 84000
},
{
label: "2017",
value: 90000
},
{
label: "2018",
value: 80000
},
{
label: "2019",
value: 100000
}
]
}
]
};
}
};
</script>
<style scoped>
.chart {
width: 100%;
height: 300px;
}
</style>

View File

@@ -0,0 +1,83 @@
<template>
<div>
<dygraphs width="800" :graphData="series" :graphOptions="options"></dygraphs>
</div>
</template>
<script>
export default {
props: ['raw_data'],
name: "LineBase",
data() {
return {
options: {
legend: 'always',
title: 'Disk Graph',
xlabel: 'Dátum',
labels: ['Dátum','Celkom','Pouzita','Volna','Percent'],
ylabel: 'Bytes',
y2label: 'Percent',
fillGraph: true,
series: {
'Percent': {
axis: 'y2'
},
},
axes: {
y: {
axisLabelWidth: 60,
labelsKMG2: true,
},
y2: {
// set axis-related properties here
labelsKMB: false
}
},
},
series: [],
};
},
created: function () {
// `this` points to the vm instance
console.log('created');
let last_time = null;
let last_total = 0;
let last_free = 0;
let last_used = 0;
for (var index = 0; index < this.raw_data.length; ++index) {
let row = this.raw_data[index];
let disk = [row["disk_total"],row["disk_used"], row["disk_free"],row["disk_percent"]];
let created_at = row["created_at"];
let time = moment(created_at);
if (last_time == null || time.unix() - last_time.unix() > 900 ) {
if (last_time != null) {
this.series.push([last_time.toDate(),0,0,0,0]);
}
this.series.push([time.toDate(),0,0,0,0]);
last_time = time;
continue;
}
this.series.push([time.toDate()].concat(disk));
last_time = time;
}
console.log(this.series);
}
};
</script>
<style scoped>
.chart {
width: 100%;
height: 300px;
}
</style>

View File

@@ -0,0 +1,23 @@
<template>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Example Component</div>
<div class="card-body">
I'm an example component.
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
mounted() {
console.log('Component mounted.')
}
}
</script>

View File

@@ -0,0 +1,66 @@
<template>
<div>
<dygraphs width="800" :graphData="series" :graphOptions="options"></dygraphs>
</div>
</template>
<script>
export default {
props: ['raw_data'],
name: "LineBase",
data() {
return {
options: {
legend: 'always',
title: 'Load Graph',
xlabel: 'Dátum',
labels: ['Dátum','Zatazenie'],
ylabel: 'Percent',
fillGraph: true
},
series: [],
};
},
created: function () {
// `this` points to the vm instance
console.log('created load');
let last_time = null;
let last_load = null;
for (var index = 0; index < this.raw_data.length; ++index) {
let row = this.raw_data[index];
let load = row["load"];
let created_at = row["created_at"];
let time = moment(created_at);
if (last_time == null || time.unix() - last_time.unix() > 900 ) {
if (last_time != null) {
this.series.push([last_time.toDate(),null]);
}
this.series.push([time.toDate(),null]);
last_time = time;
last_load = null;
continue;
}
this.series.push([time.toDate(),load]);
last_time = time;
last_load = load;
}
console.log(this.series);
}
};
</script>
<style scoped>
.chart {
width: 100%;
height: 300px;
}
</style>

View File

@@ -0,0 +1,70 @@
<template>
<div>
<dygraphs width="800" :graphData="series" :graphOptions="options"></dygraphs>
</div>
</template>
<script>
export default {
props: ['raw_data'],
name: "LineBase",
data() {
return {
options: {
legend: 'always',
title: 'Memory Graph',
xlabel: 'Dátum',
labels: ['Dátum','Celkom','Pouzita','Volna'],
ylabel: 'Bytes',
fillGraph: true
},
series: [],
};
},
created: function () {
// `this` points to the vm instance
console.log('created');
let last_time = null;
let last_total = 0;
let last_free = 0;
let last_used = 0;
for (var index = 0; index < this.raw_data.length; ++index) {
let row = this.raw_data[index];
let memory = [row["memory_total"],row["memory_used"], row["memory_free"]];
memory = memory.map(function (x) {
if (x > 8*1024) { return Math.floor(x/1024) }
else {return x}
});
let created_at = row["created_at"];
let time = moment(created_at);
if (last_time == null || time.unix() - last_time.unix() > 900 ) {
if (last_time != null) {
this.series.push([last_time.toDate(),0,0,0]);
}
this.series.push([time.toDate(),0,0,0]);
last_time = time;
continue;
}
this.series.push([time.toDate()].concat(memory));
last_time = time;
}
console.log(this.series);
}
};
</script>
<style scoped>
.chart {
width: 100%;
height: 300px;
}
</style>

View File

@@ -0,0 +1,76 @@
<template>
<div>
<dygraphs width="800" :graphData="series" :graphOptions="options"></dygraphs>
</div>
</template>
<script>
export default {
props: ['raw_data'],
name: "LineBase",
data() {
return {
options: {
legend: 'always',
title: 'Network Graph',
xlabel: 'Dátum',
labels: ['Dátum','Prijate','Odoslane'],
ylabel: 'Bytes',
labelsKMG2: true,
fillGraph: true
},
series: [],
};
},
created: function () {
// `this` points to the vm instance
console.log('created');
let last_time = null;
let last_recv = 0;
let last_sent = 0;
for (var index = 0; index < this.raw_data.length; ++index) {
let row = this.raw_data[index];
let sent = row["netstat_sent"];
let recv = row["netstat_recv"];
let created_at = row["created_at"];
let time = moment(created_at);
if (last_time == null || time.unix() - last_time.unix() > 900 || recv - last_recv < 0 || sent - last_sent < 0 ) {
if (last_time != null) {
this.series.push([last_time.toDate(),0,0]);
}
this.series.push([time.toDate(),0,0]);
last_time = time;
last_recv = 0;
last_sent = 0;
continue;
}
let rb = recv - last_recv;
let sb = sent - last_sent;
let lt = time.unix() - last_time.unix();
this.series.push([time.toDate(),rb/lt,sb/lt]);
last_time = time;
last_recv = recv;
last_sent = sent;
}
console.log(this.series);
}
};
</script>
<style scoped>
.chart {
width: 100%;
height: 300px;
}
</style>

View File

@@ -0,0 +1,66 @@
<template>
<div>
<dygraphs width="800" :graphData="series" :graphOptions="options"></dygraphs>
</div>
</template>
<script>
export default {
props: ['raw_data'],
name: "LineBase",
data() {
return {
options: {
legend: 'always',
title: 'Process Graph',
xlabel: 'Dátum',
labels: ['Dátum','Počet'],
ylabel: 'Procesov',
fillGraph: true
},
series: [],
};
},
created: function () {
// `this` points to the vm instance
console.log('created process');
let last_time = null;
let last_processes = null;
for (var index = 0; index < this.raw_data.length; ++index) {
let row = this.raw_data[index];
let processes = row["processes"];
let created_at = row["created_at"];
let time = moment(created_at);
if (last_time == null || time.unix() - last_time.unix() > 900 ) {
if (last_time != null) {
this.series.push([last_time.toDate(),null]);
}
this.series.push([time.toDate(),null]);
last_time = time;
last_processes = null;
continue;
}
this.series.push([time.toDate(),processes]);
last_time = time;
last_processes = processes;
}
console.log(this.series);
}
};
</script>
<style scoped>
.chart {
width: 100%;
height: 300px;
}
</style>

View File

@@ -0,0 +1,45 @@
<template>
<vue-suggestion :items="items"
v-model="item"
:setLabel="setLabel"
:itemTemplate="itemTemplate"
@changed="inputChange"
@selected="itemSelected">
</vue-suggestion>
</template>
<script>
import itemTemplate from './item-template.vue';
export default {
data () {
return {
item: {},
items: [
],
itemTemplate,
}
},
methods: {
itemSelected (item) {
this.item = item;
},
setLabel (item) {
return item.computer;
},
inputChange (text) {
axios.get('search/autocomplete', {
params: {
term: text,
}
})
.then((response) => {
this.items = response.data;
})
.catch(function (error) {
console.log(error);
});
},
},
};
</script>

View File

@@ -0,0 +1,66 @@
<template>
<div>
<dygraphs width="800" :graphData="series" :graphOptions="options"></dygraphs>
</div>
</template>
<script>
export default {
props: ['raw_data'],
name: "LineBase",
data() {
return {
options: {
legend: 'always',
title: 'Temperature Graph',
xlabel: 'Dátum',
labels: ['Dátum','Teplota'],
ylabel: 'Stupeň',
fillGraph: true
},
series: [],
};
},
created: function () {
// `this` points to the vm instance
console.log('created temp');
let last_time = null;
let last_temp = null;
for (var index = 0; index < this.raw_data.length; ++index) {
let row = this.raw_data[index];
let temp = row["temp"];
let created_at = row["created_at"];
let time = moment(created_at);
if (last_time == null || time.unix() - last_time.unix() > 900 ) {
if (last_time != null) {
this.series.push([last_time.toDate(),null]);
}
this.series.push([time.toDate(),null]);
last_time = time;
last_temp = null;
continue;
}
this.series.push([time.toDate(),temp]);
last_time = time;
last_temp = temp;
}
console.log(this.series);
}
};
</script>
<style scoped>
.chart {
width: 100%;
height: 300px;
}
</style>

View File

@@ -0,0 +1,15 @@
<template>
<div>
<b>#{{ item.id }}</b>
<span>{{ item.computer }}</span>
<span>{{ item.user }}</span>
</div>
</template>
<script>
export default {
props: {
item: { required: true },
}
}
</script>

58
resources/sass/_suggest.scss vendored Executable file
View File

@@ -0,0 +1,58 @@
.vue-suggestion {
// width:50%;
// max-width:400px;
// margin:0 auto
}
.vue-suggestion .vs__input-group .vs__input {
width: 100%;
display: block;
margin: 0 auto;
padding: 0.5rem 0.7rem;
font-size: 0.9rem;
line-height: 1.25;
color: #464a4c;
outline: none;
background-color: #fff;
background-image: none;
background-clip: padding-box;
border: 1px solid #cecece;
border-radius: 0.25rem;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.vue-suggestion .vs__input-group .vs__input:focus {
border: 1px solid #023d7b;
}
.vue-suggestion .vs__list {
width: 100%;
text-align: left;
border: none;
border-top: none;
max-height: 400px;
overflow-y: auto;
border-bottom: 1px solid #023d7b;
}
.vue-suggestion .vs__list .vs__list-item {
background-color: #fff;
padding: 10px;
border-left: 10px solid #023d7b;
border-right: 1px solid #023d7b;
}
.vue-suggestion .vs__list .vs__list-item:last-child {
border-bottom: none;
}
.vue-suggestion .vs__list .vs__list-item:hover {
background-color: #eee !important;
}
.vue-suggestion {
position: relative;
}
.vue-suggestion .vs__list,
.vue-suggestion .vs__loading {
position: absolute;
}
.vue-suggestion .vs__list .vs__list-item {
cursor: pointer;
}
.vue-suggestion .vs__list .vs__list-item.vs__item-active {
background-color: #f3f6fa;
}

20
resources/sass/_variables.scss vendored Executable file
View File

@@ -0,0 +1,20 @@
// Body
$body-bg: #f8fafc;
// Typography
$font-family-sans-serif: 'Nunito', sans-serif;
$font-size-base: 0.9rem;
$line-height-base: 1.6;
// Colors
$blue: #3490dc;
$indigo: #6574cd;
$purple: #9561e2;
$pink: #f66d9b;
$red: #e3342f;
$orange: #f6993f;
$yellow: #ffed4a;
$green: #38c172;
$teal: #4dc0b5;
$cyan: #6cb2eb;

17
resources/sass/app.scss vendored Executable file
View File

@@ -0,0 +1,17 @@
// Fonts
@import url('https://fonts.googleapis.com/css?family=Nunito');
// Variables
@import 'variables';
// Bootstrap
@import '~bootstrap/scss/bootstrap';
// Font Awesome
@import '~font-awesome/scss/font-awesome';
@import '~vue-datetime/dist/vue-datetime';
@import 'suggest';

111
resources/views/master.blade.php Executable file
View File

@@ -0,0 +1,111 @@
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/dygraph/2.1.0/dygraph.min.css" />
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
<script src="{{ asset('/js/app.js') }}"></script>
<!-- Styles -->
<style>
html, body {
background-color: #fff;
color: #636b6f;
font-family: 'Raleway', sans-serif;
font-weight: 100;
height: 100vh;
margin: 0;
}
.full-height {
height: 100vh;
}
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
.position-ref {
position: relative;
}
.top-right {
position: absolute;
right: 10px;
top: 18px;
}
.content {
text-align: center;
}
.title {
font-size: 84px;
}
.links > a {
color: #636b6f;
padding: 0 25px;
font-size: 12px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
.m-b-md {
margin-bottom: 30px;
}
.chart {
width: 100%;
height: 300px;
}
.linkactive {
background-color: red;
}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
@if (Route::has('login'))
<div class="top-right links">
@auth
<a href="{{ url('/home') }}">Home</a>
@else
<a href="{{ route('login') }}">Login</a>
<a href="{{ route('register') }}">Register</a>
@endauth
</div>
@endif
<div class="content">
@section('title')
<div class="title m-b-md">
Monitoring on OkU TT
</div>
@show
@section('links')
<div class="links">
<a href="{{ url('/search') }}">Search</a>
</div>
@show
@section('content')
<p></p>
@show
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,17 @@
@extends('master')
@section('title')
<div class="title m-b-md">
Search monitoring
</div>
@stop
@section('links')
<div class="links">
<a href="{{ url('/') }}">Monitoring</a>
</div>
@stop
@section('content')
@stop

View File

@@ -0,0 +1,178 @@
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<script src="{{ mix('/js/app.js') }}"></script>
<!-- Styles -->
<style>
html, body {
background-color: #fff;
color: #636b6f;
font-family: 'Raleway', sans-serif;
font-weight: 100;
height: 100vh;
margin: 0;
}
.full-height {
height: 100vh;
}
.flex-center {
align-items: center;
display: flex;
justify-content: center;
}
.position-ref {
position: relative;
}
.top-right {
position: absolute;
right: 10px;
top: 18px;
}
.content {
text-align: center;
}
.title {
font-size: 84px;
}
.links > a {
color: #636b6f;
padding: 0 25px;
font-size: 12px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
}
.m-b-md {
margin-bottom: 30px;
}
.chart {
width: 100%;
height: 300px;
}
</style>
</head>
<body>
<div class="flex-center position-ref full-height">
@if (Route::has('login'))
<div class="top-right links">
@auth
<a href="{{ url('/home') }}">Home</a>
@else
<a href="{{ route('login') }}">Login</a>
<a href="{{ route('register') }}">Register</a>
@endauth
</div>
@endif
<div class="content">
<div class="title m-b-md">
Monitoring on OkU TT
</div>
<div class="links">
<a href="{{ url('/search') }}">Search</a>
</div>
<div class="links">
<a href="{{ url('/graph/network') }}">Network</a>
<a href="{{ url('/graph/temp') }}">Temperature</a>
<a href="{{ url('/graph/memory') }}">Memory</a>
<a href="{{ url('/graph/load') }}">Load</a>
<a href="{{ url('/graph/disk') }}">Disk</a>
<a href="{{ url('/graph/processes') }}">Processes</a>
</div>
<div id="app">
<network-graph :raw_data="chartData" />
</div>
<script>
var settings = { "network": { name:"Network",prefix: "netstat",suffix: { "recv": "Received", "sent": "Send Bytes" }, units:"B"},
"temp": {name:"Temerature",prefix: null,units:"C"},
"memory": {name:"Memory",prefix:"memory", suffix: {"free":"Free Memory", "total": "Total Memory","used":"Used Memory"},units: "KB"},
"load": {name:"System Load",prefix:null, units:"%"},
"disk": {name:"Disk utilization",prefix:"disk",suffix: {"free":"Free Memory", "total": "Total Memory","used":"Used Memory"}, units:"MB"},
"processes": {name:"Number of processes",prefix: null,units:""}};
axios.get('/data', {
params: {
computer_id: 1,
from: '2020-03-10'
}
})
.then(function (response) {
var data = response.data;
var index;
for (index = 0; index < data.length; ++index) {
var row = data[index];
for (var sk in settings) {
for (var k in settings[sk].suffix) {
key = settings[sk].prefix + '_' + k;
label = row["created_at"];
value = row[key];
nr = { label: label, value: value};
if (!settings[sk].hasOwnProperty('d4')) settings[sk].d4 = {};
if (!settings[sk].d4.hasOwnProperty(k)) settings[sk].d4[k] = [];
settings[sk].d4[k].push(nr);
}
}
}
for (var k1 in settings) {
d = [];
for (var k2 in settings[k1].d4) {
name = settings[k1].suffix[k2];
d.push({name: name, data: settings[k1].d4[k2]});
}
settings[k1].data = d;
}
var app = new Vue({
el: "#app",
data: {
chartData: data
}
})
})
.catch(function (error) {
console.log(error);
});
</script>
@section('content')
<p></p>
@show
</div>
</div>
</body>
</html>

2
storage/framework/cache/data/.gitignore vendored Executable file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

7085
yarn.lock Executable file

File diff suppressed because it is too large Load Diff