Commit 96f9d10d authored by Arfin Syadziy's avatar Arfin Syadziy

Merge branch 'dev/arfin' into 'ENV-BOOTCAMP'

Dev/arfin

See merge request !1567
parents 25105f54 84e6bd54
This diff is collapsed.
This diff is collapsed.
...@@ -2,14 +2,14 @@ import React, { Component } from 'react' ...@@ -2,14 +2,14 @@ import React, { Component } from 'react'
import { Tabs, Tab, Typography, Paper, withStyles, Snackbar } from '@material-ui/core' import { Tabs, Tab, Typography, Paper, withStyles, Snackbar } from '@material-ui/core'
import ReactTooltip from 'react-tooltip' import ReactTooltip from 'react-tooltip'
import Images from '../../assets/Images' import Images from '../../assets/Images'
import ManualBookTia from './ManualBookTia' // import ManualBookTia from './ManualBookTia'
import api from '../../api' import api from '../../api'
import AuditTahunan from './AuditTahunan' // import AuditTahunan from './AuditTahunan'
import CreateManagementDoc from './CreateManagementDoc' import CreateManagementDoc from './CreateManagementDoc'
import AllDocument from './AllDocument' import AllDocument from './AllDocument'
import QReview from './QReview' // import QReview from './QReview'
import BOD from './BOD' // import BOD from './BOD'
import ManualBookETMS from './ManualBookETMS' // import ManualBookETMS from './ManualBookETMS'
import PopUpKonfirmasi from "./PopUpKonfirmasi"; import PopUpKonfirmasi from "./PopUpKonfirmasi";
import Constant from '../../library/Constant' import Constant from '../../library/Constant'
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
...@@ -30,16 +30,17 @@ export default class DocumentManagement extends Component { ...@@ -30,16 +30,17 @@ export default class DocumentManagement extends Component {
btndelete: false, btndelete: false,
load: false, load: false,
name: '', name: '',
userCompActive: [] userCompActive: [],
isHasAccessDocument: false,
} }
} }
getPermission() { getPermission(subMenu) {
let payload = { let payload = {
menu: "document management" menu: subMenu
} }
api.create().getPermission(payload).then(response => { api.create().getPermission(payload).then(response => {
// console.log(response) console.log(response)
if (response.data) { if (response.data) {
if (response.data.status === "success") { if (response.data.status === "success") {
this.setState({ this.setState({
...@@ -60,28 +61,44 @@ export default class DocumentManagement extends Component { ...@@ -60,28 +61,44 @@ export default class DocumentManagement extends Component {
} }
selectTab = (event, newEvent) => { selectTab = (event, newEvent) => {
this.setState({ tab: newEvent }) this.setState({ tab: newEvent }, () => {
// console.log(this.state.tab) console.log(this.state.tab)
this.getPermission(this.state.listData[this.state.tab].value.toLocaleLowerCase())
})
} }
componentDidMount() { componentDidMount() {
this.getDataDocument() this.getDataDocument()
this.getPermission() // this.getPermission()
this.getDetailUser() this.getDetailUser()
} }
getDataDocument(id, name) { getDataDocument(id, name) {
api.create().getDocumentCategory().then(response => { api.create().getDocumentCategory().then(response => {
// console.log(response); console.log(response);
if (response) { if (response) {
if (response.data.status === "success") { if (response.data.status === "success") {
let dataList = []
response.data.data.map((item, index) => {
// if (item.value == "Manual Book TIA 4.0sss") {
dataList.push(item)
// }
})
if (dataList.length == 0) {
this.setState({ isHasAccessDocument: dataList.length == 0 ? false : true })
} else {
this.setState({ this.setState({
listData: response.data.data, isHasAccessDocument: dataList.length == 0 ? false : true,
id: id === undefined ? response.data.data[0].setting_id : id, listData: dataList,
name: name === undefined ? response.data.data[0].value : name, id: id === undefined ? dataList[0].setting_id : id,
name: name === undefined ? dataList[0].value : name,
loadTable: true, loadTable: true,
refresh: id === undefined ? '' : 'create' refresh: id === undefined ? '' : 'create'
}, () => {
this.getPermission(dataList[0].value)
}) })
}
} else { } else {
this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => { this.setState({ alert: true, messageAlert: response.data.message, tipeAlert: 'warning', loading: false }, () => {
if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) { if (response.data.message.includes("Someone Logged In") || response.data.message.includes("Token Expired")) {
...@@ -255,7 +272,7 @@ export default class DocumentManagement extends Component { ...@@ -255,7 +272,7 @@ export default class DocumentManagement extends Component {
<Typography style={{ fontSize: '16px', color: 'white' }}>Document Management</Typography> <Typography style={{ fontSize: '16px', color: 'white' }}>Document Management</Typography>
</div> </div>
<div style={{ padding: 20 }}> <div style={{ padding: 20 }}>
{this.state.loading && loadingComponent} {this.state.loading && loadingComponent && this.state.isHasAccessDocument}
<Paper style={{ padding: 20 }}> <Paper style={{ padding: 20 }}>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}> <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
{(this.state.btncreate) && <span> {(this.state.btncreate) && <span>
...@@ -304,54 +321,15 @@ export default class DocumentManagement extends Component { ...@@ -304,54 +321,15 @@ export default class DocumentManagement extends Component {
handleLoading={this.handleLoading.bind(this)} handleLoading={this.handleLoading.bind(this)}
name={this.state.name} name={this.state.name}
/> />
// this.state.id === 68542 ?
// <AuditTahunan
// data={this.state.listData[this.state.tab]}
// refresh={this.state.refresh}
// btnedit={this.state.btnedit}
// btndelete={this.state.btndelete}
// load={this.state.load}
// />
// :
// this.state.id === 68541 ?
// <ManualBookTia
// data={this.state.listData[this.state.tab]}
// refresh={this.state.refresh}
// btnedit={this.state.btnedit}
// btndelete={this.state.btndelete}
// load={this.state.load}
// />
// :
// this.state.id === 68544 ?
// <QReview
// data={this.state.listData[this.state.tab]}
// refresh={this.state.refresh}
// btnedit={this.state.btnedit}
// btndelete={this.state.btndelete}
// load={this.state.load}
// />
// :
// this.state.id === 68543 ?
// <BOD
// data={this.state.listData[this.state.tab]}
// refresh={this.state.refresh}
// btnedit={this.state.btnedit}
// btndelete={this.state.btndelete}
// load={this.state.load}
// />
// // :
// // this.state.id === 68545 ?
// // <ManualBookETMS
// // data={this.state.listData[this.state.tab]}
// // refresh={this.state.refresh}
// // />
// :
// <span>Coming Soon</span>
)} )}
</div> </div>
</Paper> </Paper>
{!this.state.isHasAccessDocument && (
<Paper style={{ padding: 20 }}>
<label>You Don't Have Any Access in Document Management</label>
</Paper>
)}
</div> </div>
{this.state.konfirmasi && ( {this.state.konfirmasi && (
<PopUpKonfirmasi <PopUpKonfirmasi
......
import React, { Component } from 'react'
import MUIDataTable from 'mui-datatables'
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core';
import api from '../../api';
import Images from '../../assets/Images';
import ReactTooltip from 'react-tooltip';
var ct = require("../../library/CustomTable");
const getMuiTheme = () => createMuiTheme(ct.customTable());
const options = ct.customOptions();
export default class ManualBookETMS extends Component {
constructor(props) {
super(props)
this.state = {
dataTable: [],
visibleCreate: false,
refresh: ''
}
}
componentDidMount() {
// console.log(this.props.data)
this.getData()
}
componentWillReceiveProps(props) {
// console.log(props);
const { refresh, id } = this.props;
if (props.refresh !== refresh) {
this.getData()
}
}
getData() {
let payload = {
"setting_id": this.props.data.setting_id
}
api.create().getAllDocument(payload).then(response => {
console.log(response)
let dataTable = response.data.data.map((item, index) => {
return [
index,
item.document_name,
item.description,
item.company_name,
item.document_type,
String(Number(item.document_size) / 1000 + ' KB'),
item.created_by,
item.created_at,
]
})
this.setState({ dataTable })
let docPath = response.data.data.map((item) => {
return [
item.document_filepath
]
})
this.setState({ docPath })
})
}
openPopUp = async (index, val, type) =>{
if (type === 'download') {
console.log(this.state.docPath[val])
let res = await fetch(
`${process.env.REACT_APP_URL_MAIN_BE}/public/document/download_document?documentName=`+this.state.docPath[val]+"&&fileType="+index[5]
)
res = await res.blob()
// console.log(res)
if (res.size > 0) {
let url = window.URL.createObjectURL(res);
let a = document.createElement('a');
a.href = url;
a.download = index[1];
a.click();
}
}
}
render() {
let columns = [{
name: "Action",
options: {
filter: false,
sort: false,
customBodyRender: (val, tableMeta) => {
console.log(tableMeta)
return (
<div style={{ display: 'flex' }}>
{/* {this.state.btnedit && <span> */}
<a data-tip={'Download'} data-for="download">
<button
style={{
backgroundColor: 'transparent',
cursor: 'pointer',
borderColor: 'transparent',
marginRight: 15
}}
// onClick={() => console.log(tableMeta)}
onClick={() => this.openPopUp(tableMeta.rowData, val, 'download')}
>
<img src={Images.download} />
</button>
</a>
<ReactTooltip border={true} id="download" place="bottom" type="light" effect="solid" />
{/* </span>} */}
</div >
);
}
}
}, "Nama File", "Keterangan", "Perusahaan", "Tipe", "Ukuran", "Ditambahkan Oleh", "Ditambahkan Tanggal"
]
return (
<div style={{ width: '100%' }}>
<div style={{ padding: 25 }}>
<MuiThemeProvider theme={getMuiTheme()}>
<MUIDataTable
theme={getMuiTheme()}
data={this.state.dataTable}
columns={columns}
options={options}
/>
</MuiThemeProvider>
</div>
</div>
)
}
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment