Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
C
cms
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pedro-dev_2
cms
Commits
f2540d85
Commit
f2540d85
authored
Jun 23, 2021
by
PDuarte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update geolocations
parent
0aba0ae4
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
117 additions
and
37 deletions
+117
-37
index.js
src/views/settings/locations/add/index.js
+9
-11
MapTooltip.js
src/views/settings/locations/card/MapTooltip.js
+26
-2
index.js
src/views/settings/locations/card/index.js
+23
-6
index.js
src/views/settings/locations/edit/index.js
+1
-1
main.js
src/views/settings/locations/edit/main.js
+17
-17
index.js
src/views/settings/store/actions/index.js
+34
-0
index.js
src/views/settings/store/reducer/index.js
+7
-0
No files found.
src/views/settings/locations/add/index.js
View file @
f2540d85
...
@@ -25,7 +25,7 @@ const Tables = () => {
...
@@ -25,7 +25,7 @@ const Tables = () => {
const
onSubmitHandler
=
(
values
)
=>
{
const
onSubmitHandler
=
(
values
)
=>
{
dispatch
(
dispatch
(
addlocation
({
addlocation
({
projectid
:
values
.
projectid
,
idproject
:
values
.
idproject
,
name
:
values
.
name
,
name
:
values
.
name
,
order
:
values
.
order
,
order
:
values
.
order
,
country
:
values
.
country
,
country
:
values
.
country
,
...
@@ -57,16 +57,14 @@ const Tables = () => {
...
@@ -57,16 +57,14 @@ const Tables = () => {
Select
Project
Select
Project
<
/div> : <ElementCard selectedElement={
{
<
/div> : <ElementCard selectedElement={
{
id
:
'<generate>'
,
id
:
'<generate>'
,
projectid
:
storeNavbar
.
projectCurrent
.
value
,
idproject
:
storeNavbar
.
projectCurrent
.
value
,
title
:
''
,
name
:
''
,
parentid
:
null
,
order
:
1
,
parenttype
:
null
,
country
:
''
,
external_id
:
''
,
state
:
''
,
textual
:
[],
city
:
''
,
genres
:
[],
ip
:
''
,
subgenres
:
[],
polyline
:
''
availability
:
[],
imagery
:
[]
}}
}}
onSubmitHandler
=
{
onSubmitHandler
}
onSubmitHandler
=
{
onSubmitHandler
}
/
>
/
>
...
...
src/views/settings/locations/card/MapTooltip.js
View file @
f2540d85
import
{
useState
}
from
'react'
import
{
useState
,
useEffect
}
from
'react'
import
{
Card
,
CardHeader
,
CardTitle
,
CardBody
}
from
'reactstrap'
import
{
Card
,
CardHeader
,
CardTitle
,
CardBody
}
from
'reactstrap'
import
{
import
{
Circle
,
Circle
,
...
@@ -122,6 +122,30 @@ const MapTooltip = ({gis, handleGis}) => {
...
@@ -122,6 +122,30 @@ const MapTooltip = ({gis, handleGis}) => {
}
}
const
showAdd
=
gis
.
length
<
1
const
showAdd
=
gis
.
length
<
1
useEffect
(()
=>
{
// const test = gis + ''
},
[
gis
])
// const regExp = /(-?\d+(\.\d+)?)\s*(-?\d+(\.\d+)?)(,?)/
// const matches = gis.match(regExp)
// console.log(matches)
const
polygon
=
[
[
[
51.51
,
-
0.12
],
[
51.51
,
-
0.13
],
[
51.53
,
-
0.13
]
],
[
[
51.51
,
-
0.05
],
[
51.51
,
-
0.07
],
[
51.53
,
-
0.07
]
]
]
const
purpleOptions
=
{
color
:
'purple'
}
return
(
return
(
<
Card
>
<
Card
>
<
CardHeader
>
<
CardHeader
>
...
@@ -154,7 +178,7 @@ const MapTooltip = ({gis, handleGis}) => {
...
@@ -154,7 +178,7 @@ const MapTooltip = ({gis, handleGis}) => {
attribution
=
'&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
attribution
=
'&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url
=
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
url
=
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
/>
/>
<
Polygon
pathOptions
=
{
purpleOptions
}
positions
=
{
gis
}
/
>
<
/LeafletMap
>
<
/LeafletMap
>
<
/CardBody
>
<
/CardBody
>
<
/Card
>
<
/Card
>
...
...
src/views/settings/locations/card/index.js
View file @
f2540d85
...
@@ -33,6 +33,7 @@ import MapTooltip from './MapTooltip'
...
@@ -33,6 +33,7 @@ import MapTooltip from './MapTooltip'
import
'@styles/react/apps/app-users.scss'
import
'@styles/react/apps/app-users.scss'
import
'@styles/react/libs/flatpickr/flatpickr.scss'
import
'@styles/react/libs/flatpickr/flatpickr.scss'
import
'@styles/react/libs/maps/map-leaflet.scss'
import
'@styles/react/libs/maps/map-leaflet.scss'
import
{
point
}
from
'leaflet'
const
SuccessProgressToast
=
()
=>
(
const
SuccessProgressToast
=
()
=>
(
...
@@ -126,6 +127,22 @@ const handleError = (text) => {
...
@@ -126,6 +127,22 @@ const handleError = (text) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
selectedElement
!==
null
||
(
selectedElement
!==
null
&&
dataElement
!==
null
&&
selectedElement
.
id
!==
dataElement
.
id
))
{
if
(
selectedElement
!==
null
||
(
selectedElement
!==
null
&&
dataElement
!==
null
&&
selectedElement
.
id
!==
dataElement
.
id
))
{
if
(
selectedElement
.
polyline
!==
null
&&
selectedElement
.
polyline
!==
undefined
&&
selectedElement
.
polyline
!==
''
)
{
console
.
log
(
selectedElement
.
polylineis
)
const
regExp
=
/
(
-
?\d
+
(\.\d
+
)?)\s
*
(
-
?\d
+
(\.\d
+
)?)(\,?)
/gm
const
matches
=
selectedElement
.
polyline
.
match
(
regExp
)
const
polygon
=
[]
matches
.
map
(
point
=>
{
const
cords
=
point
.
replace
(
','
,
''
).
split
(
' '
)
polygon
.
push
(
cords
)
console
.
log
(
cords
)
})
console
.
log
(
matches
)
handleGis
(
polygon
)
}
return
setElementData
(
selectedElement
)
return
setElementData
(
selectedElement
)
}
}
},
[
selectedElement
])
},
[
selectedElement
])
...
@@ -212,16 +229,16 @@ return (
...
@@ -212,16 +229,16 @@ return (
<
/Col
>
<
/Col
>
<
Col
md
=
'4'
sm
=
'12'
>
<
Col
md
=
'4'
sm
=
'12'
>
<
FormGroup
>
<
FormGroup
>
<
Label
for
=
'
name
'
>
Project
ID
<
/Label
>
<
Label
for
=
'
idproject
'
>
Project
ID
<
/Label
>
<
Input
<
Input
readOnly
=
{
true
}
readOnly
=
{
true
}
type
=
'text'
type
=
'text'
name
=
'
projectid
'
name
=
'
idproject
'
id
=
'
projectid
'
id
=
'
idproject
'
innerRef
=
{
register
({
required
:
true
})}
innerRef
=
{
register
({
required
:
true
})}
placeholder
=
'
projectid
'
placeholder
=
'
idproject
'
defaultValue
=
{
dataElement
&&
dataElement
.
projectid
}
defaultValue
=
{
dataElement
&&
dataElement
.
idproject
}
className
=
{
classnames
({
'is-invalid'
:
errors
[
'
projectid
'
]
})}
className
=
{
classnames
({
'is-invalid'
:
errors
[
'
idproject
'
]
})}
/
>
/
>
<
/FormGroup
>
<
/FormGroup
>
<
/Col
>
<
/Col
>
...
...
src/views/settings/locations/edit/index.js
View file @
f2540d85
...
@@ -9,7 +9,7 @@ import Breadcrumbs from '@components/breadcrumbs'
...
@@ -9,7 +9,7 @@ import Breadcrumbs from '@components/breadcrumbs'
import
{
Row
,
Col
}
from
'reactstrap'
import
{
Row
,
Col
}
from
'reactstrap'
// ** Tables
// ** Tables
import
ElementEdit
from
'.
./card
'
import
ElementEdit
from
'.
/main
'
// ** Styles
// ** Styles
import
'@styles/react/libs/tables/react-dataTable-component.scss'
import
'@styles/react/libs/tables/react-dataTable-component.scss'
// module settings
// module settings
...
...
src/views/settings/locations/edit/main.js
View file @
f2540d85
...
@@ -2,7 +2,7 @@ import { useState, useEffect, Fragment } from 'react'
...
@@ -2,7 +2,7 @@ import { useState, useEffect, Fragment } from 'react'
import
{
useParams
,
Link
}
from
'react-router-dom'
import
{
useParams
,
Link
}
from
'react-router-dom'
// ** Store & Actions
// ** Store & Actions
import
{
get
asset
,
updateasset
}
from
'../../store/actions'
import
{
get
Location
,
updateLocation
}
from
'../../store/actions'
import
{
useSelector
,
useDispatch
}
from
'react-redux'
import
{
useSelector
,
useDispatch
}
from
'react-redux'
...
@@ -16,26 +16,26 @@ import _ from 'lodash'
...
@@ -16,26 +16,26 @@ import _ from 'lodash'
const
ElementEdit
=
()
=>
{
const
ElementEdit
=
()
=>
{
// ** States & Vars
// ** States & Vars
const
store
=
useSelector
(
state
=>
state
.
asset
s
),
const
store
=
useSelector
(
state
=>
state
.
projectsetting
s
),
[
dataElement
,
setElementData
]
=
useState
(
null
),
[
dataElement
,
setElementData
]
=
useState
(
null
),
dispatch
=
useDispatch
(),
dispatch
=
useDispatch
(),
{
id
}
=
useParams
()
{
id
}
=
useParams
()
const
onSubmitHandler
=
(
values
,
uploadFile
)
=>
{
const
onSubmitHandler
=
(
values
)
=>
{
// console.log(values)
// console.log(values)
// console.log(uploadFile)
// console.log(uploadFile)
dispatch
(
dispatch
(
update
asset
({
update
Location
({
...
dataElement
,
...
dataElement
,
idproject
:
values
.
idproject
,
idproject
:
values
.
idproject
,
title
:
values
.
titl
e
,
name
:
values
.
nam
e
,
parentid
:
values
.
parentid
,
order
:
values
.
order
,
parenttype
:
values
.
parenttype
,
country
:
values
.
country
,
external_id
:
values
.
external_id
,
state
:
values
.
state
,
genres
:
values
.
genres
,
city
:
values
.
city
,
subgenres
:
values
.
subgenres
,
ip
:
values
.
ip
,
data
:
uploadFil
e
polyline
:
values
.
polylin
e
})
})
)
)
...
@@ -43,21 +43,21 @@ const ElementEdit = () => {
...
@@ -43,21 +43,21 @@ const ElementEdit = () => {
// ** Function to get user on mount
// ** Function to get user on mount
useEffect
(()
=>
{
useEffect
(()
=>
{
dispatch
(
get
asset
(
id
))
dispatch
(
get
Location
(
id
))
},
[
dispatch
])
},
[
dispatch
])
// ** Update user image on mount or change
// ** Update user image on mount or change
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
store
.
selected
Asset
!==
null
||
(
store
.
selectedAsset
!==
null
&&
dataElement
!==
null
&&
store
.
selectedAsset
.
id
!==
dataElement
.
id
))
{
if
(
store
.
selected
Location
!==
null
||
(
store
.
selectedLocation
!==
null
&&
dataElement
!==
null
&&
store
.
selectedLocation
.
id
!==
dataElement
.
id
))
{
return
setElementData
(
store
.
selected
Asset
)
return
setElementData
(
store
.
selected
Location
)
}
}
},
[
store
.
selected
Asset
])
},
[
store
.
selected
Location
])
return
store
.
selected
Asset
!==
null
&&
store
.
selectedAsset
!==
undefined
?
(
return
store
.
selected
Location
!==
null
&&
store
.
selectedLocation
!==
undefined
?
(
<
ElementCard
<
ElementCard
selectedElement
=
{
store
.
selected
Asset
}
selectedElement
=
{
store
.
selected
Location
}
onSubmitHandler
=
{
onSubmitHandler
}
onSubmitHandler
=
{
onSubmitHandler
}
/>
/>
)
:
(
)
:
(
...
...
src/views/settings/store/actions/index.js
View file @
f2540d85
...
@@ -211,3 +211,37 @@ export const addlocation = location => {
...
@@ -211,3 +211,37 @@ export const addlocation = location => {
})
})
}
}
}
}
export
const
getLocation
=
id
=>
{
return
async
dispatch
=>
{
await
axios
.
get
(
`
${
process
.
env
.
REACT_APP_API
}
/api/locations/
${
id
}
`
)
.
then
(
response
=>
{
dispatch
({
type
:
'GET_LOCATION'
,
data
:
response
.
data
.
data
})
})
.
catch
(
err
=>
console
.
log
(
err
))
}
}
export
const
updateLocation
=
location
=>
{
return
(
dispatch
,
getState
)
=>
{
axios
.
put
(
`
${
process
.
env
.
REACT_APP_API
}
/api/locations/
${
location
.
id
}
`
,
location
)
.
then
(
response
=>
{
dispatch
({
type
:
'UPDATE_LOCATION'
,
location
})
})
.
then
(()
=>
{
dispatch
(
setSaveSatus
(
true
))
})
.
catch
(
err
=>
{
dispatch
(
setErrorMsg
(
err
.
response
.
data
.
message
))
console
.
log
(
err
.
response
.
data
)
})
}
}
src/views/settings/store/reducer/index.js
View file @
f2540d85
...
@@ -76,6 +76,7 @@ const settings = (state = initialState, action) => {
...
@@ -76,6 +76,7 @@ const settings = (state = initialState, action) => {
selectedProject
:
action
.
data
selectedProject
:
action
.
data
}
}
case
'UPDATE_PROJECT'
:
case
'UPDATE_PROJECT'
:
return
{
...
state
}
return
{
...
state
}
...
@@ -118,6 +119,12 @@ const settings = (state = initialState, action) => {
...
@@ -118,6 +119,12 @@ const settings = (state = initialState, action) => {
case
'ADD_LOCATION'
:
case
'ADD_LOCATION'
:
return
{
...
state
}
return
{
...
state
}
case
'GET_LOCATION'
:
return
{
...
state
,
selectedLocation
:
action
.
data
}
case
'UPDATE_LOCATION'
:
return
{
...
state
}
default
:
default
:
return
state
return
state
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment