Skip to content

Commit

Permalink
Merge pull request #50 from gisaia/feat/toolkit13
Browse files Browse the repository at this point in the history
Merge pull request #49 from gisaia/feat/upgradeToolkit
  • Loading branch information
sebbousquet authored Nov 30, 2023
2 parents f51b929 + bab4ac2 commit 60ffa14
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 58 deletions.
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"ajv-keywords": "5.1.0",
"arlas-wui-toolkit": "24.3.0-beta.11",
"arlas-wui-toolkit": "24.3.0-beta.14",
"eslint": "^8.2.0",
"js-yaml": "4.1.0",
"patch-package": "^6.4.7",
Expand Down
12 changes: 5 additions & 7 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import {
ArlasCollaborativesearchService, ArlasConfigurationDescriptor, ArlasIamService,
ArlasSettingsService,
ArlasStartupService, ArlasToolkitSharedModule, AuthentificationService,
CONFIG_UPDATER,
FETCH_OPTIONS, GET_OPTIONS, LoginModule, configUpdaterFactory, getOptionsFactory
FETCH_OPTIONS, GET_OPTIONS, LoginModule, PersistenceService, configUpdaterFactory, getOptionsFactory
} from 'arlas-wui-toolkit';
import { ToastrModule } from 'ngx-toastr';
import { AppRoutingModule } from './app-routing.module';
Expand All @@ -53,6 +54,7 @@ import { UserAddComponent } from './components/user/user-add/user-add.component'
import { UserFormComponent } from './components/user/user-form/user-form.component';
import { UserComponent } from './components/user/user.component';
import { IamStartupService } from './services/startup/startup.service';
import { ArlasTranslateLoader } from '@tools/customLoader';

export function startupServiceFactory(startup: IamStartupService) {
const load = () => startup.load();
Expand All @@ -63,10 +65,6 @@ export function auhtentServiceFactory(service: AuthentificationService) {
return service;
}

export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
}

