Browse Source

remove comments

pull/2/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
ab2d6f83cf
  1. 174
      src/containers/DefaultLayout/DefaultLayout.js

174
src/containers/DefaultLayout/DefaultLayout.js

@ -6,7 +6,6 @@ import axios from 'axios';
import { ALERTUSER_SEARCH, ALERT_SEARCH, MENU_SEARCH, ROLEMENU_SEARCH, ALERTUSER_STATUSVIEW, ALERT_STATUSVIEW, MENU_MANAGEMENT, CONTROL_MONITORING_SEARCH } from '../../const/ApiConst'; import { ALERTUSER_SEARCH, ALERT_SEARCH, MENU_SEARCH, ROLEMENU_SEARCH, ALERTUSER_STATUSVIEW, ALERT_STATUSVIEW, MENU_MANAGEMENT, CONTROL_MONITORING_SEARCH } from '../../const/ApiConst';
import { import {
// CIcon,
AppAside, AppAside,
AppFooter, AppFooter,
AppHeader, AppHeader,
@ -51,28 +50,19 @@ class DefaultLayout extends Component {
async componentDidMount() { async componentDidMount() {
const menu = localStorage.getItem("menu_login") const menu = localStorage.getItem("menu_login")
if (menu) this.setMenu(JSON.parse(menu)) if (menu) this.setMenu(JSON.parse(menu))
// this.getMenu();
// this.getDataMenu();
console.log("componentdidmount defaultLayout");
this.getAppBreadcrumb(); this.getAppBreadcrumb();
if(!localStorage.getItem("token")){ if(!localStorage.getItem("token")){
console.log("token kosong");
this.signOut(); this.signOut();
} }
} }
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
const menu = localStorage.getItem("menu_login") const menu = localStorage.getItem("menu_login")
console.log(" token ", localStorage.getItem("token"))
const { pathname } = this.props.location; const { pathname } = this.props.location;
if (this.state.token !== prevState.token) { if (this.state.token !== prevState.token) {
// this.getDataMenu()
this.setMenu(JSON.parse(menu)) this.setMenu(JSON.parse(menu))
} }
if (this.state.role_id !== prevState.role_id) { if (this.state.role_id !== prevState.role_id) {
// this.getDataMenu()
this.setMenu(JSON.parse(menu)) this.setMenu(JSON.parse(menu))
} }
if (this.state.menu !== prevState.menu) { if (this.state.menu !== prevState.menu) {
@ -86,17 +76,12 @@ class DefaultLayout extends Component {
const { routes2 } = this.state; const { routes2 } = this.state;
if (routes2) { if (routes2) {
const newRouter2 = routes2; const newRouter2 = routes2;
// console.log("cek newRouter 2", newRouter2)
this.state.routes2.map((val, index) => { this.state.routes2.map((val, index) => {
let indexRes = this.state.menu.items.findIndex(x => x.url === val.path); let indexRes = this.state.menu.items.findIndex(x => x.url === val.path);
if (indexRes >= 0) { if (indexRes >= 0) {
let obj = newRouter2[index] let obj = newRouter2[index]
obj['name'] = this.state.menu.items[indexRes].name obj['name'] = this.state.menu.items[indexRes].name
newRouter2[index] = obj newRouter2[index] = obj
} }
}) })
this.setState({ finalRoutes: newRouter2 }, () => { this.setState({ finalRoutes: newRouter2 }, () => {
@ -111,10 +96,8 @@ class DefaultLayout extends Component {
if (e) { if (e) {
e.preventDefault() e.preventDefault()
} }
// localStorage.removeItem("u_group");
await localStorage.removeItem("role_id"); await localStorage.removeItem("role_id");
await window.localStorage.clear(); await window.localStorage.clear();
// emptyConstants();
this.props.history.replace('/login') this.props.history.replace('/login')
} }
@ -127,16 +110,10 @@ class DefaultLayout extends Component {
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
window.localStorage.setItem('countErr', 0); window.localStorage.setItem('countErr', 0);
let resData = result.data.data let resData = result.data.data
// resData.sort((a,b) => (a.join.m_menu_sequence > b.join.m_menu_sequence) ? 1 : ((b.join.m_menu_sequence > a.join.m_menu_sequence) ? -1 : 0))
// console.log(resData)
// resData.sort(function (a, b) {
// return a.join.m_menu_sequence - b.join.m_menu_sequence;
// });
this.setMenu(resData) this.setMenu(resData)
} else { } else {
if (errorCount < 4) { if (errorCount < 4) {
@ -157,7 +134,6 @@ class DefaultLayout extends Component {
window.location.reload(); window.location.reload();
} }
} }
// NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
} }
} }
@ -198,150 +174,8 @@ class DefaultLayout extends Component {
return obj return obj
}) })
// console.log(menu)
// console.log('setMenu', data)
// const menu = data || [];
// const listMenu = []
// menu.map((val, index)=>{
// let row = {
// name:val.join.m_menu_name,
// url:val.join.m_menu_url,
// icon:val.join.m_menu_icon
// }
// listMenu.push(row)
// });
// console.log("menu list",listMenu)
// const listMenu = [
// {
// name: 'Dashboard',
// url: '/dashboard',
// icon: 'icon-speedometer',
// },
// {
// name: 'Initiating',
// url: '/base',
// icon: 'cil-home',
// children: [
// {
// name: 'Project Charter',
// url: '/project-charter',
// icon: 'cil-description',
// },
// {
// name: 'Human Resource',
// url: '/human-resource',
// icon: 'cil-people',
// },
// {
// name: 'Material Resource',
// url: '/material-resource',
// icon: 'fa fa-cube',
// }
// ],
// },
// {
// name: 'Planning',
// url: '/base',
// icon: 'cil-calendar',
// children: [
// {
// name: 'Gantt',
// url: '/gantt',
// icon: 'fa fa-list-ul',
// }
// ],
// },
// {
// name: 'Executing',
// url: '/base',
// icon: 'fa fa-check',
// children: [
// {
// name: 'Planning Harian',
// url: '/planning-harian',
// icon: 'fa fa-calendar-check-o',
// }
// ],
// },
// {
// name: 'Control Monitoring',
// url: '/control-monitoring',
// icon: 'cil-clock',
// children: [
// {
// name: 'Control Monitoring',
// url: '/control-monitoring',
// icon: 'cil-clock',
// },
// {
// name: 'Presensi Resource',
// url: '/presensi-resource',
// icon: 'fa fa-calendar-check-o',
// },
// {
// name: 'Absensi Resource',
// url: '/absensi-resource',
// icon: 'fa fa-calendar-times-o',
// },
// {
// name: 'Laporan K3',
// url: '/laporan-k3',
// icon: 'fa fa-plus-circle',
// },
// {
// name: 'Broadcast',
// url: '/broadcast',
// icon: 'cil-bullhorn',
// }
// ]
// },
// {
// name: 'Closing',
// url: '/closing',
// icon: 'fa fa-calendar-times-o'
// },
// {
// name: 'Setting Platform',
// url: '/base',
// icon: 'fa fa-cog',
// children: [
// {
// name: 'Menu',
// url: '/menu',
// icon: 'fa fa-list',
// },
// {
// name: 'Role',
// url: '/roles',
// icon: 'cil-people',
// },
// {
// name: 'Project Role',
// url: '/project-role',
// icon: 'fa fa-tags',
// },
// // {
// // name: 'Admin',
// // url: '/user-admin',
// // icon: 'icon-user',
// // },
// {
// name: 'Project Type',
// url: '/project-type',
// icon: 'fa fa-bookmark-o',
// },
// {
// name: 'Alert Notifikasi',
// url: '/config-alert',
// icon: 'fa fa-bell',
// }
// ],
// }
// ]
console.log("menu", menu)
this.setState({ menu: { items: menu } }, () => { this.setState({ menu: { items: menu } }, () => {
// this.checkLocation();
}) })
} }
@ -362,7 +196,6 @@ class DefaultLayout extends Component {
getMenu = () => { getMenu = () => {
const { u_group } = this.state; const { u_group } = this.state;
if (u_group == 'kominfo') { if (u_group == 'kominfo') {
// return <AppSidebarNav navConfig={navigation_kominfo} {...this.props} router={router} />
} }
else { else {
return <AppSidebarNav navConfig={this.state.menu} {...this.props} router={router} /> return <AppSidebarNav navConfig={this.state.menu} {...this.props} router={router} />
@ -397,12 +230,6 @@ class DefaultLayout extends Component {
} }
render() { render() {
// const u_group = localStorage.getItem('u_group')
// if(u_group === null){
// return(
// <Redirect to="/login" />
// )
// }
return ( return (
<div className="app"> <div className="app">
<AppHeader fixed> <AppHeader fixed>
@ -423,7 +250,6 @@ class DefaultLayout extends Component {
</AppSidebar> </AppSidebar>
<main className="main"> <main className="main">
{this.state.breadrCrumbReady ? this.getAppBreadcrumb() : null} {this.state.breadrCrumbReady ? this.getAppBreadcrumb() : null}
{/*<AppBreadcrumb appRoutes={routes} router={router}/>*/}
<Container fluid> <Container fluid>
<Suspense fallback={this.loading()}> <Suspense fallback={this.loading()}>
<Switch> <Switch>

Loading…
Cancel
Save