Skip to content

Commit

Permalink
ui: prepare ui to be deployed as spa
Browse files Browse the repository at this point in the history
  • Loading branch information
zzacharo committed Oct 14, 2019
1 parent 179cc86 commit 6e40da3
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 458 deletions.
21 changes: 0 additions & 21 deletions invenio_app_ils/templates/invenio_app_ils/index.html

This file was deleted.

6 changes: 6 additions & 0 deletions invenio_app_ils/ui/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
REACT_APP_JWT_TOKEN='token'
REACT_APP_USER_ID=1
REACT_APP_LOCATION_ID=1
REACT_APP_USER_ROLE=librarian
REACT_APP_JWT_TOKEN_EXPIRATION=11111111111111111111111
REACT_APP_JWT_USERNAME=librarian
1 change: 0 additions & 1 deletion invenio_app_ils/ui/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<body>
<noscript> You need to enable JavaScript to run this app. </noscript>

<div id="invenio-config" data-config='{"circulation": {"deliveryMethods": {"DELIVERY": "Have it delivered to my office", "PICKUP": "Pick it up at the library desk"}, "loanActiveStates": ["ITEM_AT_DESK", "ITEM_ON_LOAN", "ITEM_IN_TRANSIT_FOR_PICKUP", "ITEM_IN_TRANSIT_TO_HOUSE"], "loanCancelledStates": ["CANCELLED"], "loanCompletedStates": ["ITEM_RETURNED"], "loanRequestStates": ["PENDING"], "requestDuration": 60}, "default_results_size": 10, "documentRequests": {"search": {"aggs": ["state"], "sortBy": {"onEmptyQuery": null, "values": []}, "sortOrder": ["asc", "desc"]}}, "documents": {"search": {"aggs": ["tags", "languages", "document_type", "relations", "has_items", "has_eitems", "has_items_for_loan"], "sortBy": {"onEmptyQuery": "mostrecent", "values": [{"default_order": "asc", "field": "mostrecent", "order": 1, "title": "Newest"}, {"default_order": "asc", "field": "bestmatch", "order": 2, "title": "Best match"}, {"default_order": "asc", "field": "available_items", "order": 3, "title": "Available Items"}, {"default_order": "desc", "field": "mostloaned", "order": 4, "title": "Most loaned"}]}, "sortOrder": ["asc", "desc"]}}, "editor": {"url": "/editor"}, "eitems": {"search": {"aggs": [], "sortBy": {"onEmptyQuery": "mostrecent", "values": [{"field": "mostrecent", "order": 1, "title": "Newest"}, {"field": "bestmatch", "order": 2, "title": "Best match"}]}, "sortOrder": ["asc", "desc"]}}, "items": {"canCirculateStates": ["CAN_CIRCULATE"], "search": {"aggs": ["status", "medium", "circulation"], "sortBy": {"onEmptyQuery": "mostrecent", "values": [{"field": "mostrecent", "order": 1, "title": "Newest"}, {"field": "bestmatch", "order": 2, "title": "Best match"}]}, "sortOrder": ["asc", "desc"]}}, "loans": {"search": {"aggs": ["state"], "sortBy": {"onEmptyQuery": "mostrecent", "values": [{"field": "mostrecent", "order": 1, "title": "Newest"}, {"field": "bestmatch", "order": 2, "title": "Best match"}]}, "sortOrder": ["asc", "desc"]}}, "max_results_window": 10000, "patrons": {"search": {"aggs": [], "sortBy": {"onEmptyQuery": null, "values": []}, "sortOrder": ["asc", "desc"]}}, "relationTypes": [{"api": "invenio_app_ils.records.relations.nodes:PIDNodeRelated", "id": 3, "label": "Multipart Monograph", "name": "multipart_monograph", "relation_class": "invenio_app_ils.records.relations.api.ParentChildRelation", "schema": "invenio_pidrelations.serializers.schemas.RelationSchema"}, {"api": "invenio_app_ils.records.relations.nodes:PIDNodeRelated", "id": 4, "label": "Serial", "name": "serial", "relation_class": "invenio_app_ils.records.relations.api.ParentChildRelation", "schema": "invenio_pidrelations.serializers.schemas.RelationSchema"}, {"api": "invenio_app_ils.records.relations.nodes:PIDNodeRelated", "id": 0, "label": "Language", "name": "language", "relation_class": "invenio_app_ils.records.relations.api.SiblingsRelation", "schema": "invenio_pidrelations.serializers.schemas.RelationSchema"}, {"api": "invenio_app_ils.records.relations.nodes:PIDNodeRelated", "id": 1, "label": "Edition", "name": "edition", "relation_class": "invenio_app_ils.records.relations.api.SiblingsRelation", "schema": "invenio_pidrelations.serializers.schemas.RelationSchema"}, {"api": "invenio_app_ils.records.relations.nodes:PIDNodeRelated", "id": 2, "label": "Other", "name": "other", "relation_class": "invenio_app_ils.records.relations.api.SiblingsRelation", "schema": "invenio_pidrelations.serializers.schemas.RelationSchema"}], "rest_mimetype_query_arg_name": "format", "series": {"search": {"aggs": ["moi"], "sortBy": {"onEmptyQuery": "mostrecent", "values": [{"field": "mostrecent", "order": 1, "title": "Newest"}, {"field": "bestmatch", "order": 2, "title": "Best match"}]}, "sortOrder": ["asc", "desc"]}}, "support_email": "info@inveniosoftware.org"}'></div>
<div id="app"></div>
<!--
This HTML file is a template.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ class SessionManager {
// Initialize to anonymous user
this.setAnonymous();

if (process.env.NODE_ENV === 'production') {
if (
process.env.NODE_ENV === 'production' &&
!process.env.REACT_APP_JWT_TOKEN
) {
let encodedToken = authenticationService.getTokenFromDOM();
if (encodedToken) {
tokenData = authenticationService.decodeProductionToken(encodedToken);
Expand Down
205 changes: 199 additions & 6 deletions invenio_app_ils/ui/src/invenio_app_ils/common/config/invenioConfig.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,200 @@
const getInvenioConfig = () => {
const element = document.getElementById('invenio-config');
const jsonString = element ? element.getAttribute('data-config') : '{}';
return JSON.parse(jsonString);
export const invenioConfig = {
circulation: {
deliveryMethods: {
DELIVERY: 'Delivery',
PICKUP: 'Pick it up at the library desk',
},
loanActiveStates: [
'ITEM_AT_DESK',
'ITEM_ON_LOAN',
'ITEM_IN_TRANSIT_FOR_PICKUP',
'ITEM_IN_TRANSIT_TO_HOUSE',
],
loanCancelledStates: ['CANCELLED'],
loanCompletedStates: ['ITEM_RETURNED'],
loanRequestStates: ['PENDING'],
requestDuration: 60,
},
default_results_size: 10,
documentRequests: {
search: {
aggs: ['state'],
sortBy: {
onEmptyQuery: null,
values: [],
},
sortOrder: ['asc', 'desc'],
},
},
documents: {
search: {
aggs: [
'tags',
'languages',
'document_type',
'relations',
'has_items',
'has_eitems',
'has_items_for_loan',
],
sortBy: {
onEmptyQuery: 'mostrecent',
values: [
{
default_order: 'asc',
field: 'mostrecent',
order: 1,
title: 'Newest',
},
{
default_order: 'asc',
field: 'bestmatch',
order: 2,
title: 'Best match',
},
{
default_order: 'asc',
field: 'available_items',
order: 3,
title: 'Available Items',
},
{
default_order: 'desc',
field: 'mostloaned',
order: 4,
title: 'Most loaned',
},
],
},
sortOrder: ['asc', 'desc'],
},
},
editor: {
url: '/editor',
},
eitems: {
search: {
aggs: [],
sortBy: {
onEmptyQuery: 'mostrecent',
values: [
{
field: 'mostrecent',
order: 1,
title: 'Newest',
},
{
field: 'bestmatch',
order: 2,
title: 'Best match',
},
],
},
sortOrder: ['asc', 'desc'],
},
},
items: {
canCirculateStates: ['CAN_CIRCULATE'],
search: {
aggs: ['status', 'medium', 'circulation'],
sortBy: {
onEmptyQuery: 'mostrecent',
values: [
{
field: 'mostrecent',
order: 1,
title: 'Newest',
},
{
field: 'bestmatch',
order: 2,
title: 'Best match',
},
],
},
sortOrder: ['asc', 'desc'],
},
},
loans: {
search: {
aggs: ['state'],
sortBy: {
onEmptyQuery: 'mostrecent',
values: [
{
field: 'mostrecent',
order: 1,
title: 'Newest',
},
{
field: 'bestmatch',
order: 2,
title: 'Best match',
},
],
},
sortOrder: ['asc', 'desc'],
},
},
max_results_window: 10000,
patrons: {
search: {
aggs: [],
sortBy: {
onEmptyQuery: null,
values: [],
},
sortOrder: ['asc', 'desc'],
},
},
relationTypes: [
{
id: 3,
label: 'Multipart Monograph',
name: 'multipart_monograph',
},
{
id: 4,
label: 'Serial',
name: 'serial',
},
{
id: 0,
label: 'Language',
name: 'language',
},
{
id: 1,
label: 'Edition',
name: 'edition',
},
{
id: 2,
label: 'Other',
name: 'other',
},
],
rest_mimetype_query_arg_name: 'format',
series: {
search: {
aggs: ['moi'],
sortBy: {
onEmptyQuery: 'mostrecent',
values: [
{
field: 'mostrecent',
order: 1,
title: 'Newest',
},
{
field: 'bestmatch',
order: 2,
title: 'Best match',
},
],
},
sortOrder: ['asc', 'desc'],
},
},
support_email: 'info@inveniosoftware.org',
};

export const invenioConfig = getInvenioConfig();
Loading

0 comments on commit 6e40da3

Please sign in to comment.