|
|
|
@ -16,30 +16,12 @@ const BASE_URL = "http://siopas.co.id/custom-php/api/geohr/";
|
|
|
|
|
const config = { |
|
|
|
|
headers: |
|
|
|
|
{ |
|
|
|
|
Authorization : `Bearer ${token}`, |
|
|
|
|
"Content-type" : `application/json` |
|
|
|
|
Authorization: `Bearer ${token}`, |
|
|
|
|
"Content-type": `application/json` |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const columns = [ |
|
|
|
|
{ |
|
|
|
|
title: 'Action', |
|
|
|
|
dataIndex: '', |
|
|
|
|
key: 'x', |
|
|
|
|
className:'nowrap', |
|
|
|
|
render: (text, record) => <> |
|
|
|
|
<Tooltip title="Hapus"> |
|
|
|
|
<i className="cil-trash fa-lg" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i> |
|
|
|
|
</Tooltip> |
|
|
|
|
|
|
|
|
|
<Tooltip title="Edit"> |
|
|
|
|
<i className="fa fa-edit fa-lg" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i> |
|
|
|
|
</Tooltip> |
|
|
|
|
</>, |
|
|
|
|
}, |
|
|
|
|
{ title: 'Nama Role', dataIndex: 'name', key: 'name', className:"nowrap" }, |
|
|
|
|
{ title: 'Description', dataIndex: 'description', key: 'description' }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
const momentFormat = 'HH:mm'; |
|
|
|
|
|
|
|
|
@ -58,29 +40,51 @@ export default class index extends Component {
|
|
|
|
|
alertNotDelete: false, |
|
|
|
|
currentPage: 1, |
|
|
|
|
dataEdit: null, |
|
|
|
|
dataExport:[], |
|
|
|
|
dataExport: [], |
|
|
|
|
dataGs: [], |
|
|
|
|
dataIdHo: [], |
|
|
|
|
dataTable: [], |
|
|
|
|
dialogMenuForm: false, |
|
|
|
|
idDelete: 0, |
|
|
|
|
idRoles:0, |
|
|
|
|
menuRoles:[], |
|
|
|
|
idRoles: 0, |
|
|
|
|
menuRoles: [], |
|
|
|
|
openDialog: false, |
|
|
|
|
page: 0, |
|
|
|
|
rowsPerPage: LENGTH_DATA, |
|
|
|
|
search: "", |
|
|
|
|
tooltipDelete: false, |
|
|
|
|
tooltipEdit: false, |
|
|
|
|
tooltipExport:false, |
|
|
|
|
tooltipImport:false, |
|
|
|
|
tooltipExport: false, |
|
|
|
|
tooltipImport: false, |
|
|
|
|
tooltipMenu: false, |
|
|
|
|
tooltipTambah:false, |
|
|
|
|
tooltipTambah: false, |
|
|
|
|
totalPage: 0, |
|
|
|
|
typeDialog: 'Save', |
|
|
|
|
} |
|
|
|
|
this.columns = [ |
|
|
|
|
{ |
|
|
|
|
title: 'Action', |
|
|
|
|
dataIndex: '', |
|
|
|
|
key: 'x', |
|
|
|
|
className: 'nowrap', |
|
|
|
|
render: (text, record) => <> |
|
|
|
|
<Tooltip title="Hapus"> |
|
|
|
|
<i className="cil-trash fa-lg" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(text.id)}></i> |
|
|
|
|
|
|
|
|
|
</Tooltip> |
|
|
|
|
|
|
|
|
|
<Tooltip title="Edit"> |
|
|
|
|
<i className="fa fa-edit fa-lg" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(text)}></i> |
|
|
|
|
</Tooltip> |
|
|
|
|
</>, |
|
|
|
|
}, |
|
|
|
|
{ title: 'Nama Role', dataIndex: 'name', key: 'name', className: "nowrap" }, |
|
|
|
|
{ title: 'Description', dataIndex: 'description', key: 'description' }, |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async componentDidMount() { |
|
|
|
|
this.getDataRoles(); |
|
|
|
|
} |
|
|
|
@ -102,12 +106,12 @@ export default class index extends Component {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const formData = { |
|
|
|
|
"paging": {"start": start, "length": this.state.rowsPerPage}, |
|
|
|
|
"paging": { "start": start, "length": this.state.rowsPerPage }, |
|
|
|
|
"columns": [ |
|
|
|
|
{"name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND"} |
|
|
|
|
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" } |
|
|
|
|
], |
|
|
|
|
"joins": [], |
|
|
|
|
"orders": {"columns": ["id"], "ascending": false} |
|
|
|
|
"orders": { "columns": ["id"], "ascending": false } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const result = await axios |
|
|
|
@ -115,9 +119,9 @@ export default class index extends Component {
|
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if(result && result.data && result.data.code == 200){ |
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord }); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -142,7 +146,7 @@ export default class index extends Component {
|
|
|
|
|
this.showMenuRolesDialog(); |
|
|
|
|
} |
|
|
|
|
handleCloseDialogMr = (type, data) => { |
|
|
|
|
if(type==="save"){ |
|
|
|
|
if (type === "save") { |
|
|
|
|
this.saveMenuRoles(data) |
|
|
|
|
} |
|
|
|
|
this.setState({ dialogMenuForm: false }) |
|
|
|
@ -173,15 +177,15 @@ export default class index extends Component {
|
|
|
|
|
saveRole = async (data) => { |
|
|
|
|
|
|
|
|
|
const formData = { |
|
|
|
|
name:data.name, |
|
|
|
|
description:data.description |
|
|
|
|
name: data.name, |
|
|
|
|
description: data.description |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const result = await axios.post(PROJECT_ROLE_ADD, formData, config) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if(result && result.data && result.data.code===200){ |
|
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
|
this.getDataRoles(); |
|
|
|
|
NotificationManager.success(`Data project role berhasil ditambah`, 'Success!!'); |
|
|
|
|
} else { |
|
|
|
@ -193,15 +197,15 @@ export default class index extends Component {
|
|
|
|
|
editRole = async (data) => { |
|
|
|
|
|
|
|
|
|
const formData = { |
|
|
|
|
name:data.name, |
|
|
|
|
description:data.description |
|
|
|
|
name: data.name, |
|
|
|
|
description: data.description |
|
|
|
|
} |
|
|
|
|
const url = PROJECT_ROLE_EDIT(data.id) |
|
|
|
|
const result = await axios.put(url, formData, config) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
if(result && result.data && result.data.code===200){ |
|
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
|
this.getDataRoles(); |
|
|
|
|
NotificationManager.success(`Data project role berhasil diedit`, 'Success!!'); |
|
|
|
|
} else { |
|
|
|
@ -217,6 +221,7 @@ export default class index extends Component {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
handleDelete = (id) => { |
|
|
|
|
id == '1' ? this.setState({ alertNotDelete: true }) : |
|
|
|
|
this.setState({ alertDelete: true, idDelete: id }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -237,7 +242,7 @@ export default class index extends Component {
|
|
|
|
|
this.setState(prevState => ({ tooltipEdit: !prevState.tooltipEdit })) |
|
|
|
|
} else if (param === "delete") { |
|
|
|
|
this.setState(prevState => ({ tooltipDelete: !prevState.tooltipDelete })) |
|
|
|
|
} else if(param === "menu"){ |
|
|
|
|
} else if (param === "menu") { |
|
|
|
|
this.setState(prevState => ({ tooltipMenu: !prevState.tooltipMenu })) |
|
|
|
|
} else if (param === "tambah") { |
|
|
|
|
this.setState(prevState => ({ tooltipTambah: !prevState.tooltipTambah })) |
|
|
|
@ -247,7 +252,7 @@ export default class index extends Component {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dataNotAvailable = () => { |
|
|
|
|
if(this.state.dataTable.length===0){ |
|
|
|
|
if (this.state.dataTable.length === 0) { |
|
|
|
|
return ( |
|
|
|
|
<tr> |
|
|
|
|
<td align="center" colSpan="3">Tidak ada data project role</td> |
|
|
|
@ -258,29 +263,29 @@ export default class index extends Component {
|
|
|
|
|
|
|
|
|
|
handleExportExcel = async () => { |
|
|
|
|
const payload = { |
|
|
|
|
"paging": {"start": 0, "length": -1}, |
|
|
|
|
"paging": { "start": 0, "length": -1 }, |
|
|
|
|
"columns": [ |
|
|
|
|
{"name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND"} |
|
|
|
|
{ "name": "name", "logic_operator": "ilike", "value": this.state.search, "operator": "AND" } |
|
|
|
|
], |
|
|
|
|
"joins": [], |
|
|
|
|
"orders": {"columns": ["id"], "ascending": false} |
|
|
|
|
"orders": { "columns": ["id"], "ascending": false } |
|
|
|
|
} |
|
|
|
|
const result = await axios |
|
|
|
|
.post(PROJECT_ROLE_SEARCH, payload) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
if (result && result.data && result.statusText == "OK") { |
|
|
|
|
const dataRes = result.data.data|| []; |
|
|
|
|
const dataRes = result.data.data || []; |
|
|
|
|
console.log("data result", dataRes); |
|
|
|
|
const dataExport = []; |
|
|
|
|
dataRes.map((val,index)=> { |
|
|
|
|
dataRes.map((val, index) => { |
|
|
|
|
let row = { |
|
|
|
|
Nama:val.name, |
|
|
|
|
Deskripsi:val.description |
|
|
|
|
Nama: val.name, |
|
|
|
|
Deskripsi: val.description |
|
|
|
|
} |
|
|
|
|
dataExport.push(row); |
|
|
|
|
}) |
|
|
|
|
this.setState({ dataExport:dataExport },()=> { |
|
|
|
|
this.setState({ dataExport: dataExport }, () => { |
|
|
|
|
this.exportExcel(); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
@ -298,7 +303,7 @@ export default class index extends Component {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
const { tooltipTambah,tooltipExport,dialogMenuForm, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete,tooltipMenu } = this.state |
|
|
|
|
const { tooltipTambah, tooltipExport, dialogMenuForm, dataTable, openDialog, currentPage, rowsPerPage, totalPage, search, tooltipEdit, tooltipDelete, tooltipMenu } = this.state |
|
|
|
|
let noSeq = 0; |
|
|
|
|
return ( |
|
|
|
|
<div> |
|
|
|
@ -322,7 +327,7 @@ export default class index extends Component {
|
|
|
|
|
confirmBtnText="Can't Delete" |
|
|
|
|
confirmBtnBsStyle="danger" |
|
|
|
|
title="Data can't be delete!" |
|
|
|
|
onConfirm={() => this.setState({ alertNotDelete: false})} |
|
|
|
|
onConfirm={() => this.setState({ alertNotDelete: false })} |
|
|
|
|
> |
|
|
|
|
Data project role tidak dapat di hapus!! |
|
|
|
|
</SweetAlert> |
|
|
|
@ -347,7 +352,7 @@ export default class index extends Component {
|
|
|
|
|
<Button id="TooltipTambah" color="success" onClick={() => this.handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> |
|
|
|
|
</Tooltip> |
|
|
|
|
<Tooltip title="Export Excel"> |
|
|
|
|
<Button style={{marginLeft:"5px"}} id="TooltipExport" color="primary" onClick={()=> this.handleExportExcel()}><i className="fa fa-print"></i></Button> |
|
|
|
|
<Button style={{ marginLeft: "5px" }} id="TooltipExport" color="primary" onClick={() => this.handleExportExcel()}><i className="fa fa-print"></i></Button> |
|
|
|
|
</Tooltip> |
|
|
|
|
</Col> |
|
|
|
|
</Row> |
|
|
|
@ -356,13 +361,13 @@ export default class index extends Component {
|
|
|
|
|
<Table |
|
|
|
|
rowKey="id" |
|
|
|
|
size="small" |
|
|
|
|
columns={columns} |
|
|
|
|
columns={this.columns} |
|
|
|
|
dataSource={dataTable} |
|
|
|
|
pagination={false} |
|
|
|
|
bordered={false} |
|
|
|
|
/> |
|
|
|
|
<Pagination |
|
|
|
|
style={{marginTop:"25px"}} |
|
|
|
|
style={{ marginTop: "25px" }} |
|
|
|
|
showSizeChanger |
|
|
|
|
onShowSizeChange={this.onShowSizeChange} |
|
|
|
|
onChange={this.onPagination} |
|
|
|
|