Browse Source

Merge branch 'staging' of https://git.oslog.id/ordo/adw-frontend into dev-wahyun

pull/2/head
wahyuun 1 year ago
parent
commit
dc2be0322c
  1. 63
      src/views/Master/MasterRoles/DialogForm.js
  2. 6
      src/views/Master/MasterRoles/index.js
  3. 49
      src/views/Pages/Login/Login.js
  4. 284
      src/views/SimproV2/CreatedProyek/ReportAnalysis.js
  5. 30
      src/views/SimproV2/CreatedProyek/index.js

63
src/views/Master/MasterRoles/DialogForm.js

@ -3,6 +3,19 @@ import { Modal, ModalHeader, ModalBody, ModalFooter, Row, Col } from 'reactstrap
import { Button, Form, FormGroup, Label, Input } from 'reactstrap'; import { Button, Form, FormGroup, Label, Input } from 'reactstrap';
import 'antd/dist/antd.css'; import 'antd/dist/antd.css';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
import axios from 'axios';
import { Select } from 'antd';
import { MENU_SEARCH } from '../../../const/ApiConst.js';
const { Option } = Select
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
class DialogForm extends Component { class DialogForm extends Component {
constructor(props) { constructor(props) {
@ -13,11 +26,14 @@ class DialogForm extends Component {
description: "", description: "",
openDialog: false, openDialog: false,
isParentClick: false, isParentClick: false,
menu: [],
selectedMenu: null
} }
} }
async componentDidMount() { async componentDidMount() {
this.props.showDialog(this.showDialog); this.props.showDialog(this.showDialog);
this.getAllMenu();
} }
async componentDidUpdate() { async componentDidUpdate() {
@ -27,19 +43,38 @@ class DialogForm extends Component {
this.setState({ this.setState({
id: dataEdit.id, id: dataEdit.id,
name: dataEdit.name, name: dataEdit.name,
description: dataEdit.description description: dataEdit.description,
selectedMenu: dataEdit.default_page
}) })
} else { } else {
this.setState({ this.setState({
id: 0, id: 0,
name: "", name: "",
description: "" description: "",
selectedMenu: null
}) })
} }
this.setState({ isParentClick: false }); this.setState({ isParentClick: false });
} }
} }
getAllMenu = async () => {
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "name", "logic_operator": "ilike", "value": "", "operator": "AND" }
],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(MENU_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
this.setState({ menu: result.data.data });
}
}
showDialog = () => { showDialog = () => {
this.setState({ isParentClick: true }); this.setState({ isParentClick: true });
@ -60,7 +95,8 @@ class DialogForm extends Component {
const { const {
id, id,
name, name,
description description,
selectedMenu
} = this.state } = this.state
let data = ''; let data = '';
@ -70,14 +106,16 @@ class DialogForm extends Component {
data = { data = {
id, id,
name, name,
description description,
selectedMenu
} }
this.props.closeDialog('save', data); this.props.closeDialog('save', data);
} else { } else {
data = { data = {
id, id,
name, name,
description description,
selectedMenu
} }
this.props.closeDialog('edit', data); this.props.closeDialog('edit', data);
} }
@ -113,6 +151,21 @@ class DialogForm extends Component {
<Input type="text" value={this.state.description} onChange={(e) => this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} /> <Input type="text" value={this.state.description} onChange={(e) => this.setState({ description: e.target.value })} placeholder={this.props.t('inputDescription')} />
</FormGroup> </FormGroup>
</Col> </Col>
<Col md={12}>
<FormGroup>
<Label>Default Page<span style={{ color: "red" }}>*</span></Label>
<Input type="select" value={this.state.selectedMenu} placeholder={"Select default page"}
onChange={(e) => {
this.setState({ selectedMenu: e.target.value });
}}>
{this.state.menu.map((item) => (
<option key={item.id} value={item.id}>
{item.name}
</option>
))}
</Input>
</FormGroup>
</Col>
</Row> </Row>
</Form> </Form>
) )

6
src/views/Master/MasterRoles/index.js

@ -179,7 +179,8 @@ class index extends Component {
const formData = { const formData = {
name: data.name, name: data.name,
description: data.description description: data.description,
default_page : data.selectedMenu
} }
const result = await axios.post(ROLE_ADD, formData, config) const result = await axios.post(ROLE_ADD, formData, config)
@ -198,7 +199,8 @@ class index extends Component {
editRole = async (data) => { editRole = async (data) => {
const formData = { const formData = {
name: data.name, name: data.name,
description: data.description description: data.description,
default_page: data.selectedMenu
} }
const url = ROLE_EDIT(data.id) const url = ROLE_EDIT(data.id)
const result = await axios.put(url, formData, config) const result = await axios.put(url, formData, config)

49
src/views/Pages/Login/Login.js

@ -27,7 +27,7 @@ import {
CarouselItem, CarouselItem,
CarouselControl CarouselControl
} from 'reactstrap'; } from 'reactstrap';
import { USER_LOGIN, USER_LOGIN_V2, CALERTUSER_SEARCH, MENU_MANAGEMENT, APP_MODE } from '../../../const/ApiConst.js'; import { USER_LOGIN, USER_LOGIN_V2, CALERTUSER_SEARCH, MENU_MANAGEMENT, APP_MODE, ROLE_SEARCH } from '../../../const/ApiConst.js';
import { appConfig, reloadConstants } from '../../../const/MapConst.js'; import { appConfig, reloadConstants } from '../../../const/MapConst.js';
import { APP_NAME } from '../../../const/AppConst.js' import { APP_NAME } from '../../../const/AppConst.js'
import moment from "moment" import moment from "moment"
@ -65,7 +65,8 @@ class Login extends Component {
emailState: '', emailState: '',
}, },
loader: false, loader: false,
type: 'password' type: 'password',
defaultPage: ''
} }
this.handleChange = this.handleChange.bind(this); this.handleChange = this.handleChange.bind(this);
this.showHide = this.showHide.bind(this); this.showHide = this.showHide.bind(this);
@ -97,6 +98,41 @@ class Login extends Component {
}); });
} }
getDataRole = async (token, role_id) => {
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
{ "name": "id", "logic_operator": "=", "value": `${role_id}`, "operator": "AND" }
],
"joins": [
{
"name": "m_menu",
"column_join": "default_page",
"column_results": ["id", "name", "url"],
},
],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(ROLE_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let resData = result.data.data
this.setState({defaultPage: resData[0].join_first_url})
}
}
getDataMenu = async (token, role_id) => { getDataMenu = async (token, role_id) => {
const config = { const config = {
headers: headers:
@ -123,6 +159,14 @@ class Login extends Component {
else { else {
this.props.history.push("/dashboard"); this.props.history.push("/dashboard");
} }
if (this.state.defaultPage) {
this.props.history.push(this.state.defaultPage);
} else if (role_id == 28) {
this.props.history.push("/dashboard-customer/58/63");
}
else {
this.props.history.push("/dashboard");
}
} else { } else {
NotificationManager.error('Login Failed', 'Failed'); NotificationManager.error('Login Failed', 'Failed');
this.setState({ loader: false }) this.setState({ loader: false })
@ -164,6 +208,7 @@ class Login extends Component {
if (doLogin && doLogin.data && doLogin.data.code === 200) { if (doLogin && doLogin.data && doLogin.data.code === 200) {
const { access_token, data_user } = doLogin.data.data const { access_token, data_user } = doLogin.data.data
this.getDataRole(access_token, data_user.role_id)
this.getDataMenu(access_token, data_user.role_id) this.getDataMenu(access_token, data_user.role_id)
window.localStorage.setItem('isLogin', true); window.localStorage.setItem('isLogin', true);
window.localStorage.setItem('token', access_token); window.localStorage.setItem('token', access_token);

284
src/views/SimproV2/CreatedProyek/ReportAnalysis.js

@ -0,0 +1,284 @@
import React, {useState, useEffect} from 'react'
import { Modal, ModalHeader, ModalBody, ModalFooter, Card, CardHeader, CardBody } from 'reactstrap';
import { TabContent, TabPane, Nav, NavItem, NavLink, Row, Col, Input } from 'reactstrap';
import { Button } from 'reactstrap';
import axios from "../../../const/interceptorApi";
import {
NotificationManager,
} from "react-notifications";
import { BASE_SIMPRO_LUMEN } from "../../../const/ApiConst";
import 'antd/dist/antd.css';
import './style.css'
import { Select, Table } from 'antd';
const { Option } = Select
const ReportAnalysis = ({ openDialog, closeDialog, toggleDialog, projectId }) => {
const token = localStorage.getItem("token");
const [activeTab, setActiveTab] = useState('1');
const [search, setSearch] = useState('');
const [avgActivity, setAvgActivity] = useState(0);
const [dataTable, setDatatable] = useState([]);
const [dataTableActivityToHr, setDataTableActivityToHr] = useState([]);
const [hrList, setHrList] = useState([]);
const [selectedHr, setSelectedHr] = useState(null);
const toggle = (tab) => {
if (activeTab !== tab) {
setActiveTab(tab);
}
};
const HEADER = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
};
const columns = [
{title: "Activity Name", dataIndex: "name", key: "name"}
]
const columnActivityToHr = [
{title: "Activity", dataIndex: "join_third_name", key: "join_third_name"},
{title: "Human Resource", dataIndex: "join_second_name", key: "join_second_name"},
{title: "Report Date", dataIndex: "report_date", key: "report_date"},
{title: "Volume Actual", dataIndex: "qty", key: "qty"},
{title: "Volume Planned", dataIndex: "join_first_qty_planning", key: "join_first_qty_planning"},
{title: "Description", dataIndex: "description", key: "description"}
]
useEffect(() => {
if (search) {
getDataActivity()
}
}, [search]);
useEffect(() => {
if (selectedHr) {
getDataActivityToHr()
}
}, [selectedHr]);
useEffect(() => {
getDataHr()
}, []);
const handleSearch = (e) => {
const value = e.target.value;
setSearch(value);
};
const getDataHr = async () => {
const result = await axios
.get(`${BASE_SIMPRO_LUMEN}/human-resource/list`, HEADER)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
setHrList(dataRes);
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
}
const getDataActivityToHr = async () => {
setAvgActivity(0);
let sum = 0;
const payload = {
columns: [
{
name: "user_id",
logic_operator: "=",
value: selectedHr,
operator: "AND",
},
{
name: "proyek_id",
logic_operator: "=",
value: projectId,
table_name: "m_activity",
operator: "AND",
}
],
joins: [
{
name: "assign_material_to_activity",
column_join: "assign_material_id",
column_results: ["qty_planning"]
},
{
name: "m_users",
column_join: "user_id",
column_results: ["name"]
},
{
name: "m_activity",
column_join: "activity_id",
column_results: ["name", "persentase_progress"]
}
],
orders: { columns: ["id"], ascending: false },
paging: { start: 0, length: -1 },
};
const result = await axios
.post(`${BASE_SIMPRO_LUMEN}/report-activity-material/search`, payload, HEADER)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
dataRes.forEach(element => {
element.join_third_persentase_progress ? sum += parseInt(element.join_third_persentase_progress) : sum += 0;
});
setAvgActivity(sum / dataRes.length);
setDataTableActivityToHr(dataRes);
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
const getDataActivity = async () => {
setAvgActivity(0);
let sum = 0;
const payload = {
columns: [
{
name: "name",
logic_operator: "ilike",
value: search,
operator: "AND",
},
],
orders: { columns: ["id"], ascending: false },
paging: { start: 0, length: -1 },
};
const result = await axios
.post(`${BASE_SIMPRO_LUMEN}/activity/search`, payload, HEADER)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || [];
dataRes.forEach(element => {
element.persentase_progress ? sum += parseInt(element.persentase_progress) : sum += 0;
});
setAvgActivity(sum / dataRes.length);
setDatatable(dataRes);
} else {
NotificationManager.error("Gagal Mengambil Data!!", "Failed");
}
};
return (
<>
<Modal size="xl" isOpen={openDialog} toggle={toggleDialog}>
<ModalHeader className="capitalize" toggle={closeDialog}>Project</ModalHeader>
<ModalBody>
<div>
<Nav tabs>
<NavItem>
<NavLink
className={activeTab === '1' ? "active" : null}
onClick={() => {
toggle('1');
}}
>
Activity
</NavLink>
</NavItem>
<NavItem>
<NavLink
className={activeTab === '2' ? "active" : null}
onClick={() => {
toggle('2');
}}
>
Human Resource
</NavLink>
</NavItem>
</Nav>
<TabContent activeTab={activeTab}>
<TabPane tabId="1">
<Card>
<CardHeader>
<Row>
<Col>
<Input
onChange={handleSearch}
value={search}
type="text"
name="search"
id="search"
placeholder={`Search Activity Name`}
style={{ width: 200 }}
/>
</Col>
</Row>
</CardHeader>
<CardBody>
<div style={{ textAlign: 'center' }}>
<h1>
{
search && avgActivity ? `Activity ${search} adalah ${avgActivity.toFixed(2)} %` : null
}
</h1>
</div>
<Table
size="small"
columns={columns}
dataSource={dataTable}
pagination={false}
rowKey={"id"}
/>
</CardBody>
</Card>
</TabPane>
<TabPane tabId="2">
<Card>
<CardHeader>
<Row>
<Col>
<Select showSearch value={selectedHr} onChange={(val) => setSelectedHr(val)} placeholder="Select Human Resource" filterOption={(input, option) =>
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
} style={{ width: '100%' }}>
{hrList && hrList.map(res => (
<Option key={res.id} value={res.id}>{`${res.name}`}</Option>
))}
</Select>
</Col>
</Row>
</CardHeader>
<CardBody>
<div style={{ textAlign: 'center' }}>
<h1>
{
selectedHr && avgActivity ? `Activity user ini adalah ${avgActivity.toFixed(2)} %` : null
}
</h1>
</div>
<Table
size="small"
columns={columnActivityToHr}
dataSource={dataTableActivityToHr}
pagination={false}
rowKey={"id"}
/>
</CardBody>
</Card>
</TabPane>
</TabContent>
</div>
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={closeDialog}>Close</Button>
</ModalFooter>
</Modal>
</>
)
}
export default ReportAnalysis;

30
src/views/SimproV2/CreatedProyek/index.js

@ -87,6 +87,7 @@ import AssignHrProject from "./AsignHrProject";
import AssignCustProject from "./AsignCustProject"; import AssignCustProject from "./AsignCustProject";
import AssignK3Project from "./AssignK3Project"; import AssignK3Project from "./AssignK3Project";
import ViewProject from "./ViewProject"; import ViewProject from "./ViewProject";
import ReportAnalysis from "./ReportAnalysis";
import { Icon } from "@iconify/react"; import { Icon } from "@iconify/react";
// import { Link } from 'react-router-dom'; // import { Link } from 'react-router-dom';
// import SubProyekComp from './SubProyekComp'; // import SubProyekComp from './SubProyekComp';
@ -116,12 +117,14 @@ const CreatedProyek = ({ params, ...props }) => {
}; };
const [idTask, setidTask] = useState(0); const [idTask, setidTask] = useState(0);
const [projectId, setProjectId] = useState(0);
const [dataTable, setDatatable] = useState([]); const [dataTable, setDatatable] = useState([]);
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
const [currentPage, setCurrentPage] = useState(1); const [currentPage, setCurrentPage] = useState(1);
const [totalPage, setTotalPage] = useState(0); const [totalPage, setTotalPage] = useState(0);
const [openDialog, setOpenDialog] = useState(false); const [openDialog, setOpenDialog] = useState(false);
const [openDialogViewDetail, setOpenDialogViewDetail] = useState(false); const [openDialogViewDetail, setOpenDialogViewDetail] = useState(false);
const [openDialogRA, setOpenDialogRA] = useState(false);
const [openDialogMaterial, setOpenDialogMaterial] = useState(false); const [openDialogMaterial, setOpenDialogMaterial] = useState(false);
const [openDialogTools, setOpenDialogTools] = useState(false); const [openDialogTools, setOpenDialogTools] = useState(false);
const [openDialogGantt, setOpenDialogGantt] = useState(false); const [openDialogGantt, setOpenDialogGantt] = useState(false);
@ -593,6 +596,13 @@ const CreatedProyek = ({ params, ...props }) => {
getProjectDetail(data.id); getProjectDetail(data.id);
}; };
const handleOpenReport = async (data) => {
setOpenDialogRA(true);
setProjectId(data.id);
}
const handleCloseReport = async (data) => {
setOpenDialogRA(false);
}
const getDataProject = async (proyek_id) => { const getDataProject = async (proyek_id) => {
const url = PROYEK_GET_ID(proyek_id); const url = PROYEK_GET_ID(proyek_id);
const result = await axios const result = await axios
@ -851,6 +861,7 @@ const CreatedProyek = ({ params, ...props }) => {
const toggleAddDialog = () => setOpenDialog(!openDialog); const toggleAddDialog = () => setOpenDialog(!openDialog);
const toggleAddDialogProyek = () => setOpenDialogProyek(!openDialogProyek); const toggleAddDialogProyek = () => setOpenDialogProyek(!openDialogProyek);
const toggleAddDialogRA = () => setOpenDialogRA(!openDialogRA);
const toggleAddDialogView = () => { const toggleAddDialogView = () => {
if (openDialogViewDetail) { if (openDialogViewDetail) {
setProjectApproval(null); setProjectApproval(null);
@ -1506,6 +1517,12 @@ const CreatedProyek = ({ params, ...props }) => {
</span> </span>
<span className="menu-text">S Curve</span> <span className="menu-text">S Curve</span>
</div> </div>
<div className="menu-list" onClick={() => handleOpenReport(text)}>
<span className="menu-icon">
<i className="fa fa-pie-chart"></i>
</span>
<span className="menu-text">Report Analysis</span>
</div>
{/* </Link> */} {/* </Link> */}
<div <div
className="menu-list" className="menu-list"
@ -1889,7 +1906,17 @@ const CreatedProyek = ({ params, ...props }) => {
), ),
[openDialogViewDetail] [openDialogViewDetail]
); );
const renderReportAnalysis = useMemo(
() => (
<ReportAnalysis
openDialog={openDialogRA}
closeDialog={handleCloseReport}
toggleDialog={toggleAddDialogRA}
projectId={projectId}
/>
),
[openDialogRA]
);
const renderDialogGantt = useMemo( const renderDialogGantt = useMemo(
() => ( () => (
<DialogGantt <DialogGantt
@ -1933,6 +1960,7 @@ const CreatedProyek = ({ params, ...props }) => {
Delete this data Delete this data
</SweetAlert> </SweetAlert>
{ViewProyek} {ViewProyek}
{renderReportAnalysis}
{RenderDialogForm} {RenderDialogForm}
{RenderDialogFormProyek} {RenderDialogFormProyek}
{RenderDialogFormMaterial} {RenderDialogFormMaterial}

Loading…
Cancel
Save