Browse Source

Merge branch 'staging' into dev-wahyun

pull/2/head
wahyun 1 year ago
parent
commit
fef4069154
  1. 49
      src/appredux/modules/map/actions.js
  2. BIN
      src/assets/img/map/pin_route_on_trip.png
  3. 5
      src/const/ApiConst.js
  4. 48
      src/views/MapMonitoring/index.js
  5. 34
      src/views/Master/MasterBroadcast/DialogDetail.js
  6. 20
      src/views/Master/MasterBroadcast/DialogForm.js
  7. 8
      src/views/Master/MasterBroadcast/index.js

49
src/appredux/modules/map/actions.js

@ -158,11 +158,41 @@ export const getUserHistory = async (userId, dateString) => {
"features": []
}
// build waypoint line
let featureLine = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": []
}
}
userHistory.data.map((n, idx) => {
featureLine.geometry.coordinates.push([parseFloat(n.lon), parseFloat(n.lat)])
if (idx > startIdx && idx < endIdx) {
let featureOnTrip = {
"type": "Feature",
"properties": {
"type": "Working",
"wptime": n.wptime
},
"geometry": {
"type": "Point",
"coordinates": [parseFloat(n.lon), parseFloat(n.lat)]
}
}
featureCollection.features.push(featureOnTrip);
}
});
featureCollection.features.push(featureLine);
// set waypoint start
let featurePointStart = {
"type": "Feature",
"properties": {
"type": "start",
"type": "Start",
"wptime": userHistory.data[startIdx].wptime
},
"geometry": {
@ -176,7 +206,7 @@ export const getUserHistory = async (userId, dateString) => {
let featurePointEnd = {
"type": "Feature",
"properties": {
"type": "end",
"type": "End",
"wptime": userHistory.data[endIdx].wptime
},
"geometry": {
@ -186,21 +216,6 @@ export const getUserHistory = async (userId, dateString) => {
}
featureCollection.features.push(featurePointEnd);
// build waypoint line
let featureLine = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": []
}
}
userHistory.data.map(n => {
featureLine.geometry.coordinates.push([parseFloat(n.lon), parseFloat(n.lat)])
});
featureCollection.features.push(featureLine);
store.dispatch(setUserHistory(featureCollection));
store.dispatch(setIsSearchingRoute(false));
}

BIN
src/assets/img/map/pin_route_on_trip.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

5
src/const/ApiConst.js

@ -116,9 +116,8 @@ export const TOKEN_ADW =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIxMjAyIiwiZXhwIjoxNjkxODMwNDkzfQ.DvBQIOZsdFndWsliPCZT65Y6G5Xx4vWBKz8Rhe7rvRA";
// export let BASE_OSPRO = "https://ospro-api.ospro.id";
// export let BASE_OSPRO = "https://adw-api.ospro.id";
export let BASE_OSPRO = "http://localhost:8444/adw-backend";
// export let BASE_OSPRO = "http://192.168.1.123:8444"; // local
export let BASE_OSPRO = "https://adw-api.ospro.id";
// export let BASE_OSPRO = "http://localhost:8444";
// export let BASE_OSPRO = "http://103.73.125.81:8444"; // ip public adw
export let BASE_SIMPRO_LUMEN = `${BASE_OSPRO}/api`;
export let BASE_SIMPRO_LUMEN_IMAGE = `${BASE_OSPRO}/assets/image`;

48
src/views/MapMonitoring/index.js

@ -17,11 +17,15 @@ import "react-toastify/dist/ReactToastify.css";
import './MapMonitoring.css';
import { BASE_SIMPRO_LUMEN_IMAGE } from '../../const/ApiConst';
import DEFAULT_USER_ICON from '../../assets/img/avatars/user.png';
import pinRouteStart from '../../assets/img/map/pin_route_green.png';
import pinRouteEnd from '../../assets/img/map/pin_route_red.png';
import pinRouteOnTrip from '../../assets/img/map/pin_route_on_trip.png';
import 'leaflet.markercluster/dist/MarkerCluster.Default.css'
import 'leaflet.markercluster/dist/MarkerCluster.css'
import 'leaflet.markercluster/dist/leaflet.markercluster.js'
import 'leaflet-control-geocoder/dist/Control.Geocoder.css'
import 'leaflet-control-geocoder/dist/Control.Geocoder.js'
import moment from 'moment';
const MapMonitoring = () => {
@ -81,8 +85,50 @@ const MapMonitoring = () => {
if (mymap) {
removeLayerByName('userHistoryLayer');
if (userHistory) {
var startIcon = new L.Icon({
iconSize: [60, 60],
iconAnchor: [30, 47],
popupAnchor: [1, -24],
iconUrl: pinRouteStart
});
var endIcon = new L.Icon({
iconSize: [60, 60],
iconAnchor: [30, 47],
popupAnchor: [1, -24],
iconUrl: pinRouteEnd
});
var onTripIcon = new L.Icon({
iconSize: [60, 60],
iconAnchor: [30, 47],
popupAnchor: [1, -24],
iconUrl: pinRouteOnTrip
});
let userHistoryLayer = L.geoJson(userHistory, {
name: 'userHistoryLayer'
name: 'userHistoryLayer',
onEachFeature: function(feature, layer) {
var popupText = `<b>Status: </b>${feature.properties.type}<br>
<b>Time: </b> ${feature.properties.wptime ? moment(feature.properties.wptime).format("DD-MM-YYYY HH:mm:ss") : '-'}`;
layer.bindPopup(popupText, {
closeButton: true,
// offset: L.point(0, -20)
});
layer.on('click', function() {
layer.openPopup();
});
},
pointToLayer: function(feature, latlng) {
var type = feature.properties.type;
if (type === 'Start') {
return L.marker(latlng, {icon: startIcon});
}
else if (type === "Working") {
return L.marker(latlng, {icon: onTripIcon});
}
else if (type === "End") {
return L.marker(latlng, {icon: endIcon});
}
},
});
userHistoryLayer.addTo(mymap);
mymap.fitBounds(userHistoryLayer.getBounds());

34
src/views/Master/MasterBroadcast/DialogDetail.js

@ -4,10 +4,17 @@ import moment from 'moment';
import { Button, Table, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
import Select from 'react-select';
import axios from 'axios';
import { BASE_URL_GEOHR_API } from '../../../const/ApiConst';
import { BASE_SIMPRO_LUMEN, BASE_URL_GEOHR_API } from '../../../const/ApiConst';
import { Transfer } from 'antd';
import { withTranslation } from 'react-i18next';
const token = window.localStorage.getItem('token');
const config = {
headers:
{
Authorization: `Bearer ${token}`,
"Content-type": `application/json`
}
};
const ERROR_TITLE = "judul is required!"
const ERROR_MESSAGE = "message is required!"
const BASE_URL = "https://oslog.id/geohr-api/";
@ -42,26 +49,23 @@ class DialogDetail extends Component {
getDataDetail = async () => {
countError++;
let url = BASE_URL_GEOHR_API + `/broadcast-detail/search?broadcastId=${this.state.id}`;
let url = BASE_SIMPRO_LUMEN + `/broadcast/search`;
const payload = {
"paging": { "start": 0, "length": 25 },
"orders": { "columns": ["id"], "ascending": true },
"columns": [
{ "name": "status_send", "logic_operator": "ilike", "value": "", "operator": "AND" }
],
"joins": [
{ "name": "m_broadcast", "column_results": ["title_notif", "message_notif", "description", "status_send"], "column_join": "broadcast_id" }
{ "name": "id", "logic_operator": "=", "value": this.state.id, "operator": "AND" }
]
}
const result = await axios
.post(url, payload)
.post(url, payload, config)
.then(res => res)
.catch((error) => error.response);
console.log('cek data detail', result.data)
if (result && result.data && result.data.code === 200) {
if (result.data.data && result.data.data.broadcast_details) {
this.setState({ dataListDetail: result.data.data.broadcast_details })
if (result.data.data && result.data.data) {
this.setState({ dataListDetail: result.data.data })
}
} else {
if (countError < 6) {
@ -97,11 +101,11 @@ class DialogDetail extends Component {
{this.state.dataListDetail.map((val, index) => {
return (
<tr key={index}>
<td>{val.join.status_send === "" ? "-" : val.status_send}</td>
<td>{val.join.created_date === "" ? "-" : moment(val.created_date).format("YYYY-MM-DD HH:mm:ss")}</td>
<td>{val.join.broadcast_description === "" ? "-" : val.join.broadcast_description}</td>
<td>{val.join.broadcast_title_notif === "" ? "-" : val.join.broadcast_title_notif}</td>
<td>{val.join.broadcast_message_notif === "" ? "-" : val.join.broadcast_message_notif}</td>
<td>{val.status_send === "" ? "-" : val.status_send}</td>
<td>{val.created_at === "" ? "-" : moment(val.created_date).format("DD-MM-YYYY HH:mm:ss")}</td>
<td>{val.description === "" ? "-" : val.description}</td>
<td>{val.title_notif === "" ? "-" : val.title_notif}</td>
<td>{val.message_notif === "" ? "-" : val.message_notif}</td>
</tr>
)
})}

20
src/views/Master/MasterBroadcast/DialogForm.js

@ -3,7 +3,7 @@ import React, { Component } from 'react';
import { Button, Form, FormFeedback, FormGroup, Input, Label, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
import Select from 'react-select';
import axios from 'axios';
import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG } from '../../../const/ApiConst';
import { BASE_URL_GEOHR_API2, ROLE_SEARCH, USER_WASPANG, USER_LIST } from '../../../const/ApiConst';
import { Transfer } from 'antd';
import { withTranslation } from 'react-i18next';
@ -137,7 +137,7 @@ class DialogForm extends Component {
if (penerima === "all") {
idSend = this.state.allEmployeeId;
send_to_type = "all";
} else if (penerima === "division") {
} else if (penerima === "organization") {
idSend = this.state.idOrganization;
send_to_type = "roles";
} else if (penerima === "karyawan") {
@ -145,9 +145,13 @@ class DialogForm extends Component {
send_to_type = "users";
}
if(Array.isArray(idSend)){
idSend = idSend.map(function (e) {
return e.toString()
});
} else {
idSend = idSend;
}
const data = {
title,
@ -186,7 +190,7 @@ class DialogForm extends Component {
}
setEmployeeOrganization = () => {
let arrEd = this.state.dataEmployee;
let arrEd = this.state.dataEmployee.data;
let cek = arrEd.filter(this.filterId)
this.setState({ idEmployeeDivision: cek })
@ -289,14 +293,14 @@ class DialogForm extends Component {
"ascending": false
}
}
//TODO should use search instead
const result = await axios
.post(USER_WASPANG, payload, config)
.get(USER_LIST, config)
.then(res => res)
.catch((error) => error.response);
console.log('test role', result)
if (result && result.data && result.code == "200") {
if (result && result.data && result.status == 200) {
this.setState({ dataEmployee: result.data }, () => {
this.setDataEmployee();
});
@ -307,12 +311,12 @@ class DialogForm extends Component {
setDataEmployee = () => {
const listEmployee = [];
const allIdEmployee = [];
this.state.dataEmployee.map((val, index) => {
this.state.dataEmployee.data.map((val, index) => {
allIdEmployee.push(val.id);
listEmployee.push({
key: val.id,
id: val.id,
title: val.join.m_users_name
title: val.name
});
})

8
src/views/Master/MasterBroadcast/index.js

@ -5,7 +5,7 @@ import React, { Component } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import moment from 'moment';
import { API_BROADCAST_SIMPRO, BASE_SIMPRO, BASE_URL_GEOHR_API2 } from '../../../const/ApiConst';
import { API_BROADCAST_SIMPRO, BASE_SIMPRO, BASE_SIMPRO_LUMEN, BASE_URL_GEOHR_API2 } from '../../../const/ApiConst';
import { Button, Card, CardBody, CardHeader, DropdownItem, DropdownMenu, DropdownToggle, Input, InputGroup, InputGroupButtonDropdown, Table, Row, Col } from 'reactstrap';
import { DatePicker, Pagination } from 'antd';
import { NotificationContainer, NotificationManager } from 'react-notifications';
@ -85,7 +85,7 @@ class index extends Component {
};
getDataBroadcast = async () => {
let url = BASE_SIMPRO + `/broadcast/search`;
let url = BASE_SIMPRO_LUMEN + `/broadcast/search`;
const { searchDetail } = this.state
let start = 0;
@ -180,7 +180,7 @@ class index extends Component {
}
saveBroadcast = async (type, data) => {
let url = BASE_SIMPRO + `/broadcast/add`;
let url = BASE_SIMPRO_LUMEN + `/broadcast/add`;
const param = {
"title_notif": data.title,
@ -205,7 +205,7 @@ class index extends Component {
"send_to_type": "users",
"message_notif": data.message,
"description": data.description,
"send_to_id": data.id.map((id, index) => id)
"send_to_id": data.send_to_type == "users" ? data.id.map((id, index) => id) : null
}
if (data.send_to_type === "all") {

Loading…
Cancel
Save