|
|
@ -3,23 +3,17 @@ import { NavLink } from 'react-router-dom'; |
|
|
|
import { Badge, Nav, NavItem } from 'reactstrap'; |
|
|
|
import { Badge, Nav, NavItem } from 'reactstrap'; |
|
|
|
import PropTypes from 'prop-types'; |
|
|
|
import PropTypes from 'prop-types'; |
|
|
|
import { Menu, Dropdown } from 'antd' |
|
|
|
import { Menu, Dropdown } from 'antd' |
|
|
|
import { ALERTUSER_SEARCH, ALERT_SEARCH, ALERTUSER_STATUSVIEW, ALERT_STATUSVIEW, APP_MODE } from '../../const/ApiConst'; |
|
|
|
import { ALERTUSER_SEARCH, ALERT_SEARCH, ALERTUSER_STATUSVIEW, ALERT_STATUSVIEW, APP_MODE, BASE_SIMPRO_LUMEN_IMAGE } from '../../const/ApiConst'; |
|
|
|
import { AppAsideToggler, AppNavbarBrand, AppSidebarToggler } from '@coreui/react'; |
|
|
|
import { AppAsideToggler, AppNavbarBrand, AppSidebarToggler } from '@coreui/react'; |
|
|
|
import logo_ospro from '../../assets/img/OSPRO.png' |
|
|
|
import logo_ospro from '../../assets/img/OSPRO.png' |
|
|
|
import axios from 'axios'; |
|
|
|
import axios from 'axios'; |
|
|
|
import './Default.css' |
|
|
|
import './Default.css' |
|
|
|
const token = window.localStorage.getItem('token'); |
|
|
|
|
|
|
|
const propTypes = { |
|
|
|
const propTypes = { |
|
|
|
children: PropTypes.node, |
|
|
|
children: PropTypes.node, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const config = { |
|
|
|
|
|
|
|
headers: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Authorization: `Bearer ${token}`, |
|
|
|
|
|
|
|
"Content-type": `application/json` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const defaultProps = {}; |
|
|
|
const defaultProps = {}; |
|
|
|
|
|
|
|
|
|
|
@ -42,8 +36,32 @@ class DefaultHeader extends Component { |
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
componentDidMount() { |
|
|
|
this.getHeaderMenu(); |
|
|
|
this.getHeaderMenu(); |
|
|
|
|
|
|
|
const token = window.localStorage.getItem('token'); |
|
|
|
|
|
|
|
const role = window.localStorage.getItem('role_name'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (role !== 'Super Admin') { |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
configApp: JSON.parse(window.localStorage.getItem('configApp')), |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.setState({ |
|
|
|
|
|
|
|
config: { |
|
|
|
|
|
|
|
headers: { |
|
|
|
|
|
|
|
Authorization: `Bearer ${token}`, |
|
|
|
|
|
|
|
'Content-type': `application/json`, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getLogoHeaderContent = () => { |
|
|
|
|
|
|
|
const { configApp } = this.state; |
|
|
|
|
|
|
|
const logoHeaderContent = configApp && configApp.logo_header ? configApp.logo_header.content : null; |
|
|
|
|
|
|
|
return logoHeaderContent |
|
|
|
|
|
|
|
? `${BASE_SIMPRO_LUMEN_IMAGE}/${logoHeaderContent}` |
|
|
|
|
|
|
|
: logo_ospro; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps, prevState) { |
|
|
|
componentDidUpdate(prevProps, prevState) { |
|
|
|
if (this.state.listReadNotif !== prevState.listReadNotif) { |
|
|
|
if (this.state.listReadNotif !== prevState.listReadNotif) { |
|
|
|
if (this.state.listReadNotif.length > 0) { |
|
|
|
if (this.state.listReadNotif.length > 0) { |
|
|
@ -107,7 +125,7 @@ class DefaultHeader extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
const result = await axios |
|
|
|
.post(url, payload, config) |
|
|
|
.post(url, payload, this.state.config) |
|
|
|
.then(res => res) |
|
|
|
.then(res => res) |
|
|
|
.catch((error) => error.response); |
|
|
|
.catch((error) => error.response); |
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
@ -178,14 +196,14 @@ class DefaultHeader extends Component { |
|
|
|
if (parseInt(localStorage.getItem('role_id')) === 1) { |
|
|
|
if (parseInt(localStorage.getItem('role_id')) === 1) { |
|
|
|
data.map((val, index) => { |
|
|
|
data.map((val, index) => { |
|
|
|
let url = ALERT_STATUSVIEW(val) |
|
|
|
let url = ALERT_STATUSVIEW(val) |
|
|
|
promises.push(axios.put(url, payload, config) |
|
|
|
promises.push(axios.put(url, payload, this.state.config) |
|
|
|
.then(res => result.push(res))); |
|
|
|
.then(res => result.push(res))); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
data.map((val, index) => { |
|
|
|
data.map((val, index) => { |
|
|
|
let url = ALERTUSER_STATUSVIEW(val) |
|
|
|
let url = ALERTUSER_STATUSVIEW(val) |
|
|
|
promises.push(axios.put(url, payload, config) |
|
|
|
promises.push(axios.put(url, payload, this.state.config) |
|
|
|
.then(res => result.push(res))) |
|
|
|
.then(res => result.push(res))) |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -199,11 +217,14 @@ class DefaultHeader extends Component { |
|
|
|
getLogo = () => { |
|
|
|
getLogo = () => { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div style={{ width: '10%', display: 'flex', justifyContent: 'center' }}> |
|
|
|
<div style={{ width: '10%', display: 'flex', justifyContent: 'center' }}> |
|
|
|
<img style={{ width: '100%', height: '100%' }} src={logo_ospro} /> |
|
|
|
<img |
|
|
|
|
|
|
|
style={{ width: '100%', height: '100%' }} |
|
|
|
|
|
|
|
src={this.getLogoHeaderContent()} |
|
|
|
|
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// logo_ospro
|
|
|
|
getHeaderMenu = () => { |
|
|
|
getHeaderMenu = () => { |
|
|
|
const { fullname, u_group } = this.state; |
|
|
|
const { fullname, u_group } = this.state; |
|
|
|
if (u_group == 'kominfo') { |
|
|
|
if (u_group == 'kominfo') { |
|
|
|