Skip to content
Merged
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
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ gradle/
gradlew*
.env
target
dependency-reduced-pom.xml
dependency-reduced-pom.xml
# Ignore the entire "resources" folder except jsonchema
backend/src/main/resources/public/*
!backend/src/main/resources/public/js
!backend/src/main/resources/public/template
backend/src/main/resources/view/index.html
backend/src/main/resources/*.html
# backend/src/main/resources/view
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --edit $1
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm pre-commit
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm pre-push
26 changes: 16 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@

pipeline {
agent any
stages {
stage("Initialization") {
steps {
script {
def version = sh(returnStdout: true, script: 'docker-compose run --rm maven mvn $MVN_OPTS help:evaluate -Dexpression=project.version -q -DforceStdout')
buildName "${env.GIT_BRANCH.replace("origin/", "")}@${version}"
}
stages {
stage("Initialization") {
steps {
script {
def version = sh(returnStdout: true, script: 'docker-compose run --rm maven mvn $MVN_OPTS help:evaluate -Dexpression=project.version -q -DforceStdout')
buildName "${env.GIT_BRANCH.replace("origin/", "")}@${version}"
}
}
stage('Build') {
steps {
checkout scm
}
stage('Build Front') {
steps {
sh './build.sh build'
}
}
stage('Build Backend') {
steps {
dir('backend') {
sh './build.sh init clean install publish'
}
}
}
}
post {
cleanup {
sh 'docker-compose down'
Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# À propos de l'application rack

* Licence : [AGPL v3](http://www.gnu.org/licenses/agpl.txt) - Copyright Edifice
* Financeur(s) : Edifice
* Développeur(s) : Edifice
* Description : this application allows users to send documents to one another, in a different way then using the workspace app.

- Licence : [AGPL v3](http://www.gnu.org/licenses/agpl.txt) - Copyright Edifice
- Financeur(s) : Edifice
- Développeur(s) : Edifice
- Description : this application allows users to send documents to one another, in a different way then using the workspace app.

## Setup

Add to your ent-core springboard configuration file the following lines :<br>
*(you **might** want to change certain fields like port n° & mode)*
_(you **might** want to change certain fields like port n° & mode)_

```
"name": "fr.wseduc~rack~0.1-SNAPSHOT",
Expand All @@ -30,6 +29,6 @@ Add to your ent-core springboard configuration file the following lines :<br>

**Optional :**

``gridfs-address`` : grisfs persistor bus address (default : "wse.gridfs.persistor")<br>
``alertStorage`` : value in percent, threshold at which the user will be notified when free space is now (default : 80)<br>
``image-resizer-address`` : image resizer module bus address (default : "wse.image.resizer")<br>
`gridfs-address` : grisfs persistor bus address (default : "wse.gridfs.persistor")<br>
`alertStorage` : value in percent, threshold at which the user will be notified when free space is now (default : 80)<br>
`image-resizer-address` : image resizer module bus address (default : "wse.image.resizer")<br>
134 changes: 134 additions & 0 deletions backend/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/bin/bash

MVN_OPTS="-Duser.home=/var/maven"

if [ ! -e node_modules ]
then
mkdir node_modules
fi

case `uname -s` in
MINGW* | Darwin*)
USER_UID=1000
GROUP_UID=1000
;;
*)
if [ -z ${USER_UID:+x} ]
then
USER_UID=`id -u`
GROUP_GID=`id -g`
fi
esac

# Options
NO_DOCKER=""
SPRINGBOARD="recette"
for i in "$@"
do
case $i in
-s=*|--springboard=*)
SPRINGBOARD="${i#*=}"
shift
;;
--no-docker*)
NO_DOCKER="true"
shift
;;
*)
;;
esac
done

init() {
me=`id -u`:`id -g`
echo "DEFAULT_DOCKER_USER=$me" > .env
}

clean () {
if [ "$NO_DOCKER" = "true" ] ; then
rm -rf node_modules
rm -f yarn.lock
mvn clean
else
docker-compose run --rm maven mvn $MVN_OPTS clean
fi
}

install () {
docker-compose run --rm maven mvn $MVN_OPTS install -DskipTests
}

test () {
docker-compose run --rm maven mvn $MVN_OPTS test
}

#buildNode () {
#jenkins
#echo "[buildNode] Get branch name from jenkins env..."
#BRANCH_NAME=`echo $GIT_BRANCH | sed -e "s|origin/||g"`
#docker-compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "pnpm build:prod"
#docker-compose run --rm -u "$USER_UID:$GROUP_GID" -e PUBLISH_TAG="${PUBLISH_TAG:-latest}" -e DRY_RUN="${DRY_RUN:-false}" node sh -c "pnpm build:prod && pnpm publish:client-rest"
#}

publish() {
if [ "$NO_DOCKER" = "true" ] ; then
version=`docker-compose run --rm maven mvn $MVN_OPTS help:evaluate -Dexpression=project.version -q -DforceStdout`
level=`echo $version | cut -d'-' -f3`
case "$level" in
*SNAPSHOT) export nexusRepository='snapshots' ;;
*) export nexusRepository='releases' ;;
esac
mvn -DrepositoryId=ode-$nexusRepository -DskiptTests deploy
else
version=`docker-compose run --rm maven mvn $MVN_OPTS help:evaluate -Dexpression=project.version -q -DforceStdout`
level=`echo $version | cut -d'-' -f3`
case "$level" in
*SNAPSHOT) export nexusRepository='snapshots' ;;
*) export nexusRepository='releases' ;;
esac

docker-compose run --rm maven mvn -DrepositoryId=ode-$nexusRepository -DskiptTests --settings /var/maven/.m2/settings.xml deploy
fi
}

watch () {
if [ "$NO_DOCKER" = "true" ] ; then
node_modules/gulp/bin/gulp.js watch --springboard=../recette
else
docker-compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "node_modules/gulp/bin/gulp.js watch --springboard=/home/node/$SPRINGBOARD"
fi
}

for param in "$@"
do
case $param in
init)
init
;;
clean)
clean
;;
#buildNode)
#buildNode
# ;;
install)
#buildNode &&
install
;;
test)
test
;;
watch)
watch
;;
publish)
publish
;;
*)
echo "Invalid argument : $param"
esac
if [ ! $? -eq 0 ]; then
exit 1
fi
done

17 changes: 17 additions & 0 deletions backend/deployment/rack/migration/4.0.0/addViewRights.cypher
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MATCH (a:Action {name:"fr.wseduc.rack.controllers.RackController|viewInbox",type:"SECURED_ACTION_WORKFLOW"})
WITH a
MATCH (b:Action{name:"fr.wseduc.rack.controllers.RackController|view"})<-[:AUTHORIZE]-(ro:Role)
WITH a,ro
MERGE (a)<-[:AUTHORIZE]-(ro);

MATCH (a:Action {name:"fr.wseduc.rack.controllers.RackController|viewDeposits",type:"SECURED_ACTION_WORKFLOW"})
WITH a
MATCH (b:Action{name:"fr.wseduc.rack.controllers.RackController|view"})<-[:AUTHORIZE]-(ro:Role)
WITH a,ro
MERGE (a)<-[:AUTHORIZE]-(ro);

MATCH (a:Action {name:"fr.wseduc.rack.controllers.RackController|viewTrash",type:"SECURED_ACTION_WORKFLOW"})
WITH a
MATCH (b:Action{name:"fr.wseduc.rack.controllers.RackController|view"})<-[:AUTHORIZE]-(ro:Role)
WITH a,ro
MERGE (a)<-[:AUTHORIZE]-(ro);
File renamed without changes.
2 changes: 1 addition & 1 deletion pom.xml → backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>fr.wseduc</groupId>
<artifactId>rack</artifactId>
<version>2.0-develop-pedago-SNAPSHOT</version>
<version>3.0-develop-pedago-SNAPSHOT</version>

<scm>
<connection>scm:git:https://github.com/opendigitaleducation/rack.git</connection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@
import org.entcore.common.storage.Storage;
import org.entcore.common.user.UserInfos;
import org.entcore.common.user.UserUtils;
import org.entcore.common.utils.StringUtils;
import org.vertx.java.core.http.RouteMatcher;

import java.net.URLDecoder;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
Expand Down Expand Up @@ -140,10 +142,30 @@ public void init(Vertx vertx, JsonObject config, RouteMatcher rm, Map<String, fr
@Get("")
@SecuredAction(access)
public void view(HttpServerRequest request) {
renderView(request);
renderView(request, new JsonObject(), "index.html", null);
eventHelper.onAccess(request);
}

@Get("/inbox")
@SecuredAction(access)
public void viewInbox(HttpServerRequest request) {
renderView(request, new JsonObject(), "index.html", null);
eventHelper.onAccess(request);
}

@Get("/deposits")
@SecuredAction(access)
public void viewDeposits(HttpServerRequest request) {
renderView(request, new JsonObject(), "index.html", null);
eventHelper.onAccess(request);
}

@Get("/trash")
@SecuredAction(access)
public void viewTrash(HttpServerRequest request) {
renderView(request, new JsonObject(), "index.html", null);
eventHelper.onAccess(request);
}
//////////////
//// CRUD ////
//////////////
Expand Down Expand Up @@ -492,8 +514,15 @@ private void getVisibleRackUsers(final HttpServerRequest request, final String s
"WHERE has(a.name) AND a.name={action} AND NOT has(visibles.activationCode) " +
"RETURN distinct visibles.id as id, visibles.displayName as username, visibles.lastName as name, HEAD(visibles.profiles) as profile " +
"ORDER BY name ";
final String prefilter = search == null || search.trim().isEmpty() ? null : " AND m.displayName =~ {searchTerm}";
final JsonObject params = new JsonObject().put("action", "fr.wseduc.rack.controllers.RackController|listRack").put("searchTerm", "(?i).*" + search + ".*");
String searchTerm = null;
if (search != null && !search.trim().isEmpty()) {
searchTerm = normalize(search);
}
final String prefilter = searchTerm == null ? null : " AND m.displayNameSearchField CONTAINS {searchTerm}";
final JsonObject params = new JsonObject().put("action", "fr.wseduc.rack.controllers.RackController|listRack");
if (searchTerm != null) {
params.put("searchTerm", searchTerm);
}
final String queryGroups =
"RETURN distinct profileGroup.id as id, profileGroup.name as name, " +
"profileGroup.groupDisplayName as groupDisplayName, profileGroup.structureName as structureName " +
Expand Down Expand Up @@ -536,7 +565,15 @@ public void handle(JsonObject users) {
@SecuredAction(list_users)
public void searchUsers(final HttpServerRequest request)
{
final String search = request.params().get("search");
final String encodedSearch = request.params().get("search");
String search = null;
if (encodedSearch != null) {
try {
search = URLDecoder.decode(encodedSearch, "UTF-8");
} catch (Exception e) {
search = encodedSearch; // fallback
}
}
getVisibleRackUsers(request, search, new Handler<JsonObject>() {
@Override
public void handle(JsonObject users) {
Expand Down Expand Up @@ -958,4 +995,15 @@ private boolean isImage(JsonObject doc) {
);
}

private String normalize(String str) {
if (str != null) {
str = str.toLowerCase().replaceAll("\\s+", "").trim();
str = StringUtils.stripAccents(str);
if(str.isEmpty()) {
return null;
}
}
return str;
}

}
Loading