Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador Video
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IIIF
Mirador
Mirador Video
Commits
092f7cdc
Commit
092f7cdc
authored
May 7, 2020
by
Chris Beer
Browse files
Options
Downloads
Patches
Plain Diff
Initialize config with the default settings
parent
79ce771a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/MiradorViewer.js
+6
-9
6 additions, 9 deletions
src/lib/MiradorViewer.js
src/state/reducers/config.js
+8
-2
8 additions, 2 deletions
src/state/reducers/config.js
with
14 additions
and
11 deletions
src/lib/MiradorViewer.js
+
6
−
9
View file @
092f7cdc
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
ReactDOM
from
'
react-dom
'
;
import
ReactDOM
from
'
react-dom
'
;
import
{
Provider
}
from
'
react-redux
'
;
import
{
Provider
}
from
'
react-redux
'
;
import
deepmerge
from
'
deepmerge
'
;
import
uuid
from
'
uuid/v4
'
;
import
uuid
from
'
uuid/v4
'
;
import
PluginProvider
from
'
../extend/PluginProvider
'
;
import
PluginProvider
from
'
../extend/PluginProvider
'
;
import
App
from
'
../containers/App
'
;
import
App
from
'
../containers/App
'
;
import
createStore
from
'
../state/createStore
'
;
import
createStore
from
'
../state/createStore
'
;
import
createRootReducer
from
'
../state/reducers/rootReducer
'
;
import
createRootReducer
from
'
../state/reducers/rootReducer
'
;
import
*
as
actions
from
'
../state/actions
'
;
import
*
as
actions
from
'
../state/actions
'
;
import
settings
from
'
../config/settings
'
;
import
{
getCompanionWindowIdsForPosition
,
getManifestSearchService
}
from
'
../state/selectors
'
;
import
{
getCompanionWindowIdsForPosition
,
getManifestSearchService
}
from
'
../state/selectors
'
;
/**
/**
...
@@ -43,12 +41,11 @@ class MiradorViewer {
...
@@ -43,12 +41,11 @@ class MiradorViewer {
*/
*/
processConfig
()
{
processConfig
()
{
/** merge type for arrays */
/** merge type for arrays */
const
overwriteMerge
=
(
destinationArray
,
sourceArray
,
options
)
=>
sourceArray
;
const
action
=
actions
.
importConfig
(
this
.
config
);
const
mergedConfig
=
deepmerge
(
settings
,
this
.
config
,
{
arrayMerge
:
overwriteMerge
});
const
action
=
actions
.
setConfig
(
mergedConfig
);
this
.
store
.
dispatch
(
action
);
this
.
store
.
dispatch
(
action
);
const
{
config
:
storedConfig
}
=
this
.
store
.
getState
();
merg
edConfig
.
windows
.
forEach
((
miradorWindow
,
layoutOrder
)
=>
{
stor
edConfig
.
windows
.
forEach
((
miradorWindow
,
layoutOrder
)
=>
{
const
windowId
=
`window-
${
uuid
()}
`
;
const
windowId
=
`window-
${
uuid
()}
`
;
const
manifestId
=
miradorWindow
.
manifestId
||
miradorWindow
.
loadedManifest
;
const
manifestId
=
miradorWindow
.
manifestId
||
miradorWindow
.
loadedManifest
;
const
manifestAction
=
this
.
store
.
dispatch
(
actions
.
fetchManifest
(
manifestId
));
const
manifestAction
=
this
.
store
.
dispatch
(
actions
.
fetchManifest
(
manifestId
));
...
@@ -57,7 +54,7 @@ class MiradorViewer {
...
@@ -57,7 +54,7 @@ class MiradorViewer {
id
:
windowId
,
id
:
windowId
,
layoutOrder
,
layoutOrder
,
manifestId
,
manifestId
,
thumbnailNavigationPosition
:
merg
edConfig
.
thumbnailNavigation
.
defaultPosition
,
thumbnailNavigationPosition
:
stor
edConfig
.
thumbnailNavigation
.
defaultPosition
,
// ... overridden by values from the window configuration ...
// ... overridden by values from the window configuration ...
...
miradorWindow
,
...
miradorWindow
,
}));
}));
...
@@ -81,9 +78,9 @@ class MiradorViewer {
...
@@ -81,9 +78,9 @@ class MiradorViewer {
});
});
});
});
Object
.
keys
(
merg
edConfig
.
manifests
||
{}).
forEach
((
manifestId
)
=>
{
Object
.
keys
(
stor
edConfig
.
manifests
||
{}).
forEach
((
manifestId
)
=>
{
this
.
store
.
dispatch
(
this
.
store
.
dispatch
(
actions
.
requestManifest
(
manifestId
,
merg
edConfig
.
manifests
[
manifestId
]),
actions
.
requestManifest
(
manifestId
,
stor
edConfig
.
manifests
[
manifestId
]),
);
);
});
});
}
}
...
...
This diff is collapsed.
Click to expand it.
src/state/reducers/config.js
+
8
−
2
View file @
092f7cdc
import
deepmerge
from
'
deepmerge
'
;
import
deepmerge
from
'
deepmerge
'
;
import
settings
from
'
../../config/settings
'
;
import
ActionTypes
from
'
../actions/action-types
'
;
import
ActionTypes
from
'
../actions/action-types
'
;
const
initialState
=
{
...
settings
};
/** Overwrite arrays when deep merging */
const
overwriteMerge
=
(
destinationArray
,
sourceArray
,
options
)
=>
sourceArray
;
/**
/**
* configReducer - does a deep merge of the config
* configReducer - does a deep merge of the config
*/
*/
export
const
configReducer
=
(
state
=
{}
,
action
)
=>
{
export
const
configReducer
=
(
state
=
initialState
,
action
)
=>
{
switch
(
action
.
type
)
{
switch
(
action
.
type
)
{
case
ActionTypes
.
UPDATE_CONFIG
:
case
ActionTypes
.
UPDATE_CONFIG
:
case
ActionTypes
.
IMPORT_CONFIG
:
case
ActionTypes
.
IMPORT_CONFIG
:
return
deepmerge
(
state
,
action
.
config
);
return
deepmerge
(
state
,
action
.
config
,
{
arrayMerge
:
overwriteMerge
}
);
case
ActionTypes
.
SET_CONFIG
:
case
ActionTypes
.
SET_CONFIG
:
return
action
.
config
;
return
action
.
config
;
case
ActionTypes
.
IMPORT_MIRADOR_STATE
:
case
ActionTypes
.
IMPORT_MIRADOR_STATE
:
...
...
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