Skip to content

Commit

Permalink
fix: initiates new search when user is logged in sucessfully (DEV-3293)…
Browse files Browse the repository at this point in the history
… (#1469)
  • Loading branch information
irmastnt committed Feb 15, 2024
1 parent 1db2ae5 commit 70f7f25
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 55 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -54,7 +54,7 @@ The most common commands are defined in `package.json`.
| `nx run dsp-app:serve:test-server` | `npm run start-with-test-server` |
| `nx run dsp-app:serve:dev-server` | `npm run start-with-dev-server` |
| `nx run dsp-app:serve:ls-test-server` | `npm run start-with-ls-test-server` |
| `nx run dsp-app:serve:staging-server` | `npm run start-with-staging-server` |
| `nx run dsp-app:serve:stage-server` | `npm run start-with-stage-server` |
| `nx run dsp-app:serve:0845-test-server` | `npm run start-with-0845-server` |
| `nx run dsp-app:lint` | `npm run lint-ci` |
| `nx run dsp-app:lint --fix` | `npm run lint-local` |
Expand Down
32 changes: 21 additions & 11 deletions apps/dsp-app/project.json
Expand Up @@ -12,7 +12,9 @@
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
"outputs": ["{options.outputPath}"],
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/apps/dsp-app",
"index": "apps/dsp-app/src/index.html",
Expand All @@ -37,7 +39,9 @@
"output": "/assets/"
}
],
"styles": ["apps/dsp-app/src/styles.scss"],
"styles": [
"apps/dsp-app/src/styles.scss"
],
"scripts": [
"node_modules/openseadragon/build/openseadragon/openseadragon.min.js"
]
Expand Down Expand Up @@ -133,11 +137,11 @@
"vendorChunk": false,
"buildOptimizer": false
},
"staging-server": {
"stage-server": {
"fileReplacements": [
{
"replace": "apps/dsp-app/src/environments/environment.ts",
"with": "apps/dsp-app/src/environments/environment.staging-server.ts"
"with": "apps/dsp-app/src/environments/environment.stage-server.ts"
}
],
"optimization": false,
Expand Down Expand Up @@ -175,8 +179,8 @@
"0845-test-server": {
"browserTarget": "dsp-app:build:ls-test-server"
},
"staging-server": {
"browserTarget": "dsp-app:build:staging-server"
"stage-server": {
"browserTarget": "dsp-app:build:stage-server"
}
}
},
Expand All @@ -188,10 +192,14 @@
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"outputs": [
"{options.outputFile}"
],
"options": {
"lintFilePatterns": ["apps/dsp-app/**/*.{ts,html}"]
}
"lintFilePatterns": [
"apps/dsp-app/**/*.{ts,html}"
]
}
},
"test": {
"executor": "@angular-devkit/build-angular:karma",
Expand All @@ -201,7 +209,9 @@
"tsConfig": "apps/dsp-app/tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"karmaConfig": "apps/dsp-app/karma.conf.js",
"styles": ["apps/dsp-app/src/styles.scss"],
"styles": [
"apps/dsp-app/src/styles.scss"
],
"scripts": [
"node_modules/openseadragon/build/openseadragon/openseadragon.min.js"
],
Expand Down Expand Up @@ -243,4 +253,4 @@
}
}
}
}
}
Expand Up @@ -12,7 +12,12 @@ import {
import { ActivatedRoute } from '@angular/router';
import { ClassDefinition, Constants } from '@dasch-swiss/dsp-js';
import { RouteConstants } from '@dasch-swiss/vre/shared/app-config';
import { OntologyService } from '@dasch-swiss/vre/shared/app-helper-services';
import {
ComponentCommunicationEventService,
EmitEvent,
Events,
OntologyService,
} from '@dasch-swiss/vre/shared/app-helper-services';
import {
IClassItemsKeyValuePairs,
LoadClassItemsCountAction,
Expand All @@ -21,11 +26,6 @@ import {
import { Actions, Select, Store, ofActionSuccessful } from '@ngxs/store';
import { Observable, Subject, Subscription, combineLatest } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import {
ComponentCommunicationEventService,
EmitEvent,
Events,
} from '../../../main/services/component-communication-event.service';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
7 changes: 5 additions & 2 deletions apps/dsp-app/src/app/project/project.component.ts
Expand Up @@ -14,12 +14,15 @@ import { ReadOntology, ReadProject } from '@dasch-swiss/dsp-js';
import { ClassAndPropertyDefinitions } from '@dasch-swiss/dsp-js/src/models/v2/ontologies/ClassAndPropertyDefinitions';
import { getAllEntityDefinitionsAsArray } from '@dasch-swiss/vre/shared/app-api';
import { RouteConstants } from '@dasch-swiss/vre/shared/app-config';
import { ProjectService } from '@dasch-swiss/vre/shared/app-helper-services';
import {
ComponentCommunicationEventService,
Events,
ProjectService,
} from '@dasch-swiss/vre/shared/app-helper-services';
import { OntologiesSelectors, ProjectsSelectors } from '@dasch-swiss/vre/shared/app-state';
import { Actions, Select, Store } from '@ngxs/store';
import { Observable, Subject, Subscription, combineLatest } from 'rxjs';
import { filter, map, take, takeUntil } from 'rxjs/operators';
import { ComponentCommunicationEventService, Events } from '../main/services/component-communication-event.service';
import { ProjectBase } from './project-base';

type AvailableRoute =
Expand Down
Expand Up @@ -38,17 +38,19 @@ import {
} from '@dasch-swiss/dsp-js';
import { ProjectApiService } from '@dasch-swiss/vre/shared/app-api';
import { DspApiConnectionToken } from '@dasch-swiss/vre/shared/app-config';
import { OntologyService, ProjectService, SortingService } from '@dasch-swiss/vre/shared/app-helper-services';
import {
Events as CommsEvents,
ComponentCommunicationEventService,
EmitEvent,
OntologyService,
ProjectService,
SortingService,
} from '@dasch-swiss/vre/shared/app-helper-services';
import { NotificationService } from '@dasch-swiss/vre/shared/app-notification';
import { LoadClassItemsCountAction } from '@dasch-swiss/vre/shared/app-state';
import { Store } from '@ngxs/store';
import { forkJoin, Observable, Subscription } from 'rxjs';
import { Observable, Subscription, forkJoin } from 'rxjs';
import { ConfirmationWithComment, DialogComponent } from '../../../main/dialog/dialog.component';
import {
ComponentCommunicationEventService,
EmitEvent,
Events as CommsEvents,
} from '../../../main/services/component-communication-event.service';
import { DspResource } from '../dsp-resource';
import { RepresentationConstants } from '../representation/file-representation';
import { IncomingService } from '../services/incoming.service';
Expand Down
Expand Up @@ -11,7 +11,6 @@ import {
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import {
ApiResponseError,
Constants,
CreateFileValue,
CreateResource,
Expand All @@ -24,16 +23,17 @@ import {
ResourcePropertyDefinition,
} from '@dasch-swiss/dsp-js';
import { DspApiConnectionToken } from '@dasch-swiss/vre/shared/app-config';
import { DefaultClass, DefaultResourceClasses } from '@dasch-swiss/vre/shared/app-helper-services';
import {
Events as CommsEvents,
ComponentCommunicationEventService,
DefaultClass,
DefaultResourceClasses,
EmitEvent,
} from '@dasch-swiss/vre/shared/app-helper-services';
import { NotificationService } from '@dasch-swiss/vre/shared/app-notification';
import { LoadClassItemsCountAction } from '@dasch-swiss/vre/shared/app-state';
import { Store } from '@ngxs/store';
import { tap } from 'rxjs/operators';
import {
ComponentCommunicationEventService,
EmitEvent,
Events as CommsEvents,
} from '../../../main/services/component-communication-event.service';
import { ResourceService } from '../services/resource.service';
import { SelectPropertiesComponent } from './select-properties/select-properties.component';

Expand Down
Expand Up @@ -19,15 +19,11 @@ import {
ReadResourceSequence,
} from '@dasch-swiss/dsp-js';
import { DspApiConnectionToken, RouteConstants } from '@dasch-swiss/vre/shared/app-config';
import { ComponentCommunicationEventService, EmitEvent, Events } from '@dasch-swiss/vre/shared/app-helper-services';
import { NotificationService } from '@dasch-swiss/vre/shared/app-notification';
import { Store } from '@ngxs/store';
import { Subject, Subscription, combineLatest, of } from 'rxjs';
import { map, takeUntil, tap } from 'rxjs/operators';
import {
ComponentCommunicationEventService,
EmitEvent,
Events,
} from '../../../main/services/component-communication-event.service';

/**
* query: search query. It can be gravserch query or fulltext string query.
Expand Down Expand Up @@ -138,6 +134,7 @@ export class ListViewComponent implements OnChanges, OnInit, OnDestroy {

ngOnInit(): void {
this.componentCommsSubscriptions.push(
this._componentCommsService.on(Events.loginSuccess, () => this.initSearch()),
this._componentCommsService.on(Events.resourceChanged, () => this._doSearch()),
this._componentCommsService.on(Events.resourceDeleted, () => this._doSearch())
);
Expand Down
Expand Up @@ -16,14 +16,14 @@ import {
import { MatMenuTrigger } from '@angular/material/menu';
import { ApiResponseError, Constants, ReadProject } from '@dasch-swiss/dsp-js';
import { ProjectApiService } from '@dasch-swiss/vre/shared/app-api';
import { SortingService } from '@dasch-swiss/vre/shared/app-helper-services';
import { NotificationService } from '@dasch-swiss/vre/shared/app-notification';
import { Subscription } from 'rxjs';
import { tap } from 'rxjs/operators';
import {
ComponentCommunicationEventService,
Events,
} from '../../../main/services/component-communication-event.service';
SortingService,
} from '@dasch-swiss/vre/shared/app-helper-services';
import { NotificationService } from '@dasch-swiss/vre/shared/app-notification';
import { Subscription } from 'rxjs';
import { tap } from 'rxjs/operators';
import { SearchParams } from '../../results/list-view/list-view.component';

export interface PrevSearchItem {
Expand Down
@@ -1,22 +1,22 @@
{
"dspRelease": "2023.05.03",
"apiProtocol": "https",
"apiHost": "api.staging.dasch.swiss",
"apiHost": "api.stage.dasch.swiss",
"apiPort": 443,
"apiPath": "",
"iiifProtocol": "https",
"iiifHost": "iiif.staging.dasch.swiss",
"iiifHost": "iiif.stage.dasch.swiss",
"iiifPort": 443,
"iiifPath": "",
"geonameToken": "knora",
"jsonWebToken": "",
"logErrors": true,
"iriBase": "http://rdfh.ch",
"instrumentation": {
"environment": "staging-server",
"environment": "stage-server",
"rollbar": {
"enabled": false,
"accessToken": ""
}
}
}
}
Expand Up @@ -7,7 +7,7 @@
import packageJson from '../../../../package.json';

export const environment = {
name: 'staging-server',
name: 'stage-server',
production: false,
version: packageJson.version,
};
Expand Down
Expand Up @@ -36,7 +36,7 @@ export class AppConfigService {
const prodMode = env.includes('prod') || env.includes('production');
let color = 'primary';
if (!prodMode) {
if (env.includes('staging') || env.includes('dev')) {
if (env.includes('stage') || env.includes('dev')) {
color = 'accent';
} else if (env.includes('test')) {
color = 'warn';
Expand Down
1 change: 1 addition & 0 deletions libs/vre/shared/app-helper-services/src/index.ts
@@ -1,3 +1,4 @@
export * from './lib/component-communication-event.service';
export * from './lib/default-data/default-properties';
export * from './lib/default-data/default-resource-classes';
export * from './lib/ontology-class.service';
Expand Down
Expand Up @@ -16,7 +16,7 @@ export class ComponentCommunicationEventService {
return this._subject$
.pipe(
// filter down based on event name to any events that are emitted out of the subject from the emit method below.
filter((e: EmitEvent) => e.name === event && (e.value == null || e.value === true)),
filter((e: EmitEvent) => e.name === event && (e.value == null || e.value === true)) as any,
map((e: EmitEvent) => e.value)
)
.subscribe(action); // subscribe to the subject to get the data.
Expand Down
10 changes: 8 additions & 2 deletions libs/vre/shared/app-session/src/lib/auth.service.ts
@@ -1,8 +1,12 @@
import { Inject, Injectable } from '@angular/core';

import { ApiResponseData, ApiResponseError, KnoraApiConnection, LoginResponse } from '@dasch-swiss/dsp-js';
import { DspApiConnectionToken } from '@dasch-swiss/vre/shared/app-config';
import { AppError } from '@dasch-swiss/vre/shared/app-error-handler';
import {
Events as CommsEvents,
ComponentCommunicationEventService,
EmitEvent,
} from '@dasch-swiss/vre/shared/app-helper-services';
import {
ClearListsAction,
ClearOntologiesAction,
Expand All @@ -22,7 +26,8 @@ export class AuthService {
private store: Store,
private _accessTokenService: AccessTokenService,
@Inject(DspApiConnectionToken)
private _dspApiConnection: KnoraApiConnection
private _dspApiConnection: KnoraApiConnection,
private _componentCommsService: ComponentCommunicationEventService
) {}

isCredentialsValid$() {
Expand Down Expand Up @@ -52,6 +57,7 @@ export class AuthService {
const encodedJWT = (response as ApiResponseData<LoginResponse>).body.token;
this._accessTokenService.storeToken(encodedJWT);
this._dspApiConnection.v2.jsonWebToken = encodedJWT;
this._componentCommsService.emit(new EmitEvent(CommsEvents.loginSuccess));
}),
catchError(error => {
if ((error instanceof ApiResponseError && error.status === 400) || error.status === 401) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -13,7 +13,7 @@
"start-with-dev-server": "nx run dsp-app:serve:dev-server",
"start-with-ls-test-server": "nx run dsp-app:serve:ls-test-server",
"start-with-0845-test-server": "nx run dsp-app:serve:0845-test-server",
"start-with-staging-server": "nx run dsp-app:serve:staging-server",
"start-with-stage-server": "nx run dsp-app:serve:stage-server",
"generate-openapi-module": "cd libs/vre/open-api && rm -rf src/lib/generated && npx openapi-generator-cli generate",
"e2e-local": "cd apps/dsp-app && npx cypress open",
"e2e-ci-dev": "nx run dsp-app:e2e:development",
Expand Down Expand Up @@ -151,4 +151,4 @@
"publishConfig": {
"registry": "https://npm.pkg.github.com/dasch-swiss"
}
}
}

0 comments on commit 70f7f25

Please sign in to comment.