Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
waterdataui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Water Mission Area
Internet of Water
waterdataui
Commits
b30d08ba
Commit
b30d08ba
authored
5 years ago
by
Bucknell, Mary S.
Browse files
Options
Downloads
Patches
Plain Diff
Added code to set parameters in the url.
parent
f4c6c830
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
assets/src/scripts/components/hydrograph/index.js
+4
-2
4 additions, 2 deletions
assets/src/scripts/components/hydrograph/index.js
assets/src/scripts/index.js
+9
-8
9 additions, 8 deletions
assets/src/scripts/index.js
assets/src/scripts/url-params.js
+48
-0
48 additions, 0 deletions
assets/src/scripts/url-params.js
with
61 additions
and
10 deletions
assets/src/scripts/components/hydrograph/index.js
+
4
−
2
View file @
b30d08ba
...
...
@@ -8,9 +8,9 @@ import {createStructuredSelector} from 'reselect';
import
config
from
'
../../config
'
;
import
{
drawWarningAlert
,
drawInfoAlert
}
from
'
../../d3-rendering/alerts
'
;
import
{
link
}
from
'
../../lib/d3-redux
'
;
import
{
isLoadingTS
,
hasAnyTimeSeries
,
getTimeSeries
,
getCurrentParmCd
,
getVariables
}
from
'
../../selectors/time-series-selector
'
;
import
{
hasAnyTimeSeries
,
getCurrentParmCd
,
getVariables
}
from
'
../../selectors/time-series-selector
'
;
import
{
Actions
}
from
'
../../store
'
;
import
{
renderTimeSeriesUrlParams
}
from
'
../../url-params
'
;
import
{
cursorSlider
}
from
'
./cursor
'
;
import
{
drawDateRangeControls
}
from
'
./date-controls
'
;
...
...
@@ -146,6 +146,8 @@ export const attachToNode = function (store,
}),
store
));
nodeElem
.
select
(
'
.provisional-data-alert
'
)
.
attr
(
'
hidden
'
,
null
);
renderTimeSeriesUrlParams
(
store
);
}
}
});
...
...
This diff is collapsed.
Click to expand it.
assets/src/scripts/index.js
+
9
−
8
View file @
b30d08ba
...
...
@@ -3,15 +3,16 @@ import './polyfills';
import
wdfnviz
from
'
wdfn-viz
'
;
// Load misc Javascript helpers for general page interactivity.
import
{
register
}
from
'
./helpers
'
;
import
{
register
}
from
'
./helpers
'
;
register
();
import
{
configureStore
}
from
'
./store
'
;
import
{
configureStore
}
from
'
./store
'
;
import
{
getParamString
}
from
'
./url-params
'
;
import
{
attachToNode
as
EmbedComponent
}
from
'
./components/embed
'
;
import
{
attachToNode
as
DailyValueHydrographComponent
}
from
'
./components/dailyValueHydrograph
'
;
import
{
attachToNode
as
HydrographComponent
}
from
'
./components/hydrograph
'
;
import
{
attachToNode
as
MapComponent
}
from
'
./components/map
'
;
import
{
attachToNode
as
EmbedComponent
}
from
'
./components/embed
'
;
import
{
attachToNode
as
DailyValueHydrographComponent
}
from
'
./components/dailyValueHydrograph
'
;
import
{
attachToNode
as
HydrographComponent
}
from
'
./components/hydrograph
'
;
import
{
attachToNode
as
MapComponent
}
from
'
./components/map
'
;
const
COMPONENTS
=
{
embed
:
EmbedComponent
,
...
...
@@ -20,6 +21,7 @@ const COMPONENTS = {
map
:
MapComponent
};
const
load
=
function
()
{
let
nodes
=
document
.
getElementsByClassName
(
'
wdfn-component
'
);
let
store
=
configureStore
({
...
...
@@ -31,8 +33,7 @@ const load = function () {
// If options is specified on the node, expect it to be a JSON string.
// Otherwise, use the dataset attributes as the component options.
const
options
=
node
.
dataset
.
options
?
JSON
.
parse
(
node
.
dataset
.
options
)
:
node
.
dataset
;
let
hash
=
window
.
location
.
hash
;
const
hashOptions
=
hash
.
length
?
Object
.
fromEntries
(
new
window
.
URLSearchParams
(
hash
.
substring
(
1
)))
:
{};
const
hashOptions
=
Object
.
fromEntries
(
new
window
.
URLSearchParams
(
getParamString
()));
COMPONENTS
[
node
.
dataset
.
component
](
store
,
node
,
Object
.
assign
({},
options
,
hashOptions
));
}
...
...
This diff is collapsed.
Click to expand it.
assets/src/scripts/url-params.js
0 → 100644
+
48
−
0
View file @
b30d08ba
import
{
DateTime
}
from
'
luxon
'
;
import
{
createStructuredSelector
}
from
'
reselect
'
;
import
{
listen
}
from
'
./lib/d3-redux
'
;
import
{
getCurrentMethodID
,
getMethods
,
getCurrentDateRange
,
getCustomTimeRange
,
getCurrentParmCd
,
getIanaTimeZone
}
from
'
./selectors/time-series-selector
'
;
export
const
getParamString
=
function
()
{
const
hash
=
window
.
location
.
hash
;
return
hash
.
length
?
hash
.
substring
(
1
)
:
''
;
};
export
const
renderTimeSeriesUrlParams
=
function
(
store
)
{
// subscribe to selectors for setting url parameter state
listen
(
store
,
createStructuredSelector
({
parameterCode
:
getCurrentParmCd
,
methodId
:
getCurrentMethodID
,
methods
:
getMethods
,
compare
:
(
state
)
=>
state
.
timeSeriesState
.
showSeries
.
compare
,
currentDateRange
:
getCurrentDateRange
,
customTimeRange
:
getCustomTimeRange
,
timeZone
:
getIanaTimeZone
}),
({
parameterCode
,
methodId
,
methods
,
compare
,
currentDateRange
,
customTimeRange
,
timeZone
})
=>
{
let
params
=
new
window
.
URLSearchParams
();
params
.
set
(
'
parameterCode
'
,
parameterCode
);
if
(
Object
.
keys
(
methods
).
length
>
1
)
{
params
.
set
(
'
timeSeriesId
'
,
methodId
);
}
switch
(
currentDateRange
)
{
case
'
P30D
'
:
case
'
P1Y
'
:
params
.
set
(
'
period
'
,
currentDateRange
);
break
;
case
'
custom
'
:
params
.
set
(
'
startDT
'
,
DateTime
.
fromMillis
(
customTimeRange
.
startDT
,
{
zone
:
timeZone
}).
toFormat
(
'
yyyy-LL-dd
'
));
params
.
set
(
'
endDT
'
,
DateTime
.
fromMillis
(
customTimeRange
.
endDT
,
{
zone
:
timeZone
}).
toFormat
(
'
yyyy-LL-dd
'
));
}
if
(
compare
)
{
params
.
set
(
'
compare
'
,
true
);
}
window
.
location
.
hash
=
`#
${
params
.
toString
()}
`
;
});
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment