From d9570b96e4230fb6b114c040260253e6fc812758 Mon Sep 17 00:00:00 2001
From: mdelez <60604010+mdelez@users.noreply.github.com>
Date: Tue, 9 Aug 2022 13:12:53 +0200
Subject: [PATCH] feat(projects): changes to nav bar (DEV-1101) (#790)
* feat(projects): changes to nav bar
* feat(projects): more changes to navbar
* feat(projects): even more changes to navbar
* feat(project): only show tooltips if the text is cut off
* test(collaboartion): attempt to fix constantly "failing" test
* test(permission): attempt to fix constantly "failing" test
* test(collaboration): attempt to fix constantly "failing" test
* remove fdescribe
* feat(project): allow click on entire accordion header to open the accordion. Only for signed out users for now until the onto editor is moved to the settings
* feat(project, ontology-class-item): rename method
---
src/app/main/status/status.component.spec.ts | 3 +-
.../ontology-class-item.component.html | 40 +++---
.../ontology-class-item.component.scss | 94 ++++++++++----
.../ontology-class-item.component.ts | 47 ++++++-
.../ontology-classes.component.html | 4 +-
.../collaboration.component.spec.ts | 6 +-
.../permission/permission.component.spec.ts | 16 ++-
src/app/project/project.component.html | 118 ++++++++++--------
src/app/project/project.component.scss | 26 +++-
src/app/project/project.component.ts | 10 ++
.../resource-list.component.html | 15 +--
.../resource-list/resource-list.component.ts | 28 ++++-
src/assets/style/_layout.scss | 64 +++++++---
13 files changed, 339 insertions(+), 132 deletions(-)
diff --git a/src/app/main/status/status.component.spec.ts b/src/app/main/status/status.component.spec.ts
index 96301a7ee3..4cc127ad1e 100644
--- a/src/app/main/status/status.component.spec.ts
+++ b/src/app/main/status/status.component.spec.ts
@@ -80,7 +80,8 @@ describe('StatusComponent', () => {
declarations: [
StatusComponent,
NoContentTestHostComponent,
- TeapotTestHostComponent
+ TeapotTestHostComponent,
+ MockPipe
],
imports: [
BrowserAnimationsModule,
diff --git a/src/app/project/beta/ontology-classes/ontology-class-item/ontology-class-item.component.html b/src/app/project/beta/ontology-classes/ontology-class-item/ontology-class-item.component.html
index bfbaf735ca..f7a9616a96 100644
--- a/src/app/project/beta/ontology-classes/ontology-class-item/ontology-class-item.component.html
+++ b/src/app/project/beta/ontology-classes/ontology-class-item/ontology-class-item.component.html
@@ -1,16 +1,24 @@
-
- {{resClass.label}}
-
- {{results | i18nPlural: itemPluralMapping['resource']}}
-
-
-
-
-
-
-
+
+
+
+
+
+
{{resClass.label}}
+
{{results | i18nPlural: itemPluralMapping['entry']}}
+
+
+
+
+ add_circle_outline
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/project/beta/ontology-classes/ontology-class-item/ontology-class-item.component.scss b/src/app/project/beta/ontology-classes/ontology-class-item/ontology-class-item.component.scss
index f9b039c6cd..80b72611df 100644
--- a/src/app/project/beta/ontology-classes/ontology-class-item/ontology-class-item.component.scss
+++ b/src/app/project/beta/ontology-classes/ontology-class-item/ontology-class-item.component.scss
@@ -1,33 +1,81 @@
@import "../../../../../assets/style/config";
-:host {
+
+.class-item-container {
width: 100%;
+ display: flex;
+ justify-content: center;
+ align-content: center;
+ padding: 10px 0px;
- &:hover {
- .hover-only {
- display: block;
+ .content {
+ width: 90%;
+ border-radius: 5px;
+ box-shadow: 0px 1px 3px rgb(0 0 0 / 10%), 0px 1px 2px rgb(0 0 0 / 6%);
+ border-bottom: 2px solid #F9FAFB;
+ &.is-active{
+ border-bottom: 2px solid #1F2937;
}
- }
-}
-.mat-line {
- width: 100%;
+ .top {
+ display: inline-flex;
+ align-items: center;
+ padding: 20px 0px;
+ width: 100%;
- &.label {
- display: flex;
- flex-direction: row;
+ .file-icon {
- }
- &.instances {
- color: $primary_500;
- }
-}
+ .icon-wrapper {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ width: 48px;
+ height: 48px;
+ background: #1F2937;
+ border-radius: 6px;
+ margin: 0px 20px;
-.overlay-buttons {
- position: absolute;
- right: 0;
- bottom: 12px;
-}
+ mat-icon {
+ color: white;
+ }
+ }
+ }
-.hover-only {
- display: none;
+ .info {
+
+ .label {
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+ padding-right: 16px;
+ color: #6B7280;
+ margin: 0px;
+ }
+
+ .entries {
+ color: #111827;
+ font-size: 24px;
+ margin: 0px;
+ padding-top: 5px;
+ }
+
+ }
+ }
+
+ .bottom {
+ display: flex;
+ align-items: center;
+ background: #F9FAFB;
+
+ .add-icon {
+ margin: 0px 10px;
+
+ mat-icon {
+ font-size: 32px;
+ width: 32px;
+ height: 32px;
+ }
+ }
+ }
+ }
}
diff --git a/src/app/project/beta/ontology-classes/ontology-class-item/ontology-class-item.component.ts b/src/app/project/beta/ontology-classes/ontology-class-item/ontology-class-item.component.ts
index 1f2a28a193..829de38035 100644
--- a/src/app/project/beta/ontology-classes/ontology-class-item/ontology-class-item.component.ts
+++ b/src/app/project/beta/ontology-classes/ontology-class-item/ontology-class-item.component.ts
@@ -1,6 +1,6 @@
import { Component, Inject, Input, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
-import { ClassDefinition, KnoraApiConnection, CountQueryResponse, ApiResponseError } from '@dasch-swiss/dsp-js';
+import { ClassDefinition, KnoraApiConnection, CountQueryResponse, ApiResponseError, Constants } from '@dasch-swiss/dsp-js';
import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
import { ErrorHandlerService } from 'src/app/main/services/error-handler.service';
import { OntologyService } from 'src/app/project/ontology/ontology.service';
@@ -22,11 +22,13 @@ export class OntologyClassItemComponent implements OnInit {
link: string;
+ icon: string;
+
// i18n setup
itemPluralMapping = {
- resource: {
- '=1': '1 resource',
- other: '# resources'
+ entry: {
+ '=1': '1 Entry',
+ other: '# Entries'
}
};
@@ -58,12 +60,24 @@ export class OntologyClassItemComponent implements OnInit {
this._errorHandler.showMessage(error);
}
);
+
+ this.icon = this._getIcon();
}
open(route: string) {
this._router.navigateByUrl(route);
}
+ /**
+ * given an Html element, compare the scrollHeight and the clientHeight
+ *
+ * @param elem the element which has the line-clamp css
+ * @returns inverse of comparison between the scrollHeight and the clientHeight of elem
+ */
+ compareElementHeights(elem: HTMLElement): boolean {
+ return !(elem.scrollHeight > elem.clientHeight);
+ }
+
private _setGravsearch(iri: string): string {
return `
PREFIX knora-api:
@@ -82,4 +96,29 @@ export class OntologyClassItemComponent implements OnInit {
OFFSET 0`;
}
+ /**
+ * return the correct mat-icon depending on the subclass of the resource
+ *
+ * @returns mat-icon name as string
+ */
+ private _getIcon(): string {
+
+ switch (this.resClass.subClassOf[0]) {
+ case Constants.AudioRepresentation:
+ return 'audio_file';
+ case Constants.ArchiveRepresentation:
+ return 'folder_zip';
+ case Constants.DocumentRepresentation:
+ return 'description';
+ case Constants.MovingImageRepresentation:
+ return 'video_file';
+ case Constants.StillImageRepresentation:
+ return 'image';
+ case Constants.TextRepresentation:
+ return 'text_snippet';
+ default: // resource does not have a file representation
+ return 'insert_drive_file';
+ }
+ }
+
}
diff --git a/src/app/project/beta/ontology-classes/ontology-classes.component.html b/src/app/project/beta/ontology-classes/ontology-classes.component.html
index 2a64e1fd60..7f77b32917 100644
--- a/src/app/project/beta/ontology-classes/ontology-classes.component.html
+++ b/src/app/project/beta/ontology-classes/ontology-classes.component.html
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/src/app/project/collaboration/collaboration.component.spec.ts b/src/app/project/collaboration/collaboration.component.spec.ts
index e27a0020d9..abd833d10b 100644
--- a/src/app/project/collaboration/collaboration.component.spec.ts
+++ b/src/app/project/collaboration/collaboration.component.spec.ts
@@ -32,7 +32,7 @@ describe('CollaborationComponent', () => {
beforeEach(waitForAsync(() => {
- const cacheServiceSpy = jasmine.createSpyObj('CacheService', ['get', 'set']);
+ const cacheServiceSpy = jasmine.createSpyObj('CacheService', ['get', 'set', 'del']);
TestBed.configureTestingModule({
declarations: [
@@ -141,6 +141,10 @@ describe('CollaborationComponent', () => {
fixture.detectChanges();
});
+ afterEach(() => {
+ fixture.destroy();
+ });
+
it('should create', () => {
expect(localStorage.getItem('session')).toBe(
JSON.stringify(TestConfig.CurrentSession)
diff --git a/src/app/project/permission/permission.component.spec.ts b/src/app/project/permission/permission.component.spec.ts
index 692fb02fe2..fc83a1c1b6 100644
--- a/src/app/project/permission/permission.component.spec.ts
+++ b/src/app/project/permission/permission.component.spec.ts
@@ -1,4 +1,5 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { Pipe, PipeTransform } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { MatDialogModule } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
@@ -18,6 +19,18 @@ import { TestConfig } from 'test.config';
import { AddGroupComponent } from './add-group/add-group.component';
import { PermissionComponent } from './permission.component';
+
+/**
+ * mocked linkify pipe from main/pipes.
+ */
+@Pipe({ name: 'appLinkify' })
+class MockPipe implements PipeTransform {
+ transform(value: string): string {
+ // do stuff here, if you want
+ return value;
+ }
+}
+
describe('PermissionComponent', () => {
let component: PermissionComponent;
let fixture: ComponentFixture;
@@ -32,7 +45,8 @@ describe('PermissionComponent', () => {
AddGroupComponent,
GroupsListComponent,
DialogComponent,
- StatusComponent
+ StatusComponent,
+ MockPipe
],
imports: [
BrowserAnimationsModule,
diff --git a/src/app/project/project.component.html b/src/app/project/project.component.html
index f072b95da2..ad72e5ab2a 100644
--- a/src/app/project/project.component.html
+++ b/src/app/project/project.component.html
@@ -17,89 +17,93 @@
+
+
+
+ {{project.longname}}
+
+
-
-
-
- {{project.longname}}
-
-
-
- {{project.shortname | uppercase}}
-
-
-
-
-
+
+
Go to projects overview
+
+
+ chevron_right
+
+
-
-
+
+
bubble_chart
- Data Models
+ Data models
+
+
+
+
+
+ add_circle_outline
+ Add a new data model
-
-
-
+
-
-
+
+
-