Skip to content
Snippets Groups Projects
Commit cb6185ab authored by François Agneray's avatar François Agneray
Browse files

Fixed bug => load instance private images

parent dcf243b6
No related branches found
No related tags found
2 merge requests!72Develop,!34New features
<div class="row align-items-center jumbotron"> <div class="row align-items-center jumbotron">
<div class="col-6 col-md-4 order-md-2 mx-auto text-center"> <div class="col-6 col-md-4 order-md-2 mx-auto text-center">
<img class="img-fluid mb-3 mb-md-0" src="{{ getLogoSrc() }}" alt="Instance logo"> <img class="img-fluid mb-3 mb-md-0" [src]="getLogoSrc() | authImage | async" alt="Instance logo">
</div> </div>
<div class="col-md-8 order-md-1 text-justify pr-md-5" [innerHtml]="instance.home_component_config.home_component_text"></div> <div class="col-md-8 order-md-1 text-justify pr-md-5" [innerHtml]="instance.home_component_config.home_component_text"></div>
</div> </div>
...@@ -22,8 +22,12 @@ ...@@ -22,8 +22,12 @@
</p> </p>
</div> </div>
<div class="card-footer bg-transparent text-right"> <div class="card-footer bg-transparent text-right">
<button [disabled]="!isInstanceAccessible()" routerLink="/instance/{{ instance.name }}" class="btn btn-outline-primary" title="Go to instance"> <button *ngIf="!isInstanceAccessible()" class="btn btn-outline-danger disabled" title="You are not authorized to access this project">
Go to instance <span class="fa-solid fa-lock"></span> Private
</button>
<button *ngIf="isInstanceAccessible()" routerLink="/instance/{{ instance.name }}" class="btn btn-outline-primary" title="Go to instance">
<span *ngIf="!instance.public" class="fa-solid fa-lock-open"></span> Access to the project
</button> </button>
</div> </div>
</div> </div>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
</a> </a>
<a *ngIf="instance" routerLink="/instance/{{ instance.name }}" class="navbar-brand"> <a *ngIf="instance" routerLink="/instance/{{ instance.name }}" class="navbar-brand">
<img src="{{ getLogoHref() }}" alt="Instance logo" /> <img [src]="getLogoHref() | authImage | async" alt="Instance logo" />
</a> </a>
<!-- Right Navigation --> <!-- Right Navigation -->
......
/**
* This file is part of Anis Client.
*
* @copyright Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { Pipe, PipeTransform } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Pipe({ name: 'authImage' })
export class AuthImagePipe implements PipeTransform {
constructor(private http: HttpClient) { }
async transform(src: string): Promise<string> {
try {
const imageBlob = await this.http.get(src, { responseType: 'blob' }).toPromise();
const reader = new FileReader();
return new Promise((resolve, reject) => {
reader.onloadend = () => resolve(reader.result as string);
reader.readAsDataURL(imageBlob);
});
} catch {
return 'assets/fallback.png';
}
}
}
...@@ -13,6 +13,7 @@ import { OptionListBySelectPipe } from './option-list-by-select.pipe'; ...@@ -13,6 +13,7 @@ import { OptionListBySelectPipe } from './option-list-by-select.pipe';
import { OutputFamilyByIdPipe } from './output-family-by-id.pipe'; import { OutputFamilyByIdPipe } from './output-family-by-id.pipe';
import { DatasetByNamePipe } from './dataset-by-name.pipe'; import { DatasetByNamePipe } from './dataset-by-name.pipe';
import { InstanceByNamePipe } from './instance-by-name.pipe'; import { InstanceByNamePipe } from './instance-by-name.pipe';
import { AuthImagePipe } from './auth-image.pipe';
export const sharedPipes = [ export const sharedPipes = [
DatasetListByFamilyPipe, DatasetListByFamilyPipe,
...@@ -20,5 +21,6 @@ export const sharedPipes = [ ...@@ -20,5 +21,6 @@ export const sharedPipes = [
OptionListBySelectPipe, OptionListBySelectPipe,
OutputFamilyByIdPipe, OutputFamilyByIdPipe,
DatasetByNamePipe, DatasetByNamePipe,
InstanceByNamePipe InstanceByNamePipe,
AuthImagePipe
]; ];
...@@ -35,7 +35,7 @@ services: ...@@ -35,7 +35,7 @@ services:
SSO_AUTH_URL: "http://localhost:8180/auth" SSO_AUTH_URL: "http://localhost:8180/auth"
SSO_REALM: "anis" SSO_REALM: "anis"
SSO_CLIENT_ID: "anis-client" SSO_CLIENT_ID: "anis-client"
TOKEN_ENABLED: 1 TOKEN_ENABLED: 0
TOKEN_JWKS_URL: "http://keycloak:8180/auth/realms/anis/protocol/openid-connect/certs" TOKEN_JWKS_URL: "http://keycloak:8180/auth/realms/anis/protocol/openid-connect/certs"
TOKEN_ADMIN_ROLES: anis_admin,superuser TOKEN_ADMIN_ROLES: anis_admin,superuser
RMQ_HOST: rmq RMQ_HOST: rmq
......
...@@ -70,7 +70,7 @@ abstract class AbstractAction ...@@ -70,7 +70,7 @@ abstract class AbstractAction
if (!$this->isAdmin($adminRoles, $roles)) { if (!$this->isAdmin($adminRoles, $roles)) {
$qb = $this->em->createQueryBuilder(); $qb = $this->em->createQueryBuilder();
$qb->select('d.name') $qb->select('d.name')
->from('App\Entity\Group', 'g') ->from('App\Entity\DatasetGroup', 'g')
->join('g.datasets', 'd') ->join('g.datasets', 'd')
->where($qb->expr()->in('g.role', $roles)) ->where($qb->expr()->in('g.role', $roles))
->andWhere($qb->expr()->eq('d.name', ':dname')); ->andWhere($qb->expr()->eq('d.name', ':dname'));
......
...@@ -92,7 +92,7 @@ final class DatasetListByInstanceAction extends AbstractAction ...@@ -92,7 +92,7 @@ final class DatasetListByInstanceAction extends AbstractAction
$qb->andWhere($qb->expr()->eq('d.public', 'true')); $qb->andWhere($qb->expr()->eq('d.public', 'true'));
$qb2 = $this->em->createQueryBuilder(); $qb2 = $this->em->createQueryBuilder();
$qb2->select('d2.name') $qb2->select('d2.name')
->from('App\Entity\Group', 'g') ->from('App\Entity\DatasetGroup', 'g')
->join('g.datasets', 'd2') ->join('g.datasets', 'd2')
->where($qb2->expr()->in('g.role', $roles)); ->where($qb2->expr()->in('g.role', $roles));
$qb->orWhere($qb->expr()->in('d.name', $qb2->getDQL())); $qb->orWhere($qb->expr()->in('d.name', $qb2->getDQL()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment