github.com/YoungNK/go-ethereum@v1.9.7/dashboard/assets/common.jsx (about)

     1  // @flow
     2  
     3  // Copyright 2017 The go-ethereum Authors
     4  // This file is part of the go-ethereum library.
     5  //
     6  // The go-ethereum library is free software: you can redistribute it and/or modify
     7  // it under the terms of the GNU Lesser General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // The go-ethereum library is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    14  // GNU Lesser General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU Lesser General Public License
    17  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    18  
    19  import {faHome, faLink, faGlobeEurope, faTachometerAlt, faList} from '@fortawesome/free-solid-svg-icons';
    20  import {faCreditCard} from '@fortawesome/free-regular-svg-icons';
    21  
    22  type ProvidedMenuProp = {|title: string, icon: string|};
    23  const menuSkeletons: Array<{|id: string, menu: ProvidedMenuProp|}> = [
    24  	{
    25  		id:   'home',
    26  		menu: {
    27  			title: 'Home',
    28  			icon:  faHome,
    29  		},
    30  	}, {
    31  		id:   'chain',
    32  		menu: {
    33  			title: 'Chain',
    34  			icon:  faLink,
    35  		},
    36  	}, {
    37  		id:   'txpool',
    38  		menu: {
    39  			title: 'TxPool',
    40  			icon:  faCreditCard,
    41  		},
    42  	}, {
    43  		id:   'network',
    44  		menu: {
    45  			title: 'Network',
    46  			icon:  faGlobeEurope,
    47  		},
    48  	}, {
    49  		id:   'system',
    50  		menu: {
    51  			title: 'System',
    52  			icon:  faTachometerAlt,
    53  		},
    54  	}, {
    55  		id:   'logs',
    56  		menu: {
    57  			title: 'Logs',
    58  			icon:  faList,
    59  		},
    60  	},
    61  ];
    62  export type MenuProp = {|...ProvidedMenuProp, id: string|};
    63  // The sidebar menu and the main content are rendered based on these elements.
    64  // Using the id is circumstantial in some cases, so it is better to insert it also as a value.
    65  // This way the mistyping is prevented.
    66  export const MENU: Map<string, {...MenuProp}> = new Map(menuSkeletons.map(({id, menu}) => ([id, {id, ...menu}])));
    67  
    68  export const DURATION = 200;
    69  
    70  export const chartStrokeWidth = 0.2;
    71  
    72  export const styles = {
    73  	light: {
    74  		color: 'rgba(255, 255, 255, 0.54)',
    75  	},
    76  };
    77  
    78  // unit contains the units for the bytePlotter.
    79  export const unit = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi'];
    80  
    81  // simplifyBytes returns the simplified version of the given value followed by the unit.
    82  export const simplifyBytes = (x: number) => {
    83  	let i = 0;
    84  	for (; x > 1024 && i < 8; i++) {
    85  		x /= 1024;
    86  	}
    87  	return x.toFixed(2).toString().concat(' ', unit[i], 'B');
    88  };
    89  
    90  // hues contains predefined colors for gradient stop colors.
    91  export const hues     = ['#00FF00', '#FFFF00', '#FF7F00', '#FF0000'];
    92  export const hueScale = [0, 2048, 102400, 2097152];