Skip to content
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
11 changes: 11 additions & 0 deletions admin/src/main/resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,17 @@
"management.structure.informations.attach.parent.error.title": "Erreur d'ajout",
"management.structure.informations.attach.parent.success.content": "Cette structure a bien été attachée à une structure parente",
"management.structure.informations.attach.parent.success.title": "Structure parente attachée",
"management.structure.informations.communications.title": "Droits de communications",
"management.structure.informations.communications.description": "Ré-initialisation des droits de communications de l'établissement",
"management.structure.informations.communications.reset.action": "Ré-initialiser",
"management.structure.informations.communications.warning.title": "Réinitialisation",
"management.structure.informations.communications.warning.content": "La réinitialisation des droits de communication est une action irréversible. Elle supprimera les modifications apportées aux règles de communication entre les différents groupe (sauf groupes manuels) de votre établissement pour remettre la configuration par défaut.",
"management.structure.informations.communications.warning.continue": "Continuer",
"management.structure.informations.communications.confirm.content": "Êtes-vous sur de vouloir réinitialiser les règles de communications",
"management.structure.informations.communications.notify.success.content" : "Les règles de communications ont bien été réinitialisées",
"management.structure.informations.communications.notify.success.title": "Réinitialisation",
"management.structure.informations.communications.notify.error.content" : "Les règles de communications n'ont pas pu être réinitialisées",
"management.structure.informations.communications.notify.error.title": "Erreur de réinitialisation",
"management.structure.informations.detach.parent.error.content": "Cette structure n'a pas pu être détachée de son parent",
"management.structure.informations.detach.parent.error.title": "Erreur lors de la suppression",
"management.structure.informations.detach.parent.success.content": "Cette structure a bien été détachée de son parent",
Expand Down
8 changes: 4 additions & 4 deletions admin/src/main/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"font-awesome": "4.7.0",
"jquery": "^3.4.1",
"ngx-infinite-scroll": "14.0.1",
"ngx-ode-core": "dev",
"ngx-ode-sijil": "dev",
"ngx-ode-ui": "dev",
"ngx-ode-core": "develop-b2school",
"ngx-ode-sijil": "develop-b2school",
"ngx-ode-ui": "develop-b2school",
"ngx-trumbowyg": "^6.0.7",
"noty": "2.4.1",
"reflect-metadata": "0.1.10",
Expand Down Expand Up @@ -72,4 +72,4 @@
"typescript": "~4.6.4",
"webpack": "^5.70.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ export class CommunicationRulesService {
.filter(group => !!group)
.filter(group => group.id === groupId);
}

public resetCommunication(structureId: string): Observable<any> {
return this.http.post(`/communication/rules/${structureId}/reset`, null);
}
}

export interface BidirectionalCommunicationRules {
Expand Down
4 changes: 3 additions & 1 deletion admin/src/main/ts/src/app/management/management.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { StructureUserPositionComponent } from './structure-user-positions/struc
import { MatDialogModule } from '@angular/material/dialog';
import { StructureUserPositionsComponent } from './structure-user-positions/structure-user-positions.component';
import { SharedModule } from '../_shared/shared.module';
import {CommunicationRulesService} from "../communication/communication-rules.service";

@NgModule({
imports: [
Expand Down Expand Up @@ -115,7 +116,8 @@ import { SharedModule } from '../_shared/shared.module';
SubjectsService,
CalendarService,
ImportEDTReportsService,
SubjectsGuardService
SubjectsGuardService,
CommunicationRulesService
]
})
export class ManagementModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,38 @@ <h3>
</p>
</ode-lightbox-confirm>
</div>


<div class="container has-shadow settings" *ngIf="isADMC == true">
<h2>
<s5l>management.structure.informations.communications.title</s5l>
</h2>
<s5l>management.structure.informations.communications.description</s5l>
<form #settingsForm="ngForm" (ngSubmit)="showResetCommunicationWarningLightBox = true;">
<div class="action-communication">
<button class="is-danger">
<s5l>management.structure.informations.communications.reset.action</s5l>
</button>
</div>
</form>
<ode-lightbox-confirm
[show]="showResetCommunicationWarningLightBox"
lightboxTitle="management.structure.informations.communications.warning.title"
(onCancel)="closeLightbox()"
(onConfirm)="openConfirmResetConfirmation()"
confirmText="management.structure.informations.communications.warning.continue">
<p>
<s5l>management.structure.informations.communications.warning.content</s5l>
</p>
</ode-lightbox-confirm>
<ode-lightbox-confirm
[show]="showResetCommunicationConfirmLightBox"
lightboxTitle="management.structure.informations.communications.warning.title"
(onCancel)="closeLightbox()"
(onConfirm)="resetCommunicationRules()">
<p>
<s5l>management.structure.informations.communications.confirm.content</s5l>
</p>
</ode-lightbox-confirm>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
justify-content: flex-end;
}

.action-communication {
display: flex;
margin-top: 1em;
}

input[type="checkbox"],
button.cancel,
ode-message-sticker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Session } from 'src/app/core/store/mappings/session';
import { SessionModel } from 'src/app/core/store/models/session.model';
import { BundlesService } from 'ngx-ode-sijil';
import { Context } from 'src/app/core/store/mappings/context';
import {CommunicationRulesService} from "../../communication/communication-rules.service";

