Skip to content

Commit

Permalink
chore: run prettier to format frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
CyndieKamau committed Aug 15, 2024
1 parent fd85c46 commit be7f7e6
Show file tree
Hide file tree
Showing 27 changed files with 253 additions and 297 deletions.
2 changes: 1 addition & 1 deletion frontend/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile.README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# substrate-telemetry-frontend

### [Documentation](https://github.com/paritytech/substrate-telemetry/blob/master/README.md)
### [Documentation](https://github.com/paritytech/substrate-telemetry/blob/master/README.md)
18 changes: 10 additions & 8 deletions frontend/assets/index.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<title>Polkadot Telemetry</title>
<script type="text/javascript" src="/tmp/env-config.js"></script>
<style>
body, html {
body,
html {
background: #fff;
color: #111;
}
</style>
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<noscript> You need to enable JavaScript to run this app. </noscript>
<div id="root"></div>
</body>
</html>
2 changes: 1 addition & 1 deletion frontend/assets/mock.image.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// loading images gives back a path. This is what we replace
// that with for tests:
module.exports = 'test-image-stub';
module.exports = 'test-image-stub';
2 changes: 1 addition & 1 deletion frontend/assets/mock.style.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// For loading styles, give back an empty object in tests:
module.exports = {};
module.exports = {};
6 changes: 3 additions & 3 deletions frontend/images.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

declare module '*.svg'
declare module '*.png'
declare module '*.jpg'
declare module '*.svg';
declare module '*.png';
declare module '*.jpg';
7 changes: 4 additions & 3 deletions frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module.exports = {
testEnvironment: 'jsdom',
setupFiles: ['<rootDir>/setupJest.js'],
moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/assets/mock.image.js",
"\\.(css|less|scss|sass)$": "<rootDir>/assets/mock.style.js"
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/assets/mock.image.js',
'\\.(css|less|scss|sass)$': '<rootDir>/assets/mock.style.js',
},
};
};
2 changes: 1 addition & 1 deletion frontend/setupJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;

