Browse Source

update conflict and add logo ospro

pull/2/head
ibnu 1 year ago
parent
commit
f1de077b7a
  1. 63
      src/views/Master/MasterRoles/DialogForm.js
  2. 6
      src/views/Master/MasterRoles/index.js
  3. 51
      src/views/Pages/Login/Login.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 'antd/dist/antd.css';
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 {
constructor(props) {
@ -13,11 +26,14 @@ class DialogForm extends Component {
description: "",
openDialog: false,
isParentClick: false,
menu: [],
selectedMenu: null
}
}
async componentDidMount() {
this.props.showDialog(this.showDialog);
this.getAllMenu();
}
async componentDidUpdate() {
@ -27,19 +43,38 @@ class DialogForm extends Component {
this.setState({
id: dataEdit.id,
name: dataEdit.name,
description: dataEdit.description
description: dataEdit.description,
selectedMenu: dataEdit.default_page
})
} else {
this.setState({
id: 0,
name: "",
description: ""
description: "",
selectedMenu: null
})
}
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 = () => {
this.setState({ isParentClick: true });
@ -60,7 +95,8 @@ class DialogForm extends Component {
const {
id,
name,
description
description,
selectedMenu
} = this.state
let data = '';
@ -70,14 +106,16 @@ class DialogForm extends Component {
data = {
id,
name,
description
description,
selectedMenu
}
this.props.closeDialog('save', data);
} else {
data = {
id,
name,
description
description,
selectedMenu
}
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')} />
</FormGroup>
</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>
</Form>
)

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

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

51
src/views/Pages/Login/Login.js

@ -27,7 +27,7 @@ import {
CarouselItem,
CarouselControl
} 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 { APP_NAME } from '../../../const/AppConst.js'
import moment from "moment"
@ -37,7 +37,7 @@ import logo_login_adw from '../../../assets/img/logo_adyawinsa.jpg'
import logo_login_kit from '../../../assets/img/logo_kit.png'
import logo_login_nawakara from '../../../assets/img/logo_nawakara.png'
import logo_login_si from '../../../assets/img/logo-surveyor-indonesia.png'
import logo_ospro from '../../../assets/img/OSPRO.png'
import logo_ospro '../../../assets/img/OSPRO.png'
const antIcon = <LoadingOutlined style={{ fontSize: 24 }} spin />;
@ -65,7 +65,8 @@ class Login extends Component {
emailState: '',
},
loader: false,
type: 'password'
type: 'password',
defaultPage: ''
}
this.handleChange = this.handleChange.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) => {
const config = {
headers:
@ -123,6 +159,14 @@ class Login extends Component {
else {
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 {
NotificationManager.error('Login Failed', 'Failed');
this.setState({ loader: false })
@ -164,6 +208,7 @@ class Login extends Component {
if (doLogin && doLogin.data && doLogin.data.code === 200) {
const { access_token, data_user } = doLogin.data.data
this.getDataRole(access_token, data_user.role_id)
this.getDataMenu(access_token, data_user.role_id)
window.localStorage.setItem('isLogin', true);
window.localStorage.setItem('token', access_token);

Loading…
Cancel
Save