Browse Source

map monitoring by filter project

pull/1/head
farhantock 1 year ago
parent
commit
b92c3a2c4a
  1. 53
      src/services/api/modules/project/index.js
  2. 33
      src/views/MapMonitoring/index.js

53
src/services/api/modules/project/index.js

@ -2,34 +2,33 @@ import { BASE_SIMPRO_LUMEN } from "../../../../const/ApiConst";
import RequestApi from '../../base'; import RequestApi from '../../base';
export default class ApiProject extends RequestApi { export default class ApiProject extends RequestApi {
static async list() { static async search(role_id) {
// const user_id = store.getState().userReducer && store.getState().userReducer.user && store.getState().userReducer.user.data_user ? store.getState().userReducer.user.data_user.id : 0; // const user_id = store.getState().userReducer && store.getState().userReducer.user && store.getState().userReducer.user.data_user ? store.getState().userReducer.user.data_user.id : 0;
const URL = `${BASE_SIMPRO_LUMEN}/project/list` const URL = `${BASE_SIMPRO_LUMEN}/project/search`
// const payload = { let hierarchy = [];
// "paging": { "start": 0, "length": 25 }, hierarchy.push(JSON.parse(localStorage.getItem("hierarchy")));
// // "columns": [ const payload = {
// // { "name": "user_id", "logic_operator": "=", "value": user_id } columns: [],
// // ], select: [
// // "joins": [ "id",
// // { "nama",
// // "name": "m_proyek", "kode_sortname",
// // "column_join": "proyek_id", "type_proyek_id",
// // "column_results": [ "currency_symbol",
// // "nama", "kode_sortname", "mulai_proyek", "akhir_proyek" "mulai_proyek",
// // ] "akhir_proyek",
// // }, ],
// // {
// // "name": "m_activity", orders: { columns: ["nama"], ascending: true },
// // "column_join": "activity_id", paging: { start: 0, length: -1 },
// // "column_results": [ };
// // "name", "start_date", "end_date", "persentase_progress" if (parseInt(role_id) !== 70) {
// // ] payload["columns"] = [
// // } { name: "created_by_id", logic_operator: "IN", value: hierarchy, operator: "AND" }
// // ], ];
// "orders": { "columns": ["id"], "ascending": false } }
// } return await RequestApi.Request().post(
return await RequestApi.Request().get( URL, payload,
URL,
RequestApi.HeaderWithToken()).then(res => { RequestApi.HeaderWithToken()).then(res => {
if (res) { if (res) {
if (res && res.data && res.data.data) { if (res && res.data && res.data.data) {

33
src/views/MapMonitoring/index.js

@ -15,7 +15,7 @@ import "react-loader-spinner/dist/loader/css/react-spinner-loader.css";
import { ToastContainer, toast } from "react-toastify"; import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css"; import "react-toastify/dist/ReactToastify.css";
import './MapMonitoring.css'; import './MapMonitoring.css';
import { BASE_SIMPRO_LUMEN_IMAGE } from '../../const/ApiConst'; import { BASE_SIMPRO_LUMEN_IMAGE, PROYEK_SEARCH } from '../../const/ApiConst';
import DEFAULT_USER_ICON from '../../assets/img/avatars/user.png'; import DEFAULT_USER_ICON from '../../assets/img/avatars/user.png';
import pinRouteStart from '../../assets/img/map/pin_route_green.png'; import pinRouteStart from '../../assets/img/map/pin_route_green.png';
import pinRouteEnd from '../../assets/img/map/pin_route_red.png'; import pinRouteEnd from '../../assets/img/map/pin_route_red.png';
@ -26,9 +26,28 @@ import 'leaflet.markercluster/dist/leaflet.markercluster.js'
import 'leaflet-control-geocoder/dist/Control.Geocoder.css' import 'leaflet-control-geocoder/dist/Control.Geocoder.css'
import 'leaflet-control-geocoder/dist/Control.Geocoder.js' import 'leaflet-control-geocoder/dist/Control.Geocoder.js'
import moment from 'moment'; import moment from 'moment';
import axios from "../../const/interceptorApi";
const MapMonitoring = ({ ...props }) => {
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '';
if (props.location.state && props.location.state.role_id && props.location.state.user_id) {
role_id = props.location.state.role_id;
user_id = props.location.state.user_id;
token = props.location.state.token;
isLogin = props.location.state.isLogin;
const MapMonitoring = () => { } else {
role_id = localStorage.getItem("role_id");
proyek_id = localStorage.getItem("proyek_id");
user_id = localStorage.getItem("user_id");
token = localStorage.getItem("token");
isLogin = localStorage.getItem("isLogin");
}
const HEADER = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
};
const GRID_LEFT = 6; const GRID_LEFT = 6;
const GRID_MIDDLE = 12; const GRID_MIDDLE = 12;
const GRID_RIGHT = 6; const GRID_RIGHT = 6;
@ -155,9 +174,11 @@ const MapMonitoring = () => {
// init for left content panel, get projects and build tree select antd // init for left content panel, get projects and build tree select antd
const getMapLeftContent = async () => { const getMapLeftContent = async () => {
store.dispatch(setMapLoading(true)); store.dispatch(setMapLoading(true));
let project = await ApiProject.list();
// console.log('project', project); let project = await ApiProject.search(role_id);
if (project && project.status && project.data && project.data.length > 0) { // console.log('projectsearch', projectsearch.data.data);
console.log('project', project);
if (project && project.data && project.data.length > 0) {
let projectData = [ let projectData = [
{ {
"title": 'All', "title": 'All',

Loading…
Cancel
Save