Skip to content

Commit

Permalink
Merge branch 'main' into feature/dev-2490-refactor-sessionservice-to-…
Browse files Browse the repository at this point in the history
…return-true-observables-that-also

* main:
  refactor(date picker): implement date picker as standalone component (#1251)
  fix(app/help): fix links to releases (#1253)
  fix(app/resource): removed developer feature that created annotation bug (#1254)
  feat(expert search): implement default gravsearch as placeholder (#1247)
  feat(project description): order project descriptions by language (#1250)

# Conflicts:
#	apps/dsp-app/src/app/project/description/description.component.ts
  • Loading branch information
irmastnt committed Oct 31, 2023
2 parents 3f2ec5b + e89dba8 commit 8370de6
Show file tree
Hide file tree
Showing 22 changed files with 145 additions and 203 deletions.
4 changes: 2 additions & 2 deletions apps/dsp-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ import {
BuildTagToken,
} from '@dasch-swiss/vre/shared/app-config';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { AppDatePickerModule } from '@dasch-swiss/vre/shared/app-date-picker';
import { AppDatePickerComponent } from '@dasch-swiss/vre/shared/app-date-picker';
import { AdvancedSearchComponent } from '@dasch-swiss/vre/advanced-search';
import { NgxsStoragePluginModule } from '@ngxs/storage-plugin';
import { apiConnectionTokenProvider } from './providers/api-connection-token.provider';
Expand Down Expand Up @@ -296,7 +296,7 @@ export function httpLoaderFactory(httpClient: HttpClient) {
],
imports: [
AngularSplitModule,
AppDatePickerModule,
AppDatePickerComponent,
AppProgressIndicatorComponent,
AppRoutingModule,
BrowserAnimationsModule,
Expand Down
9 changes: 3 additions & 6 deletions apps/dsp-app/src/app/main/help/help.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class HelpComponent implements OnInit {
{
title: 'DSP-API ',
text: 'Framework to store, share, and work with primary resources in the humanities.',
url: 'https://github.com/dasch-swiss/dsp-api/releases/tag/v',
url: 'https://github.com/dasch-swiss/dsp-api/releases/tag/',
urlText: 'Release notes',
},
{
Expand Down Expand Up @@ -108,11 +108,8 @@ export class HelpComponent implements OnInit {

this.support[0].url += this.dsp.environment + ': ' + this.dsp.release;

// quick solution; todo: has to be done in a better way
// to go directly to the page e.g. https://dasch.atlassian.net/wiki/spaces/changelog/pages/25067546/Releasenews+2022.01.02
// or https://dasch.atlassian.net/wiki/spaces/changelog/pages/21266446/Releasenews+2022.01.01
this.releaseNotesUrl =
'https://dasch.atlassian.net/wiki/search?text=' + this.dsp.release;
'https://github.com/dasch-swiss/dsp-das/releases/tag/v' + this.appVersion;

this._dspApiConnection.system.versionEndpoint.getVersion().subscribe(
(response: ApiResponseData<VersionResponse>) => {
Expand All @@ -124,7 +121,7 @@ export class HelpComponent implements OnInit {

// set dsp-api version
this.tools[1].title += this.apiVersion.webapi;
this.tools[1].url += this.apiVersion.webapi;
this.tools[1].url += this.apiVersion.webapi.split('-')[0];

// set dsp-sipi version
this.tools[2].title += this.apiVersion.sipi;
Expand Down
33 changes: 24 additions & 9 deletions apps/dsp-app/src/app/project/description/description.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { Select, Store } from '@ngxs/store';
import { map, take } from 'rxjs/operators';
import { ProjectsSelectors, UserSelectors } from '@dasch-swiss/vre/shared/app-state';
import {RouteConstants} from "@dasch-swiss/vre/shared/app-config";
import { StringLiteral } from '@dasch-swiss/dsp-js/src/models/admin/string-literal';
import { AppGlobal } from '@dsp-app/src/app/app-global';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down Expand Up @@ -63,17 +65,29 @@ export class DescriptionComponent implements OnInit {
}

ngOnInit() {
this.initProject();
}

// returns the project with the descriptions sorted by language
private projectWithSortedDescriptions(project: ReadProject): ReadProject {
if (project.description && project.description.length > 1) {
// sort the descriptions by language
project.description = this.sortDescriptionsByLanguage(project.description);
}
return project;
}

// returns the descriptions sorted by language
private sortDescriptionsByLanguage(descriptions: StringLiteral[]): StringLiteral[] {
const languageOrder = AppGlobal.languagesList.map((l) => l.language);

/**
* initProject: get the project data from the application state service and update
* if the user has permission to edit the project if not a sysadmin
*/
initProject() {

return descriptions.sort((a, b) => {
const indexA = languageOrder.indexOf(a.language);
const indexB = languageOrder.indexOf(b.language);

return indexA - indexB;
});
}

editProject() {
this._router.navigate([RouteConstants.project, this.projectUuid, RouteConstants.edit]);
}
Expand All @@ -83,6 +97,7 @@ export class DescriptionComponent implements OnInit {
return null;
}

return projects.find(x => x.id.split('/').pop() === this.projectUuid);
const project = projects.find(x => x.id.split('/').pop() === this.projectUuid);
return this.projectWithSortedDescriptions(project);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class TestHostCreateListComponent {
/**
* test component that mocks StringLiteralInputComponent
*/
@Component({ selector: 'app-string-literal-input', template: '' })
@Component({ selector: 'dasch-swiss-app-string-literal', template: '' })
class MockStringLiteralInputComponent {
@Input() placeholder = 'Label';
@Input() language: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { EditListItemComponent } from './edit-list-item.component';
import { MockProvider } from 'ng-mocks';
import { AppLoggingService } from '@dasch-swiss/vre/shared/app-logging';


/**
* test host component to simulate parent component for updating an existing child node.
*/
Expand Down Expand Up @@ -70,7 +71,7 @@ class TestHostInsertChildNodeComponent {
constructor() {}
}

@Component({ selector: 'app-string-literal-input', template: '' })
@Component({ selector: 'dasch-swiss-app-string-literal', template: '' })
class MockStringLiteralInputComponent {
@Input() placeholder = 'Label';
@Input() language: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ import { ApplicationStateService } from '@dasch-swiss/vre/shared/app-state-servi
import { MockProvider } from 'ng-mocks';
import { AppLoggingService } from '@dasch-swiss/vre/shared/app-logging';


@Component({
selector: 'dasch-swiss-app-progress-indicator',
template: '',
})
class MockProgressIndicatorComponent {}

/**
* test host component to simulate parent component.
*/
Expand Down Expand Up @@ -84,7 +91,7 @@ class TestHostComponent implements OnInit {
/**
* test component that mocks StringLiteralInputComponent
*/
@Component({ selector: 'app-string-literal-input', template: '' })
@Component({ selector: 'dasch-swiss-app-string-literal', template: '' })
class MockStringLiteralInputComponent {
@Input() placeholder = 'Label';
@Input() language: string;
Expand Down Expand Up @@ -128,6 +135,7 @@ describe('ListItemFormComponent', () => {
StringifyStringLiteralPipe,
TruncatePipe,
MockStringLiteralInputComponent,
MockProgressIndicatorComponent,
],
imports: [
BrowserAnimationsModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class ListHostComponent {
};
}

@Component({ selector: 'app-string-literal-input', template: '' })
@Component({ selector: 'dasch-swiss-app-string-literal', template: '' })
class MockStringLiteralInputComponent {
@Input() placeholder = 'Label';
@Input() language: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { ResourceClassFormComponent } from './resource-class-form.component';
import { MockProvider } from 'ng-mocks';
import { AppLoggingService } from '@dasch-swiss/vre/shared/app-logging';


/**
* test host component to simulate parent component.
*/
Expand All @@ -46,10 +47,9 @@ import { AppLoggingService } from '@dasch-swiss/vre/shared/app-logging';
})
class TestHostResourceClassFormComponent {}

@Component({ selector: 'app-string-literal-input', template: '' })
@Component({ selector: 'dasch-swiss-app-string-literal', template: '' })
class MockStringLiteralInputComponent {
@Input() placeholder = 'Label';
@Input() language: string;
@Input() textarea: boolean;
@Input() value: StringLiteral[] = [];
@Input() disabled: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { MockProvider } from 'ng-mocks';
import { AppLoggingService } from '@dasch-swiss/vre/shared/app-logging';
import {convertToParamMap} from "@angular/router";

@Component({ selector: 'app-string-literal-input', template: '' })
@Component({ selector: 'dasch-swiss-app-string-literal', template: '' })
class MockStringLiteralInputComponent {
@Input() placeholder = 'Label';
@Input() language: string;
Expand Down
2 changes: 1 addition & 1 deletion apps/dsp-app/src/app/project/project.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class MockOntologyClassesComponent {
}

@Component({
selector: 'app-progress-indicator',
selector: 'dasch-swiss-app-progress-indicator',
template: '',
})
class MockProgressIndicatorComponent {}
Expand Down
9 changes: 9 additions & 0 deletions apps/dsp-app/src/app/user/account/account.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ import { StatusComponent } from '@dsp-app/src/app/main/status/status.component';
import { TestConfig } from '@dsp-app/src/test.config';
import { PasswordFormComponent } from '../user-form/password-form/password-form.component';
import { AccountComponent } from './account.component';
import { Component } from '@angular/core';

@Component({
selector: 'dasch-swiss-app-progress-indicator',
template: '',
})
class MockProgressIndicatorComponent {}


describe('AccountComponent', () => {
let component: AccountComponent;
Expand All @@ -32,6 +40,7 @@ describe('AccountComponent', () => {
PasswordFormComponent,
DialogComponent,
StatusComponent,
MockProgressIndicatorComponent
],
imports: [
BrowserAnimationsModule,
Expand Down
16 changes: 15 additions & 1 deletion apps/dsp-app/src/app/user/profile/profile.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,28 @@ import { DialogComponent } from '@dsp-app/src/app/main/dialog/dialog.component';
import { StatusComponent } from '@dsp-app/src/app/main/status/status.component';
import { TestConfig } from '@dsp-app/src/test.config';
import { ProfileComponent } from './profile.component';
import { Component } from '@angular/core';


@Component({
selector: 'dasch-swiss-app-progress-indicator',
template: '',
})
class MockProgressIndicatorComponent {}


describe('ProfileComponent', () => {
let component: ProfileComponent;
let fixture: ComponentFixture<ProfileComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ProfileComponent, DialogComponent, StatusComponent],
declarations: [
ProfileComponent,
DialogComponent,
StatusComponent,
MockProgressIndicatorComponent
],
imports: [
BrowserAnimationsModule,
MatButtonModule,
Expand Down
2 changes: 1 addition & 1 deletion apps/dsp-app/src/app/user/user.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { AppLoggingService } from '@dasch-swiss/vre/shared/app-logging';
* test component to simulate child component, here progress-indicator from action module.
*/
@Component({
selector: 'app-progress-indicator',
selector: 'dasch-swiss-app-progress-indicator',
template: '',
})
class TestProgressIndicatorComponent {}
Expand Down
10 changes: 0 additions & 10 deletions apps/dsp-app/src/app/workspace/resource/resource.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,16 +583,6 @@ export class ResourceComponent implements OnChanges, OnDestroy {
representations.push(stillImage);

this.annotationResources = annotations;

// developer feature: this keeps the annotations tab open, if you add "/annotations" to the end of the URL
// e.g. http://0.0.0.0:4200/resource/[project-shortcode]/[resource-iri]/annotations
if (
this.valueUuid === 'annotations' ||
this.selectedRegion === this.resourceIri
) {
this.selectedTab = this.incomingResource ? 2 : 1;
this.selectedTabLabel = 'annotations';
}
}
} else if (resource.res.properties[Constants.HasDocumentFileValue]) {
const fileValues: ReadDocumentFileValue[] = resource.res.properties[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<form [formGroup]="expertSearchForm" class="expert-search-form app-form-content">
<mat-form-field class="textarea-field large-field">
<mat-label>Write your Gravsearch query</mat-label>
<textarea matInput [formControlName]="'gravsearchquery'" cdkTextareaAutosize cdkAutosizeMinRows="12"
<textarea
#textArea
matInput
[formControlName]="'gravsearchquery'"
[placeholder]='defaultGravsearchQuery'
cdkTextareaAutosize cdkAutosizeMinRows="12"
cdkAutosizeMaxRows="24" class="textarea-field-content">
</textarea>
<mat-error *ngIf="expertSearchForm.controls.gravsearchquery.hasError('forbiddenName')">
Expand Down

0 comments on commit 8370de6

Please sign in to comment.