Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Embedded Genesys UI
Commits
87406384
Commit
87406384
authored
Nov 20, 2020
by
Oleksii Savran
Committed by
Matija Obreza
Nov 20, 2020
Browse files
Config: Added default configuration options
parent
b08f2c8c
Changes
4
Hide whitespace changes
Inline
Side-by-side
entrypoints/client.tsx
View file @
87406384
...
...
@@ -10,9 +10,7 @@ const config = {
clientKey
:
'
changeme
'
,
apiUrl
:
'
http://localhost:8080
'
,
filter
:
{
institute
:
{
code
:
[
'
COL003
'
,
'
BEL084
'
,
'
ETH013
'
]
}
},
accession
:
{
enabled
:
true
},
language
:
{
locale
:
queryLang
,
enableSwitch
:
true
},
request
:
{
enabled
:
true
},
};
showGenesysUI
(
document
.
getElementById
(
'
genesys
'
),
config
);
...
...
src/config/config.ts
View file @
87406384
export
class
Config
{
public
apiUrl
:
string
;
public
apiUrl
?
:
string
;
public
clientId
:
string
;
public
clientKey
:
string
;
public
filter
:
Record
<
string
,
any
>
;
public
filter
?
:
Record
<
string
,
any
>
;
// module config
public
language
:
Partial
<
LanguageConfig
>
;
public
language
?
:
Partial
<
LanguageConfig
>
;
public
accession
?:
BaseFeatureConfig
;
public
request
?:
BaseFeatureConfig
;
public
constructor
(
config
:
Config
)
{
this
.
apiUrl
=
config
.
apiUrl
;
this
.
apiUrl
=
config
.
apiUrl
||
defaultConfig
.
apiUrl
;
this
.
clientId
=
config
.
clientId
;
this
.
clientKey
=
config
.
clientKey
;
this
.
filter
=
config
.
filter
;
this
.
filter
=
config
.
filter
||
defaultConfig
.
filter
;
// features
this
.
accession
=
config
.
accession
||
{}
as
BaseFeatureConfig
;
this
.
request
=
config
.
request
||
{}
as
BaseFeatureConfig
;
this
.
language
=
config
.
language
||
{
locale
:
'
en
'
}
;
this
.
accession
=
config
.
accession
||
defaultConfig
.
accession
;
this
.
request
=
config
.
request
||
defaultConfig
.
request
;
this
.
language
=
config
.
language
||
defaultConfig
.
language
;
}
}
...
...
@@ -31,7 +31,7 @@ class LanguageConfig {
public
enableSwitch
:
boolean
;
}
export
const
D
efaultConfig
=
new
Config
(
{
export
const
d
efaultConfig
=
{
apiUrl
:
'
https://api.sandbox.genesys-pgr.org
'
,
clientId
:
'
clientid@genesys
'
,
clientKey
:
'
changeme
'
,
...
...
@@ -39,4 +39,4 @@ export const DefaultConfig = new Config( {
language
:
{
locale
:
'
en
'
,
enableSwitch
:
true
},
accession
:
{
enabled
:
true
},
request
:
{
enabled
:
true
},
}
)
;
};
src/core/reducer/appConfig.ts
View file @
87406384
...
...
@@ -13,8 +13,10 @@ export default (state = INITIAL_STATE, action: { type?: string, payload?: any }
switch
(
action
.
type
)
{
case
RECEIVE_APP_CONFIG
:
{
const
config
=
new
Config
(
action
.
payload
);
return
update
(
state
,
{
config
:
{
$set
:
action
.
payload
},
config
:
{
$set
:
config
},
});
}
...
...
src/genesys.tsx
View file @
87406384
...
...
@@ -10,7 +10,7 @@ import { Provider } from 'react-redux';
import
{
reconfigureServiceAxios
,
LoginService
}
from
'
@genesys/client/service
'
;
import
App
from
'
ui/core/App
'
;
import
ApiAccessError
from
'
ui/core/ApiAccessError
'
;
import
{
Config
,
DefaultConfig
}
from
'
config/config
'
;
import
{
Config
}
from
'
config/config
'
;
import
rootReducer
from
'
core/reducer
'
;
import
{
setConfig
}
from
'
core/actions/appConfig
'
;
import
OverviewPage
from
'
accession/OverviewPage
'
;
...
...
@@ -51,7 +51,7 @@ function checkAccessTokens(apiUrl: string, clientId: string, clientSecret: strin
return
appLogin
;
};
export
function
showGenesysUI
(
holdingNode
:
HTMLElement
,
config
:
Config
=
DefaultConfig
)
{
export
function
showGenesysUI
(
holdingNode
:
HTMLElement
,
config
:
Config
)
{
const
{
apiUrl
,
clientId
,
clientKey
,
language
}
=
config
;
reconfigureServiceAxios
({
apiUrl
});
...
...
@@ -76,7 +76,7 @@ export function showGenesysUI(holdingNode: HTMLElement, config: Config = Default
}
export
function
showOverview
(
holdingNode
:
HTMLElement
,
config
:
Config
=
DefaultConfig
)
{
export
function
showOverview
(
holdingNode
:
HTMLElement
,
config
:
Config
)
{
const
{
apiUrl
,
clientId
,
clientKey
,
language
}
=
config
;
reconfigureServiceAxios
({
apiUrl
});
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment