Commit b420fe0e authored by François-Xavier Lebastard's avatar François-Xavier Lebastard
Browse files

merge develop

remplacement des routes /workspace/list (etc) par des routes /workspace
redirection automatique de /admin vers /admin/workspace
parent de753f43
......@@ -3,35 +3,38 @@ package com.unantes.orientactive.filariane;
import com.unantes.orientactive.security.AuthoritiesConstants;
import com.unantes.orientactive.security.permissions.PermissionService;
import com.unantes.orientactive.service.FormService;
import com.unantes.orientactive.service.ScreenService;
import com.unantes.orientactive.service.WorkspaceService;
import com.unantes.orientactive.service.dto.FormDTO;
import com.unantes.orientactive.service.dto.ScreenDTO;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import com.unantes.orientactive.service.dto.WorkspaceDTO;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
/**
* Contrôleur permettant de récupérer le fils d'ariane pour un élément.
*/
@RestController
@RequestMapping("/api/filariane")
public class FilArianeController {
/**
* Service des formulaires.
* Service des workspaces.
*/
private final FormService formService;
private final WorkspaceService workspaceService;
/**
* Service des écrans.
* Service des formulaires.
*/
private final ScreenService screenService;
private final FormService formService;
/**
* Elément du fil d'ariane correspondant à l'accueil.
......@@ -41,18 +44,17 @@ public class FilArianeController {
/**
* Constructeur.
*
* @param formService Le service des formulaires.
* @param screenService Le service des écrans.
* @param formService Le service des formulaires.
*/
public FilArianeController(
final WorkspaceService workspaceService,
final FormService formService,
final ScreenService screenService,
final ApplicationContext applicationContext
) {
String homeTitle = applicationContext.getMessage("filariane.home.title", new Object[] {}, Locale.getDefault());
String homeTitle = applicationContext.getMessage("filariane.home.title", new Object[]{}, Locale.getDefault());
this.workspaceService = workspaceService;
this.filArianeHome = new FilArianeElement(homeTitle, Path.HOME);
this.formService = formService;
this.screenService = screenService;
}
/**
......@@ -60,7 +62,7 @@ public class FilArianeController {
*
* @return Le fil d'ariane.
*/
@GetMapping("/home")
@GetMapping("/user/home")
@ResponseBody
public String getUserHome() {
if (PermissionService.currentUserHasAuthority(AuthoritiesConstants.AUTHORITY_VIEW_WORKSPACE)) {
......@@ -76,9 +78,9 @@ public class FilArianeController {
*
* @return Le fil d'ariane.
*/
@GetMapping("/filariane/workspaces")
@GetMapping("/home")
@ResponseBody
public List<FilArianeElement> getFilArianeForWorkspaces() {
public List<FilArianeElement> getFilArianeForHome() {
return Collections.singletonList(filArianeHome);
}
......@@ -88,10 +90,13 @@ public class FilArianeController {
* @param idWorkspace L'identifiant du workspace.
* @return Le fil d'ariane.
*/
@GetMapping("/filariane/workspace/{idWorkspace}")
@GetMapping("/workspace/{idWorkspace}")
@ResponseBody
public List<FilArianeElement> getFilArianeForWorkspace(@PathVariable("idWorkspace") final Long idWorkspace) {
return Collections.singletonList(filArianeHome);
LinkedList<FilArianeElement> filAriane = new LinkedList<>();
filAriane.add(filArianeHome);
addFilArianeWorkspace(filAriane, idWorkspace);
return filAriane;
}
/**
......@@ -100,47 +105,31 @@ public class FilArianeController {
* @param idForm L'identifiant du formulaire.
* @return Le fil d'ariane.
*/
@GetMapping("/filariane/form/{idForm}")
@GetMapping("/form/{idForm}")
@ResponseBody
public List<FilArianeElement> getFilArianeForForm(@PathVariable("idForm") final Long idForm) {
final List<FilArianeElement> filAriane = new LinkedList<>();
LinkedList<FilArianeElement> filAriane = new LinkedList<>();
filAriane.add(filArianeHome);
addFilArianeWorkspace(filAriane, idForm);
return filAriane;
}
/**
* Récupération du fil d'ariane pour un écran.
*
* @param idScreen L'identifiant de l'écran.
* @return Le fil d'ariane.
*/
@GetMapping("/filariane/screen/{idScreen}")
@ResponseBody
public List<FilArianeElement> getFilArianeForScreen(@PathVariable("idScreen") final Long idScreen) {
final List<FilArianeElement> filAriane = new LinkedList<>();
if (PermissionService.currentUserHasAuthority(AuthoritiesConstants.AUTHORITY_VIEW_FORM)) {
final Optional<ScreenDTO> screenOptional = screenService.findOne(idScreen);
final ScreenDTO screen = screenOptional.orElseThrow(() -> new FilArianeException("L'écran n'existe pas."));
filAriane.add(new FilArianeElement(screen.getFormName(), Path.WORKSPACE + "/" + screen.getFormId()));
addFilArianeWorkspace(filAriane, screen.getFormId());
final Optional<FormDTO> formDTO = formService.findOne(idForm);
final FormDTO form = formDTO.orElseThrow(() -> new FilArianeException("Le formulaire n'existe pas."));
addFilArianeWorkspace(filAriane, form.getWorkspaceId());
filAriane.add(new FilArianeElement(form.getName(), Path.FORMS + "/" + form.getId() + "/view"));
}
filAriane.add(filArianeHome);
Collections.reverse(filAriane);
return filAriane;
}
/**
* Ajout du fil d'ariane du workspace concerné par le formulaire.
*
* @param filAriane Le fil d'ariane.
* @param formId L'identifiant du formulaire.
* @param filAriane Le fil d'ariane.
* @param workspaceId L'identifiant du workspace.
*/
private void addFilArianeWorkspace(final List<FilArianeElement> filAriane, final Long formId) {
private void addFilArianeWorkspace(final List<FilArianeElement> filAriane, final Long workspaceId) {
if (PermissionService.currentUserHasAuthority(AuthoritiesConstants.AUTHORITY_VIEW_WORKSPACE)) {
final Optional<FormDTO> formOptional = formService.findOne(formId);
final FormDTO form = formOptional.orElseThrow(() -> new FilArianeException("Le formulaire n'existe pas."));
filAriane.add(new FilArianeElement(form.getWorkspaceName(), Path.WORKSPACE + "/" + form.getWorkspaceId()));
final Optional<WorkspaceDTO> workspaceOptional = workspaceService.findOne(workspaceId);
final WorkspaceDTO workspace = workspaceOptional.orElseThrow(() -> new FilArianeException("Le workspace n'existe pas."));
filAriane.add(new FilArianeElement(workspace.getName(), Path.WORKSPACE + "/" + workspace.getId() + "/view"));
}
}
}
......@@ -5,8 +5,10 @@ package com.unantes.orientactive.filariane;
*/
public class Path {
public static final String HOME = "/home";
public static final String LIST_WORKSPACES = "/workspaces";
public static final String WORKSPACE = "/workspace";
public static final String LIST_FORMS = "/forms";
public static final String HOME = "/admin/workspace";
public static final String WORKSPACE = "/admin/workspace";
public static final String FORMS = "/admin/forms";
public static final String LIST_WORKSPACES = "/admin/workspaces";
public static final String LIST_FORMS = "/admin/forms";
}
......@@ -125,4 +125,8 @@ public class VariableService {
}
return variableMapper.toDto(variableRepository.findByFormId(formId));
}
public List<VariableDTO> findVariableByFormId(Long formId) {
return variableRepository.findByFormId(formId).stream().map(variableMapper::toDto).collect(Collectors.toList());
}
}
......@@ -144,6 +144,11 @@ public class VariableResource {
return variableService.findAll();
}
@GetMapping("/forms/{formId}/variables")
public List<VariableDTO> getVariableByFormId(@PathVariable Long formId) {
return variableService.findVariableByFormId(formId);
}
/**
* {@code GET /variables/:id} : get the "id" variable.
*
......
insert into scope (id_user, id_role, wildcard) values (3, 3, true);
......@@ -40,6 +40,7 @@
<include file="config/liquibase/changelog/20210420150500_add_constraint_screen_index.sql" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20210420151000_drop_screen_previous_id.sql" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20210422143300_screen_name_bo.sql" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20210427153800_migration_workspace.sql" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
<!-- jhipster-needle-liquibase-add-incremental-changelog - JHipster will add incremental liquibase changelogs here -->
</databaseChangeLog>
<template>
<div>
<div class="row justify-content-center">
<div>
<div class="row justify-content-center">
<div class="col-md-8">
<h1 v-text="$t('activate.title')">Activation</h1>
<div class="alert alert-success" v-if="success">
<span v-html="$t('activate.messages.success')"><strong>Your user account has been activated.</strong> Please </span>
<a class="alert-link" v-on:click="openLogin" v-text="$t('global.messages.info.authenticated.link')">sign in</a>.
</div>
<div class="alert alert-danger" v-if="error" v-html="$t('activate.messages.error')">
<strong>Your user could not be activated.</strong> Please use the registration form to sign up.
</div>
<h1 v-text="$t('activate.title')">Activation</h1>
<div class="alert alert-success" v-if="success">
<span v-html="$t('activate.messages.success')"><strong>Your user account has been activated.</strong> Please </span>
<a class="alert-link" v-on:click="openLogin" v-text="$t('global.messages.info.authenticated.link')">sign in</a>.
</div>
<div class="alert alert-danger" v-if="error" v-html="$t('activate.messages.error')">
<strong>Your user could not be activated.</strong> Please use the registration form to sign up.
</div>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" src="./activate.component.ts">
</script>
<script lang="ts" src="./activate.component.ts"></script>
<template>
<div>
<div class="row justify-content-center">
<div class="col-md-8 toastify-container">
<h2 v-if="account" id="password-title"><span v-html="$t('password.title', { 'username': username})">Password for [<b>{{username}}</b>]</span></h2>
<div>
<div class="row justify-content-center">
<div class="col-md-8 toastify-container">
<h2 v-if="account" id="password-title">
<span v-html="$t('password.title', { username: username })"
>Password for [<b>{{ username }}</b
>]</span
>
</h2>
<div class="alert alert-success" role="alert" v-if="success" v-html="$t('password.messages.success')">
<strong>Password changed!</strong>
</div>
<div class="alert alert-danger" role="alert" v-if="error" v-html="$t('password.messages.error')">
<strong>An error has occurred!</strong> The password could not be changed.
</div>
<div class="alert alert-danger" role="alert" v-if="doNotMatch" v-text="$t('global.messages.error.dontmatch')">
The password and its confirmation do not match!
</div>
<form name="form" role="form" id="password-form" v-on:submit.prevent="changePassword()">
<div class="alert alert-success" role="alert" v-if="success" v-html="$t('password.messages.success')">
<strong>Password changed!</strong>
</div>
<div class="alert alert-danger" role="alert" v-if="error" v-html="$t('password.messages.error')">
<strong>An error has occurred!</strong> The password could not be changed.
</div>
<div class="form-group">
<label class="form-control-label" for="currentPassword" v-text="$t('global.form[\'currentpassword.label\']')">Current password</label>
<input type="password" class="form-control" id="currentPassword" name="currentPassword"
:class="{'valid': !$v.resetPassword.currentPassword.$invalid, 'invalid': $v.resetPassword.currentPassword.$invalid }"
v-bind:placeholder="$t('global.form[\'currentpassword.placeholder\']')"
v-model="$v.resetPassword.currentPassword.$model" required>
<div v-if="$v.resetPassword.currentPassword.$anyDirty && $v.resetPassword.currentPassword.$invalid">
<small class="form-text text-danger"
v-if="!$v.resetPassword.currentPassword.required" v-text="$t('global.messages.validate.newpassword.required')">
Your password is required.
</small>
</div>
</div>
<div class="form-group">
<label class="form-control-label" for="newPassword" v-text="$t('global.form[\'newpassword.label\']')">New password</label>
<input type="password" class="form-control" id="newPassword" name="newPassword"
v-bind:placeholder="$t('global.form[\'newpassword.placeholder\']')"
:class="{'valid': !$v.resetPassword.newPassword.$invalid, 'invalid': $v.resetPassword.newPassword.$invalid }"
v-model="$v.resetPassword.newPassword.$model" minlength=4 maxlength=50 required>
<div v-if="$v.resetPassword.newPassword.$anyDirty && $v.resetPassword.newPassword.$invalid">
<small class="form-text text-danger"
v-if="!$v.resetPassword.newPassword.required" v-text="$t('global.messages.validate.newpassword.required')">
Your password is required.
</small>
<small class="form-text text-danger"
v-if="!$v.resetPassword.newPassword.minLength" v-text="$t('global.messages.validate.newpassword.minlength')">
Your password is required to be at least 4 characters.
</small>
<small class="form-text text-danger"
v-if="!$v.resetPassword.newPassword.maxLength" v-text="$t('global.messages.validate.newpassword.maxlength')">
Your password cannot be longer than 50 characters.
</small>
</div>
<!--<jhi-password-strength-bar [passwordToCheck]="newPassword"></jhi-password-strength-bar>-->
</div>
<div class="form-group">
<label class="form-control-label" for="confirmPassword" v-text="$t('global.form[\'confirmpassword.label\']')">New password confirmation</label>
<input type="password" class="form-control" id="confirmPassword" name="confirmPassword"
:class="{'valid': !$v.resetPassword.confirmPassword.$invalid, 'invalid': $v.resetPassword.confirmPassword.$invalid }"
v-bind:placeholder="$t('global.form[\'confirmpassword.placeholder\']')"
v-model="$v.resetPassword.confirmPassword.$model" minlength=4 maxlength=50 required>
<div v-if="$v.resetPassword.confirmPassword.$anyDirty && $v.resetPassword.confirmPassword.$invalid">
<small class="form-text text-danger"
v-if="!$v.resetPassword.confirmPassword.required" v-text="$t('global.messages.validate.confirmpassword.required')">
Your confirmation password is required.
</small>
<small class="form-text text-danger"
v-if="!$v.resetPassword.confirmPassword.minLength" v-text="$t('global.messages.validate.confirmpassword.minlength')">
Your confirmation password is required to be at least 4 characters.
</small>
<small class="form-text text-danger"
v-if="!$v.resetPassword.confirmPassword.maxLength" v-text="$t('global.messages.validate.confirmpassword.maxlength')">
Your confirmation password cannot be longer than 50 characters.
</small>
</div>
</div>
<div class="alert alert-danger" role="alert" v-if="doNotMatch" v-text="$t('global.messages.error.dontmatch')">
The password and its confirmation do not match!
</div>
<button type="submit" :disabled="$v.resetPassword.$invalid" class="btn btn-primary" v-text="$t('password.form.button')">Save</button>
</form>
<form name="form" role="form" id="password-form" v-on:submit.prevent="changePassword()">
<div class="form-group">
<label class="form-control-label" for="currentPassword" v-text="$t('global.form[\'currentpassword.label\']')"
>Current password</label
>
<input
type="password"
class="form-control"
id="currentPassword"
name="currentPassword"
:class="{ valid: !$v.resetPassword.currentPassword.$invalid, invalid: $v.resetPassword.currentPassword.$invalid }"
v-bind:placeholder="$t('global.form[\'currentpassword.placeholder\']')"
v-model="$v.resetPassword.currentPassword.$model"
required
/>
<div v-if="$v.resetPassword.currentPassword.$anyDirty && $v.resetPassword.currentPassword.$invalid">
<small
class="form-text text-danger"
v-if="!$v.resetPassword.currentPassword.required"
v-text="$t('global.messages.validate.newpassword.required')"
>
Your password is required.
</small>
</div>
</div>
</div>
<div class="form-group">
<label class="form-control-label" for="newPassword" v-text="$t('global.form[\'newpassword.label\']')">New password</label>
<input
type="password"
class="form-control"
id="newPassword"
name="newPassword"
v-bind:placeholder="$t('global.form[\'newpassword.placeholder\']')"
:class="{ valid: !$v.resetPassword.newPassword.$invalid, invalid: $v.resetPassword.newPassword.$invalid }"
v-model="$v.resetPassword.newPassword.$model"
minlength="4"
maxlength="50"
required
/>
<div v-if="$v.resetPassword.newPassword.$anyDirty && $v.resetPassword.newPassword.$invalid">
<small
class="form-text text-danger"
v-if="!$v.resetPassword.newPassword.required"
v-text="$t('global.messages.validate.newpassword.required')"
>
Your password is required.
</small>
<small
class="form-text text-danger"
v-if="!$v.resetPassword.newPassword.minLength"
v-text="$t('global.messages.validate.newpassword.minlength')"
>
Your password is required to be at least 4 characters.
</small>
<small
class="form-text text-danger"
v-if="!$v.resetPassword.newPassword.maxLength"
v-text="$t('global.messages.validate.newpassword.maxlength')"
>
Your password cannot be longer than 50 characters.
</small>
</div>
<!--<jhi-password-strength-bar [passwordToCheck]="newPassword"></jhi-password-strength-bar>-->
</div>
<div class="form-group">
<label class="form-control-label" for="confirmPassword" v-text="$t('global.form[\'confirmpassword.label\']')"
>New password confirmation</label
>
<input
type="password"
class="form-control"
id="confirmPassword"
name="confirmPassword"
:class="{ valid: !$v.resetPassword.confirmPassword.$invalid, invalid: $v.resetPassword.confirmPassword.$invalid }"
v-bind:placeholder="$t('global.form[\'confirmpassword.placeholder\']')"
v-model="$v.resetPassword.confirmPassword.$model"
minlength="4"
maxlength="50"
required
/>
<div v-if="$v.resetPassword.confirmPassword.$anyDirty && $v.resetPassword.confirmPassword.$invalid">
<small
class="form-text text-danger"
v-if="!$v.resetPassword.confirmPassword.required"
v-text="$t('global.messages.validate.confirmpassword.required')"
>
Your confirmation password is required.
</small>
<small
class="form-text text-danger"
v-if="!$v.resetPassword.confirmPassword.minLength"
v-text="$t('global.messages.validate.confirmpassword.minlength')"
>
Your confirmation password is required to be at least 4 characters.
</small>
<small
class="form-text text-danger"
v-if="!$v.resetPassword.confirmPassword.maxLength"
v-text="$t('global.messages.validate.confirmpassword.maxlength')"
>
Your confirmation password cannot be longer than 50 characters.
</small>
</div>
</div>
<button type="submit" :disabled="$v.resetPassword.$invalid" class="btn btn-primary" v-text="$t('password.form.button')">
Save
</button>
</form>
</div>
</div>
</div>
</template>
<script lang="ts" src="./change-password.component.ts">
</script>
<script lang="ts" src="./change-password.component.ts"></script>
<template>
<div class="modal-body">
<div class="row justify-content-center">
<div class="col-md-8">
<b-alert show variant="danger" v-if="authenticationError" v-html="$t('login.messages.error.authentication')">
<strong>Failed to sign in!</strong> Please check your credentials and try again.
</b-alert>
</div>
<div class="col-md-8">
<b-form role="form" v-on:submit.prevent="doLogin()">
<b-form-group v-bind:label="$t('global.form[\'username.label\']')" label-for="username">
<b-form-input id="username" type="text" name="username" autofocus v-bind:placeholder="$t('global.form[\'username.placeholder\']')" v-model="login">
</b-form-input>
</b-form-group>
<b-form-group v-bind:label="$t('login.form.password')" label-for="password">
<b-form-input id="password" type="password" name="password" v-model.trim="name" v-bind:placeholder="$t('login.form[\'password.placeholder\']')" v-model="password">
</b-form-input>
</b-form-group>
<b-form-checkbox id="rememberMe" name="rememberMe" v-model="rememberMe" checked >
<span v-text="$t('login.form.rememberme')">Remember me</span>
</b-form-checkbox>
<div>
<b-button type="submit" variant="primary" v-text="$t('login.form.button')">Sign in</b-button>
</div>
</b-form>
<p></p>
<div>
<b-alert show variant="warning">
<b-link :to="'/account/reset/request'" class="alert-link" v-text="$t('login.password.forgot')">Did you forget your password?</b-link>
</b-alert>
</div>
<div>
<b-alert show variant="warning">
<span v-text="$t('global.messages.info.register.noaccount')">You don't have an account yet?</span>
<b-link :to="'/register'" class="alert-link" v-text="$t('global.messages.info.register.link')">Register a new account</b-link>
</b-alert>
</div>
</div>
<div class="modal-body">
<div class="row justify-content-center">
<div class="col-md-8">
<b-alert show variant="danger" v-if="authenticationError" v-html="$t('login.messages.error.authentication')">
<strong>Failed to sign in!</strong> Please check your credentials and try again.
</b-alert>
</div>
<div class="col-md-8">
<b-form role="form" v-on:submit.prevent="doLogin()">
<b-form-group v-bind:label="$t('global.form[\'username.label\']')" label-for="username">
<b-form-input
id="username"
type="text"
name="username"
autofocus
v-bind:placeholder="$t('global.form[\'username.placeholder\']')"
v-model="login"
>
</b-form-input>
</b-form-group>
<b-form-group v-bind:label="$t('login.form.password')" label-for="password">
<b-form-input
id="password"
type="password"
name="password"
v-model.trim="name"
v-bind:placeholder="$t('login.form[\'password.placeholder\']')"
v-model="password"
>
</b-form-input>
</b-form-group>
<b-form-checkbox id="rememberMe" name="rememberMe" v-model="rememberMe" checked>
<span v-text="$t('login.form.rememberme')">Remember me</span>
</b-form-checkbox>
<div>
<b-button type="submit" variant="primary" v-text="$t('login.form.button')">Sign in</b-button>
</div>
</b-form>
<p></p>
<div>
<b-alert show variant="warning">
<b-link :to="'/account/reset/request'" class="alert-link" v-text="$t('login.password.forgot')"
>Did you forget your password?</b-link
>
</b-alert>
</div>
<div>
<b-alert show variant="warning">
<span v-text="$t('global.messages.info.register.noaccount')">You don't have an account yet?</span>
<b-link :to="'/register'" class="alert-link" v-text="$t('global.messages.info.register.link')">Register a new account</b-link>
</b-alert>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" src="./login-form.component.ts">
</script>
<script lang="ts" src="./login-form.component.ts"></script>
<template>
<div>
<div class="row justify-content-center">
<div class="col-md-8 toastify-container">
<h1 v-text="$t('register.title')" id="register-title">Registration</h1>
<div>
<div class="row justify-content-center">
<div class="col-md-8 toastify-container">