Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SemApps instance for Glocal-Lowtech #789

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/frontend/boilerplates/archipelago/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REACT_APP_MIDDLEWARE_URL=http://localhost:3000/
REACT_APP_MIDDLEWARE_URL=https://data.gl.flod.io/
REACT_APP_MAPBOX_ACCESS_TOKEN=
PORT=5000
2 changes: 1 addition & 1 deletion src/frontend/boilerplates/archipelago/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const App = () => (
<Admin
disableTelemetry
history={history}
title="Archipel"
title="Glocal Low-Tech"
authProvider={authProvider}
dataProvider={dataProvider}
i18nProvider={i18nProvider}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { ImageInput, SelectInput, TextInput, TabbedForm, FormTab } from 'react-admin';
import { EditWithPermissions } from '@semapps/auth-provider';
import { MarkdownInput } from '@semapps/markdown-components';
import { ActorsInput, DocumentsInput, ThemesInput, ResourcesInput } from '../../../../pair';
import { ActorsInput, DocumentsInput, ThemesInput, ResourcesInput, ActivitiesInput } from '../../../../pair';
import ProjectTitle from './ProjectTitle';
import { ImageField, ReferenceInput } from '@semapps/semantic-data-provider';

Expand All @@ -22,6 +22,8 @@ const ProjectEdit = props => (
</ImageInput>
</FormTab>
<FormTab label="Relations">
<ActivitiesInput source="pair:partOf" />
<ActivitiesInput source="pair:hasPart" />
<ActorsInput source="pair:involves" />
<ResourcesInput source="pair:needs" />
<DocumentsInput source="pair:documentedBy" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ const ProjectShow = props => (
<Hero image="image">
<TextField label="Courte description" source="pair:comment" />
<UrlField label="Site web" source="pair:homePage" />

<ReferenceArrayField reference="Project" source="pair:partOf">
<SingleFieldList linkType="show">
<ChipField source="pair:label" color="secondary" />
</SingleFieldList>
</ReferenceArrayField>

<ReferenceArrayField reference="Activity" source="pair:hasPart">
<SingleFieldList linkType="show">
<ChipField source="pair:label" color="secondary" />
</SingleFieldList>
</ReferenceArrayField>

<ReferenceArrayField reference="Status" source="pair:hasStatus">
<SeparatedListField linkType={false}>
<TextField source="pair:label" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ export default {
'pair:description': 'Description',
'pair:hasStatus': 'Statut',
'pair:homePage': 'Site web',
'pair:involves': 'Implique',
'pair:involves': 'Implique les acteurs',
'pair:needs': 'Compétences requises',
'pair:documentedBy': 'Documenté par',
'pair:hasTopic': 'A pour thème'
'pair:documentedBy': 'Documents liés',
'pair:hasTopic': 'A pour thème',
'pair:partOf': 'Fait partie du projet',
'pair:hasPart': 'Contient les activités'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const TaskEdit = props => (
<ActorsInput source="pair:hasFollower" />
<ActorsInput source="pair:involves" />
<TasksInput source="pair:inspiredBy" />
<TasksInput source="pair:requires" />
<ThemesInput source="pair:hasTopic" />
<SkillsInput source="pair:needs" />
<DocumentsInput source="pair:uses" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ const TaskShow = props => (
<TextField source="pair:label" />
</SeparatedListField>
</ReferenceArrayField>

<ReferenceArrayField reference="Task" source="pair:inspiredBy">
<SeparatedListField linkType={false}>
<TextField source="pair:label" />
</SeparatedListField>
</ReferenceArrayField>

<ReferenceArrayField reference="Task" source="pair:requires">
<SeparatedListField linkType={false}>
<TextField source="pair:label" />
</SeparatedListField>
</ReferenceArrayField>
</Hero>

<MainList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ export default {
fields: {
'pair:label': 'Titre',
'pair:description': 'Description',
'pair:assignedTo': 'Est assigné à',
'pair:partOf': 'Fait partie de',
'pair:assignedTo': 'Est assigné à la personne',
'pair:partOf': 'Fait partie du projet',
'pair:hasType': 'Type',
'pair:hasStatus': 'Statut',
'pair:dueDate': 'Date attendue',
'pair:endDate': 'Date de fin effective',
'pair:hasFollower': 'Suivie par',
'pair:involves': 'Implique',
'pair:inspiredBy': 'Inspiré par',
'pair:hasFollower': 'Suivie par la personne',
'pair:involves': 'Implique la personne',
'pair:inspiredBy': 'Inspiré par la tâche',
'pair:hasTopic': 'A pour thème',
'pair:needs': 'A besoin de',
'pair:uses': 'Utilise'
'pair:needs': 'A besoin de la compétence',
'pair:uses': 'Utilise le doc',
'pair:requires': 'Est dépendant de la tâche'
}
}
}
Expand Down
20 changes: 13 additions & 7 deletions src/frontend/packages/auth-provider/src/authProvider.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import jwtDecode from 'jwt-decode';
import { defaultToArray, getAclUri, getAclContext } from './utils';

const authProvider = ({ middlewareUri, allowAnonymous = true, checkUser, httpClient, checkPermissions, resources }) => ({
const authProvider = ({
middlewareUri,
allowAnonymous = true,
checkUser,
httpClient,
checkPermissions,
resources
}) => ({
login: async params => {
const url = new URL(window.location.href);
window.location.href = `${middlewareUri}auth?redirectUrl=` + encodeURIComponent(url.origin + '/login?login=true')
window.location.href = `${middlewareUri}auth?redirectUrl=` + encodeURIComponent(url.origin + '/login?login=true');
},
logout: async () => {
const url = new URL(window.location.href);
if( !allowAnonymous ) {
if (!allowAnonymous) {
localStorage.removeItem('token');
window.location.href =
`${middlewareUri}auth/logout?redirectUrl=` + encodeURIComponent(url.origin + '/login')
window.location.href = `${middlewareUri}auth/logout?redirectUrl=` + encodeURIComponent(url.origin + '/login');
} else {
// Redirect to login page after disconnecting from SSO
// The login page will remove the token, display a notification and redirect to the homepage
Expand All @@ -24,10 +30,10 @@ const authProvider = ({ middlewareUri, allowAnonymous = true, checkUser, httpCli
},
checkAuth: async () => {
const token = localStorage.getItem('token');
if( !token && !allowAnonymous ) throw new Error();
if (!token && !allowAnonymous) throw new Error();
},
checkUser: userData => {
if( checkUser ) {
if (checkUser) {
return checkUser(userData);
} else {
return true;
Expand Down