Commit efbc0b93 authored by Florent POITTEVIN's avatar Florent POITTEVIN
Browse files

feat: [DLCM-1776] migration DLCM to last version of solidify 1.3.0

parent eb872742
......@@ -33,7 +33,7 @@ describe("Deposit Page", () => {
/* TestHelper.getTestData(DataTestEnum.depositLicenseId)
.click()
.get("dlcm-shared-searchable-single-select-content")
.get("solidify-searchable-single-select-content")
.click()
.get("li")
.contains("CC BY-NC 4.0 (Creative Commons Attribution-NonCommercial 4.0 International)")
......
......@@ -43,7 +43,7 @@ export class OrgunitHelper {
TestHelper.getTestData(DataTestEnum.adminOrgUnitListSearchName).type(orgUnitName, {delay: 0, release: false});
cy.get("dlcm-shared-data-table").should("attr", "data-test-info-number-line").then((numberElement: number | any) => {
cy.get("solidify-data-table").should("attr", "data-test-info-number-line").then((numberElement: number | any) => {
if (numberElement === "1") {
return;
} else if (numberElement === "0") {
......@@ -80,7 +80,7 @@ export class OrgunitHelper {
TestHelper.getTestData(DataTestEnum.adminOrgUnitSubmissionPolicy)
.click()
.get("dlcm-shared-multi-select-default-value-content li")
.get("solidify-multi-select-default-value-content li")
.first()
.click();
......@@ -88,7 +88,7 @@ export class OrgunitHelper {
TestHelper.getTestData(DataTestEnum.adminOrgUnitPreservationPolicy)
.click()
.get("dlcm-shared-multi-select-default-value-content li")
.get("solidify-multi-select-default-value-content li")
.first()
.click();
......@@ -105,10 +105,10 @@ export class OrgunitHelper {
.last()
.click()
.wait("@personInit")
.get("dlcm-shared-searchable-single-select-content input")
.get("solidify-searchable-single-select-content input")
.type("USER Last Name")
.wait("@personSearch")
.get("dlcm-shared-searchable-single-select-content li")
.get("solidify-searchable-single-select-content li")
.first()
.click();
......
......@@ -19,7 +19,7 @@ export class PreservationSpaceCommonHelper {
static goToOrgUnitDetail(orgUnitName: string): void {
TestHelper.getTestData(DataTestEnum.preservationSpaceOrgUnitListSearchName).type(orgUnitName, {delay: 0, release: false});
cy.get("dlcm-shared-data-table").should("attr", "data-test-info-number-line").should("eq", "1");
cy.get("solidify-data-table").should("attr", "data-test-info-number-line").should("eq", "1");
TestHelper.waitXhrs(["organizational-units/*"],
() => cy.get("tbody").find("tr").first().click());
......@@ -30,4 +30,4 @@ export class PreservationSpaceCommonHelper {
TestHelper.getTestData(DataTestEnum.preservationSpaceOrgUnitName).click({force: true});
TestHelper.getTestData(DataTestEnum.save).should("not.exist");
}
}
\ No newline at end of file
}
{
"name": "dlcm-frontend",
"version": "2.0.8-SNAPSHOT",
"version": "2.1.0-SNAPSHOT",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -14924,9 +14924,9 @@
}
},
"solidify-frontend": {
"version": "0.6.9",
"resolved": "https://nexus.unige.ch/repository/npm-all/solidify-frontend/-/solidify-frontend-0.6.9.tgz",
"integrity": "sha512-/KD62NXGZJnZZSDNIYVpO0yZtLyljqvfuGjU6MO6/qyZITyFtGXMrv/FrH57irj21T4KBmqmayytH1lGVBmP/Q==",
"version": "1.3.0",
"resolved": "https://nexus.unige.ch/repository/npm-all/solidify-frontend/-/solidify-frontend-1.3.0.tgz",
"integrity": "sha512-uwPtC36GeKXgdjYUM+DnBtYhEjT9uBT3zwOtR0xsCBNOo+iaD1C6x4redn1hRDBygD0+b/PLoZnslHcCZDsi8Q==",
"requires": {
"tslib": "^2.0.0"
}
......
import {NgModule} from "@angular/core";
import {RouterModule} from "@angular/router";
import {PageNotFoundPresentational} from "@app/components/presentationals/page-not-found/page-not-found.presentational";
import {IconAppRoutable} from "@app/components/routables/icon-app/icon-app.routable";
import {MaintenanceModeRoutable} from "@app/components/routables/maintenance-mode/maintenance-mode.routable";
import {ServerOfflineModeRoutable} from "@app/components/routables/server-offline-mode/server-offline-mode.routable";
import {ApplicationRolePermissionEnum} from "@app/shared/enums/application-role-permission.enum";
import {AppRoutesEnum} from "@app/shared/enums/routes.enum";
import {ApplicationRoleGuardService} from "@app/shared/guards/application-role-guard.service";
import {DlcmRoutes} from "@app/shared/models/dlcm-route.model";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {ApplicationDevGuardService} from "@shared/guards/application-dev-guard.service";
import {ApplicationMaintenanceGuardService} from "@shared/guards/application-maintenance-guard.service";
import {PreventLeaveGuardService} from "@shared/guards/prevent-leave-guard.service";
import {UrlQueryParamHelper} from "@shared/helpers/url-query-param.helper";
import {
DevGuardService,
IconAppSummaryRoutable,
MaintenanceModeRoutable,
PreventLeaveGuardService,
ServerOfflineModeRoutable,
UrlQueryParamHelper,
} from "solidify-frontend";
const routes: DlcmRoutes = [
{
......@@ -76,8 +78,8 @@ const routes: DlcmRoutes = [
},
{
path: AppRoutesEnum.icons,
component: IconAppRoutable,
canActivate: [ApplicationDevGuardService],
component: IconAppSummaryRoutable,
canActivate: [DevGuardService],
},
{
path: AppRoutesEnum.maintenance,
......
<dlcm-ribbon></dlcm-ribbon>
<solidify-ribbon></solidify-ribbon>
<div *ngIf="isMaintenanceModeActive"
class="maintenance-mode"
......@@ -11,7 +11,7 @@
</ng-template>
<div *ngIf="!(isApplicationInitializedObs | async)"
[dlcmSpinner]="true"
[solidifySpinner]="true"
class="spinner-general-wrapper"
>
</div>
......@@ -49,14 +49,14 @@
<div [class.hide]="isHomePage"
class="header-sticky-bar"
>
<dlcm-shared-breadcrumb (navigateChange)="navigate($event)"
<solidify-breadcrumb (navigateChange)="navigate($event)"
class="breadcrumb"
></dlcm-shared-breadcrumb>
<dlcm-shared-banner [class]="colorBannerObs | async"
></solidify-breadcrumb>
<solidify-banner [class]="colorBannerObs | async"
[conditionToDisplay]="displayBannerObs | async"
[messageToTranslate]="messageBannerObs | async"
[parameters]="parametersObs | async"
></dlcm-shared-banner>
></solidify-banner>
</div>
<div class="content-and-sidebar-userguide">
......@@ -87,6 +87,7 @@
></dlcm-cookie-consent>
</div>
<!--TODO FIND A WAY TO MOVE THIS ON SOLIDIFY AND AVOID ERRROR : NgxmTourService was not found in ngx-tour-md-menu -->
<tour-step-template>
<ng-template let-step="step">
<div class="ngx-tour_panel">
......
@import "abstracts/variables";
@import "abstracts/mixins";
@import "src/sass/abstracts/abstracts";
:host {
.maintenance-mode {
......
import {DOCUMENT} from "@angular/common";
import {
AfterViewInit,
Component,
ElementRef,
HostListener,
Inject,
OnInit,
Injector,
Renderer2,
ViewChild,
} from "@angular/core";
import {MatDialog} from "@angular/material/dialog";
import {
Router,
RouterStateSnapshot,
} from "@angular/router";
import {UpdateVersionDialog} from "@app/components/dialogs/update-version/update-version.dialog";
import {Router} from "@angular/router";
import {UserDialog} from "@app/components/dialogs/user/user.dialog";
import {SharedAbstractPresentational} from "@app/shared/components/presentationals/shared-abstract/shared-abstract.presentational";
import {
RoutesEnum,
urlSeparator,
} from "@app/shared/enums/routes.enum";
import {ThemeEnum} from "@app/shared/enums/theme.enum";
import {LocalStateModel} from "@app/shared/models/local-state.model";
import {AppAction} from "@app/stores/app.action";
import {RoutesEnum} from "@app/shared/enums/routes.enum";
import {appActionNameSpace} from "@app/stores/app.action";
import {AppState} from "@app/stores/app.state";
import {AppBannerState} from "@app/stores/banner/app-banner.state";
import {AppCartArchiveState} from "@app/stores/cart/archive/app-cart-archive.state";
import {AppUserState} from "@app/stores/user/app-user.state";
import {Enums} from "@enums";
......@@ -33,105 +18,58 @@ import {environment} from "@environments/environment";
import {HomeHelper} from "@home/helpers/home.helper";
import {User} from "@models";
import {TranslateService} from "@ngx-translate/core";
import {Navigate} from "@ngxs/router-plugin";
import {
Select,
Store,
} from "@ngxs/store";
import {Store} from "@ngxs/store";
import {ApplicationRolePermissionEnum} from "@shared/enums/application-role-permission.enum";
import {BannerColorEnum} from "@shared/enums/banner-color.enum";
import {ChemicalMoleculeVisualizationEnum} from "@shared/enums/chemical-molecule-visualization.enum";
import {LabelTranslateEnum} from "@shared/enums/label-translate.enum";
import {SessionStorageEnum} from "@shared/enums/session-storage.enum";
import {TourEnum} from "@shared/enums/tour.enum";
import {SessionStorageHelper} from "@shared/helpers/session-storage.helper";
import {UrlQueryParamHelper} from "@shared/helpers/url-query-param.helper";
import {AppStatusService} from "@shared/services/app-status.service";
import {BreakpointService} from "@shared/services/breakpoint.service";
import {GoogleAnalyticsService} from "@shared/services/google-analytics.service";
import {ScrollService} from "@shared/services/scroll.service";
import {PermissionUtil} from "@shared/utils/permission.util";
import {TourService} from "ngx-tour-md-menu";
import {
combineLatest,
fromEvent,
Observable,
} from "rxjs";
import {
distinctUntilChanged,
filter,
map,
take,
tap,
} from "rxjs/operators";
import {
isFalse,
isFalsy,
AbstractAppComponent,
AppStatusService,
BreakpointService,
isNotNullNorUndefined,
isNullOrUndefined,
isTrue,
isUndefined,
LoggingService,
MARK_AS_TRANSLATABLE,
MemoizedUtil,
NotificationService,
ScrollService,
SOLIDIFY_CONSTANTS,
UrlQueryParamHelper,
} from "solidify-frontend";
declare let gtag: Function;
const urlSeparator: string = SOLIDIFY_CONSTANTS.URL_SEPARATOR;
@Component({
selector: "dlcm-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.scss"],
})
export class AppComponent extends SharedAbstractPresentational implements OnInit, AfterViewInit {
private readonly _ATTRIBUTE_SRC_DIFFER_KEY: string = "src-differ";
private readonly _ATTRIBUTE_SRC: string = "src";
export class AppComponent extends AbstractAppComponent {
private static readonly _themeAttributeName: string = "theme";
private static readonly _uiAttributeName: string = "ui";
currentModule: string;
isHomePage: boolean;
logo: string;
@Select((state: LocalStateModel) => state.router.state) urlStateObs: Observable<RouterStateSnapshot>;
appLanguageObs: Observable<Enums.Language.LanguageEnum> = MemoizedUtil.select(this._store, AppState, state => state.appLanguage);
isLoggedObs: Observable<boolean> = MemoizedUtil.select(this._store, AppState, state => state.isLoggedIn);
isApplicationInitializedObs: Observable<boolean> = MemoizedUtil.select(this._store, AppState, state => state.isApplicationInitialized);
isServerOfflineObs: Observable<boolean> = MemoizedUtil.select(this._store, AppState, state => state.isServerOffline);
themeObs: Observable<ThemeEnum> = MemoizedUtil.select(this._store, AppState, state => state.theme);
displayCookieConsentObs: Observable<boolean> = MemoizedUtil.select(this._store, AppState, state => state.displayCookieConsent);
userRolesObs: Observable<Enums.UserApplicationRole.UserApplicationRoleEnum[]> = MemoizedUtil.select(this._store, AppState, state => state.userRoles);
currentUserObs: Observable<User> = MemoizedUtil.current(this._store, AppUserState);
currentPhotoUserObs: Observable<string> = MemoizedUtil.select(this._store, AppUserState, state => state.logo);
displayBannerObs: Observable<boolean> = MemoizedUtil.select(this._store, AppBannerState, state => state.display);
messageBannerObs: Observable<string> = MemoizedUtil.select(this._store, AppBannerState, state => state.message);
parametersObs: Observable<object> = MemoizedUtil.select(this._store, AppBannerState, state => state.parameters);
colorBannerObs: Observable<BannerColorEnum> = MemoizedUtil.select(this._store, AppBannerState, state => state.color);
isTouchInterfaceObs: Observable<boolean> = MemoizedUtil.select(this._store, AppState, state => state.isTouchInterface);
numberArchiveInCartObs: Observable<number> = MemoizedUtil.total(this._store, AppCartArchiveState);
ignoreGrid: boolean = false;
displayCart: boolean = false;
isMaintenanceModeActive: boolean = false;
@ViewChild("main")
mainElementRef: ElementRef;
@HostListener("window:beforeunload", ["$event"])
leaveWithoutSaveNotification($event: Event): void {
const preventExit = this._store.selectSnapshot((state: LocalStateModel) => state.application.preventExit);
const ignorePreventExit = this._store.selectSnapshot((state: LocalStateModel) => state.application.ignorePreventLeavePopup);
if (isFalse(ignorePreventExit) && isTrue(preventExit)) {
$event.returnValue = true;
}
}
get sessionStorageHelper(): typeof SessionStorageHelper {
return SessionStorageHelper;
}
get sessionStorageEnum(): typeof SessionStorageEnum {
return SessionStorageEnum;
}
......@@ -144,93 +82,48 @@ export class AppComponent extends SharedAbstractPresentational implements OnInit
return TourEnum;
}
constructor(private readonly _store: Store,
private readonly _router: Router,
private readonly _translate: TranslateService,
private readonly _renderer: Renderer2,
@Inject(DOCUMENT) private readonly _document: Document,
private readonly _notificationService: NotificationService,
private readonly _loggingService: LoggingService,
get labelTranslateEnum(): typeof LabelTranslateEnum {
return LabelTranslateEnum;
}
constructor(protected readonly _store: Store,
protected readonly _router: Router,
protected readonly _translate: TranslateService,
protected readonly _renderer: Renderer2,
@Inject(DOCUMENT) protected readonly _document: Document,
protected readonly _injector: Injector,
protected readonly _notificationService: NotificationService,
protected readonly _loggingService: LoggingService,
public readonly appStatusService: AppStatusService,
public readonly breakpointService: BreakpointService,
private readonly _dialog: MatDialog,
protected readonly _dialog: MatDialog,
public readonly tourService: TourService,
private _scrollService: ScrollService,
private router: Router,
protected readonly router: Router,
protected readonly _scrollService: ScrollService,
private readonly _googleAnalyticsService: GoogleAnalyticsService) {
super();
this._store.dispatch(new AppAction.InitApplication());
this._setOverrideCssStyleSheet();
super(AppState,
AppUserState as any,
_store,
_router,
_translate,
_renderer,
_document,
_injector,
_notificationService,
_loggingService,
appStatusService,
breakpointService,
_dialog,
router,
_scrollService,
);
this._listenCurrentModule();
this.subscribe(this._observeThemeChange());
this.observeOfflineOnlineMode();
this.themeChange(environment.theme);
this.subscribe(this.observeUpdateAvailableForModal());
this.subscribe(this.observeLoggedUserForCart());
this.checkOrcidQueryParam();
this._activeChemicalMoleculePreviewIfEnable();
this.subscribe(this.listenLanguageChange());
this.subscribe(this.listenAppReady());
this._googleAnalyticsService.init(this._renderer);
}
ngOnInit(): void {
super.ngOnInit();
this.subscribe(this.isApplicationInitializedObs.pipe(
filter(isInitialized => isTrue(isInitialized)),
take(1),
tap(() => this.isMaintenanceModeActive = environment.maintenanceMode),
));
this.subscribe(this.isTouchInterfaceObs, isTouchInterface => this.setTouchInterface(isTouchInterface));
this.subscribe(this.observeTouchEvent());
}
ngAfterViewInit(): void {
super.ngAfterViewInit();
this._scrollService.init(this.mainElementRef);
}
private observeTouchEvent(): Observable<Event> {
return fromEvent(document, "touchstart")
.pipe(
take(1),
tap(event => this._store.dispatch(new AppAction.SetIsTouchInterface(true)),
),
);
}
private observeOfflineOnlineMode(): void {
let previousStateIsOnline: boolean | undefined = undefined;
this.subscribe(this.appStatusService.online.pipe(
distinctUntilChanged(),
tap((isOnline: boolean) => {
if ((isUndefined(previousStateIsOnline) || isTrue(previousStateIsOnline)) && isFalsy(isOnline)) {
this._notificationService.showWarning(MARK_AS_TRANSLATABLE("app.status.offline"));
previousStateIsOnline = isOnline;
return;
}
if (isFalse(previousStateIsOnline) && isTrue(isOnline)) {
this._notificationService.showInformation(MARK_AS_TRANSLATABLE("app.status.backToOnline"));
previousStateIsOnline = isOnline;
return;
}
return;
}),
));
}
private observeUpdateAvailableForModal(): Observable<string> {
return this.appStatusService.updateAvailable.pipe(
distinctUntilChanged(),
filter(version => !isNullOrUndefined(version)),
tap((version) => {
this._dialog.open(UpdateVersionDialog);
}),
);
}
private observeLoggedUserForCart(): Observable<boolean> {
return combineLatest([this.isLoggedObs, this.userRolesObs])
.pipe(
......@@ -243,7 +136,7 @@ export class AppComponent extends SharedAbstractPresentational implements OnInit
this.subscribe(this.currentUserObs.pipe(
filter(user => isNotNullNorUndefined(user)),
take(1),
tap(user => {
tap((user: User) => {
this._dialog.open(UserDialog, {
data: user,
width: "90%",
......@@ -254,47 +147,6 @@ export class AppComponent extends SharedAbstractPresentational implements OnInit
}
}
useLanguage(language: Enums.Language.LanguageEnum): void {
this._store.dispatch(new AppAction.ChangeAppLanguage(language));
}
navigate(route: string): void {
this._store.dispatch(new Navigate([route]));
}
private _setTitle(): void {
setTimeout(() => {
this._document.title = environment.appTitle;
const description = environment.appDescription;
this._document.querySelector("meta[name=\"description\"]").setAttribute("content", description);
}, 0);
}
private setTheme(): void {
this._renderer.setAttribute(this._document.body, AppComponent._themeAttributeName, environment.theme);
}
private setTouchInterface(isTouchInterface: boolean): void {
this._renderer.setAttribute(this._document.body, AppComponent._uiAttributeName, isTouchInterface ? "touch" : "standard");
}
private setFavicon(): void {
const header = this._document.querySelector("head");
const oldFavicon = this._document.querySelector("head link[type='image/x-icon']");
let link = this._document.createElement("link");
if (isNotNullNorUndefined(oldFavicon)) {
link = oldFavicon as any;
}
this._renderer.setAttribute(link, "type", "image/x-icon");
this._renderer.setAttribute(link, "rel", "shortcut icon");
this._renderer.setAttribute(link, "href", `./assets/themes/${environment.theme}/favicon.ico`);
this._renderer.appendChild(header, link);
}
private setImageToolbar(): void {
this.logo = `assets/themes/${environment.theme}/toolbar-header-image.svg`;
}
private _listenCurrentModule(): void {
this.subscribe(this.urlStateObs
.pipe(
......@@ -359,60 +211,10 @@ export class AppComponent extends SharedAbstractPresentational implements OnInit
);
}
logout(): void {
this._store.dispatch(new AppAction.Logout());
}
getTitle(): string {
return this._document.title;
}
themeChange(theme: ThemeEnum): void {
if (theme !== this._store.selectSnapshot((state: LocalStateModel) => state.application.theme)) {
this._store.dispatch(new AppAction.ChangeAppTheme(theme));
}
}
navigateToHome(): void {
this.navigate(RoutesEnum.homePage);
}
private _observeThemeChange(): Observable<ThemeEnum> {
return this.themeObs.pipe(
distinctUntilChanged(),
tap((theme: ThemeEnum) => {
this.setTheme();
this.setFavicon();
this.setImageToolbar();
}),
);
}
private listenLanguageChange(): Observable<Enums.Language.LanguageEnum> {
return this.appLanguageObs.pipe(
tap((language: Enums.Language.LanguageEnum) => {
this._setTitle();
}),
);
}
private listenAppReady(): Observable<boolean> {
return this.isApplicationInitializedObs.pipe(
tap((isInit: boolean) => {
this._setTitle();
}),
);
}
private _setOverrideCssStyleSheet(): void {
const header = this._document.querySelector("head");
const link = this._document.createElement("link");
this._renderer.setAttribute(link, "type", "text/css");
this._renderer.setAttribute(link, "rel", "stylesheet");
this._renderer.setAttribute(link, "href", `./assets/styles/override.css`);
this._renderer.appendChild(header, link);
}
computeDisplayCart(isLogged: boolean, userRoles: Enums.UserApplicationRole.UserApplicationRoleEnum[]): boolean {
this.displayCart = PermissionUtil.isUserHavePermission(isLogged, ApplicationRolePermissionEnum.userPermission, userRoles);
return this.displayCart;
......@@ -476,30 +278,11 @@ export class AppComponent extends SharedAbstractPresentational implements OnInit
});
}
private _getValueScriptDiffer(script: Element): string | undefined {
if (isNullOrUndefined(script) || isNullOrUndefined(script.attributes)) {
return undefined;
}
const attribute = script.attributes[this._ATTRIBUTE_SRC_DIFFER_KEY];
return isNullOrUndefined(attribute) ? undefined : attribute.value;
}
private _getScriptWithValueEndWith(listScript: Element[], threeDimensionalLib: string): Element | undefined {
return listScript.find(script => {
const value = this._getValueScriptDiffer(script);
return isNotNullNorUndefined(value) && value.endsWith(threeDimensionalLib);
});
}
openUserGuideSidebar(): void {
this._store.dispatch(new AppAction.ChangeDisplaySidebarUserGuide(true));
}