Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f376756
Added sort by key feature in WiFi tab and Improved UI in WiFi tab
hanupratap Mar 17, 2021
d1ee1ca
Highlighted row and added active dot for connected network. Removed u…
hanupratap Mar 18, 2021
433147f
Added Chips for WPA, Updated dependecies, cleaned code
hanupratap Mar 19, 2021
4b06a8e
Added camer load graph
hanupratap Mar 21, 2021
e128d87
Minor UI Changes and code improvement
hanupratap Mar 21, 2021
2bd325f
Minor function name changes
hanupratap Mar 22, 2021
d17e912
Changed graph library to ApexCharts
hanupratap Mar 23, 2021
59d1f6e
graph update
hanupratap Mar 23, 2021
9ad8da4
Added bars icon
hanupratap Mar 23, 2021
8a7d92b
formatted code
hanupratap Mar 23, 2021
317f1e6
Refactored command and graph widget
hanupratap Mar 25, 2021
5b94db9
Fixed graph reset on re-render
hanupratap Mar 25, 2021
f8fe2be
Formatted Code
hanupratap Mar 25, 2021
463328d
Removed ticks and added loading text for no data
hanupratap Mar 26, 2021
7512d10
Changed case for setstate
hanupratap Mar 26, 2021
9afde1a
added showGraph in rebuild list
hanupratap Mar 26, 2021
e359728
Added CanvasJs Charts
hanupratap Mar 27, 2021
eb839ff
Changed lib to chartjs, removed unnecessary libs and files, formatted…
hanupratap Mar 29, 2021
7124ed4
minor improvements
hanupratap Mar 29, 2021
9c4fe9f
minor performance improvement
hanupratap Mar 29, 2021
2ff76b7
Fixed color in tooltip
hanupratap Mar 29, 2021
dd257e0
chartjs replaced with Dygraph charts
hanupratap Mar 30, 2021
04b462d
Graph autoscale x-direction
hanupratap Mar 31, 2021
a0b7b3e
Added open source animation
hanupratap Mar 31, 2021
13308ee
code format
hanupratap Mar 31, 2021
c435618
Added apertus animation
hanupratap Mar 31, 2021
3777914
changed tooltip position, removed hardcoded theme
hanupratap Apr 4, 2021
dfa8512
format code
hanupratap Apr 4, 2021
ddbf771
added accordion on sys-info, improved performanec
hanupratap Apr 4, 2021
8c9ecc8
format code
hanupratap Apr 4, 2021
0685002
small change in accordion
hanupratap Apr 4, 2021
8cc9a8c
added dark mode
hanupratap Apr 7, 2021
efb28fb
color highlight fix
hanupratap Apr 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions frontend/components/CommandWidgets.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
import { default as React, useEffect, useState } from 'react';
import { exec } from '../util/exec';
import React from 'react';