@NgModule({
declarations: [
AppComponent,
Expand Down Expand Up @@ -117,8 +115,8 @@ export function createTranslateLoader(http: HttpClient) {
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpClient]
useClass: ArlasTranslateLoader,
deps: [HttpClient, ArlasSettingsService, PersistenceService]
}
}),
ToastrModule.forRoot({
Expand Down
26 changes: 6 additions & 20 deletions src/app/components/home/home.component.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<arlas-top-menu [showAboutButton]="false">
<div left-menu>{{'ARLAS IAM' | translate}}</div>
<div right-menu>
<div right-menu class="right-menu">
<div *ngIf="!domainOrgExist || isSuperAdmin" class="create-org">
<button class="add-org" (click)="addOrg()" mat-flat-button color="accent">{{'Create organisation' |
translate}}</button>
</div>
<div class="orga">
<div class="orga" *ngIf="organisations.length > 0">
{{'Organisation'| translate}}
<mat-select #currentOrg class="current-orga" [value]="currentSelectedOrg"
(selectionChange)="updateCurrentOrga(currentOrg.value)">
Expand All @@ -24,31 +24,31 @@
</span>
<span class="label">{{'Home' | translate}}</span>
</mat-list-item>
<mat-list-item [matTooltip]="'User' | translate" [routerLink]="'user'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
<mat-list-item [matTooltip]="'User' | translate" [disabled]="currentSelectedOrg === null" [routerLink]="'user'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
[queryParamsHandling]="'preserve'">
<span class="material-symbols-outlined">
person
</span>
<span class="label">{{'Users' | translate}}</span>
</mat-list-item>
<mat-divider></mat-divider>
<mat-list-item [matTooltip]="'Groups' | translate" [routerLink]="'role'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
<mat-list-item [matTooltip]="'Groups' | translate" [disabled]="currentSelectedOrg === null" [routerLink]="'role'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
[queryParamsHandling]="'preserve'">
<span class="material-symbols-outlined">
group
</span>
<span class="label">{{'Groups'| translate}}</span>
</mat-list-item>
<mat-divider></mat-divider>
<mat-list-item [matTooltip]="'Permissions' | translate" [routerLink]="'permission'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
<mat-list-item [matTooltip]="'Permissions' | translate" [disabled]="currentSelectedOrg === null" [routerLink]="'permission'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
[queryParamsHandling]="'preserve'">
<span class="material-symbols-outlined">
verified_user
</span>
<span class="label">{{'Permissions'| translate}}</span>
</mat-list-item>
<mat-divider></mat-divider>
<mat-list-item [matTooltip]="'Rules' | translate" [routerLink]="'rule'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
<mat-list-item [matTooltip]="'Rules' | translate" [disabled]="currentSelectedOrg === null" [routerLink]="'rule'" routerLinkActive="active-page" [matTooltipPosition]="'right'"
[queryParamsHandling]="'preserve'">
<span class="material-symbols-outlined">
rule
Expand All @@ -58,20 +58,6 @@



</mat-nav-list>
<mat-nav-list class="route-nav-list login">
<mat-list-item [matTooltip]="this.user?.email" [matTooltipPosition]="'above'" class="username">
<span class="material-symbols-outlined">
person
</span>
<span class="label">{{this.user?.email}}</span>
</mat-list-item>
<mat-list-item [matTooltip]="'Logout' | translate" (click)="logout()" [matTooltipPosition]="'right'">
<span class="material-symbols-outlined">
logout
</span>
<span class="label">{{'Logout' | translate}}</span>
</mat-list-item>
</mat-nav-list>
</div>
<div class="main-view">
Expand Down
35 changes: 25 additions & 10 deletions src/app/components/home/home.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,28 @@
background-color: $primaryColor !important;
padding: 0 10px !important;
color: white;
.orga {
font-size: medium;
font-weight: 300;
padding-right: 15px;

.current-orga {
width: 150px;
background-color: white;
color: black;
padding: 0 5px;
.right-menu {
display: flex;
align-items: baseline;
gap: 0 5px;
.create-org {
padding-right: 15px;
.add-org {
line-height: 32px;
vertical-align: bottom;
}
}
.orga {
font-size: medium;
font-weight: 300;
padding-right: 15px;

.current-orga {
width: 150px;
background-color: white;
color: black;
padding: 0 5px;
}
}
}
}
Expand Down Expand Up @@ -45,6 +57,9 @@
}
.mat-list-item {
color: #28292b;
&.mat-list-item-disabled {
cursor: not-allowed !important;
}
}
.mat-list-item-content {
margin: 15px !important;
Expand Down
5 changes: 5 additions & 0 deletions src/app/components/user/user-add/user-add.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
display: flex;
flex-direction: column;

mat-form-field {
width: fit-content;
min-width: 400px;
}

.owner{
padding: 0 0 15px 10px;
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/user/user-add/user-add.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ export class UserAddComponent implements OnInit, OnDestroy {
if (err.status === 404) {
this.toastr.error(this.translate.instant('User not found'));
}
if (err.status === 400) {
this.toastr.error(this.translate.instant('User is already in organisation'));
}
}
});
}
Expand Down
17 changes: 12 additions & 5 deletions src/app/services/startup/startup.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,22 @@ export class IamStartupService {
next: loginData => {
if (!!loginData) {
const storedArlasOrganisation = this.arlasIamService.getOrganisation();
const org = !!storedArlasOrganisation ? storedArlasOrganisation : loginData.user?.organisations[0]?.name;
const org = !!storedArlasOrganisation ? storedArlasOrganisation
: (!!loginData.user?.organisations[0] ? loginData.user?.organisations[0].name : null);

this.arlasIamService.setHeaders(org, loginData.accessToken);

const iamHeader = {
Authorization: 'Bearer ' + loginData.accessToken,
};
// Set the org filter only if the organisation is defined
if (!!org) {
// @ts-ignore
iamHeader['arlas-org-filter'] = org;
}

this.managerService.setOptions({
headers: {
Authorization: 'Bearer ' + loginData.accessToken,
'arlas-org-filter': org
}
headers: iamHeader
});
}
return Promise.resolve(data);
Expand Down
Loading

0 comments on commit 60ffa14

Please sign in to comment.