Skip to content

Commit

Permalink
Make the tables in Admin Panel Mobile Responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-jindal authored and akshatnitd committed May 11, 2019
1 parent e51ab1c commit a1bdb1a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/Utils/isMobileView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function() {
return window.innerWidth <= 520;
}
18 changes: 14 additions & 4 deletions src/components/Admin/ListSkills/ListSkills.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import './ListSkills.css';
import * as $ from 'jquery';

import { urls } from '../../../Utils';
import isMobileView from '../../../Utils/isMobileView';
import ChatConstants from '../../../constants/ChatConstants';

const cookies = new Cookies();
Expand Down Expand Up @@ -446,19 +447,23 @@ class ListSkills extends React.Component {
textAlign: 'left',
display: 'inline-block',
};

let MobileView = isMobileView();

let columns = [
{
title: 'Name',
dataIndex: 'skillName',
width: '20%',
width: MobileView ? '30vw' : '20%',
fixed: MobileView ? 'left' : null,
},
{
title: 'Group',
dataIndex: 'group',
filters: this.state.groups,
onFilter: (value, record) => record.group.indexOf(value) === 0,
sorter: (a, b) => a.group.length - b.group.length,
width: '10%',
width: MobileView ? 'auto' : '10%',
},
{
title: 'Language',
Expand Down Expand Up @@ -571,12 +576,13 @@ class ListSkills extends React.Component {
{
title: 'Name',
dataIndex: 'skillName',
width: '20%',
width: MobileView ? '30vw' : '20%',
fixed: MobileView ? 'fixed' : null,
},
{
title: 'Model',
dataIndex: 'model',
width: '10%',
width: MobileView ? 'auto' : '10%',
},
{
title: 'Group',
Expand Down Expand Up @@ -618,6 +624,8 @@ class ListSkills extends React.Component {
},
];

const Scroll = { x: 1500, y: 300 };

return (
<div>
{cookies.get('showAdmin') === 'true' ? (
Expand Down Expand Up @@ -892,6 +900,7 @@ class ListSkills extends React.Component {
rowKey={record => record.registered}
dataSource={this.state.skillsData}
loading={this.state.loading}
scroll={MobileView ? Scroll : ''}
/>
</LocaleProvider>
</TabPane>
Expand All @@ -905,6 +914,7 @@ class ListSkills extends React.Component {
}}
rowKey={record => record.registered}
dataSource={this.state.deletedSkills}
scroll={MobileView ? Scroll : ''}
/>
</LocaleProvider>
</TabPane>
Expand Down
15 changes: 12 additions & 3 deletions src/components/Admin/SystemSettings/SystemSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import enUS from 'antd/lib/locale-provider/en_US';
import NotFound from '../../NotFound/NotFound.react';

import urls from '../../../Utils/urls';
import isMobileView from '../../../Utils/isMobileView.js';

const cookies = new Cookies();

Expand All @@ -26,16 +27,19 @@ class SystemSettings extends Component {
loading: true,
};

let MobileView = isMobileView();

this.keysColumns = [
{
title: 'S.No.',
dataIndex: 'serialNum',
width: '10%',
width: MobileView ? '15vw' : '10%',
fixed: MobileView ? 'left' : null,
},
{
title: 'Key Name',
dataIndex: 'keyName',
width: '30%',
width: MobileView ? 'auto' : '30%',
},
{
title: 'Value',
Expand Down Expand Up @@ -101,6 +105,10 @@ class SystemSettings extends Component {
display: 'inline-block',
};

const Scroll = { x: 1500, y: 300 };

let MobileView = isMobileView();

return (
<div>
{cookies.get('showAdmin') === 'true' ? (
Expand Down Expand Up @@ -135,8 +143,9 @@ class SystemSettings extends Component {
loading={this.state.loading}
pagination={false}
style={{
width: '50%',
width: '100%',
}}
scroll={MobileView ? Scroll : ''}
/>
</LocaleProvider>
</div>
Expand Down

0 comments on commit a1bdb1a

Please sign in to comment.