export function Command(props) {
export function Command({ command, output, children }) {
return (
<pre style={{ backgroundColor: '#eee', overflowX: 'auto' }}>
$ {props.command} {`\n`} <PlainCommand {...props} />
$ {command} {`\n`} <PlainCommand children={children} output={output} />
</pre>
);
}

export function PlainCommand({ command, interval, children }) {
const [output, setOutput] = useState('');
useEffect(() => {
const callback = () =>
exec(command)
.then(result => setOutput(result[0]))
.catch(err => setOutput(err[1]));
const interval_handle = setInterval(callback, interval);
callback();
return () => clearInterval(interval_handle);
}, [command]);
export function PlainCommand({ children, output }) {
if (!output) return null;

if (children === undefined) {
return <>{output}</>;
Expand Down
84 changes: 84 additions & 0 deletions frontend/components/LoadChartWidget.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import Chart from 'react-apexcharts';
import React, { useEffect } from 'react';
import ApexCharts from 'apexcharts';

const graph_height = 400;

export default function LoadChartWidget(props) {
const options = {
chart: {
height: graph_height,
type: 'line',
zoom: {
enabled: true,
},
id: 'load_chart',
},
dataLabels: {
enabled: false,
},
title: {
text: props.title,
},
stroke: {
width: 2,
curve: 'smooth',
},
colors: ['#2E93fA', '#66DA26', '#546E7A'],
fill: {
type: 'gradient',
gradient: {
shadeIntensity: 1,
inverseColors: true,
gradientToColors: ['#ff0fd7', '#b7ff00', '#0841ff'],
opacityFrom: 1,
opacityTo: 1,
type: 'vertical',
stops: [0, 30],
},
},
};

const series = [
{
name: '1 minute',
data: [],
},
{
name: '5 minute',
data: [],
},
{
name: '15 mintue',
Comment thread
rroohhh marked this conversation as resolved.
Outdated
data: [],
},
];

useEffect(() => {
ApexCharts.exec('load_chart', 'updateOptions', {
xaxis: {
labels: {
show: false,
},
},
});

ApexCharts.exec('load_chart', 'appendData', [
{
data: props.data[0],
},
{
data: props.data[1],
},
{
data: props.data[2],
},
]);
});

return (
<div id="chart">
<Chart options={options} series={series} type="line" height={graph_height} />
</div>
);
}
71 changes: 71 additions & 0 deletions frontend/components/RunCommand.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { Box } from '@material-ui/core';
Comment thread
rroohhh marked this conversation as resolved.
Outdated
import React, { useEffect, useState } from 'react';
import { Command } from './CommandWidgets';
import LoadChartWidget from './LoadChartWidget';

const uptime_cmd = 'uptime';

const graph_title = 'Load average';

export default function RunCommand(props) {
const [state, setstate] = useState({
Comment thread
rroohhh marked this conversation as resolved.
Outdated
labels: [],
data: [[], [], []],
output: '',
});

function extractLoadFromString(str = '') {
let list = str.split(',').map(ele => {
return ele.trim();
});

let one_min = parseFloat(list[2].split(':')[1]);
let five_min = parseFloat(list[3]);
let fifteen_min = parseFloat(list[4]);

return {
y_value: [one_min, five_min, fifteen_min],
original_str: str,
};
}

function updateData(new_data) {
setstate({
data: [[new_data.y_value[0]], [new_data.y_value[1]], [new_data.y_value[2]]],
output: new_data.original_str,
});
}

useEffect(() => {
const callback = () =>
exec(props.command)
.then(result => {
if (props.showGraph) updateData(extractLoadFromString(result[0]));
else
setstate(prevState => ({
...prevState,
output: result[0],
}));
})
.catch(err => console.log(err[1]));
const interval_handle = setInterval(callback, props.interval);
callback();
return () => clearInterval(interval_handle);
}, [props.command]);
Comment thread
rroohhh marked this conversation as resolved.
Outdated

return (
<div>
{props.showGraph !== undefined && props.command === uptime_cmd ? (
<Box
style={{
padding: '1.5rem',
}}
>
<LoadChartWidget data={state.data} title={graph_title} />
</Box>
) : null}

<Command command={props.command} output={state.output} children={props.children} />
</div>
);
}
2 changes: 1 addition & 1 deletion frontend/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const theme = createMuiTheme({
palette: {
primary: {
main: '#FA8756',
contrastText: 'white',
contrastText: '#ffffff',
},
secondary: green,
},
Expand Down
16 changes: 8 additions & 8 deletions frontend/routes/SystemInformation.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import * as React from 'react';
import { Command } from '../components/CommandWidgets';
import RunCommand from '../components/RunCommand';

export const title = 'System Information';
export const route = '/system_information';
export const explanation = `Get an overview of whats going on in the linux side of your camera.
Ip address, system load, etc can be found here`;

export function Component(props) {
export function Component() {
return (
<div>
<Command command="date" interval={1000} />
<Command command="uptime" interval={1000} />
<Command command="free -h" interval={1000} />
<Command command="ip a" interval={1000} />
<Command command="uname -a" interval={10000} />
<Command command="ps -aef --forest" interval={10000} />
<RunCommand command="uptime" interval={1000} showGraph={true} />
<RunCommand command="date" interval={1000} />
<RunCommand command="free -h" interval={1000} />
<RunCommand command="ip a" interval={1000} />
<RunCommand command="uname -a" interval={10000} />
<RunCommand command="ps -aef --forest" interval={10000} />
</div>
);
}
Loading