Skip to content

Commit

Permalink
added loadingbar and incorporated into the filterabledatatable
Browse files Browse the repository at this point in the history
  • Loading branch information
ridz1208 committed Oct 10, 2024
1 parent 2d91a56 commit 0864121
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
6 changes: 5 additions & 1 deletion jsx/FilterableDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import Panel from 'jsx/Panel';
import DataTable from 'jsx/DataTable';
import Filter from 'jsx/Filter';
import LoadingBar from 'jsx/LoadingBar';

/**
* FilterableDataTable component.
Expand Down Expand Up @@ -149,7 +150,10 @@ class FilterableDataTable extends Component {
/>
);

const dataTable = (
const { progress } = this.props;
const dataTable = !isNaN(progress) && progress < 100 ? (
<LoadingBar progress={progress}/>
) : (
<DataTable
data={this.props.data}
fields={this.props.fields}
Expand Down
47 changes: 47 additions & 0 deletions jsx/LoadingBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// ########### CBIGR START ###########
import React from 'react';

/**
* LoadingBar is a React component which shows a loading bar while
* something is loading.
*
* @param {array} props - The React props
*
* @return {DOMObject} - Loading Bar React component
*/
function LoadingBar(props) {
const {progress} = props;

const wrapperStyle = {
margin: 50,
};

const containerStyles = {
height: 5,
backgroundColor: '#e0e0de',
borderRadius: 50,
};

const fillerStyles = {
height: '100%',
width: `${progress}%`,
backgroundColor: '#E89A0C',
borderRadius: 'inherit',
textAlign: 'right',
transition: 'width 1s linear',
};

const progressBar = progress >= 0 ? (
<div style={wrapperStyle}>
<h5 className='animate-flicker'>Loading...</h5>
<div style={containerStyles}>
<div style={fillerStyles}/>
</div>
</div>
) : null;

return progressBar;
};

export default LoadingBar;
// ########### CBIGR END ###########
1 change: 1 addition & 0 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const resolve: webpack.ResolveOptions = {
FilterableDataTable: path.resolve(__dirname, './jsx/FilterableDataTable'),
FilterForm: path.resolve(__dirname, './jsx/FilterForm'),
Loader: path.resolve(__dirname, './jsx/Loader'),
LoadingBar: path.resolve(__dirname, './jsx/LoadingBar'),
Modal: path.resolve(__dirname, './jsx/Modal'),
MultiSelectDropdown: path.resolve(__dirname, './jsx/MultiSelectDropdown'),
PaginationLinks: path.resolve(__dirname, './jsx/PaginationLinks'),
Expand Down

0 comments on commit 0864121

Please sign in to comment.