class UserMetric {
active: number = 0;
Expand Down Expand Up @@ -66,15 +67,17 @@ export class StructureInformationsComponent extends OdeComponent implements OnIn
public showMfaWarningLightbox = false;
public isADMC: boolean = false;
public showSettingsLightbox = false;
public showResetCommunicationWarningLightBox = false;
public showResetCommunicationConfirmLightBox = false;

public metrics: StructureMetrics = new StructureMetrics();
public settings: DuplicationSettings = new DuplicationSettings();

constructor(injector: Injector,
private infoService: StructureInformationsService,
private notify: NotifyService,
private bundles: BundlesService)
{
private bundles: BundlesService,
private communicationService: CommunicationRulesService) {
super(injector);
}

Expand Down Expand Up @@ -259,6 +262,23 @@ export class StructureInformationsComponent extends OdeComponent implements OnIn
closeLightbox(): void
{
this.showSettingsLightbox = false;
this.showResetCommunicationConfirmLightBox = false;
this.showResetCommunicationWarningLightBox = false;
this.changeDetector.markForCheck();
}

openConfirmResetConfirmation(): void {
this.closeLightbox();
this.showResetCommunicationConfirmLightBox = true;
}

resetCommunicationRules(): void {
this.closeLightbox();
this.communicationService.resetCommunication(this.structure._id).subscribe(
{
next: (data) => this.notify.success("management.structure.informations.communications.notify.success.content", "management.structure.informations.communications.notify.success.title"),
error: (error) => this.notify.notify("management.structure.informations.communications.notify.error.content", "management.structure.informations.communications.notify.error.title", error, "error")
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void handle(Buffer buff)
}
catch(Exception e)
{
log.error(e, e.getMessage());
log.error(e.getMessage(), e);
badRequest(request);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,14 +638,14 @@ public void context(final HttpServerRequest request) {
pwdResetFormatByLang.put(lang, i18n.translate("password.rules.reset", Renders.getHost(request), lang));
} catch (Exception e) {
pwdResetFormatByLang.put(lang, "");
log.error("error when translating password.rules.reset in {0} : {1}", lang, e);
log.error(String.format("error when translating password.rules.reset in %s : ", lang), e);
}

try {
pwdActivationFormatByLang.put(lang, i18n.translate("password.rules.activation", Renders.getHost(request), lang));
} catch (Exception e) {
pwdActivationFormatByLang.put(lang, "");
log.error("error when translating password.rules.activation in {0} : {1}", lang, e);
log.error(String.format("error when translating password.rules.activation in %s : ", lang), e);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/org/entcore/common/neo4j/Neo.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Neo {

private Neo4j neo4j;

public Neo (Vertx vertx, EventBus eb, Logger log) {
public Neo (Vertx vertx, EventBus eb, Object log) {
neo4j = Neo4j.getInstance();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ public StatementsBuilder add(String query, JsonObject params) {
}
return this;
}
public StatementsBuilder add(StatementsBuilder st) {
st.build()
.stream()
.map(JsonObject.class::cast)
.forEach(job -> this.add(job.getString("statement"), job.getJsonObject("parameters")));
return this;
}

public StatementsBuilder add(String query, Map<String, Object> params) {
return add(query, new JsonObject(params));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ else if (users.getJsonObject(i) != null && users.getJsonObject(i).getString("id"
" : " + eventOwner.body().getString("message"));
}
// find updated resources
final Bson findByKey = Filters.eq("_deleteUsersKey", timestamp);
final JsonObject query = MongoQueryBuilder.build(findByKey);
final JsonObject query = new JsonObject().put("_deleteUsersKey", timestamp);
mongo.find(collection, query, eventFind -> {
final JsonArray results = eventFind.body().getJsonArray("results");
final List<ResourceChanges> list = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.entcore.common.communication.CommunicationUtils;
import org.entcore.common.http.filter.AdminFilter;
import org.entcore.common.http.filter.ResourceFilter;
import org.entcore.common.http.filter.SuperAdminFilter;
import org.entcore.common.user.UserUtils;
import org.entcore.common.validation.StringValidation;
import org.entcore.communication.filters.CommunicationDiscoverVisibleFilter;
Expand Down Expand Up @@ -403,6 +404,15 @@ public void handle(JsonObject body) {
});
}

@Post("/rules/:structureId/reset")
@SecuredAction(value = "", type = ActionType.RESOURCE)
@ResourceFilter(SuperAdminFilter.class)
@MfaProtected()
public void resetRules(final HttpServerRequest request) {
String structureId = request.params().get("structureId");
communicationService.resetRules(structureId, defaultResponseHandler(request));
}

/**
* Send the default communication rules contained inside the mod.json file.
* @param request Incoming request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ public interface CommunicationService {
List<String> EXPECTED_TYPES = Arrays.asList(
"User", "Group", "ManualGroup", "ProfileGroup", "FunctionalGroup", "FunctionGroup", "HTGroup", "CommunityGroup", "DirectionGroup");

//enum VisibleType { USERS, GROUPS, BOTH }
/**
* Reset all communication rules on a structure and apply the default one configured
* in console or configuration
* @param structureId The target structure to reset
* @param eitherHandler handler for the response to the client
*/
void resetRules(String structureId, Handler<Either<String, JsonObject>> eitherHandler);

//enum VisibleType { USERS, GROUPS, BOTH }
enum Direction {
INCOMING (0x01),
OUTGOING (0x10),
Expand Down
Loading