T17: sweep of the WebApp after the feature-parity work
Removed the legacy indicator layout, unused chart helpers, styles and exports, the card-actions component, fetch-all and explanatory comments; one pager shared by the four worklists, shared filter-row styles, one FHIR name and CURP reader, downloads through export/, the concept-map editor on Material controls.
This commit is contained in:
@@ -5,7 +5,6 @@ import { firstValueFrom } from 'rxjs';
|
||||
import { ApiConfiguration } from '../api/api-configuration';
|
||||
import type { Domain } from '../api/models/domain';
|
||||
|
||||
/** Who is signed in, and the domains the app shows them. */
|
||||
export interface User {
|
||||
id: string;
|
||||
email: string;
|
||||
@@ -14,18 +13,14 @@ export interface User {
|
||||
domains: Domain[];
|
||||
}
|
||||
|
||||
/** The web app's sign-in (the API's fastapi-users, a session cookie). It decides only what
|
||||
* the app shows: the API answers without a session. */
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class Auth {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly root = inject(ApiConfiguration).rootUrl;
|
||||
/** undefined: not asked yet; null: nobody signed in. */
|
||||
private readonly current = signal<User | null | undefined>(undefined);
|
||||
readonly user = this.current.asReadonly();
|
||||
readonly signedIn = computed(() => !!this.current());
|
||||
|
||||
/** Whether the signed-in user may see the domain (an administrator sees every one). */
|
||||
canSee(domain: string): boolean {
|
||||
const u = this.current();
|
||||
return !!u && (u.is_superuser || u.domains.includes(domain as Domain));
|
||||
@@ -40,7 +35,6 @@ export class Auth {
|
||||
return this.current() ?? null;
|
||||
}
|
||||
|
||||
/** Signs in; a wrong user or password comes back as words for the form. */
|
||||
async login(email: string, password: string): Promise<string | null> {
|
||||
const body = new HttpParams().set('username', email.trim()).set('password', password);
|
||||
try {
|
||||
@@ -64,15 +58,13 @@ export class Auth {
|
||||
}
|
||||
}
|
||||
|
||||
/** Pages show only to someone signed in; the others go to the sign-in page and come back. */
|
||||
export const signedIn: CanActivateFn = async (_route, state) => {
|
||||
const auth = inject(Auth);
|
||||
const router = inject(Router); // before any await: inject works only in the guard's first turn
|
||||
const router = inject(Router);
|
||||
const user = auth.user() === undefined ? await auth.load() : auth.user();
|
||||
return user ? true : router.createUrlTree(['/login'], { queryParams: { next: state.url } });
|
||||
};
|
||||
|
||||
/** A domain's pages show only to whom may see it. */
|
||||
export const domainAllowed: CanActivateFn = (route) => {
|
||||
const auth = inject(Auth);
|
||||
const domain = route.paramMap.get('domain') ?? route.data['domain'];
|
||||
|
||||
Reference in New Issue
Block a user