// polyfill fetch since it's not in jsdom:
require('whatwg-fetch');
require('whatwg-fetch');
5 changes: 2 additions & 3 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export default class App extends React.Component {
blockpropagation: true,
blocklasttime: false,
uptime: false,
version: true,
version: true,
target_os: true,
target_arch: true,
target_arch: true,
core_count: true,
memory: true,
is_virtual_machine: true,
Expand All @@ -85,7 +85,6 @@ export default class App extends React.Component {
disk_sequential_write_score: true,
disk_random_write_score: true,
cpu_vendor: true,

},
(settings) => {
const selectedColumns = this.selectedColumns(settings);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class Connection {
this.bindSocket();
}

public subscribe(chain: Types.GenesisHash) {
public subscribe(chain: Types.GenesisHash) {
if (
this.appState.subscribed != null &&
this.appState.subscribed !== chain
Expand Down Expand Up @@ -210,7 +210,7 @@ export class Connection {
nodeHardware,
blockDetails,
location,
startupTime,
startupTime
);

nodes.add(node);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/common/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ interface AddedNodeMessage extends MessageBase {
NodeHardware,
BlockDetails,
Maybe<NodeLocation>,
Maybe<Timestamp>,
Maybe<Timestamp>
];
}

Expand Down
20 changes: 9 additions & 11 deletions frontend/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ export type NodeId = Id<'Node'>;
export type NodeName = Opaque<string, 'NodeName'>;
export type NodeImplementation = Opaque<string, 'NodeImplementation'>;
export type NodeVersion = Opaque<string, 'NodeVersion'>;
export type OperatingSystem = Opaque<string, 'OperatingSystem'>;
export type CpuArchitecture = Opaque<string, 'CpuArchitecture'>;
export type Cpu = string;
export type CpuCores = number;
export type TargetEnv = string;
export type Memory = number;
export type VirtualMachine = boolean;
export type LinuxKernel = string;
export type LinuxDistro = string;
export type OperatingSystem = Opaque<string, 'OperatingSystem'>;
export type CpuArchitecture = Opaque<string, 'CpuArchitecture'>;
export type Cpu = string;
export type CpuCores = number;
export type TargetEnv = string;
export type Memory = number;
export type VirtualMachine = boolean;
export type LinuxKernel = string;
export type LinuxDistro = string;
export type BlockNumber = Opaque<number, 'BlockNumber'>;
export type BlockHash = Opaque<string, 'BlockHash'>;
export type Address = Opaque<string, 'Address'>;
Expand All @@ -52,8 +52,6 @@ export type Bytes = Opaque<number, 'Bytes'>;
export type BytesPerSecond = Opaque<number, 'BytesPerSecond'>;
export type NetworkId = Opaque<string, 'NetworkId'>;



export type NodeSysInfo = {
cpu: string | null;
memory: number | null;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/List/Column/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
BlockPropagationColumn,
LastBlockColumn,
UptimeColumn,
CpuArchitectureColumn, //extra columns added
CpuArchitectureColumn, //extra columns added
CpuColumn,
CpuCoresColumn,
LinuxKernelColumn,
Expand Down
43 changes: 18 additions & 25 deletions frontend/src/components/List/Column/CpuArchitectureColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,23 @@ import { Node } from '../../../state';
import icon from '../../../icons/file-binary.svg';

export class CpuArchitectureColumn extends React.Component<ColumnProps> {
public static readonly label = 'CPU Architecture';
public static readonly icon = icon;
public static readonly width = 154;
public static readonly setting = 'target_arch';
public static readonly sortBy = ({ target_arch }: Node) => target_arch || '';

private data: string;


public shouldComponentUpdate(nextProps: ColumnProps) {
return this.data !== nextProps.node.hash;
}

render() {
const { target_arch } = this.props.node;

this.data = target_arch;

return (
<td className="Column">
{target_arch}
</td>
);
}
public static readonly label = 'CPU Architecture';
public static readonly icon = icon;
public static readonly width = 154;
public static readonly setting = 'target_arch';
public static readonly sortBy = ({ target_arch }: Node) => target_arch || '';

private data: string;

public shouldComponentUpdate(nextProps: ColumnProps) {
return this.data !== nextProps.node.hash;
}


render() {
const { target_arch } = this.props.node;

this.data = target_arch;

return <td className="Column">{target_arch}</td>;
}
}
46 changes: 19 additions & 27 deletions frontend/src/components/List/Column/CpuColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,23 @@ import { Node } from '../../../state';
import icon from '../../../icons/file-binary.svg';

export class CpuColumn extends React.Component<ColumnProps> {
public static readonly label = 'CPU Column';
public static readonly icon = icon;
public static readonly width = 154;
public static readonly setting = 'cpu';
public static readonly sortBy = ({ cpu }: Node) => cpu || 0;

private data: string;

public shouldComponentUpdate(nextProps: ColumnProps) {
return this.data !== nextProps.node.cpu;
}

render() {
const { cpu } = this.props.node;

this.data = cpu;

return (
<td className="Column">
{cpu}
</td>
);

}


public static readonly label = 'CPU Column';
public static readonly icon = icon;
public static readonly width = 154;
public static readonly setting = 'cpu';
public static readonly sortBy = ({ cpu }: Node) => cpu || 0;

private data: string;

public shouldComponentUpdate(nextProps: ColumnProps) {
return this.data !== nextProps.node.cpu;
}

render() {
const { cpu } = this.props.node;

this.data = cpu;

return <td className="Column">{cpu}</td>;
}
}
43 changes: 19 additions & 24 deletions frontend/src/components/List/Column/CpuCoresColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,23 @@ import { Node } from '../../../state';
import icon from '../../../icons/file-binary.svg';

export class CpuCoresColumn extends React.Component<ColumnProps> {
public static readonly label = 'CPU Cores';
public static readonly icon = icon;
public static readonly width = 154;
public static readonly setting = 'core_count';
public static readonly sortBy = ({ core_count }: Node) => core_count || 0;

private data: number;

public shouldComponentUpdate(nextProps: ColumnProps) {
return this.data !== nextProps.node.core_count;
}

render() {
const { core_count } = this.props.node;

this.data = core_count;

return (
<td className="Column">
{core_count}
</td>
);
}
public static readonly label = 'CPU Cores';
public static readonly icon = icon;
public static readonly width = 154;
public static readonly setting = 'core_count';
public static readonly sortBy = ({ core_count }: Node) => core_count || 0;

private data: number;

public shouldComponentUpdate(nextProps: ColumnProps) {
return this.data !== nextProps.node.core_count;
}

render() {
const { core_count } = this.props.node;

this.data = core_count;

return <td className="Column">{core_count}</td>;
}
}
44 changes: 20 additions & 24 deletions frontend/src/components/List/Column/IsVirtualMachineColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,24 @@ import { Node } from '../../../state';
import icon from '../../../icons/file-binary.svg';

export class IsVirtualMachineColumn extends React.Component<ColumnProps> {
public static readonly label = 'Virtual Machine';
public static readonly icon = icon;
public static readonly width = 154;
public static readonly setting = 'is_virtual_machine';
public static readonly sortBy = ({ is_virtual_machine }: Node) => is_virtual_machine || false;

private data: boolean;
public static readonly label = 'Virtual Machine';
public static readonly icon = icon;
public static readonly width = 154;
public static readonly setting = 'is_virtual_machine';
public static readonly sortBy = ({ is_virtual_machine }: Node) =>
is_virtual_machine || false;


public shouldComponentUpdate(nextProps: ColumnProps) {
return this.data !== nextProps.node.is_virtual_machine;
}

render() {
const { is_virtual_machine } = this.props.node;

this.data = is_virtual_machine;

return (
<td className="Column">
{is_virtual_machine ? "True" : "False"}
</td>
);
}
}
private data: boolean;

public shouldComponentUpdate(nextProps: ColumnProps) {
return this.data !== nextProps.node.is_virtual_machine;
}

render() {
const { is_virtual_machine } = this.props.node;

this.data = is_virtual_machine;

return <td className="Column">{is_virtual_machine ? 'True' : 'False'}</td>;
}
}
Loading

0 comments on commit be7f7e6

Please sign in to comment.