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 = () => {
const
onSubmitHandler
=
(
values
)
=>
{
dispatch
(
addlocation
({
projectid
:
values
.
projectid
,
idproject
:
values
.
idproject
,
name
:
values
.
name
,
order
:
values
.
order
,
country
:
values
.
country
,
...
...
@@ -57,16 +57,14 @@ const Tables = () => {
Select
Project
<
/div> : <ElementCard selectedElement={
{
id
:
'<generate>'
,
projectid
:
storeNavbar
.
projectCurrent
.
value
,
title
:
''
,
parentid
:
null
,
parenttype
:
null
,
external_id
:
''
,
textual
:
[],
genres
:
[],
subgenres
:
[],
availability
:
[],
imagery
:
[]
idproject
:
storeNavbar
.
projectCurrent
.
value
,
name
:
''
,
order
:
1
,
country
:
''
,
state
:
''
,
city
:
''
,
ip
:
''
,
polyline
:
''
}}
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
{
Circle
,
...
...
@@ -122,6 +122,30 @@ const MapTooltip = ({gis, handleGis}) => {
}
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
(
<
Card
>
<
CardHeader
>
...
...
@@ -154,7 +178,7 @@ const MapTooltip = ({gis, handleGis}) => {
attribution
=
'&copy <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url
=
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
/>
<
Polygon
pathOptions
=
{
purpleOptions
}
positions
=
{
gis
}
/
>
<
/LeafletMap
>
<
/CardBody
>
<
/Card
>
...
...
src/views/settings/locations/card/index.js
View file @
f2540d85
...
...
@@ -33,6 +33,7 @@ import MapTooltip from './MapTooltip'
import
'@styles/react/apps/app-users.scss'
import
'@styles/react/libs/flatpickr/flatpickr.scss'
import
'@styles/react/libs/maps/map-leaflet.scss'
import
{
point
}
from
'leaflet'
const
SuccessProgressToast
=
()
=>
(
...
...
@@ -126,6 +127,22 @@ const handleError = (text) => {
useEffect
(()
=>
{
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
)
}
},
[
selectedElement
])
...
...
@@ -212,16 +229,16 @@ return (
<
/Col
>
<
Col
md
=
'4'
sm
=
'12'
>
<
FormGroup
>
<
Label
for
=
'
name
'
>
Project
ID
<
/Label
>
<
Label
for
=
'
idproject
'
>
Project
ID
<
/Label
>
<
Input
readOnly
=
{
true
}
type
=
'text'
name
=
'
projectid
'
id
=
'
projectid
'
name
=
'
idproject
'
id
=
'
idproject
'
innerRef
=
{
register
({
required
:
true
})}
placeholder
=
'
projectid
'
defaultValue
=
{
dataElement
&&
dataElement
.
projectid
}
className
=
{
classnames
({
'is-invalid'
:
errors
[
'
projectid
'
]
})}
placeholder
=
'
idproject
'
defaultValue
=
{
dataElement
&&
dataElement
.
idproject
}
className
=
{
classnames
({
'is-invalid'
:
errors
[
'
idproject
'
]
})}
/
>
<
/FormGroup
>
<
/Col
>
...
...
src/views/settings/locations/edit/index.js
View file @
f2540d85
...
...
@@ -9,7 +9,7 @@ import Breadcrumbs from '@components/breadcrumbs'
import
{
Row
,
Col
}
from
'reactstrap'
// ** Tables
import
ElementEdit
from
'.
./card
'
import
ElementEdit
from
'.
/main
'
// ** Styles
import
'@styles/react/libs/tables/react-dataTable-component.scss'
// module settings
...
...
src/views/settings/locations/edit/main.js
View file @
f2540d85
...
...
@@ -2,7 +2,7 @@ import { useState, useEffect, Fragment } from 'react'
import
{
useParams
,
Link
}
from
'react-router-dom'
// ** Store & Actions
import
{
get
asset
,
updateasset
}
from
'../../store/actions'
import
{
get
Location
,
updateLocation
}
from
'../../store/actions'
import
{
useSelector
,
useDispatch
}
from
'react-redux'
...
...
@@ -16,26 +16,26 @@ import _ from 'lodash'
const
ElementEdit
=
()
=>
{
// ** States & Vars
const
store
=
useSelector
(
state
=>
state
.
asset
s
),
const
store
=
useSelector
(
state
=>
state
.
projectsetting
s
),
[
dataElement
,
setElementData
]
=
useState
(
null
),
dispatch
=
useDispatch
(),
{
id
}
=
useParams
()
const
onSubmitHandler
=
(
values
,
uploadFile
)
=>
{
const
onSubmitHandler
=
(
values
)
=>
{
// console.log(values)
// console.log(uploadFile)
dispatch
(
update
asset
({
update
Location
({
...
dataElement
,
idproject
:
values
.
idproject
,
title
:
values
.
titl
e
,
parentid
:
values
.
parentid
,
parenttype
:
values
.
parenttype
,
external_id
:
values
.
external_id
,
genres
:
values
.
genres
,
subgenres
:
values
.
subgenres
,
data
:
uploadFil
e
name
:
values
.
nam
e
,
order
:
values
.
order
,
country
:
values
.
country
,
state
:
values
.
state
,
city
:
values
.
city
,
ip
:
values
.
ip
,
polyline
:
values
.
polylin
e
})
)
...
...
@@ -43,21 +43,21 @@ const ElementEdit = () => {
// ** Function to get user on mount
useEffect
(()
=>
{
dispatch
(
get
asset
(
id
))
dispatch
(
get
Location
(
id
))
},
[
dispatch
])
// ** Update user image on mount or change
useEffect
(()
=>
{
if
(
store
.
selected
Asset
!==
null
||
(
store
.
selectedAsset
!==
null
&&
dataElement
!==
null
&&
store
.
selectedAsset
.
id
!==
dataElement
.
id
))
{
return
setElementData
(
store
.
selected
Asset
)
if
(
store
.
selected
Location
!==
null
||
(
store
.
selectedLocation
!==
null
&&
dataElement
!==
null
&&
store
.
selectedLocation
.
id
!==
dataElement
.
id
))
{
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
selectedElement
=
{
store
.
selected
Asset
}
selectedElement
=
{
store
.
selected
Location
}
onSubmitHandler
=
{
onSubmitHandler
}
/>
)
:
(
...
...
src/views/settings/store/actions/index.js
View file @
f2540d85
...
...
@@ -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) => {
selectedProject
:
action
.
data
}
case
'UPDATE_PROJECT'
:
return
{
...
state
}
...
...
@@ -118,6 +119,12 @@ const settings = (state = initialState, action) => {
case
'ADD_LOCATION'
:
return
{
...
state
}
case
'GET_LOCATION'
:
return
{
...
state
,
selectedLocation
:
action
.
data
}
case
'UPDATE_LOCATION'
:
return
{
...
state
}
default
:
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