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';
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 URL = `${BASE_SIMPRO_LUMEN}/project/list`
// const payload = {
// "paging": { "start": 0, "length": 25 },
// // "columns": [
// // { "name": "user_id", "logic_operator": "=", "value": user_id }
// // ],
// // "joins": [
// // {
// // "name": "m_proyek",
// // "column_join": "proyek_id",
// // "column_results": [
// // "nama", "kode_sortname", "mulai_proyek", "akhir_proyek"
// // ]
// // },
// // {
// // "name": "m_activity",
// // "column_join": "activity_id",
// // "column_results": [
// // "name", "start_date", "end_date", "persentase_progress"
// // ]
// // }
// // ],
// "orders": { "columns": ["id"], "ascending": false }
// }
return await RequestApi.Request().get(
URL,
const URL = `${BASE_SIMPRO_LUMEN}/project/search`
let hierarchy = [];
hierarchy.push(JSON.parse(localStorage.getItem("hierarchy")));
const payload = {
columns: [],
select: [
"id",
"nama",
"kode_sortname",
"type_proyek_id",
"currency_symbol",
"mulai_proyek",
"akhir_proyek",
],
orders: { columns: ["nama"], ascending: true },
paging: { start: 0, length: -1 },
};
if (parseInt(role_id) !== 70) {
payload["columns"] = [
{ name: "created_by_id", logic_operator: "IN", value: hierarchy, operator: "AND" }
];
}
return await RequestApi.Request().post(
URL, payload,
RequestApi.HeaderWithToken()).then(res => {
if (res) {
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 "react-toastify/dist/ReactToastify.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 pinRouteStart from '../../assets/img/map/pin_route_green.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.js'
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_MIDDLE = 12;
const GRID_RIGHT = 6;
@ -155,9 +174,11 @@ const MapMonitoring = () => {
// init for left content panel, get projects and build tree select antd
const getMapLeftContent = async () => {
store.dispatch(setMapLoading(true));
let project = await ApiProject.list();
// console.log('project', project);
if (project && project.status && project.data && project.data.length > 0) {
let project = await ApiProject.search(role_id);
// console.log('projectsearch', projectsearch.data.data);
console.log('project', project);
if (project && project.data && project.data.length > 0) {
let projectData = [
{
"title": 'All',

Loading…
Cancel
Save