Commit 48f0843a authored by Vladislav Gumerov's avatar Vladislav Gumerov

added gulpfile

parent 34eeba3f
#.idea folder
.idea/
\ No newline at end of file
.idea/
#node_modules folder
node_modules
\ No newline at end of file
const gulp = require('gulp');
const babel = require('gulp-babel');
const cssmin = require('gulp-minify-css');
const uglify = require('gulp-uglify-es').default;
gulp.task('css-min', function () {
return gulp.src('src/css/**/*.css')
.pipe(cssmin())
.pipe(gulp.dest('public/css/'))
});
gulp.task('js-min', function () {
return gulp.src('src/js/**/*.js')
.pipe(babel({
plugins: ['transform-react-jsx']}))
.pipe(uglify())
.pipe(gulp.dest('public/js/'));
});
gulp.task('php', function () {
return gulp.src('src/core/*.php')
.pipe(gulp.dest('public/core/'));
});
gulp.task('watch', function () {
gulp.watch('src/css/**/*.css', gulp.parallel('css-min'));
gulp.watch('src/js/**/*.js', gulp.parallel('js-min'));
gulp.watch('src/core/*.php', gulp.parallel('php'));
});
gulp.task('default', gulp.parallel('watch'));
\ No newline at end of file
let secondRow = $('.second-row').children();
interval = setInterval(function() {
$.get('core/etersoft.php', function (data) {
data = JSON.parse(data);
let i = 0;
console.log(data);
$.each(data, function (index, elem) {
secondRow[i].innerHTML = elem;
i++;
});
})
}, 2000);
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "system-load",
"version": "0.0.1",
"description": "test task for Etersoft",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"gulp": "^4.0.0",
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.3.1",
"babel-plugin-transform-react-jsx": "^6.24.1",
"gulp-babel": "^8.0.0",
"gulp-minify-css": "^1.2.4",
"gulp-uglify-es": "^1.0.4"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/AstR0x/system-load.git"
},
"author": "AstR0x",
"license": "MIT"
}
table{font-family:"Lucida Sans Unicode","Lucida Grande",Sans-Serif;font-size:14px;border-collapse:collapse;text-align:center}td:first-child,th{background:#AFCDE7;color:#fff;padding:10px 20px}td,th{border-style:solid;border-width:0 1px 1px 0;border-color:#fff}td{background:#D8E6F3}td:first-child,th:first-child{text-align:left}
\ No newline at end of file
......@@ -8,25 +8,11 @@
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<table class="system-load-table" width="100%">
<tr class="first_row">
<th>CPU</th>
<th>Total memory</th>
<th>Free memory</th>
<th>5 minute</th>
<th>10 minute</th>
<th>15 minute</th>
</tr>
<tr class="second-row">
<th>0</th>
<th>0</th>
<th>0</th>
<th>0</th>
<th>0</th>
<th>0</th>
</tr>
</table>
<div id="root">
</div>
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="js/index.js"></script>
<script src="js/index.js"></script>
</body>
</html>
\ No newline at end of file
function App(e){return React.createElement("table",{className:"system-load-table",width:"100%"},React.createElement("tbody",null,React.createElement("tr",{className:"first_row"},React.createElement("th",null,"CPU"),React.createElement("th",null,"Total memory"),React.createElement("th",null,"Free memory"),React.createElement("th",null,"5 minute"),React.createElement("th",null,"10 minute"),React.createElement("th",null,"15 minute")),React.createElement("tr",{className:"second-row"},React.createElement("th",null,e.data.CPI),React.createElement("th",null,(e.data.TotalMemory/1024).toFixed(2)+" МБ"),React.createElement("th",null,(e.data.FreeMemory/1024).toFixed(2)+" МБ"),React.createElement("th",null,e.data["5minute"]),React.createElement("th",null,e.data["10minute"]),React.createElement("th",null,e.data["15minute"]))))}setInterval(function(){$.get("core/data.php",function(e){e=JSON.parse(e),ReactDOM.render(React.createElement(App,{data:e}),document.getElementById("root"))})},500);
\ No newline at end of file
<?php
$cpu = shell_exec('ps aux | awk \'{s += $3} END {print s "%"}\'');
$total_mem = shell_exec("cat /proc/meminfo | grep MemTotal | awk '{ print $2 }' ");
$free_mem = shell_exec("cat /proc/meminfo | grep MemFree | awk '{ print $2 }' ");
$average1 = shell_exec("uptime | awk '{ print $10 }' ");
$average2 = shell_exec("uptime | awk '{ print $11 }' ");
$average3 = shell_exec("uptime | awk '{ print $12 }' ");
$arr = array('CPI' => trim($cpu),
'TotalMemory' => trim($total_mem),
'FreeMemory' => trim($free_mem),
"5minute" => substr(trim($average1), 0, -1),
"10minute" => substr(trim($average2), 0, -1),
"15minute" => substr(trim($average3), 0, -1));
exit (json_encode($arr));
?>
\ No newline at end of file
function App(props) {
return (
<table className="system-load-table" width="100%">
<tbody>
<tr className="first_row">
<th>CPU</th>
<th>Total memory</th>
<th>Free memory</th>
<th>5 minute</th>
<th>10 minute</th>
<th>15 minute</th>
</tr>
<tr className="second-row">
<th>{props.data['CPI']}</th>
<th>{(props.data['TotalMemory'] / 1024).toFixed(2) + ' МБ'}</th>
<th>{(props.data['FreeMemory'] / 1024).toFixed(2) + ' МБ'}</th>
<th>{props.data['5minute']}</th>
<th>{props.data['10minute']}</th>
<th>{props.data['15minute']}</th>
</tr>
</tbody>
</table>
);
}
setInterval(function () {
$.get('core/data.php', function (data) {
data = JSON.parse(data);
ReactDOM.render(<App data={data}/>, document.getElementById('root'));
});
}, 500);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment