Skip to content
GitLab
Menu
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
b08f2c8c
Commit
b08f2c8c
authored
Nov 20, 2020
by
Oleksii Savran
Committed by
Matija Obreza
Nov 20, 2020
Browse files
showOverview with Redux
parent
224787fd
Changes
5
Hide whitespace changes
Inline
Side-by-side
entrypoints/client.tsx
View file @
b08f2c8c
import
{
showGenesysUI
}
from
'
genesys
'
;
import
{
showGenesysUI
,
// showOverview, // for testing
}
from
'
genesys
'
;
const
queryLang
=
document
.
location
.
search
&&
document
.
location
.
search
.
substr
(
1
)
||
undefined
;
showGenesysUI
(
document
.
getElementById
(
'
genesys
'
),
{
const
config
=
{
clientId
:
'
defaultclient@localhost
'
,
clientKey
:
'
changeme
'
,
apiUrl
:
'
http://localhost:8080
'
,
filter
:
{
institute
:
{
code
:
[
'
COL003
'
,
'
BEL084
'
,
'
ETH013
'
]
}
},
accession
:
{
enabled
:
true
},
language
:
{
locale
:
queryLang
,
enableSwitch
:
true
},
request
:
{
enabled
:
false
},
});
request
:
{
enabled
:
true
},
};
showGenesysUI
(
document
.
getElementById
(
'
genesys
'
),
config
);
// showOverview(document.getElementById('genesys'), config);
src/accession/AccessionOverviewSection.tsx
View file @
b08f2c8c
...
...
@@ -193,7 +193,7 @@ class AccessionOverviewSection extends React.Component<IAccessionOverviewPagePro
}
const
mapStateToProps
=
(
state
)
=>
({
countryCodes
:
state
.
decoding
.
codes
,
countryCodes
:
state
.
decoding
.
co
untryCo
des
,
});
export
default
connect
(
mapStateToProps
)(
withTranslation
()(
AccessionOverviewSection
));
src/config/config.ts
View file @
b08f2c8c
...
...
@@ -5,15 +5,20 @@ export class Config {
public
filter
:
Record
<
string
,
any
>
;
// module config
public
accession
:
BaseFeatureConfig
;
public
language
:
Partial
<
LanguageConfig
>
;
public
request
:
BaseFeatureConfig
;
public
accession
?:
BaseFeatureConfig
;
public
request
?:
BaseFeatureConfig
;
public
constructor
(
config
:
Config
)
{
this
.
apiUrl
=
config
.
apiUrl
;
this
.
clientId
=
config
.
clientId
;
this
.
clientKey
=
config
.
clientKey
;
this
.
filter
=
config
.
filter
;
// features
this
.
accession
=
config
.
accession
||
{}
as
BaseFeatureConfig
;
this
.
request
=
config
.
request
||
{}
as
BaseFeatureConfig
;
this
.
language
=
config
.
language
||
{
locale
:
'
en
'
};
}
}
...
...
@@ -34,4 +39,4 @@ export const DefaultConfig = new Config( {
language
:
{
locale
:
'
en
'
,
enableSwitch
:
true
},
accession
:
{
enabled
:
true
},
request
:
{
enabled
:
true
},
})
})
;
src/core/reducer/decoding.ts
View file @
b08f2c8c
...
...
@@ -3,9 +3,9 @@ import update from 'immutability-helper';
import
{
RECEIVE_COUNTRY_CODES_DECODED
}
from
'
core/constants/decoding
'
;
const
INITIAL_STATE
:
{
codes
:
Record
<
string
,
string
>
,
co
untryCo
des
:
Record
<
string
,
string
>
,
}
=
{
codes
:
null
,
co
untryCo
des
:
null
,
};
export
default
(
state
=
INITIAL_STATE
,
action
:
{
type
?:
string
,
payload
?:
any
}
=
{
type
:
''
,
payload
:
{}
})
=>
{
...
...
@@ -13,7 +13,7 @@ export default (state = INITIAL_STATE, action: { type?: string, payload?: any }
switch
(
action
.
type
)
{
case
RECEIVE_COUNTRY_CODES_DECODED
:
{
return
update
(
state
,
{
codes
:
{
$set
:
action
.
payload
},
co
untryCo
des
:
{
$set
:
action
.
payload
},
});
}
...
...
src/genesys.tsx
View file @
b08f2c8c
...
...
@@ -52,10 +52,10 @@ function checkAccessTokens(apiUrl: string, clientId: string, clientSecret: strin
};
export
function
showGenesysUI
(
holdingNode
:
HTMLElement
,
config
:
Config
=
DefaultConfig
)
{
const
{
apiUrl
,
clientId
,
clientKey
}
=
config
;
const
{
apiUrl
,
clientId
,
clientKey
,
language
}
=
config
;
reconfigureServiceAxios
({
apiUrl
});
initI18n
(
config
.
language
.
locale
);
initI18n
(
language
.
locale
);
store
.
dispatch
(
setConfig
(
config
));
checkAccessTokens
(
apiUrl
,
clientId
,
clientKey
).
then
(
(
result
)
=>
{
...
...
@@ -76,16 +76,19 @@ export function showGenesysUI(holdingNode: HTMLElement, config: Config = Default
}
export
function
showOverview
(
holdingNode
:
HTMLElement
,
config
:
Config
=
DefaultConfig
,
language
:
string
=
'
en
'
)
{
const
{
apiUrl
,
clientId
,
clientKey
,
filter
}
=
config
;
export
function
showOverview
(
holdingNode
:
HTMLElement
,
config
:
Config
=
DefaultConfig
)
{
const
{
apiUrl
,
clientId
,
clientKey
,
language
}
=
config
;
reconfigureServiceAxios
({
apiUrl
});
initI18n
(
language
);
initI18n
(
language
.
locale
);
store
.
dispatch
(
setConfig
(
config
));
checkAccessTokens
(
apiUrl
,
clientId
,
clientKey
).
then
(
(
result
)
=>
{
ReactDOM
.
render
(
<
OverviewPage
filter
=
{
filter
}
/>,
<
Provider
store
=
{
store
}
>
<
OverviewPage
/>
</
Provider
>,
holdingNode
,
);
}).
catch
((
err
)
=>
{
...
...
Write
Preview
Supports
Markdown
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