Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Rex Dri
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Julien Jerphanion
Rex Dri
Commits
8647ed5c
Commit
8647ed5c
authored
Feb 08, 2019
by
Florent Chehab
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added js linting settings and fixed linting issues
Added editor config
parent
7c509208
Changes
112
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
112 changed files
with
2098 additions
and
1812 deletions
+2098
-1812
.editorconfig
.editorconfig
+18
-0
frontend/.eslintrc.js
frontend/.eslintrc.js
+42
-0
frontend/.eslintrc.yml
frontend/.eslintrc.yml
+0
-1
frontend/package-lock.json
frontend/package-lock.json
+438
-222
frontend/package.json
frontend/package.json
+5
-1
frontend/src/actions/action-types.js
frontend/src/actions/action-types.js
+6
-6
frontend/src/actions/filter.js
frontend/src/actions/filter.js
+10
-10
frontend/src/actions/map.js
frontend/src/actions/map.js
+5
-5
frontend/src/actions/search.js
frontend/src/actions/search.js
+10
-10
frontend/src/actions/theme.js
frontend/src/actions/theme.js
+10
-10
frontend/src/actions/universityPage.js
frontend/src/actions/universityPage.js
+5
-5
frontend/src/api/CrudActions.js
frontend/src/api/CrudActions.js
+10
-10
frontend/src/api/CrudReducers.js
frontend/src/api/CrudReducers.js
+26
-26
frontend/src/api/SmartActions.js
frontend/src/api/SmartActions.js
+25
-24
frontend/src/api/buildApiActionsAndReducers.js
frontend/src/api/buildApiActionsAndReducers.js
+2
-2
frontend/src/api/getActions.js
frontend/src/api/getActions.js
+3
-4
frontend/src/api/getCrudActionTypes.js
frontend/src/api/getCrudActionTypes.js
+1
-1
frontend/src/components/App.js
frontend/src/components/App.js
+37
-37
frontend/src/components/CustomComponentForAPI.js
frontend/src/components/CustomComponentForAPI.js
+18
-16
frontend/src/components/ThemeProvider.js
frontend/src/components/ThemeProvider.js
+12
-12
frontend/src/components/filter/DownshiftMultiple.js
frontend/src/components/filter/DownshiftMultiple.js
+66
-65
frontend/src/components/filter/Filter.js
frontend/src/components/filter/Filter.js
+23
-23
frontend/src/components/map/MyCardMedia.js
frontend/src/components/map/MyCardMedia.js
+16
-16
frontend/src/components/map/UnivMakers.js
frontend/src/components/map/UnivMakers.js
+10
-10
frontend/src/components/map/UnivMap.js
frontend/src/components/map/UnivMap.js
+14
-13
frontend/src/components/map/UnivPopupContent.js
frontend/src/components/map/UnivPopupContent.js
+18
-18
frontend/src/components/other/Loading.js
frontend/src/components/other/Loading.js
+5
-5
frontend/src/components/other/TextLink.js
frontend/src/components/other/TextLink.js
+8
-8
frontend/src/components/pages/PageHome.js
frontend/src/components/pages/PageHome.js
+23
-22
frontend/src/components/pages/PageMap.js
frontend/src/components/pages/PageMap.js
+8
-8
frontend/src/components/pages/PageSearch.js
frontend/src/components/pages/PageSearch.js
+8
-8
frontend/src/components/pages/PageSettings.js
frontend/src/components/pages/PageSettings.js
+8
-7
frontend/src/components/pages/PageUniversity.js
frontend/src/components/pages/PageUniversity.js
+19
-19
frontend/src/components/search/Search.js
frontend/src/components/search/Search.js
+13
-13
frontend/src/components/search/UnivList.js
frontend/src/components/search/UnivList.js
+23
-22
frontend/src/components/settings/ColorDemo.js
frontend/src/components/settings/ColorDemo.js
+17
-17
frontend/src/components/settings/ColorTools.js
frontend/src/components/settings/ColorTools.js
+48
-49
frontend/src/components/settings/Settings.js
frontend/src/components/settings/Settings.js
+3
-3
frontend/src/components/shared/Markdown.js
frontend/src/components/shared/Markdown.js
+41
-37
frontend/src/components/shared/MyBadge.js
frontend/src/components/shared/MyBadge.js
+3
-3
frontend/src/components/shared/UnivContext.js
frontend/src/components/shared/UnivContext.js
+1
-1
frontend/src/components/shared/VisibilityContext.js
frontend/src/components/shared/VisibilityContext.js
+1
-1
frontend/src/components/template/listItems.js
frontend/src/components/template/listItems.js
+17
-18
frontend/src/components/university/CoverGallery.js
frontend/src/components/university/CoverGallery.js
+11
-11
frontend/src/components/university/UniversityTemplate.js
frontend/src/components/university/UniversityTemplate.js
+30
-30
frontend/src/components/university/editors/CountryDriEditor.js
...end/src/components/university/editors/CountryDriEditor.js
+10
-13
frontend/src/components/university/editors/CountryScholarshipsEditor.js
...omponents/university/editors/CountryScholarshipsEditor.js
+8
-9
frontend/src/components/university/editors/UniversityDriEditor.js
.../src/components/university/editors/UniversityDriEditor.js
+10
-12
frontend/src/components/university/editors/UniversityGeneralEditor.js
.../components/university/editors/UniversityGeneralEditor.js
+15
-15
frontend/src/components/university/editors/UniversityScholarshipsEditor.js
...onents/university/editors/UniversityScholarshipsEditor.js
+8
-9
frontend/src/components/university/editors/UniversitySemestersDatesEditor.js
...ents/university/editors/UniversitySemestersDatesEditor.js
+17
-19
frontend/src/components/university/modules/CountryDri.js
frontend/src/components/university/modules/CountryDri.js
+20
-17
frontend/src/components/university/modules/CountryScholarships.js
.../src/components/university/modules/CountryScholarships.js
+17
-16
frontend/src/components/university/modules/PreviousDeparture.js
...nd/src/components/university/modules/PreviousDeparture.js
+10
-10
frontend/src/components/university/modules/UniversityDri.js
frontend/src/components/university/modules/UniversityDri.js
+19
-17
frontend/src/components/university/modules/UniversityGeneral.js
...nd/src/components/university/modules/UniversityGeneral.js
+25
-24
frontend/src/components/university/modules/UniversityScholarships.js
...c/components/university/modules/UniversityScholarships.js
+18
-17
frontend/src/components/university/modules/UniversitySemestersDates.js
...components/university/modules/UniversitySemestersDates.js
+24
-24
frontend/src/components/university/shared/Alert.js
frontend/src/components/university/shared/Alert.js
+24
-21
frontend/src/components/university/shared/Editor.js
frontend/src/components/university/shared/Editor.js
+37
-38
frontend/src/components/university/shared/GenericGroupModule.js
...nd/src/components/university/shared/GenericGroupModule.js
+20
-20
frontend/src/components/university/shared/GenericModule.js
frontend/src/components/university/shared/GenericModule.js
+29
-29
frontend/src/components/university/shared/History.js
frontend/src/components/university/shared/History.js
+45
-44
frontend/src/components/university/shared/Module.js
frontend/src/components/university/shared/Module.js
+2
-2
frontend/src/components/university/shared/Notification.js
frontend/src/components/university/shared/Notification.js
+22
-21
frontend/src/components/university/shared/PendingModeration.js
...end/src/components/university/shared/PendingModeration.js
+28
-27
frontend/src/components/university/shared/Scholarship.js
frontend/src/components/university/shared/Scholarship.js
+24
-25
frontend/src/components/university/shared/ScholarshipsEditor.js
...nd/src/components/university/shared/ScholarshipsEditor.js
+18
-19
frontend/src/components/university/shared/UnivInfoConsumer.js
...tend/src/components/university/shared/UnivInfoConsumer.js
+9
-9
frontend/src/components/university/shared/UnivInfoProvider.js
...tend/src/components/university/shared/UnivInfoProvider.js
+10
-11
frontend/src/components/university/shared/editorFunctions/getMapDispatchToPropsForEditor.js
.../shared/editorFunctions/getMapDispatchToPropsForEditor.js
+1
-1
frontend/src/components/university/shared/editorFunctions/getMapStateToPropsForEditor.js
...ity/shared/editorFunctions/getMapStateToPropsForEditor.js
+1
-1
frontend/src/components/university/shared/editorFunctions/renderFieldsMixIn.js
...ts/university/shared/editorFunctions/renderFieldsMixIn.js
+43
-43
frontend/src/components/university/shared/editorStyle.js
frontend/src/components/university/shared/editorStyle.js
+3
-3
frontend/src/components/university/shared/fields/DateField.js
...tend/src/components/university/shared/fields/DateField.js
+19
-20
frontend/src/components/university/shared/fields/Field.js
frontend/src/components/university/shared/fields/Field.js
+7
-7
frontend/src/components/university/shared/fields/FieldWrapper.js
...d/src/components/university/shared/fields/FieldWrapper.js
+9
-9
frontend/src/components/university/shared/fields/MarkdownField.js
.../src/components/university/shared/fields/MarkdownField.js
+22
-22
frontend/src/components/university/shared/fields/MultiSelectField.js
...c/components/university/shared/fields/MultiSelectField.js
+16
-17
frontend/src/components/university/shared/fields/NumberField.js
...nd/src/components/university/shared/fields/NumberField.js
+24
-24
frontend/src/components/university/shared/fields/SelectField.js
...nd/src/components/university/shared/fields/SelectField.js
+13
-13
frontend/src/components/university/shared/fields/TextField.js
...tend/src/components/university/shared/fields/TextField.js
+23
-23
frontend/src/components/university/shared/fields/UsefulLinksField.js
...c/components/university/shared/fields/UsefulLinksField.js
+36
-37
frontend/src/components/university/shared/genericModuleFunctions/getEditTooltipAndClass.js
...y/shared/genericModuleFunctions/getEditTooltipAndClass.js
+3
-3
frontend/src/components/university/shared/genericModuleFunctions/getModerationTooltipAndClass.js
...ed/genericModuleFunctions/getModerationTooltipAndClass.js
+4
-4
frontend/src/components/university/shared/genericModuleFunctions/getVersionTooltipAndClass.js
...hared/genericModuleFunctions/getVersionTooltipAndClass.js
+5
-5
frontend/src/components/university/shared/genericModuleFunctions/renderFirstRow.js
...niversity/shared/genericModuleFunctions/renderFirstRow.js
+22
-22
frontend/src/components/university/shared/genericModuleFunctions/renderTitle.js
...s/university/shared/genericModuleFunctions/renderTitle.js
+11
-11
frontend/src/components/university/shared/genericModuleFunctions/renderUpdateInfo.js
...versity/shared/genericModuleFunctions/renderUpdateInfo.js
+6
-6
frontend/src/components/university/shared/genericModuleFunctions/renderUsefulLinks.js
...ersity/shared/genericModuleFunctions/renderUsefulLinks.js
+10
-10
frontend/src/components/university/tabs/CampusesCitiesTab.js
frontend/src/components/university/tabs/CampusesCitiesTab.js
+7
-7
frontend/src/components/university/tabs/GeneralInfoTab.js
frontend/src/components/university/tabs/GeneralInfoTab.js
+24
-24
frontend/src/components/university/tabs/MoreTab.js
frontend/src/components/university/tabs/MoreTab.js
+7
-6
frontend/src/components/university/tabs/PreviousDeparturesTab.js
...d/src/components/university/tabs/PreviousDeparturesTab.js
+8
-8
frontend/src/components/university/tabs/ScholarshipsTab.js
frontend/src/components/university/tabs/ScholarshipsTab.js
+15
-15
frontend/src/components/university/tabs/UniversityMoreTab.js
frontend/src/components/university/tabs/UniversityMoreTab.js
+7
-8
frontend/src/index.js
frontend/src/index.js
+10
-10
frontend/src/reducers/filter.js
frontend/src/reducers/filter.js
+16
-16
frontend/src/reducers/index.js
frontend/src/reducers/index.js
+6
-6
frontend/src/reducers/map.js
frontend/src/reducers/map.js
+11
-11
frontend/src/reducers/search.js
frontend/src/reducers/search.js
+16
-16
frontend/src/reducers/theme.js
frontend/src/reducers/theme.js
+20
-20
frontend/src/reducers/universityPage.js
frontend/src/reducers/universityPage.js
+7
-7
frontend/src/store/index.js
frontend/src/store/index.js
+20
-20
frontend/src/utils/areSameObjets.js
frontend/src/utils/areSameObjets.js
+1
-1
frontend/src/utils/areSameThemes.js
frontend/src/utils/areSameThemes.js
+13
-13
frontend/src/utils/dateStrToDate.js
frontend/src/utils/dateStrToDate.js
+2
-2
frontend/src/utils/dateStrToStr.js
frontend/src/utils/dateStrToStr.js
+1
-1
frontend/src/utils/dateTimeStrToStr.js
frontend/src/utils/dateTimeStrToStr.js
+12
-12
frontend/src/utils/dateToDateStr.js
frontend/src/utils/dateToDateStr.js
+3
-3
frontend/src/utils/isModerationRequired.js
frontend/src/utils/isModerationRequired.js
+26
-26
frontend/src/utils/stringHasExtension.js
frontend/src/utils/stringHasExtension.js
+2
-2
No files found.
.editorconfig
0 → 100644
View file @
8647ed5c
# editorconfig.org
root = true
[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.py]
indent_size = 4
[*.js]
indent_size = 2
[*.json]
indent_size = 2
\ No newline at end of file
frontend/.eslintrc.js
0 → 100644
View file @
8647ed5c
module
.
exports
=
{
"
env
"
:
{
"
browser
"
:
true
,
"
es6
"
:
true
,
},
"
extends
"
:
[
"
eslint:recommended
"
,
"
plugin:react/recommended
"
],
"
parser
"
:
"
babel-eslint
"
,
"
parserOptions
"
:
{
"
ecmaVersion
"
:
2018
,
"
sourceType
"
:
"
module
"
,
"
ecmaFeatures
"
:
{
"
jsx
"
:
true
}
},
"
plugins
"
:
[
"
react
"
],
"
rules
"
:
{
"
indent
"
:
[
"
error
"
,
2
],
"
linebreak-style
"
:
[
"
error
"
,
"
unix
"
],
"
quotes
"
:
[
"
error
"
,
"
double
"
],
"
semi
"
:
[
"
error
"
,
"
always
"
],
"
react/no-unescaped-entities
"
:
"
warn
"
,
"
react/prop-types
"
:
"
warn
"
,
"
react/no-deprecated
"
:
"
warn
"
}
};
frontend/.eslintrc.yml
deleted
100644 → 0
View file @
7c509208
extends
:
google
frontend/package-lock.json
View file @
8647ed5c
This diff is collapsed.
Click to expand it.
frontend/package.json
View file @
8647ed5c
...
...
@@ -4,6 +4,8 @@
"description"
:
"[](https://gitlab.utc.fr/chehabfl/outgoing_rex/pipelines) [](https://chehabfl.gitlab.utc.fr/outgoing_rex/) [](https://opensource.org/licenses/BSD-2-Clause)"
,
"main"
:
"manage.py"
,
"scripts"
:
{
"lint"
:
"eslint
\"
./src/**/*.js
\"
"
,
"lint-fix"
:
"eslint
\"
./src/**/*.js
\"
--fix"
,
"dev"
:
"webpack --mode development"
,
"build"
:
"webpack --mode production"
,
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
,
...
...
@@ -45,6 +47,7 @@
"devDependencies"
:
{
"autoprefixer"
:
"^9.1.5"
,
"babel-core"
:
"^6.26.3"
,
"babel-eslint"
:
"^10.0.1"
,
"babel-loader"
:
"^7.1.5"
,
"babel-plugin-transform-class-properties"
:
"^6.24.1"
,
"babel-preset-env"
:
"^1.7.0"
,
...
...
@@ -52,8 +55,9 @@
"babel-preset-react"
:
"^6.24.1"
,
"babel-preset-stage-1"
:
"^6.24.1"
,
"css-loader"
:
"^1.0.0"
,
"eslint"
:
"^5.
4
.0"
,
"eslint"
:
"^5.
13
.0"
,
"eslint-config-google"
:
"^0.9.1"
,
"eslint-plugin-react"
:
"^7.12.4"
,
"file-loader"
:
"^2.0.0"
,
"js-yaml-loader"
:
"^1.0.1"
,
"mini-css-extract-plugin"
:
"^0.4.2"
,
...
...
frontend/src/actions/action-types.js
View file @
8647ed5c
export
const
SAVE_MAIN_MAP_POSITION
=
'
SAVE_MAIN_MAP_POSITION
'
;
export
const
SAVE_SELECTED_UNIVERSITIES
=
'
SAVE_SELECTED_UNIVERSITIES
'
;
export
const
SAVE_FILTER_CONFIG
=
'
SAVE_FILTER_CONFIG
'
;
export
const
SAVE_APP_THEME
=
'
SAVE_APP_THEME
'
;
export
const
SAVE_APP_COLOR_PICKER
=
'
SAVE_APP_COLOR_PICKER
'
;
export
const
SAVE_UNIVERSITY_BEING_VIEWED
=
'
SAVE_UNIVERSITY_BEING_VIEWED
'
;
export
const
SAVE_MAIN_MAP_POSITION
=
"
SAVE_MAIN_MAP_POSITION
"
;
export
const
SAVE_SELECTED_UNIVERSITIES
=
"
SAVE_SELECTED_UNIVERSITIES
"
;
export
const
SAVE_FILTER_CONFIG
=
"
SAVE_FILTER_CONFIG
"
;
export
const
SAVE_APP_THEME
=
"
SAVE_APP_THEME
"
;
export
const
SAVE_APP_COLOR_PICKER
=
"
SAVE_APP_COLOR_PICKER
"
;
export
const
SAVE_UNIVERSITY_BEING_VIEWED
=
"
SAVE_UNIVERSITY_BEING_VIEWED
"
;
frontend/src/actions/filter.js
View file @
8647ed5c
import
{
SAVE_SELECTED_UNIVERSITIES
,
SAVE_FILTER_CONFIG
SAVE_SELECTED_UNIVERSITIES
,
SAVE_FILTER_CONFIG
}
from
"
./action-types
"
;
export
function
saveSelectedUniversities
(
new_selection
)
{
return
{
type
:
SAVE_SELECTED_UNIVERSITIES
,
new_selection
};
return
{
type
:
SAVE_SELECTED_UNIVERSITIES
,
new_selection
};
}
export
function
saveFilterConfig
(
config
)
{
return
{
type
:
SAVE_FILTER_CONFIG
,
config
};
return
{
type
:
SAVE_FILTER_CONFIG
,
config
};
}
frontend/src/actions/map.js
View file @
8647ed5c
import
{
SAVE_MAIN_MAP_POSITION
SAVE_MAIN_MAP_POSITION
}
from
"
./action-types
"
;
export
function
saveMainMapPosition
(
new_position
)
{
return
{
type
:
SAVE_MAIN_MAP_POSITION
,
new_position
};
return
{
type
:
SAVE_MAIN_MAP_POSITION
,
new_position
};
}
frontend/src/actions/search.js
View file @
8647ed5c
import
{
SAVE_SELECTED_UNIVERSITIES
,
SAVE_FILTER_CONFIG
SAVE_SELECTED_UNIVERSITIES
,
SAVE_FILTER_CONFIG
}
from
"
./action-types
"
;
export
function
saveSelectedUniversities
(
new_selection
)
{
return
{
type
:
SAVE_SELECTED_UNIVERSITIES
,
new_selection
};
return
{
type
:
SAVE_SELECTED_UNIVERSITIES
,
new_selection
};
}
export
function
saveFilterConfig
(
config
)
{
return
{
type
:
SAVE_FILTER_CONFIG
,
config
};
return
{
type
:
SAVE_FILTER_CONFIG
,
config
};
}
frontend/src/actions/theme.js
View file @
8647ed5c
import
{
SAVE_APP_THEME
,
SAVE_APP_COLOR_PICKER
SAVE_APP_THEME
,
SAVE_APP_COLOR_PICKER
}
from
"
./action-types
"
;
export
function
saveAppTheme
(
theme
)
{
return
{
type
:
SAVE_APP_THEME
,
theme
};
return
{
type
:
SAVE_APP_THEME
,
theme
};
}
export
function
saveAppColorPicker
(
s
)
{
return
{
type
:
SAVE_APP_COLOR_PICKER
,
state
:
s
};
return
{
type
:
SAVE_APP_COLOR_PICKER
,
state
:
s
};
}
frontend/src/actions/universityPage.js
View file @
8647ed5c
import
{
SAVE_UNIVERSITY_BEING_VIEWED
SAVE_UNIVERSITY_BEING_VIEWED
}
from
"
./action-types
"
;
export
function
saveUniversityBeingViewed
(
univId
)
{
return
{
type
:
SAVE_UNIVERSITY_BEING_VIEWED
,
univId
};
return
{
type
:
SAVE_UNIVERSITY_BEING_VIEWED
,
univId
};
}
frontend/src/api/CrudActions.js
View file @
8647ed5c
...
...
@@ -9,7 +9,7 @@ function _isReading(status, type) {
return
{
type
,
status
}
}
;
}
function
_readFailed
(
failed
,
error
,
type
)
{
...
...
@@ -17,7 +17,7 @@ function _readFailed(failed, error, type) {
type
,
failed
,
error
}
}
;
}
function
_readSucceeded
(
data
,
type
)
{
...
...
@@ -82,7 +82,7 @@ export default class CrudActions {
readAllSucceeded
,
this
.
setInvalidatedAll
.
bind
(
this
),
readAllFailed
)
)
;
}
...
...
@@ -116,7 +116,7 @@ export default class CrudActions {
readSpecificSucceeded
,
this
.
setInvalidatedSpecific
.
bind
(
this
),
readSpecificFailed
)
)
;
}
...
...
@@ -182,7 +182,7 @@ export default class CrudActions {
isCreating
,
createSucceeded
,
createFailed
)
)
;
}
/**
...
...
@@ -218,7 +218,7 @@ export default class CrudActions {
}
self
.
_checkNotReadonly
();
if
(
!
'
id
'
in
data
)
{
if
(
!
(
"
id
"
in
data
)
)
{
throw
Error
(
"
When updating an object, an id is expected in the data
"
);
}
...
...
@@ -228,7 +228,7 @@ export default class CrudActions {
isUpdating
,
updateSucceeded
,
updateFailed
)
)
;
}
///////////
...
...
@@ -246,10 +246,10 @@ export default class CrudActions {
return
{
type
:
this
.
types
.
isInvalidatedAll
,
isInvalidated
:
bool
}
}
;
}
/**
/**
* Function to tell the store that this element has been invalidated relative to "specific"
*
* @param {boolean} bool
...
...
@@ -260,6 +260,6 @@ export default class CrudActions {
return
{
type
:
this
.
types
.
isInvalidatedSpecific
,
isInvalidated
:
bool
}
}
;
}
}
\ No newline at end of file
frontend/src/api/CrudReducers.js
View file @
8647ed5c
import
{
combineReducers
}
from
'
redux
'
;
import
{
combineReducers
}
from
"
redux
"
;
import
getCrudActionTypes
from
"
./getCrudActionTypes
"
;
import
SmartActions
from
"
./SmartActions
"
;
...
...
@@ -6,47 +6,47 @@ import SmartActions from "./SmartActions";
// generic function helpers
function
failed
(
state
,
action
,
type
)
{
switch
(
action
.
type
)
{
case
type
:
return
{
failed
:
action
.
failed
,
error
:
action
.
error
}
default
:
return
state
;
case
type
:
return
{
failed
:
action
.
failed
,
error
:
action
.
error
};
default
:
return
state
;
}
}
function
succeeded
(
state
,
action
,
type
)
{
switch
(
action
.
type
)
{
case
type
:
return
{
data
:
action
.
data
,
readAt
:
(
new
Date
()).
getTime
()
}
default
:
return
state
;
case
type
:
return
{
data
:
action
.
data
,
readAt
:
(
new
Date
()).
getTime
()
};
default
:
return
state
;
}
}
function
is
(
state
,
action
,
type
)
{
switch
(
action
.
type
)
{
case
type
:
return
action
.
status
;
case
type
:
return
action
.
status
;
default
:
return
state
;
default
:
return
state
;
}
}
function
invalidate
(
state
,
action
,
type
)
{
switch
(
action
.
type
)
{
case
type
:
return
action
.
isInvalidated
;
case
type
:
return
action
.
isInvalidated
;
default
:
return
state
;
default
:
return
state
;
}
}
...
...
@@ -150,7 +150,7 @@ export default class CrudReducers {
readSucceeded
:
readSpecificSucceeded
,
readFailed
:
readSpecificFailed
,
isInvalidated
:
isInvalidatedSpecific
,
}
}
;
// Add only appropriate reducers
if
(
this
.
readOnly
!==
true
)
{
...
...
frontend/src/api/SmartActions.js
View file @
8647ed5c
import
Cookies
from
'
js-cookie
'
;
import
Cookies
from
"
js-cookie
"
;
// TODO uodate parameters name to match new CRUD actions
...
...
@@ -19,7 +19,7 @@ export default class SmartActions {
}
/**
* Generic function for handling a GET request to the API
* Generic function for handling a GET request to the API
*
* @param {string} pk
* @param {string} api_end_point
...
...
@@ -32,11 +32,11 @@ export default class SmartActions {
* @memberof SmartActions
*/
_FetchData
(
pk
,
api_end_point
,
_IsLoading
,
_FetchDataSuccess
,
_Invalidated
,
_HasError
,
pk_required
=
false
)
{
if
(
pk_required
&&
(
typeof
pk
==
'
undefined
'
))
{
if
(
pk_required
&&
(
typeof
pk
==
"
undefined
"
))
{
throw
"
pk shouldn't be empty when requesting a specific element
"
;
}
if
(
pk
!=
""
)
{
api_end_point
+=
pk
+
'
/
'
;
api_end_point
+=
pk
+
"
/
"
;
}
if
(
!
this
.
shouldFetchEndPoint
(
api_end_point
))
{
...
...
@@ -47,8 +47,8 @@ export default class SmartActions {
return
(
dispatch
)
=>
{
dispatch
(
_IsLoading
(
true
));
let
token
=
Cookies
.
get
(
'
csrftoken
'
);
fetch
(
api_end_point
,
{
credentials
:
'
same-origin
'
,
headers
:
{
'
X-CSRFToken
'
:
token
}
})
let
token
=
Cookies
.
get
(
"
csrftoken
"
);
fetch
(
api_end_point
,
{
credentials
:
"
same-origin
"
,
headers
:
{
"
X-CSRFToken
"
:
token
}
})
.
then
((
response
)
=>
{
if
(
!
response
.
ok
)
{
this
.
fetching
.
delete
(
api_end_point
);
...
...
@@ -74,7 +74,7 @@ export default class SmartActions {
/**
* Generic function for handling a PUT and POST requests to the API
* Generic function for handling a PUT and POST requests to the API
*
* @param {object} data, to update the data, `data` should contains the `id` field.
* @param {string} api_end_point
...
...
@@ -88,26 +88,26 @@ export default class SmartActions {
return
(
dispatch
)
=>
{
let
method
=
"
POST
"
;
let
pk
=
""
;
if
(
'
id
'
in
data
)
{
if
(
"
id
"
in
data
)
{
method
=
"
PUT
"
;
pk
=
data
.
id
+
'
/
'
;
pk
=
data
.
id
+
"
/
"
;
}
let
__apiAttr
=
''
;
if
(
'
__apiAttr
'
in
data
&&
data
.
__apiAttr
!=
''
)
{
__apiAttr
=
data
.
__apiAttr
+
'
/
'
;
let
__apiAttr
=
""
;
if
(
"
__apiAttr
"
in
data
&&
data
.
__apiAttr
!=
""
)
{
__apiAttr
=
data
.
__apiAttr
+
"
/
"
;
}
let
errorStatusText
=
''
;
let
errorStatusText
=
""
;
dispatch
(
_ElIsSaving
(
true
));
let
token
=
Cookies
.
get
(
'
csrftoken
'
);
let
token
=
Cookies
.
get
(
"
csrftoken
"
);
fetch
(
api_end_point
+
__apiAttr
+
pk
,
{
method
:
method
,
credentials
:
'
same-origin
'
,
credentials
:
"
same-origin
"
,
headers
:
{
'
Accept
'
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
'
X-CSRFToken
'
:
token
"
Accept
"
:
"
application/json
"
,
"
Content-Type
"
:
"
application/json
"
,
"
X-CSRFToken
"
:
token
},
body
:
JSON
.
stringify
(
data
)
})
...
...
@@ -123,18 +123,19 @@ export default class SmartActions {
dispatch
(
_ElIsSaving
(
false
));
})
.
catch
((
e
)
=>
{
if
(
typeof
e
.
json
==
'
function
'
)
{
return
e
.
json
()
if
(
typeof
e
.
json
==
"
function
"
)
{
return
e
.
json
()
;
}
else
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
resolve
(
e
)
});
// eslint-disable-next-line no-unused-vars
return
new
Promise
(
function
(
resolve
,
reject
)
{
resolve
(
e
);
});
}
})
.
then
((
errorContent
)
=>
{
if
(
typeof
errorContent
!=
'
undefined
'
)
{
if
(
typeof
errorContent
!=
"
undefined
"
)
{
dispatch
(
_ElHasError
(
true
,
{
message
:
errorStatusText
,
content
:
errorContent
}));
dispatch
(
_ElIsSaving
(
false
));
}
})
})
;
};
}
}
\ No newline at end of file
}
frontend/src/api/buildApiActionsAndReducers.js
View file @
8647ed5c
...
...
@@ -14,7 +14,7 @@ const otherAPI = [
name
:
"
serverModerationStatus
"
,
api_end_point
:
"
serverModerationStatus
"
}
]
]
;
/**
* Create api actions and reducers for given the info in each arr obj
...
...
@@ -43,7 +43,7 @@ function addAPIs(arr) {
const
reducers
=
new
CrudReducers
(
apiInfo
);
apiReducersTmp
[
`
${
apiInfo
.
name
}
All`
]
=
reducers
.
getCombinedAll
();
apiReducersTmp
[
`
${
apiInfo
.
name
}
Specific`
]
=
reducers
.
getCombinedSpecific
();
})
})
;
}
addAPIs
(
otherAPI
);
...
...
frontend/src/api/getActions.js
View file @
8647ed5c
import
{
apiActions
}
from
"
./buildApiActionsAndReducers
"
;
import
CrudActions
from
"
./CrudActions
"
;
/**
* Function to get the the actions corresponding to an API end point.
* Function to get the the actions corresponding to an API end point.
*
* @export
* @param {string} name
...
...
@@ -10,8 +9,8 @@ import CrudActions from "./CrudActions";
*/
export
default
function
getActions
(
name
)
{
if
(
!
(
name
in
apiActions
))
{
console
.
error
(
"
available actions
"
,
apiActions
);
console
.
error
(
"
available actions
"
,
apiActions
);
// eslint-disable-line no-console
throw
Error
(
`Requested api action is not defined, check the name:
${
name
}
`
);
}
return
apiActions
[
name
];
}
\ No newline at end of file
}
frontend/src/api/getCrudActionTypes.js
View file @
8647ed5c
...
...
@@ -30,5 +30,5 @@ export default function getCrudActionTypes(name) {
// Not directly a CRUD action but needed for in app behavior
isInvalidatedAll
:
`API_
${
name
}
_ALL_INVALIDATED`
,
isInvalidatedSpecific
:
`API_
${
name
}
_SPECIFIC_INVALIDATED`
,
}
}
;
}
\ No newline at end of file
frontend/src/components/App.js
View file @
8647ed5c
// Inspired by https://github.com/mui-org/material-ui/tree/master/docs/src/pages/page-layout-examples/dashboard
import
React
from
'
react
'
;
import
PropTypes
from
'
prop-types
'
;
import
classNames
from
'
classnames
'
;
import
withStyles
from
'
@material-ui/core/styles/withStyles
'
;
import
CssBaseline
from
'
@material-ui/core/CssBaseline
'
;
import
Drawer
from
'
@material-ui/core/Drawer
'
;
import
List
from
'
@material-ui/core/List
'
;
import
Divider
from
'
@material-ui/core/Divider
'
;
import
IconButton
from
'
@material-ui/core/IconButton
'
;
import
MenuIcon
from
'
@material-ui/icons/Menu
'
;
import
Chip
from
'
@material-ui/core/Chip
'
;
import
Avatar
from
'
@material-ui/core/Avatar
'
;
import
ChevronLeftIcon
from
'
@material-ui/icons/ChevronLeft
'
;
import
SchoolIcon
from
'
@material-ui/icons/School
'
;
import
{
mainListItems
,
secondaryListItems
,
thirdListItems
}
from
'
./template/listItems
'
;
import
React
from
"
react
"
;
import
PropTypes
from
"
prop-types
"
;
import
classNames
from
"
classnames
"
;
import
withStyles
from
"
@material-ui/core/styles/withStyles
"
;
import
CssBaseline
from
"
@material-ui/core/CssBaseline
"
;
import
Drawer
from
"
@material-ui/core/Drawer
"
;
import
List
from
"
@material-ui/core/List
"
;
import
Divider
from
"
@material-ui/core/Divider
"
;
import
IconButton
from
"
@material-ui/core/IconButton
"
;
import
MenuIcon
from
"
@material-ui/icons/Menu
"
;
import
Chip
from
"
@material-ui/core/Chip
"
;
import
Avatar
from
"
@material-ui/core/Avatar
"
;
import
ChevronLeftIcon
from
"
@material-ui/icons/ChevronLeft
"
;
import
SchoolIcon
from
"
@material-ui/icons/School
"
;
import
{
mainListItems
,
secondaryListItems
,
thirdListItems
}
from
"
./template/listItems
"
;
import
{
connect
}
from
"
react-redux
"
;
import
CustomComponentForA