diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index e5bb184f8..c8c054f8d 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -20,11 +20,10 @@ const appRoutes: Routes = [ pathMatch: 'full' }, { - path: 'datasetcreatewizard', - loadChildren: () => import('./ui/dataset-create-wizard/dataset-create-wizard.module').then(m => m.DatasetCreateWizardModule), + path: 'home', + loadChildren: () => import('./ui/dashboard/dashboard.module').then(m => m.DashboardModule), data: { - breadcrumb: true, - title: 'GENERAL.TITLES.DATASETCREATEWIZARD' + breadcrumb: true } }, { @@ -43,23 +42,6 @@ const appRoutes: Routes = [ title: 'GENERAL.TITLES.EXPLORE' } }, - { - path: 'about', - loadChildren: () => import('./ui/about/about.module').then(m => m.AboutModule), - data: { - breadcrumb: true, - title: 'GENERAL.TITLES.ABOUT' - } - }, - // ----------- UNCOMMENT TO ADD AGAIN GRANTS -------- - // { - // path: 'grants', - // loadChildren: () => import('./ui/grant/grant.module').then(m => m.GrantModule), - // data: { - // breadcrumb: true, - // title: 'GENERAL.TITLES.GRANTS' - // } - // }, { path: 'plans', loadChildren: () => import('./ui/dmp/dmp.module').then(m => m.DmpModule), @@ -88,6 +70,36 @@ const appRoutes: Routes = [ }) } }, + + + + { + path: 'datasetcreatewizard', + loadChildren: () => import('./ui/dataset-create-wizard/dataset-create-wizard.module').then(m => m.DatasetCreateWizardModule), + data: { + breadcrumb: true, + title: 'GENERAL.TITLES.DATASETCREATEWIZARD' + } + }, + + { + path: 'about', + loadChildren: () => import('./ui/about/about.module').then(m => m.AboutModule), + data: { + breadcrumb: true, + title: 'GENERAL.TITLES.ABOUT' + } + }, + // ----------- UNCOMMENT TO ADD AGAIN GRANTS -------- + // { + // path: 'grants', + // loadChildren: () => import('./ui/grant/grant.module').then(m => m.GrantModule), + // data: { + // breadcrumb: true, + // title: 'GENERAL.TITLES.GRANTS' + // } + // }, + { path: 'quick-wizard', loadChildren: () => import('./ui/quick-wizard/quick-wizard.module').then(m => m.OuickWizardModule), @@ -192,13 +204,7 @@ const appRoutes: Routes = [ title: 'GENERAL.TITLES.COOKIES-POLICY' } }, - { - path: 'home', - loadChildren: () => import('./ui/dashboard/dashboard.module').then(m => m.DashboardModule), - data: { - breadcrumb: true - } - }, + // { // path: 'splash', // loadChildren: () => import('./ui/splash/splash.module').then(m => m.SplashModule), diff --git a/dmp-frontend/src/app/core/common/enum/recent-activity-item-type.ts b/dmp-frontend/src/app/core/common/enum/recent-activity-item-type.ts new file mode 100644 index 000000000..c999a8e12 --- /dev/null +++ b/dmp-frontend/src/app/core/common/enum/recent-activity-item-type.ts @@ -0,0 +1,4 @@ +export enum RecentActivityItemType { + Dmp = 0, + Description = 1 +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/common/enum/recent-activity-order.ts b/dmp-frontend/src/app/core/common/enum/recent-activity-order.ts index bfed5fac8..7956e8ee5 100644 --- a/dmp-frontend/src/app/core/common/enum/recent-activity-order.ts +++ b/dmp-frontend/src/app/core/common/enum/recent-activity-order.ts @@ -1,4 +1,9 @@ export enum RecentActivityOrder { + UpdatedAt = 0, + Label = 1, + Status = 2, + + //TODO: delete them since these are from the prerefactor model LABEL = "label", CREATED = "created", MODIFIED = "modified", diff --git a/dmp-frontend/src/app/core/common/enum/recent-activity-type.ts b/dmp-frontend/src/app/core/common/enum/recent-activity-type.ts deleted file mode 100644 index 34ddb808e..000000000 --- a/dmp-frontend/src/app/core/common/enum/recent-activity-type.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum RecentActivityType { - Grant = 0, - Dataset = 1, - Dmp = 2 -} diff --git a/dmp-frontend/src/app/core/model/dashboard/dashboard-statistics-model.ts b/dmp-frontend/src/app/core/model/dashboard/dashboard-statistics-model.ts deleted file mode 100644 index 1b11ace71..000000000 --- a/dmp-frontend/src/app/core/model/dashboard/dashboard-statistics-model.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface DashboardStatisticsModel { - totalDataManagementPlanCount: number; - totalGrantCount: number; - totalDataSetCount: number; - totalOrganisationCount: number; -} diff --git a/dmp-frontend/src/app/core/model/dashboard/dashboard-statistics.ts b/dmp-frontend/src/app/core/model/dashboard/dashboard-statistics.ts new file mode 100644 index 000000000..e7ad0f895 --- /dev/null +++ b/dmp-frontend/src/app/core/model/dashboard/dashboard-statistics.ts @@ -0,0 +1,6 @@ +export interface DashboardStatistics { + dmpCount: number; + descriptionCount: number; + organizationCount: number; + grantCount: number; +} diff --git a/dmp-frontend/src/app/core/model/dashboard/recent-activity-item.ts b/dmp-frontend/src/app/core/model/dashboard/recent-activity-item.ts new file mode 100644 index 000000000..9c17bbf07 --- /dev/null +++ b/dmp-frontend/src/app/core/model/dashboard/recent-activity-item.ts @@ -0,0 +1,9 @@ +import { RecentActivityItemType } from "@app/core/common/enum/recent-activity-item-type"; +import { Description } from "../description/description"; +import { Dmp } from "../dmp/dmp"; + +export interface RecentActivityItem { + type: RecentActivityItemType; + dmp: Dmp; + description: Description; +} diff --git a/dmp-frontend/src/app/core/model/recent-activity/recent-activity.model.ts b/dmp-frontend/src/app/core/model/recent-activity/recent-activity.model.ts deleted file mode 100644 index 2102171e2..000000000 --- a/dmp-frontend/src/app/core/model/recent-activity/recent-activity.model.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { RecentActivityType } from '@app/core/common/enum/recent-activity-type'; -import { UserInfoListingModel } from '../user/user-info-listing'; -import { DatasetProfileModel } from '../dataset/dataset-profile'; - -export class RecentActivityModel { - id: string; - title: string; - description: String; - created: Date; - modified: Date; - status: number; - version: number; - grant: String; - grantAbbreviation: String; - grantId: String; - finalizedAt: Date; - publishedAt: Date; - profile: DatasetProfileModel; - type: RecentActivityType; - users: UserInfoListingModel[]; - public: boolean; -} - diff --git a/dmp-frontend/src/app/core/model/recent-activity/recent-dataset-activity.model.ts b/dmp-frontend/src/app/core/model/recent-activity/recent-dataset-activity.model.ts deleted file mode 100644 index 5fb6bca2b..000000000 --- a/dmp-frontend/src/app/core/model/recent-activity/recent-dataset-activity.model.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { RecentActivityModel } from "./recent-activity.model"; - -export class RecentDatasetModel extends RecentActivityModel { - dmp: String; - dmpId: String; - dataRepositories: String; - registries: String; - services: String; -} diff --git a/dmp-frontend/src/app/core/model/recent-activity/recent-dmp-activity.model.ts b/dmp-frontend/src/app/core/model/recent-activity/recent-dmp-activity.model.ts deleted file mode 100644 index b9037b771..000000000 --- a/dmp-frontend/src/app/core/model/recent-activity/recent-dmp-activity.model.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { DatasetUrlListing } from '../dataset/dataset-url-listing'; -import { RecentActivityModel } from './recent-activity.model'; - -export class RecentDmpModel extends RecentActivityModel { - doi: String; - extraProperties: Map; - datasets: DatasetUrlListing[]; - organisations: String; - groupId: string; -} diff --git a/dmp-frontend/src/app/core/query/recent-activity-item-lookup.lookup.ts b/dmp-frontend/src/app/core/query/recent-activity-item-lookup.lookup.ts new file mode 100644 index 000000000..b22f8fdde --- /dev/null +++ b/dmp-frontend/src/app/core/query/recent-activity-item-lookup.lookup.ts @@ -0,0 +1,25 @@ +import { Lookup } from "@common/model/lookup"; +import { RecentActivityOrder } from "../common/enum/recent-activity-order"; +import { ReferenceType } from "../common/enum/reference-type"; + +export class RecentActivityItemLookup implements RecentActivityItemFilter { + like: string; + onlyDraft: boolean; + userIds: string; + page: Lookup.Paging; + project: Lookup.FieldDirectives; + orderField: RecentActivityOrder; + + constructor() { + } +} + + +export interface RecentActivityItemFilter { + like: string; + onlyDraft: boolean; + userIds: string; + page: Lookup.Paging; + project: Lookup.FieldDirectives; + orderField: RecentActivityOrder; +} \ No newline at end of file diff --git a/dmp-frontend/src/app/core/query/recent-activity/recent-activity-criteria.ts b/dmp-frontend/src/app/core/query/recent-activity/recent-activity-criteria.ts deleted file mode 100644 index 8b6e134db..000000000 --- a/dmp-frontend/src/app/core/query/recent-activity/recent-activity-criteria.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; -import { BaseCriteria } from '../base-criteria'; - -export class RecentActivityCriteria extends BaseCriteria{ - public status?: Number; - public order: RecentActivityOrder = RecentActivityOrder.MODIFIED; -} diff --git a/dmp-frontend/src/app/core/services/dashboard/dashboard.service.ts b/dmp-frontend/src/app/core/services/dashboard/dashboard.service.ts index fac61010b..5c82b3a14 100644 --- a/dmp-frontend/src/app/core/services/dashboard/dashboard.service.ts +++ b/dmp-frontend/src/app/core/services/dashboard/dashboard.service.ts @@ -1,38 +1,38 @@ import { HttpHeaders } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { environment } from '../../../../environments/environment'; -import { DashboardStatisticsModel } from '../../model/dashboard/dashboard-statistics-model'; -import { BaseHttpService } from '../http/base-http.service'; +import { DashboardStatistics } from '@app/core/model/dashboard/dashboard-statistics'; +import { RecentActivityItem } from '@app/core/model/dashboard/recent-activity-item'; +import { RecentActivityItemLookup } from '@app/core/query/recent-activity-item-lookup.lookup'; +import { Observable, throwError } from 'rxjs'; +import { catchError } from 'rxjs/operators'; import { ConfigurationService } from '../configuration/configuration.service'; -import { RecentActivityModel } from '@app/core/model/recent-activity/recent-activity.model'; -import { RecentActivityCriteria } from '@app/core/query/recent-activity/recent-activity-criteria'; -import { DataTableRequest, DataTableMultiTypeRequest } from '@app/core/model/data-table/data-table-request'; +import { BaseHttpV2Service } from '../http/base-http-v2.service'; @Injectable() export class DashboardService { - private headers: HttpHeaders; + private headers = new HttpHeaders(); + + constructor( + private http: BaseHttpV2Service, + private configurationService: ConfigurationService, + ) { + } + private get apiBase(): string { return `${this.configurationService.server}dashboard`; } - - constructor(private http: BaseHttpService, - private configurationService: ConfigurationService) { + getMyRecentActivityItems(q: RecentActivityItemLookup): Observable { + const url = `${this.apiBase}/mine/recent-activity`; + return this.http.post(url, q).pipe(catchError((error: any) => throwError(error))); } - getStatistics(): Observable { - return this.http.get(`${this.apiBase}/getStatistics`, { headers: this.headers }); + getMyDashboardStatistics(): Observable { + const url = `${this.apiBase}/mine/get-statistics`; + return this.http.get(url).pipe(catchError((error: any) => throwError(error))); } - getUserStatistics(): Observable { - return this.http.get(`${this.apiBase}/me/getStatistics`, { headers: this.headers }); + getPublicDashboardStatistics(): Observable { + const url = `${this.apiBase}/public/get-statistics`; + return this.http.get(url).pipe(catchError((error: any) => throwError(error))); } - - getRecentActivity(request: DataTableMultiTypeRequest): Observable { - return this.http.post(`${this.apiBase}/recentActivity`, request, {headers: this.headers}); - } - - // getRecentActivity(request: DataTableRequest): Observable> { - // return this.http.post>(this.actionUrl + 'recentActivity', request, {headers: this.headers}); - // } } diff --git a/dmp-frontend/src/app/ui/dashboard/card/card.component.html b/dmp-frontend/src/app/ui/dashboard/card/card.component.html deleted file mode 100644 index 9106d0fea..000000000 --- a/dmp-frontend/src/app/ui/dashboard/card/card.component.html +++ /dev/null @@ -1,14 +0,0 @@ -
-
- {{ headerIcon }} -
-
-

{{ category | translate }}

-

{{ title }}

- -
- -
diff --git a/dmp-frontend/src/app/ui/dashboard/card/card.component.scss b/dmp-frontend/src/app/ui/dashboard/card/card.component.scss deleted file mode 100644 index 3b7eed15a..000000000 --- a/dmp-frontend/src/app/ui/dashboard/card/card.component.scss +++ /dev/null @@ -1,68 +0,0 @@ -.figure-card { - display: inline-block; - position: relative; - width: 100%; - margin: 25px 0; -} - -.card-content { - text-align: center; - padding: 15px 20px 13px 20px; -} - -.card-header { - float: left; - text-align: center; - /*background: linear-gradient(60deg, #ffa726, #fb8c00);*/ - /*box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(255, 152, 0, 0.4);*/ - margin: -20px 15px 0; - border-radius: 3px; - padding: 15px; - position: relative; -} - -.clickable{ - cursor: pointer; -} - -.card-header i { - font-size: 36px; - line-height: 56px; - width: 56px; - height: 56px; - color: #fff; -} - -.category { - color: #999; -} - -.card-footer { - margin: 0 20px 10px; - padding-top: 10px; - border-top: 1px solid #eee; - color: #999; - font-size: 12px; - position: relative; -} - -.card-footer i { - font-size: 16px; - position: relative; - top: 4px; - color: #999; -} - -.card { - padding: 25px 20px 20px 20px; - display: flex; - flex-direction: column; - align-items: center; -} - -.card { - box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.14); - border-radius: 6px; - color: rgba(0, 0, 0, 0.87); - background: #fff; -} diff --git a/dmp-frontend/src/app/ui/dashboard/card/card.component.ts b/dmp-frontend/src/app/ui/dashboard/card/card.component.ts deleted file mode 100644 index 15bae14d2..000000000 --- a/dmp-frontend/src/app/ui/dashboard/card/card.component.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Component, Input, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; -import { AuthService } from '../../../core/services/auth/auth.service'; - -@Component({ - selector: 'app-dashboard-card', - templateUrl: './card.component.html', - styleUrls: ['./card.component.scss'] -}) -export class CardComponent implements OnInit { - @Input() headerIcon: string; - @Input() category: string; - @Input() title: string; - @Input() footerIcon: string; - @Input() footContent: string; - @Input() linearColor: string; - @Input() boxShadow: string; - @Input() routelLink: string; - @Input() hasFootContent = false; - @Input() buttonTitle: string; - @Input() buttonRedirectLink: string; - - constructor(private router: Router, private authService: AuthService) { } - - ngOnInit() { - } - - navigateToUrl() { - if (!this.isAuthenticated()) { return; } - this.router.navigate([this.routelLink]); - } - - createNew() { - this.router.navigate([this.buttonRedirectLink]); - } - - isAuthenticated() { - return this.authService.currentAccountIsAuthenticated(); - } - -} diff --git a/dmp-frontend/src/app/ui/dashboard/dashboard.component.html b/dmp-frontend/src/app/ui/dashboard/dashboard.component.html index 18fa44347..a118f2776 100644 --- a/dmp-frontend/src/app/ui/dashboard/dashboard.component.html +++ b/dmp-frontend/src/app/ui/dashboard/dashboard.component.html @@ -1,186 +1,163 @@
-
-
-
-
- clear +
+
+
+
+ clear -

{{'DASHBOARD.DMP-QUESTION' | translate}}

-

{{'DASHBOARD.INFO-DMP-TEXT' | translate}}

+

{{'DASHBOARD.DMP-QUESTION' | translate}}

+

{{'DASHBOARD.INFO-DMP-TEXT' | translate}}

-

- {{'DASHBOARD.NEW-QUESTION' | translate}} {{'DASHBOARD.OPEN-AIR-GUIDE' | translate}} {{'DASHBOARD.LEARN-MORE' | translate}} -

-

{{'DASHBOARD.DMP-ABOUT-BEG' | translate}} - {{'DASHBOARD.DATASET-DESCRIPTIONS-DASHBOARD-TEXT' | translate}} - {{'DASHBOARD.DMP-ABOUT-END' | translate}} -

+

+ {{'DASHBOARD.NEW-QUESTION' | translate}} {{'DASHBOARD.OPEN-AIR-GUIDE' | translate}} {{'DASHBOARD.LEARN-MORE' | translate}} +

+

{{'DASHBOARD.DMP-ABOUT-BEG' | translate}} + {{'DASHBOARD.DATASET-DESCRIPTIONS-DASHBOARD-TEXT' | translate}} + {{'DASHBOARD.DMP-ABOUT-END' | translate}} +

-
-
- -
-
- -
- - - +
+
+
-
- -
-
{{'DASHBOARD.LATEST-ACTIVITY' | translate}}
- - - - -
{{'DASHBOARD.EMPTY-LIST' | translate}}
-
- - - -
{{'DASHBOARD.EMPTY-LIST' | translate}}
-
> - - - -
{{'DASHBOARD.EMPTY-LIST' | translate}}
-
- - - -
{{'DASHBOARD.EMPTY-LIST' | translate}}
-
- -
-
-
+
+ +
+ + +
- - - -
-
{{'DASHBOARD.PERSONAL-USAGE' | translate}}
-
- {{dashboardStatisticsData?.totalDataManagementPlanCount}}
- {{'DASHBOARD.DMPS' | translate}} -
- {{dashboardStatisticsData?.totalDataSetCount}}
- {{'DASHBOARD.DESCRIPTIONS' | translate}} -
- {{dashboardStatisticsData?.totalGrantCount}}
- {{'DASHBOARD.GRANTS' | translate}} -
- {{dashboardStatisticsData?.totalOrganisationCount}}
- {{'DASHBOARD.RELATED-ORGANISATIONS' | translate}} +
+
{{'DASHBOARD.LATEST-ACTIVITY' | translate}}
+ + + +
{{'DASHBOARD.EMPTY-LIST' | translate}}
+
+ + +
{{'DASHBOARD.EMPTY-LIST' | translate}}
+
> + + +
{{'DASHBOARD.EMPTY-LIST' | translate}}
+
+ + +
{{'DASHBOARD.EMPTY-LIST' | translate}}
+
+ +
+
+
-
- -
-
+ + +
+
{{'DASHBOARD.PERSONAL-USAGE' | translate}}
+
+ {{dashboardStatistics?.dmpCount}}
+ {{'DASHBOARD.DMPS' | translate}} +
+ {{dashboardStatistics?.descriptionCount}}
+ {{'DASHBOARD.DESCRIPTIONS' | translate}} +
+ {{dashboardStatistics?.grantCount}}
+ {{'DASHBOARD.GRANTS' | translate}} +
+ {{dashboardStatistics?.organizationCount}}
+ {{'DASHBOARD.RELATED-ORGANISATIONS' | translate}}
+
- -
-
- -
-
-
-
-
- clear -
-

{{'DASHBOARD.TITLE' | translate}}

-

{{'DASHBOARD.INFO-TEXT' | translate}}

-
-
- - - -
+
+
+ +
+
+
+ + +
+
+
+
+
+
+
+ clear +
+

{{'DASHBOARD.TITLE' | translate}}

+

{{'DASHBOARD.INFO-TEXT' | translate}}

-
-
{{'DASHBOARD.LATEST-ACTIVITY' | translate}}
- - - - -
{{'DASHBOARD.EMPTY-LIST' | translate}}
-
- - - -
{{'DASHBOARD.EMPTY-LIST' | translate}}
-
- - - -
{{'DASHBOARD.EMPTY-LIST' | translate}}
- -
-
+
+
-
- -
-
{{'DASHBOARD.PUBLIC-USAGE' | translate}}
-
- {{dashboardStatisticsData?.totalDataManagementPlanCount}}
- {{'DASHBOARD.PUBLIC-DMPS' | translate}} -
- {{dashboardStatisticsData?.totalDataSetCount}}
- {{'DASHBOARD.PUBLIC-DATASETS' | translate}} -
- {{dashboardStatisticsData?.totalGrantCount}}
- {{'DASHBOARD.GRANTS' | translate}} -
- {{dashboardStatisticsData?.totalOrganisationCount}}
- {{'DASHBOARD.RELATED-ORGANISATIONS' | translate}} -
+ +
+
+ +
+
{{'DASHBOARD.PUBLIC-USAGE' | translate}}
+
+ {{dashboardStatistics?.dmpCount}}
+ {{'DASHBOARD.PUBLIC-DMPS' | translate}} +
+ {{dashboardStatistics?.descriptionCount}}
+ {{'DASHBOARD.PUBLIC-DATASETS' | translate}} +
+ {{dashboardStatistics?.grantCount}}
+ {{'DASHBOARD.GRANTS' | translate}} +
+ {{dashboardStatistics?.organizationCount}}
+ {{'DASHBOARD.RELATED-ORGANISATIONS' | translate}}
@@ -188,107 +165,4 @@
- - - - +
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dashboard/dashboard.component.scss b/dmp-frontend/src/app/ui/dashboard/dashboard.component.scss index 6df4b8c2c..9c0cfa9e1 100644 --- a/dmp-frontend/src/app/ui/dashboard/dashboard.component.scss +++ b/dmp-frontend/src/app/ui/dashboard/dashboard.component.scss @@ -423,131 +423,4 @@ input[type="text"] { ::ng-deep .mat-form-field-appearance-outline .mat-form-field-infix { padding: 0.3rem 0rem 0.6rem 0rem !important; -} - -/* ::ng-deep .mat-tab-group { - height: 100%; - } - - ::ng-deep .mat-tab-body-wrapper { - flex-grow: 1; - } - - ::ng-deep .mat-tab-body { - display: flex !important; - flex-direction: column; - } - - ::ng-deep .mat-tab-body-content { - display: flex; - flex-direction: column; - flex-grow: 1; - } */ - -// .header-text-container { -// background: rgba(255, 255, 255, 0.7); -// position: absolute; -// bottom: 0px; -// padding-left: 5em; -// padding-right: 10em; -// padding-top: 2em; -// padding-bottom: 2em; -// } - -// .dashboard-main-container { -// margin-top: 0px; -// } - -// .non-auth-main-container { -// padding: 0; -// } - -// .non-auth-stats { -// background-color: rgba(255, 255, 255, 0.5); -// } - -// .non-auth-title-container { -// margin-top: 3em; -// } - -// .dashboard { -// .card { -// padding: 25px 20px 20px 20px; -// display: flex; -// flex-direction: column; -// align-items: center; -// } - -// .card h6, -// p { -// color: #999; -// } - -// .icon { -// margin-top: 20px; -// width: 130px; -// height: 130px; -// border: 1px solid #e5e5e5; -// border-radius: 50%; -// display: flex; -// justify-content: center; -// align-items: center; -// } - -// .icon i { -// font-size: 55px; -// color: #e91e63; -// } - -// .card-title { -// margin-top: 30px; -// margin-bottom: 3px; -// } - -// .card-description { -// margin-bottom: 20px; -// } - -// .card-dataset { -// display: flex; -// flex-direction: column; -// padding: 20px; -// position: relative; -// margin-top: 40px; -// } - -// .card { -// box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.14); -// border-radius: 6px; -// color: rgba(0, 0, 0, 0.87); -// background: #fff; -// } - -// .card-raised { -// box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.42), 0 4px 25px 0px rgba(0, 0, 0, 0.12), -// 0 8px 10px -5px rgba(0, 0, 0, 0.2); -// } - -// .full-width { -// width: 100%; -// } -// } - -// .info { -// display: flex; -// flex-wrap: nowrap; -// } - -// .subtitle { -// margin-bottom: 0px !important; -// } - -// .view-all { -// margin-left: auto; -// margin-bottom: 0px !important; -// color: #6aa4d9; -// } - -// .view-all:hover { -// color: rgb(46, 117, 182) !important; -// } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dashboard/dashboard.component.ts b/dmp-frontend/src/app/ui/dashboard/dashboard.component.ts index 9f5b0c132..e96011ff1 100644 --- a/dmp-frontend/src/app/ui/dashboard/dashboard.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/dashboard.component.ts @@ -1,38 +1,17 @@ import { Component, OnInit } from '@angular/core'; -import { UntypedFormControl } from '@angular/forms'; +import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Router } from '@angular/router'; -import { RecentActivityType } from '@app/core/common/enum/recent-activity-type'; -import { DashboardStatisticsModel } from '@app/core/model/dashboard/dashboard-statistics-model'; -import { SearchBarItem } from '@app/core/model/dashboard/search-bar-item'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { GrantCriteria } from '@app/core/query/grant/grant-criteria'; -import { RequestItem } from '@app/core/query/request-item'; +import { DashboardStatistics } from '@app/core/model/dashboard/dashboard-statistics'; import { AuthService } from '@app/core/services/auth/auth.service'; import { DashboardService } from '@app/core/services/dashboard/dashboard.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { GrantService } from '@app/core/services/grant/grant.service'; -import { SearchBarService } from '@app/core/services/search-bar/search-bar.service'; -import { UserServiceOld } from '@app/core/services/user/user.service-old'; -import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; -import { BaseComponent } from '@common/base/base.component'; -import { Observable, of as observableOf } from 'rxjs'; -import { mergeMap, takeUntil } from 'rxjs/operators'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { MatDialog } from '@angular/material/dialog'; -import { StartNewDmpDialogComponent } from '../dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component'; -import { StartNewDatasetDialogComponent } from '../dmp/start-new-dataset-dialogue/start-new-dataset-dialog.component'; -import { DatasetWizardEditorModel } from '../dataset/dataset-wizard/dataset-wizard-editor.model'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { TranslateService } from '@ngx-translate/core'; -import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service'; -import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service'; -import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; +import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants'; +import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service'; +import { BaseComponent } from '@common/base/base.component'; +import { TranslateService } from '@ngx-translate/core'; +import { takeUntil } from 'rxjs/operators'; +import { StartNewDmpDialogComponent } from '../dmp/start-new-dmp-dialogue/start-new-dmp-dialog.component'; @Component({ @@ -42,62 +21,27 @@ import { MatomoService } from '@app/core/services/matomo/matomo-service'; }) export class DashboardComponent extends BaseComponent implements OnInit { - public isVisible = true - - public userInfo: any; - datasetActivities: any[]; - grantActivities: any[]; - dmpActivities: any[]; - organisationActivities: any[]; - public dashboardStatisticsData: DashboardStatisticsModel; - public formControl = new UntypedFormControl(); - grantAutoCompleteConfiguration: SingleAutoCompleteConfiguration; - public searchControl = new UntypedFormControl(); - filteredOptions: Observable; - recentActivityTypeEnum = RecentActivityType; - public search = false; - dmpListingItems: DmpListingModel[] = []; - datasetListingItems: DatasetListingModel[] = []; - - totalDatasets: number; - totalDmps: number; - totalDraftDatasets: number; - totalRecents: number; - - dmpText: string; - datasetText: string; - importFileText: string; - startWizardText: string; + public dashboardStatistics: DashboardStatistics; currentType: string = "recent"; constructor( private router: Router, private route: ActivatedRoute, - private grantService: GrantService, - private dmpService: DmpService, - private datasetService: DatasetService, - private datasetWizardService: DatasetWizardService, private dashboardService: DashboardService, - private searchBarService: SearchBarService, private authentication: AuthService, - private userService: UserServiceOld, private dialog: MatDialog, private language: TranslateService, - private uiNotificationService: UiNotificationService, private guidedTourService: GuidedTourService, private matomoService: MatomoService ) { super(); - // this.dashboardStatisticsData.totalDataManagementPlanCount = 0; - // this.dashboardStatisticsData.totalDataSetCount = 0; - // this.dashboardStatisticsData.totalGrantCount = 0; } ngOnInit() { this.route.queryParams.subscribe(params => { let type = params['type']; - if(type || type == "recent" || (type == "drafts" && this.isAuthenticated()) || type == "dmps" || type == "datasets") { + if (type || type == "recent" || (type == "drafts" && this.isAuthenticated()) || type == "dmps" || type == "descriptions") { this.currentType = type; } else { this.currentType = "recent"; @@ -105,157 +49,47 @@ export class DashboardComponent extends BaseComponent implements OnInit { }); this.matomoService.trackPageView('Home Dashboard'); - // if (this.isAuthenticated()) { - // this.userService.getRecentActivity() - // .pipe(takeUntil(this._destroyed)) - // .subscribe(response => { - // this.datasetActivities = response['recentDatasetActivities']; - // this.dmpActivities = response['recentDmpActivities']; - // this.grantActivities = response['recentGrantActivities']; - // this.organisationActivities = response['totalOrganisationCount']; - // }); - // } - - // this.grantAutoCompleteConfiguration = { - // filterFn: this.searchGrant.bind(this), - // items: this.searchGrant(''), - // displayFn: (item) => item['label'], - // titleFn: (item) => item['label'] - // }; if (!this.isAuthenticated()) { - this.dashboardService.getStatistics() + this.dashboardService.getPublicDashboardStatistics() .pipe(takeUntil(this._destroyed)) .subscribe(results => { - //let data = results['payload']; - this.dashboardStatisticsData = results; + this.dashboardStatistics = results; }); - // this.getPublicDmps(); - // this.getPublicDatasets(); } else { - this.dashboardService.getUserStatistics() + this.dashboardService.getMyDashboardStatistics() .pipe(takeUntil(this._destroyed)) .subscribe(results => { - this.dashboardStatisticsData = results; + this.dashboardStatistics = results; - if (this.dashboardStatisticsData && this.dashboardStatisticsData.totalDataManagementPlanCount === 0) { + if (this.dashboardStatistics && this.dashboardStatistics.dmpCount === 0) { this.openDashboardTour(); } }); } - - this.filteredOptions = this.searchControl.valueChanges.pipe(mergeMap(x => { - return this.searchBarService.search(x); - })); } public get indexFromCurrentType() { - if(this.currentType == "recent") { + if (this.currentType == "recent") { return 0; } - if(this.currentType == "drafts") { + if (this.currentType == "drafts") { return 1; } - if(this.currentType == "dmps") { + if (this.currentType == "dmps") { return this.isAuthenticated() ? 2 : 1; } - if(this.currentType == "datasets") { + if (this.currentType == "descriptions") { return this.isAuthenticated() ? 3 : 2; } return 0; } - // ngAfterContentChecked(): void { - // if (this.dashboardStatisticsData && this.dashboardStatisticsData.totalDataManagementPlanCount === 0) { - // this.openTour(); - // } - // } - public isAuthenticated(): boolean { return this.authentication.currentAccountIsAuthenticated(); } - searchGrant(query: string) { - const grantRequestItem: RequestItem = new RequestItem(); - grantRequestItem.criteria = new GrantCriteria(); - grantRequestItem.criteria.like = query; - return this.grantService.getWithExternal(grantRequestItem); - } - - redirect(id: string, type: RecentActivityType) { - switch (type) { - case RecentActivityType.Grant: { - this.router.navigate(['grants/edit/' + id]); - return; - } - case RecentActivityType.Dataset: { - this.router.navigate(['datasets/edit/' + id]); - return; - } - case RecentActivityType.Dmp: { - this.router.navigate(['plans/edit/' + id]); - return; - } - default: throw new Error('Unsupported Activity Type '); - } - } - - getPublicDmps() { - const dmpCriteria = new DmpCriteria(); - dmpCriteria.allVersions = false; - dmpCriteria.isPublic = true; - dmpCriteria.onlyPublic = true; - const fields: Array = new Array(); - fields.push('-finalizedAt'); - const dataTableRequest: DataTableRequest = new DataTableRequest(0, 2, { fields: fields }); - dataTableRequest.criteria = dmpCriteria; - return this.dmpService.getPaged(dataTableRequest, "listing").pipe(takeUntil(this._destroyed)).subscribe(result => { this.dmpListingItems = result.data; }); - } - - getPublicDatasets() { - const dmpCriteria = new DatasetCriteria(); - dmpCriteria.allVersions = false; - dmpCriteria.isPublic = true; - const fields: Array = new Array(); - fields.push('-modified'); - const dataTableRequest: DataTableRequest = new DataTableRequest(0, 4, { fields: fields }); - dataTableRequest.criteria = dmpCriteria; - return this.datasetService.getPaged(dataTableRequest).pipe(takeUntil(this._destroyed)).subscribe(result => { this.datasetListingItems = result.data; }); - } - - dmpClicked(dmp: DmpListingModel) { - if (!this.isAuthenticated()) { - this.router.navigate(['../explore-plans/publicOverview', dmp.id], { relativeTo: this.route }); - } else { - this.router.navigate(['/plans/publicEdit/' + dmp.id]); - } - } - - datasetClicked(dataset: DatasetListingModel) { - this.router.navigate(['/datasets/publicEdit/' + dataset.id]); - } - - public closeCard(): void { - this.isVisible = false; - } - - onCountDmps(event): void { - this.totalDmps = event; - } - - onCountDatasets(event): void { - this.totalDatasets = event; - } - - onCountDraftDatasets(event): void { - this.totalDraftDatasets = event; - } - - onCountAllRecent(event): void { - this.totalRecents = event; - } - openNewDmpDialog() { if (this.dialog.openDialogs.length > 0) { this.dialog.closeAll(); @@ -271,43 +105,35 @@ export class DashboardComponent extends BaseComponent implements OnInit { } public hasDmps(): boolean { - if (this.dashboardStatisticsData) { - return this.dashboardStatisticsData.totalDataManagementPlanCount !== 0 - || this.dashboardStatisticsData.totalDataSetCount !== 0 - || this.dashboardStatisticsData.totalGrantCount !== 0 - || this.dashboardStatisticsData.totalOrganisationCount !== 0; + if (this.dashboardStatistics) { + return this.dashboardStatistics.dmpCount !== 0 + || this.dashboardStatistics.descriptionCount !== 0 + || this.dashboardStatistics.grantCount !== 0 + || this.dashboardStatistics.organizationCount !== 0; } else { return false; } } - addNewDataset() { - const dialogRef = this.dialog.open(StartNewDatasetDialogComponent, { - disableClose: false, - restoreFocus: false, - data: { - startNewDmp: false, - formGroup: new DatasetWizardEditorModel().buildForm() - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - if (result.startNewDmp) { - this.openNewDmpDialog(); - } else { - this.router.navigate(['/plans', 'edit', result.formGroup.get('dmp').value.id]); - // Save dataset direct but missing title and template - // this.datasetWizardService.createDataset(result.formGroup.getRawValue()) - // .pipe(takeUntil(this._destroyed)) - // .subscribe( - // data => { - // this.onCallbackSuccess(data); - // }, - // error => this.onCallbackError(error) - // ); - } - } - }); + addNewDescription() { + //TODO: add this + // const dialogRef = this.dialog.open(StartNewDescriptionDialogComponent, { + // disableClose: false, + // restoreFocus: false, + // data: { + // startNewDmp: false, + // formGroup: new DescriptionWizardEditorModel().buildForm() + // } + // }); + // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { + // if (result) { + // if (result.startNewDmp) { + // this.openNewDmpDialog(); + // } else { + // this.router.navigate(['/plans', 'edit', result.formGroup.get('dmp').value.id]); + // } + // } + // }); } public dashboardTour: GuidedTour = { @@ -338,7 +164,7 @@ export class DashboardComponent extends BaseComponent implements OnInit { closeAction: () => this.dialog.closeAll() }, { - selector: '.new-dataset-tour', + selector: '.new-description-tour', content: 'Step 4', orientation: Orientation.BottomLeft, isStepUnique: false, @@ -348,49 +174,32 @@ export class DashboardComponent extends BaseComponent implements OnInit { }; public setDashboardTourDmpText(): void { - this.dmpText = this.language.instant('DASHBOARD.TOUR-GUIDE.DMP') + '\n\n' + + const dmpText = this.language.instant('DASHBOARD.TOUR-GUIDE.DMP') + '\n\n' + this.language.instant('DASHBOARD.TOUR-GUIDE.START-NEW'); - this.dashboardTour.steps[0].title = this.dmpText; + this.dashboardTour.steps[0].title = dmpText; } public setDashboardImportFileText(): void { - this.importFileText = this.language.instant('DASHBOARD.TOUR-GUIDE.IMPORT-DMP'); - this.dashboardTour.steps[1].title = this.importFileText; + const importFileText = this.language.instant('DASHBOARD.TOUR-GUIDE.IMPORT-DMP'); + this.dashboardTour.steps[1].title = importFileText; } public setDashboardStartWizardText(): void { - this.startWizardText = this.language.instant('DASHBOARD.TOUR-GUIDE.START-WIZARD'); - this.dashboardTour.steps[2].title = this.startWizardText; + const startWizardText = this.language.instant('DASHBOARD.TOUR-GUIDE.START-WIZARD'); + this.dashboardTour.steps[2].title = startWizardText; } - public setDatasetText(): void { - this.datasetText = this.language.instant('DASHBOARD.TOUR-GUIDE.DATASET') + '\n\n' + - this.language.instant('DASHBOARD.TOUR-GUIDE.NEW-DATASET'); - this.dashboardTour.steps[3].title = this.datasetText; + public setDescriptionText(): void { + const descriptionText = this.language.instant('DASHBOARD.TOUR-GUIDE.description') + '\n\n' + + this.language.instant('DASHBOARD.TOUR-GUIDE.NEW-description'); + this.dashboardTour.steps[3].title = descriptionText; } openDashboardTour() { this.setDashboardTourDmpText(); this.setDashboardImportFileText(); this.setDashboardStartWizardText(); - this.setDatasetText(); + this.setDescriptionText(); this.guidedTourService.startTour(this.dashboardTour); } - - // onCallbackSuccess(datasetId: String): void { - // this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION'), SnackBarNotificationLevel.Success); - // this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', datasetId]); }); - // } - - // onCallbackError(error: any) { - // this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error); - // } - - // viewAllPublicDmpsClicked() { - // this.router.navigate(['/explore-plans']); - // } - - // viewAllPublicDatasetsClicked() { - // this.router.navigate(['explore']); - // } } diff --git a/dmp-frontend/src/app/ui/dashboard/dashboard.module.ts b/dmp-frontend/src/app/ui/dashboard/dashboard.module.ts index 48e536d65..915656f2c 100644 --- a/dmp-frontend/src/app/ui/dashboard/dashboard.module.ts +++ b/dmp-frontend/src/app/ui/dashboard/dashboard.module.ts @@ -1,48 +1,39 @@ import { NgModule } from '@angular/core'; -import { ExportMethodDialogModule } from '@app/library/export-method-dialog/export-method-dialog.module'; -import { CardComponent } from '@app/ui/dashboard/card/card.component'; -import { DashboardComponent } from '@app/ui/dashboard/dashboard.component'; -import { DashboardRoutingModule } from '@app/ui/dashboard/dashboard.routing'; -import { DatasetInfoCounterComponent } from '@app/ui/dashboard/dataset-info-counter/dataset-info-counter.component'; -import { DraftsComponent } from '@app/ui/dashboard/drafts/drafts.component'; -import { InfoCounterComponent } from '@app/ui/dashboard/info-counter/info-counter.component'; -import { QuickWizardCreateAdd } from '@app/ui/dashboard/quick-wizard-create-add/quick-wizard-create-add.component'; -import { RecentActivityComponent } from '@app/ui/dashboard/recent-activity/recent-activity.component'; -import { RecentEditedActivityComponent } from '@app/ui/dashboard/recent-edited-activity/recent-edited-activity.component'; -import { RecentVisitedActivityComponent } from '@app/ui/dashboard/recent-visited-activity/recent-visited-activity.component'; -import { WizardComponent } from '@app/ui/dashboard/wizard/wizard.component'; -import { CommonUiModule } from '@common/ui/common-ui.module'; -import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; -import { RecentEditedDatasetActivityComponent } from './recent-edited-dataset-activity/recent-edited-dataset-activity.component'; -import { DatasetCopyDialogModule } from '../dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module'; -import { RecentEditedDmpActivityComponent } from './recent-edited-dmp-activity/recent-edited-dmp-activity.component'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormattingModule } from '@app/core/formatting.module'; +import { ExportMethodDialogModule } from '@app/library/export-method-dialog/export-method-dialog.module'; +import { DashboardComponent } from '@app/ui/dashboard/dashboard.component'; +import { DashboardRoutingModule } from '@app/ui/dashboard/dashboard.routing'; +import { ConfirmationDialogModule } from '@common/modules/confirmation-dialog/confirmation-dialog.module'; +import { CommonUiModule } from '@common/ui/common-ui.module'; +import { DatasetCopyDialogModule } from '../dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.module'; +import { DescriptionModule } from '../description/description.module'; +import { DmpModule } from '../dmp/dmp.module'; +import { DraftsComponent } from './drafts/drafts.component'; +import { RecentEditedActivityComponent } from './recent-edited-activity/recent-edited-activity.component'; +import { RecentEditedDescriptionActivityComponent } from './recent-edited-description-activity/recent-edited-description-activity.component'; +import { RecentEditedDmpActivityComponent } from './recent-edited-dmp-activity/recent-edited-dmp-activity.component'; @NgModule({ - imports: [ - CommonUiModule, - FormattingModule, - DashboardRoutingModule, - ExportMethodDialogModule, - ConfirmationDialogModule, - DatasetCopyDialogModule, - FormsModule, - ReactiveFormsModule - ], - declarations: [ - DashboardComponent, - RecentActivityComponent, - CardComponent, - QuickWizardCreateAdd, - WizardComponent, - InfoCounterComponent, - RecentVisitedActivityComponent, - RecentEditedActivityComponent, - DraftsComponent, - DatasetInfoCounterComponent, - RecentEditedDatasetActivityComponent, - RecentEditedDmpActivityComponent - ] + imports: [ + CommonUiModule, + FormattingModule, + DashboardRoutingModule, + ExportMethodDialogModule, + ConfirmationDialogModule, + DatasetCopyDialogModule, + FormsModule, + ReactiveFormsModule, + + DmpModule, //TODO: add only listing component to a seperate module + DescriptionModule //TODO: add only listing component to a seperate module + ], + declarations: [ + DashboardComponent, + RecentEditedActivityComponent, + RecentEditedDmpActivityComponent, + RecentEditedDescriptionActivityComponent, + DraftsComponent + ] }) export class DashboardModule { } diff --git a/dmp-frontend/src/app/ui/dashboard/dashboard.routing.ts b/dmp-frontend/src/app/ui/dashboard/dashboard.routing.ts index cf1f8b527..e3698abd2 100644 --- a/dmp-frontend/src/app/ui/dashboard/dashboard.routing.ts +++ b/dmp-frontend/src/app/ui/dashboard/dashboard.routing.ts @@ -1,7 +1,6 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { DashboardComponent } from './dashboard.component'; -import { QuickWizardCreateAdd } from './quick-wizard-create-add/quick-wizard-create-add.component'; const routes: Routes = [ { diff --git a/dmp-frontend/src/app/ui/dashboard/dataset-info-counter/dataset-info-counter.component.css b/dmp-frontend/src/app/ui/dashboard/dataset-info-counter/dataset-info-counter.component.css deleted file mode 100644 index 0a315c365..000000000 --- a/dmp-frontend/src/app/ui/dashboard/dataset-info-counter/dataset-info-counter.component.css +++ /dev/null @@ -1,77 +0,0 @@ -.listing-item { - background-color: #ffffff; -} - -.gray-container { - letter-spacing: 5px; - color: #aaaaaa; -} - -.container-header { - display: flex; - align-items: baseline; - margin-top: 0px; - padding-top: 10px; - text-transform: uppercase; - min-height: 2.1em; -} - -.container-header p { - letter-spacing: 5px; - color: #aaaaaa; - /* padding: 5px 30px; */ - margin-bottom: 0px; -} - -/* h4 { - display: inline; - padding-left: 1em; -} */ - -/* .title h4 { - padding-left: 30px; - line-height: 2em; -} */ - -.about-item { - display: flex; -} - -.about-item .length { - color: var(--primary-color-3); - /* color: #089dbb; */ -} - -.about-item .title { - margin: 2px 10px; -} - -.about-item p { - margin-left: auto; - margin-bottom: 0px; - padding-top: 7px; - color: #aaaaaa; -} - -.icon { - color: #08bd63; - /* color: #92d050; */ -} - -hr { - margin: 0.6em 0em; -} - -.date { - display: flex; -} - -.date p { - margin-left: auto; - margin-bottom: 0em; - color: #aaaaaa; -} - -.desc { - min-height: 1.5em; -} diff --git a/dmp-frontend/src/app/ui/dashboard/dataset-info-counter/dataset-info-counter.component.html b/dmp-frontend/src/app/ui/dashboard/dataset-info-counter/dataset-info-counter.component.html deleted file mode 100644 index 417abce37..000000000 --- a/dmp-frontend/src/app/ui/dashboard/dataset-info-counter/dataset-info-counter.component.html +++ /dev/null @@ -1,31 +0,0 @@ -
-
-
-
-

{{ dataset.grantAbbreviation }}

-
-
-
-
- bookmark -

{{ dataset.label }}

-
-
-
-
-

{{dataset.description}}

-
-
-
-
-
-
{{ dataset.profile }}
-
-
-
-
-
-

{{'DATASET-LISTING.COLUMNS.PUBLISHED' | translate}} {{dataset.created | date: "shortDate"}}

-
-
-
diff --git a/dmp-frontend/src/app/ui/dashboard/dataset-info-counter/dataset-info-counter.component.spec.ts b/dmp-frontend/src/app/ui/dashboard/dataset-info-counter/dataset-info-counter.component.spec.ts deleted file mode 100644 index a95cf5c28..000000000 --- a/dmp-frontend/src/app/ui/dashboard/dataset-info-counter/dataset-info-counter.component.spec.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; - -import { DatasetInfoCounterComponent } from './dataset-info-counter.component'; - -describe('DatasetInfoCounterComponent', () => { - let component: DatasetInfoCounterComponent; - let fixture: ComponentFixture; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [DatasetInfoCounterComponent], - teardown: { destroyAfterEach: false } -}) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(DatasetInfoCounterComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/dmp-frontend/src/app/ui/dashboard/dataset-info-counter/dataset-info-counter.component.ts b/dmp-frontend/src/app/ui/dashboard/dataset-info-counter/dataset-info-counter.component.ts deleted file mode 100644 index 49c75cc03..000000000 --- a/dmp-frontend/src/app/ui/dashboard/dataset-info-counter/dataset-info-counter.component.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; -import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing'; - -@Component({ - selector: 'app-dataset-info-counter', - templateUrl: './dataset-info-counter.component.html', - styleUrls: ['./dataset-info-counter.component.css'] -}) -export class DatasetInfoCounterComponent implements OnInit { - - @Input() dataset: DatasetListingModel; - @Output() onClick: EventEmitter = new EventEmitter(); - - constructor() { } - - ngOnInit() { - } - - itemClicked() { - this.onClick.emit(this.dataset); - } -} diff --git a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html index 172ecfb54..647f8a1c7 100644 --- a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html +++ b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html @@ -1,7 +1,7 @@ -
+
{{'DMP-LISTING.EMPTY-LIST' | translate}}
-
+
{{'DMP-LISTING.SORT-BY' | translate}}: @@ -9,8 +9,6 @@ {{enumUtils.toRecentActivityOrderString(order.MODIFIED)}} {{enumUtils.toRecentActivityOrderString(order.LABEL)}} - - @@ -22,144 +20,17 @@
-
+
-
-
- -
-
- -
+
+ +
-
+
{{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}}
-
+
diff --git a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts index 0d975c4ab..38de03551 100644 --- a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.ts @@ -1,48 +1,20 @@ import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; -import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; -import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; +import { Component, Input, OnInit } from '@angular/core'; +import { UntypedFormBuilder, UntypedFormControl } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DmpBlueprintSectionFieldCategory } from '@app/core/common/enum/dmp-blueprint-section-field-category'; -import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type'; import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; -import { Role } from '@app/core/common/enum/role'; -import { DatasetUrlListing } from "@app/core/model/dataset/dataset-url-listing"; -import { DmpBlueprintDefinition } from '@app/core/model/dmp-blueprint/dmp-blueprint'; -import { DmpModel } from "@app/core/model/dmp/dmp"; -import { DmpListingModel } from "@app/core/model/dmp/dmp-listing"; -import { RecentActivityModel } from "@app/core/model/recent-activity/recent-activity.model"; -import { RecentDatasetModel } from "@app/core/model/recent-activity/recent-dataset-activity.model"; -import { RecentDmpModel } from "@app/core/model/recent-activity/recent-dmp-activity.model"; -import { RecentActivityCriteria } from "@app/core/query/recent-activity/recent-activity-criteria"; +import { RecentActivityItem } from '@app/core/model/dashboard/recent-activity-item'; +import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; +import { Description } from '@app/core/model/description/description'; +import { Dmp, DmpUser } from "@app/core/model/dmp/dmp"; +import { DmpReference, Reference } from '@app/core/model/reference/reference'; +import { RecentActivityItemLookup } from '@app/core/query/recent-activity-item-lookup.lookup'; import { DashboardService } from "@app/core/services/dashboard/dashboard.service"; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; -import { DmpService } from "@app/core/services/dmp/dmp.service"; -import { LockService } from '@app/core/services/lock/lock.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { DatasetCopyDialogueComponent } from '@app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component'; -import { CloneDialogComponent } from "@app/ui/dmp/clone/clone-dialog/clone-dialog.component"; -import { DmpEditorModel } from "@app/ui/dmp/editor/dmp-editor.model"; -import { ExtraPropertiesFormModel } from "@app/ui/dmp/editor/general-tab/extra-properties-form.model"; -import { FunderFormModel } from "@app/ui/dmp/editor/grant-tab/funder-form-model"; -import { GrantTabModel } from "@app/ui/dmp/editor/grant-tab/grant-tab-model"; -import { ProjectFormModel } from "@app/ui/dmp/editor/grant-tab/project-form-model"; -import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; import { BaseComponent } from '@common/base/base.component'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { debounceTime, map, takeUntil } from 'rxjs/operators'; -import { DmpStatus } from '../../../core/common/enum/dmp-status'; -import { RecentActivityType } from '../../../core/common/enum/recent-activity-type'; -import { DataTableMultiTypeRequest } from '../../../core/model/data-table/data-table-request'; -import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing'; +import { debounceTime, takeUntil } from 'rxjs/operators'; +import { nameof } from 'ts-simple-nameof'; import { AuthService } from '../../../core/services/auth/auth.service'; @Component({ @@ -52,21 +24,10 @@ import { AuthService } from '../../../core/services/auth/auth.service'; }) export class DraftsComponent extends BaseComponent implements OnInit { - @Output() totalCountRecentEdited: EventEmitter = new EventEmitter(); - - @ViewChild("results") resultsContainer; - allRecentActivities: RecentActivityModel[]; - recentActivityTypeEnum = RecentActivityType; - dmpModel: DmpEditorModel; - isDraft: boolean; - totalCount: number; - startIndex: number = 0; - dmpOffset: number = 0; - datasetOffset: number = 0; - offsetLess: number = 0; + lookup: RecentActivityItemLookup = new RecentActivityItemLookup(); pageSize: number = 5; - dmpFormGroup: UntypedFormGroup; - hasMoreActivity: boolean = true; + listingItems: RecentActivityItem[]; + public formGroup = new UntypedFormBuilder().group({ like: new UntypedFormControl(), order: new UntypedFormControl() @@ -75,6 +36,9 @@ export class DraftsComponent extends BaseComponent implements OnInit { order = RecentActivityOrder; + totalCount: number; + startIndex: number = 0; + offsetLess: number = 0; page: number = 1; @Input() isActive: boolean = false; @@ -83,38 +47,34 @@ export class DraftsComponent extends BaseComponent implements OnInit { private router: Router, public enumUtils: EnumUtils, private authentication: AuthService, - private dmpService: DmpService, - private dmpBlueprintService: DmpBlueprintService, private dashboardService: DashboardService, - private language: TranslateService, - private dialog: MatDialog, - private uiNotificationService: UiNotificationService, - private datasetWizardService: DatasetWizardService, private location: Location, - private lockService: LockService, - private httpClient: HttpClient, - private matomoService: MatomoService, - private fileUtils: FileUtils + private matomoService: MatomoService ) { super(); } ngOnInit() { - this.matomoService.trackPageView('Drafts'); + this.matomoService.trackPageView('Recent DMP Activity'); this.route.queryParams.subscribe(params => { if (this.isActive) { let page = (params['page'] === undefined) ? 1 : +params['page']; this.page = (page <= 0) ? 1 : page; - this.datasetOffset = (this.page - 1) * this.pageSize; - this.dmpOffset = (this.page - 1) * this.pageSize; + this.startIndex = (this.page - 1) * this.pageSize; if (this.page > 1) { this.offsetLess = (this.page - 2) * this.pageSize; } let order = params['order']; - if (order === undefined || (order != this.order.MODIFIED && order != this.order.LABEL)) { - order = this.order.MODIFIED; + if (this.isAuthenticated()) { + if (order === undefined || (order != this.order.UpdatedAt && order != this.order.Label && order != this.order.Status)) { + order = this.order.UpdatedAt; + } + } else { + if (order === undefined || (order != this.order.PUBLISHED && order != this.order.LABEL)) { + order = this.order.PUBLISHED; + } } this.formGroup.get('order').setValue(order); @@ -125,49 +85,7 @@ export class DraftsComponent extends BaseComponent implements OnInit { } }); if (this.isAuthenticated()) { - if (!this.formGroup.get('order').value) { - this.formGroup.get('order').setValue(this.order.MODIFIED); - } - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - const allDataTableRequest: DataTableMultiTypeRequest = new DataTableMultiTypeRequest(this.dmpOffset, this.datasetOffset, 5, { fields: fields }); - allDataTableRequest.criteria = new RecentActivityCriteria(); - allDataTableRequest.criteria.like = this.formGroup.get('like').value; - allDataTableRequest.criteria.order = this.formGroup.get('order').value; - allDataTableRequest.criteria.status = 0; - - this.dashboardService - .getRecentActivity(allDataTableRequest) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - this.allRecentActivities = response; - this.allRecentActivities.forEach(recentActivity => { - if (recentActivity.type === RecentActivityType.Dataset) { - // this.datasetOffset = this.datasetOffset + 1; - this.datasetOffset = this.page * this.pageSize; - } else if (recentActivity.type === RecentActivityType.Dmp) { - // this.dmpOffset = this.dmpOffset + 1; - this.dmpOffset = this.page * this.pageSize; - } - }); - this.totalCountRecentEdited.emit(this.allRecentActivities.length); - if (this.allRecentActivities.length == 0 && this.page > 1) { - let queryParams = { type: "recent", page: 1, order: this.formGroup.get("order").value }; - if (this.formGroup.get("like").value) { - queryParams['keyword'] = this.formGroup.get("like").value; - } - this.router.navigate(["/home"], { queryParams: queryParams }) - } - }); - this.formGroup.get('like').valueChanges - .pipe(takeUntil(this._destroyed), debounceTime(500)) - .subscribe(x => { - this.refresh() - }); - this.formGroup.get('order').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.refresh() - }); + this.refresh(); } } @@ -178,578 +96,93 @@ export class DraftsComponent extends BaseComponent implements OnInit { } updateUrl() { - let parameters = "?type=drafts" + + let parameters = "?type=dmps" + (this.page != 1 ? "&page=" + this.page : "") + - (this.formGroup.get("order").value != this.order.MODIFIED ? "&order=" + this.formGroup.get("order").value : "") + + (((this.formGroup.get("order").value != this.order.MODIFIED && !this.publicMode) || (this.formGroup.get("order").value != this.order.PUBLISHED && this.publicMode)) ? "&order=" + this.formGroup.get("order").value : "") + (this.formGroup.get("like").value ? ("&keyword=" + this.formGroup.get("like").value) : ""); this.location.go(this.router.url.split('?')[0] + parameters); } - getDatasets(activity: RecentDmpModel): DatasetUrlListing[] { - return activity.datasets; - } - - getGroupId(activity: RecentDmpModel): string { - return activity.groupId; - } - - getDmp(activity: RecentDatasetModel): String { - return activity.dmp; - } - - getDmpId(activity: RecentDatasetModel): String { - return activity.dmpId; - } - public isAuthenticated(): boolean { return this.authentication.currentAccountIsAuthenticated(); } - isUserOwner(activity: DmpListingModel): boolean { - const principalId: string = this.authentication.userId()?.toString(); - if (principalId) return !!activity.users.find(x => (x.role === Role.Owner) && (principalId === x.id)); - } - - editClicked(dmp: DmpListingModel) { - this.router.navigate(['/plans/edit/' + dmp.id]); - } - - deleteDmpClicked(dmp: DmpListingModel) { - this.lockService.checkLockStatus(dmp.id).pipe(takeUntil(this._destroyed)) - .subscribe(lockStatus => { - if (!lockStatus) { - this.openDeleteDmpDialog(dmp); - } else { - this.openDmpLockedByUserDialog(); - } - }); - } - - cloneOrNewVersionClicked(dmp: RecentActivityModel, isNewVersion: boolean) { - this.dmpService.getSingle(dmp.id).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.dmpModel = new DmpEditorModel(); - this.dmpModel.grant = new GrantTabModel(); - this.dmpModel.project = new ProjectFormModel(); - this.dmpModel.funder = new FunderFormModel(); - this.dmpModel.extraProperties = new ExtraPropertiesFormModel(); - this.dmpModel.fromModel(data); - this.dmpModel.status = DmpStatus.Draft; - this.dmpFormGroup = this.dmpModel.buildForm(); - - if (!isNullOrUndefined(this.formGroup.get('profile').value)) { - this.dmpBlueprintService.getSingle(this.formGroup.get('profile').value) - .pipe(takeUntil(this._destroyed)) - .subscribe(result => { - this.checkForGrant(result.definition); - this.checkForFunder(result.definition); - this.checkForProject(result.definition); - }); - } - - if (!isNewVersion) { - this.dmpFormGroup.get('label').setValue(dmp.title + " New"); - } - this.openCloneDialog(isNewVersion); - }); - } - - private checkForGrant(blueprint: DmpBlueprintDefinition) { - let hasGrant = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.GRANT) { - hasGrant = true; - } - } - )); - if (!hasGrant) { - this.formGroup.removeControl('grant'); - } - } - - private checkForFunder(blueprint: DmpBlueprintDefinition) { - let hasFunder = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.FUNDER) { - hasFunder = true; - } - } - )); - if (!hasFunder) { - this.formGroup.removeControl('funder'); - } - } - - private checkForProject(blueprint: DmpBlueprintDefinition) { - let hasProject = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.PROJECT) { - hasProject = true; - } - } - )); - if (!hasProject) { - this.formGroup.removeControl('project'); - } - } - - openCloneDialog(isNewVersion: boolean) { - const dialogRef = this.dialog.open(CloneDialogComponent, { - maxWidth: '700px', - maxHeight: '80vh', - data: { - formGroup: this.dmpFormGroup, - datasets: this.dmpFormGroup.get('datasets').value, - isNewVersion: isNewVersion, - confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.SAVE'), - cancelButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CANCEL'), - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - if (!isNewVersion) { - this.dmpService.clone(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCloneOrNewVersionCallbackSuccess(complete), - error => this.onCloneOrNewVersionCallbackError(error) - ); - } else if (isNewVersion) { - this.dmpService.newVersion(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCloneOrNewVersionCallbackSuccess(complete), - error => this.onCloneOrNewVersionCallbackError(error) - ); - } - } - }); - } - - openDeleteDmpDialog(dmp: DmpListingModel) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.dmpService.delete(dmp.id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onDeleteCallbackSuccess(), - error => this.onDeleteCallbackError(error) - ); - } - }); - } - - openDmpLockedByUserDialog() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '400px', - restoreFocus: false, - data: { - message: this.language.instant('DMP-EDITOR.ACTIONS.LOCK') - } - }); - } - - openShareDialog(rowId: any, rowName: any) { - const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { - // height: '250px', - // width: '700px', - autoFocus: false, - restoreFocus: false, - data: { - dmpId: rowId, - dmpName: rowName - } - }); - } - - isDraftDmp(activity: DmpListingModel) { - return activity.status == DmpStatus.Draft; - } - - onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans']); - } - - reloadPage(): void { - const path = this.location.path(); - this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => { - this.router.navigate([path]); - }); - } - - onDeleteCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); - this.reloadPage(); - } - - onDeleteCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? this.language.instant(error.error.message) : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); - } - - onCloneOrNewVersionCallbackSuccess(dmpId: String): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans/edit/', dmpId]); - } - - onCloneOrNewVersionCallbackError(error: any) { - this.uiNotificationService.snackBarNotification(error.error.message ? this.language.instant(error.error.message) : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-CLONE'), SnackBarNotificationLevel.Error); - } - - redirect(id: string, type: RecentActivityType) { - switch (type) { - case RecentActivityType.Grant: { - this.router.navigate(["grants/edit/" + id]); - return; - } - case RecentActivityType.Dataset: { - if (this.isAuthenticated()) { - this.router.navigate(['../datasets/overview/' + id]); - } - return; - } - case RecentActivityType.Dmp: { - if (this.isAuthenticated()) { - this.router.navigate(['../plans/overview/' + id]); - } - return; - } - default: - throw new Error("Unsupported Activity Type "); - } - } - - navigateToUrl(id: string, type: RecentActivityType): string[] { - switch (type) { - case RecentActivityType.Grant: { - return ["grants/edit/" + id]; - } - case RecentActivityType.Dataset: { - if (this.isAuthenticated()) { - return ['../datasets/overview/' + id]; - } else { - return ['../explore/publicOverview', id]; - } - } - case RecentActivityType.Dmp: { - if (this.isAuthenticated()) { - return ['../plans/overview/' + id]; - } else { - return ['../explore-plans/publicOverview', id]; - } - } - default: - throw new Error("Unsupported Activity Type "); - } - } - - roleDisplay(value: any) { - const principalId: string = this.authentication.userId()?.toString(); - let role: number; - if (principalId) { - value.forEach(element => { - if (principalId === element.id) { - role = element.role; - } - }); - } - if (role === 0) { - return this.language.instant('DMP-LISTING.OWNER'); - } - else if (role === 1) { - return this.language.instant('DMP-LISTING.MEMBER'); - } - else { - return this.language.instant('DMP-LISTING.OWNER'); - } - } - - // dmpBlueprintDisplay(value: any) { - // if (value != null) { - // return value; - // } - // else { - // return "--"; - // } - // } - - downloadXml(id: string) { - this.dmpService.downloadXML(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "xml", id); - }); - } - - downloadDocx(id: string) { - this.dmpService.downloadDocx(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "docx", id); - }); - } - - downloadPdf(id: string) { - this.dmpService.downloadPDF(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/pdf' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "pdf", id); - }); - } - - downloadJson(id: string) { - this.dmpService.downloadJson(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/json' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "json", id); - }, async error => { - this.onExportCallbackError(error); - }); - } - - async onExportCallbackError(error: any) { - const errorJsonText = await error.error.text(); - const errorObj = JSON.parse(errorJsonText); - this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error); - } - - downloadPDF(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadPDF(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/pdf' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "pdf", dataset.id); - }); - } - - downloadDOCX(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadDOCX(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "docx", dataset.id); - }); - - } - - downloadXML(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadXML(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "xml", dataset.id); - }); - } - - viewVersions(rowId: String, rowLabel: String, activity: DmpListingModel) { - if (activity.public && !this.isUserOwner(activity)) { - let url = this.router.createUrlTree(['/explore-plans/versions/', rowId, { groupLabel: rowLabel }]); - window.open(url.toString(), '_blank'); - // this.router.navigate(['/explore-plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); - } else { - let url = this.router.createUrlTree(['/plans/versions/', rowId, { groupLabel: rowLabel }]); - window.open(url.toString(), '_blank'); - // this.router.navigate(['/plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); - } - } - - openDmpSearchDialogue(dataset: RecentDatasetModel) { - const formControl = new UntypedFormControl(); - const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, { - width: '500px', - restoreFocus: false, - data: { - formControl: formControl, - datasetId: dataset.id, - datasetProfileId: dataset.profile.id, - datasetProfileExist: false, - confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'), - cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL') - } - }); - - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result && result.datasetProfileExist) { - const newDmpId = result.formControl.value.id; - // let url = this.router.createUrlTree(['/datasets/copy/', result.datasetId, { newDmpId: newDmpId }]); - // window.open(url.toString(), '_blank'); - this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } }); - } - }); - } - - deleteDatasetClicked(id: string) { - this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed)) - .subscribe(lockStatus => { - if (!lockStatus) { - this.openDeleteDatasetDialog(id); - } else { - this.openDatasetLockedByUserDialog(); - } - }); - } - - openDeleteDatasetDialog(id: string): void { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetWizardService.delete(id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onDeleteCallbackSuccess(), - error => this.onDeleteCallbackError(error) - ); - } - }); - } - - openDatasetLockedByUserDialog() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '400px', - restoreFocus: false, - data: { - message: this.language.instant('DATASET-WIZARD.ACTIONS.LOCK') - } - }); - } - refresh(): void { - this.datasetOffset = 0; - this.dmpOffset = 0; - this.page = 1; - this.updateUrl(); + if (!this.formGroup.get('order').value) { + this.formGroup.get('order').setValue(this.order.UpdatedAt); + } + this.lookup.onlyDraft = true; + this.lookup.page = { size: this.pageSize, offset: 0 }; + this.lookup.orderField = this.formGroup.get('order').value; + this.lookup.like = this.formGroup.get('like').value; + this.lookup.project = { - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - // const fields: Array = ["-modified"]; - this.startIndex = 0; - const allDataTableRequest: DataTableMultiTypeRequest = new DataTableMultiTypeRequest(0, 0, this.pageSize, { fields: fields }); - allDataTableRequest.criteria = new RecentActivityCriteria(); - allDataTableRequest.criteria.like = this.formGroup.get("like").value; - allDataTableRequest.criteria.order = this.formGroup.get("order").value; - allDataTableRequest.criteria.status = 0; + fields: [ + [nameof(x => x.dmp), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.label)].join('.'), + [nameof(x => x.dmp), nameof(x => x.status)].join('.'), + [nameof(x => x.dmp), nameof(x => x.accessType)].join('.'), + [nameof(x => x.dmp), nameof(x => x.version)].join('.'), + [nameof(x => x.dmp), nameof(x => x.groupId)].join('.'), + [nameof(x => x.dmp), nameof(x => x.updatedAt)].join('.'), + [nameof(x => x.dmp), nameof(x => x.descriptions), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.descriptions), nameof(x => x.label)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.user.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.role)].join('.'), + + [nameof(x => x.description), nameof(x => x.id)].join('.'), + [nameof(x => x.description), nameof(x => x.label)].join('.'), + [nameof(x => x.description), nameof(x => x.status)].join('.'), + [nameof(x => x.description), nameof(x => x.updatedAt)].join('.'), + [nameof(x => x.description), nameof(x => x.descriptionTemplate), nameof(x => x.id)].join('.'), + [nameof(x => x.description), nameof(x => x.descriptionTemplate), nameof(x => x.label)].join('.'), + [nameof(x => x.description), nameof(x => x.descriptionTemplate), nameof(x => x.groupId)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.id)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.label)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.accessType)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.id)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.user.id)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.role)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.id)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.id)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.label)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.type)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.reference)].join('.'), + ] + }; this.dashboardService - .getRecentActivity(allDataTableRequest) + .getMyRecentActivityItems(this.lookup) .pipe(takeUntil(this._destroyed)) .subscribe(response => { - this.allRecentActivities = response; - this.allRecentActivities.forEach(recentActivity => { - if (recentActivity.type === RecentActivityType.Dataset) { - // this.datasetOffset = this.datasetOffset + 1; - this.datasetOffset = this.page * this.pageSize; - } else if (recentActivity.type === RecentActivityType.Dmp) { - // this.dmpOffset = this.dmpOffset + 1; - this.dmpOffset = this.page * this.pageSize; - } - }); + this.listingItems = response; + //this.totalCount = response.totalCount; - if (response.length < this.pageSize) { - this.hasMoreActivity = false; - } else { - this.hasMoreActivity = true; - } - this.totalCountRecentEdited.emit(this.allRecentActivities.length); + + //this.totalCountDmps.emit(this.dmpActivities.length); + // if (this.totalCount > 0 && this.totalCount <= (this.page - 1) * this.pageSize && this.page > 1) { + // let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value }; + // if (this.formGroup.get("like").value) { + // queryParams['keyword'] = this.formGroup.get("like").value; + // } + // this.router.navigate(["/home"], { queryParams: queryParams }) + // } + // this.totalCount < this.pageSize ? this.totalCountDmps.emit(response.totalCount) : this.totalCountDmps.emit(this.pageSize); + // this.totalCountDmps.emit(this.totalCount); + // this.dmpActivities.forEach(dmpActivity => { + // const recentActivity: RecentActivity = { + // activityData: dmpActivity, + // activityType: RecentActivityType.Dmp + // }; + // this.allRecentActivities.push(recentActivity) + // }) }); - } - - public loadNextOrPrevious(more: boolean = true) { - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - // const fields: Array = ["-modified"]; - let request; - if (more) { - request = new DataTableMultiTypeRequest(this.dmpOffset, this.datasetOffset, this.pageSize, { fields: fields }); - } else { - request = new DataTableMultiTypeRequest(this.offsetLess, this.offsetLess, this.pageSize, { fields: fields }); - } - request.criteria = new RecentActivityCriteria(); - request.criteria.like = this.formGroup.get("like").value ? this.formGroup.get("like").value : ""; - request.criteria.order = this.formGroup.get("order").value; - request.criteria.status = 0; - - this.dashboardService.getRecentActivity(request).pipe(takeUntil(this._destroyed)).subscribe(result => { - if (!result || result.length == 0) { - this.hasMoreActivity = false; - // return []; - } else { - this.page = this.page + (more ? 1 : -1); - this.updateUrl(); - // if(more) { - // result.forEach(recentActivity => { - // if (recentActivity.type === RecentActivityType.Dataset) { - // this.datasetOffset = this.datasetOffset + 1; - this.datasetOffset = this.page * this.pageSize; - // } else if (recentActivity.type === RecentActivityType.Dmp) { - // this.dmpOffset = this.dmpOffset + 1; - this.dmpOffset = this.page * this.pageSize; - // } - // }); - // } - if (this.page > 1) { - this.offsetLess = (this.page - 2) * this.pageSize; - } - - if (result.length < this.pageSize) { - this.hasMoreActivity = false; - } else { - this.hasMoreActivity = true; - } - - // this.allRecentActivities = this.allRecentActivities.concat(result); - // this.allRecentActivities = this.allRecentActivities.length > 0 ? this.mergeTwoSortedLists(this.allRecentActivities, result, this.formGroup.get('order').value) : result; - this.allRecentActivities = result; - this.totalCountRecentEdited.emit(this.allRecentActivities.length); - if (more) { - this.resultsContainer.nativeElement.scrollIntoView(); - } - } - }); + this.formGroup.get('like').valueChanges + .pipe(takeUntil(this._destroyed), debounceTime(500)) + .subscribe(x => this.refresh()); + this.formGroup.get('order').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => this.refresh()); } } diff --git a/dmp-frontend/src/app/ui/dashboard/info-counter/info-counter.component.css b/dmp-frontend/src/app/ui/dashboard/info-counter/info-counter.component.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/dashboard/info-counter/info-counter.component.html b/dmp-frontend/src/app/ui/dashboard/info-counter/info-counter.component.html deleted file mode 100644 index 637414fc0..000000000 --- a/dmp-frontend/src/app/ui/dashboard/info-counter/info-counter.component.html +++ /dev/null @@ -1,20 +0,0 @@ -
-
-
- {{ icon }} -
-
- {{ icon }} -
-

{{ title | translate }}

-

- {{ subtitle }} -

-
- -
diff --git a/dmp-frontend/src/app/ui/dashboard/info-counter/info-counter.component.ts b/dmp-frontend/src/app/ui/dashboard/info-counter/info-counter.component.ts deleted file mode 100644 index 4d1c16fcb..000000000 --- a/dmp-frontend/src/app/ui/dashboard/info-counter/info-counter.component.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; -import { Router } from "@angular/router"; -import { AuthService } from "../../../core/services/auth/auth.service"; - -// declare interface RouteInfo { -// path: string; -// title: string; -// subtitle: string; -// icon: string; -// } -// export const INFO_COUNTER_ROUTES: RouteInfo[] = [ -// { path: '', title: 'DATA MANAGEMENT PLANS', subtitle: '4', icon: 'view_agenda' }, -// { path: '', title: 'RELATED DATA DESCRIPTIONS', subtitle: '20', icon: 'library_books' }, -// { path: '', title: 'RELATED GRANTS', subtitle: '4', icon: 'work_outline' }, -// { path: '', title: 'ORGANIZATIONS', subtitle: '20', icon: 'scatter_plot' } -// ]; - -@Component({ - selector: "app-info-counter", - templateUrl: "./info-counter.component.html", - styleUrls: ["./info-counter.component.css"] -}) -export class InfoCounterComponent implements OnInit { - @Input() title: string; - @Input() subtitle: string; - @Input() icon: string; - @Input() routerLink: string; - @Input() buttonRedirectLink: string; - @Output() onClick: EventEmitter = new EventEmitter(); - - infoCounterItems: any[]; - - constructor(private router: Router, private authService: AuthService) {} - - ngOnInit() { - // this.infoCounterItems = INFO_COUNTER_ROUTES.filter(infoCounterItem => infoCounterItem); - } - - navigateToUrl() { - if (!this.isAuthenticated()) { return; } - this.router.navigate([this.routerLink]); - } - - createNew() { - this.router.navigate([this.buttonRedirectLink]); - } - - isAuthenticated() { - return this.authService.currentAccountIsAuthenticated(); - } - - viewAllClicked() { - this.onClick.emit(); - } -} diff --git a/dmp-frontend/src/app/ui/dashboard/quick-wizard-create-add/quick-wizard-create-add.component.html b/dmp-frontend/src/app/ui/dashboard/quick-wizard-create-add/quick-wizard-create-add.component.html deleted file mode 100644 index d5ba9d1af..000000000 --- a/dmp-frontend/src/app/ui/dashboard/quick-wizard-create-add/quick-wizard-create-add.component.html +++ /dev/null @@ -1,21 +0,0 @@ -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dashboard/quick-wizard-create-add/quick-wizard-create-add.component.scss b/dmp-frontend/src/app/ui/dashboard/quick-wizard-create-add/quick-wizard-create-add.component.scss deleted file mode 100644 index b1804315c..000000000 --- a/dmp-frontend/src/app/ui/dashboard/quick-wizard-create-add/quick-wizard-create-add.component.scss +++ /dev/null @@ -1,33 +0,0 @@ -.figure-card { - display: inline-block; - position: relative; - width: 100%; - margin: 25px 0; -} - -.card { - padding: 25px 20px 20px 20px; - display: flex; - flex-direction: column; - align-items: center; -} - -.card { - box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.14); - border-radius: 6px; - color: rgba(0, 0, 0, 0.87); - background: #fff; -} - -.vl { - border-left: solid #999; - height: 100%; - } - -a { - text-decoration: none; - } - .conteiner{ - padding: 1em; - background-color: #eef1f5; - } \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dashboard/quick-wizard-create-add/quick-wizard-create-add.component.ts b/dmp-frontend/src/app/ui/dashboard/quick-wizard-create-add/quick-wizard-create-add.component.ts deleted file mode 100644 index d64a2de98..000000000 --- a/dmp-frontend/src/app/ui/dashboard/quick-wizard-create-add/quick-wizard-create-add.component.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Component, OnInit } from "@angular/core"; -import { MatSnackBar } from "@angular/material/snack-bar"; -import { ActivatedRoute, Router } from "@angular/router"; -import { BaseComponent } from '@common/base/base.component'; -import { TranslateService } from "@ngx-translate/core"; - -@Component({ - selector: 'app-quick-wizard-create-add-component', - templateUrl: 'quick-wizard-create-add.component.html', - styleUrls: ['./quick-wizard-create-add.component.scss'] -}) -export class QuickWizardCreateAdd extends BaseComponent implements OnInit { - - constructor( - private router: Router, - private languageService: TranslateService, - public snackBar: MatSnackBar, - public route: ActivatedRoute - ) { - super(); - } - - - ngOnInit(): void { - - } - - navigateToCreate() { - this.router.navigate(["/quick-wizard"]); - } - - - navigateToAdd() { - this.router.navigate(["/datasetcreatewizard"]); - } - - -} diff --git a/dmp-frontend/src/app/ui/dashboard/recent-activity/recent-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-activity/recent-activity.component.html deleted file mode 100644 index e5c31fcf8..000000000 --- a/dmp-frontend/src/app/ui/dashboard/recent-activity/recent-activity.component.html +++ /dev/null @@ -1,67 +0,0 @@ -
-
- - - - {{'RECENT-ACTIVITY.MY-TITLE-DMP' | translate}} - - - - - -

- {{activity.label}} -

-

- {{activity.timestamp | date:'shortDate'}} -

-
-
-
-
-
-
- - - - {{'RECENT-ACTIVITY.MY-TITLE-GRANT' | translate}} - - - - - -

- {{activity.label}} -

-

- {{activity.timestamp | date:'shortDate'}} -

-
-
-
- -
-
-
- - - - {{'RECENT-ACTIVITY.MY-TITLE-DATASET' | translate}} - - - - - -

- {{activity.label}} -

-

- {{activity.timestamp | date:'shortDate'}} -

-
-
- -
-
-
-
diff --git a/dmp-frontend/src/app/ui/dashboard/recent-activity/recent-activity.component.scss b/dmp-frontend/src/app/ui/dashboard/recent-activity/recent-activity.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/dmp-frontend/src/app/ui/dashboard/recent-activity/recent-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-activity/recent-activity.component.ts deleted file mode 100644 index 8bba3ea0a..000000000 --- a/dmp-frontend/src/app/ui/dashboard/recent-activity/recent-activity.component.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; -import { RecentActivityType } from '@app/core/common/enum/recent-activity-type'; -import { UserServiceOld } from '@app/core/services/user/user.service-old'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-recent-activity', - templateUrl: './recent-activity.component.html', - styleUrls: ['./recent-activity.component.scss'] -}) -export class RecentActivityComponent extends BaseComponent implements OnInit { - - datasetActivities: any[]; - grantActivities: any[]; - dmpActivities: any[]; - recentActivityTypeEnum = RecentActivityType; - - constructor( - private router: Router, - private userService: UserServiceOld - ) { super(); } - - ngOnInit() { - this.userService.getRecentActivity() - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - this.datasetActivities = response['recentDatasetActivities']; - this.dmpActivities = response['recentDmpActivities']; - this.grantActivities = response['recentGrantActivities']; - }); - } - - redirect(id: string, type: RecentActivityType) { - switch (type) { - case RecentActivityType.Grant: { - this.router.navigate(['grants/edit/' + id]); - return; - } - case RecentActivityType.Dataset: { - this.router.navigate(['datasets/edit/' + id]); - return; - } - case RecentActivityType.Dmp: { - this.router.navigate(['plans/edit/' + id]); - return; - } - default: throw new Error('Unsupported Activity Type '); - } - - } -} diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html index 5a7384aef..54e05f9cd 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.html @@ -1,7 +1,7 @@ -
+
{{'DMP-LISTING.EMPTY-LIST' | translate}}
-
+
{{'DMP-LISTING.SORT-BY' | translate}}: @@ -11,7 +11,6 @@ {{enumUtils.toRecentActivityOrderString(order.PUBLISHED)}} {{enumUtils.toRecentActivityOrderString(order.LABEL)}} {{enumUtils.toRecentActivityOrderString(order.STATUS)}} - @@ -26,143 +25,9 @@
-
-
-
- - -
-
{{ 'DMP-LISTING.DMP' | translate }}
-
{{ 'DMP-LISTING.EDITED' | translate }}: {{ activity.modified | dateTimeCultureFormatter: "d MMMM y" }}
-
{{ 'DMP-LISTING.PUBLISHED' | translate }}: {{ activity.publishedAt | dateTimeCultureFormatter: "d MMMM y" }}
-
-
{{activity.title}}
-
- {{ roleDisplay(activity.users) }} - . - public{{'TYPES.DMP-VISIBILITY.PUBLIC' | translate}} - done{{ enumUtils.toDmpStatusString(activity.status) }} - create{{ enumUtils.toDmpStatusString(activity.status) }} - . - {{'DMP-LISTING.VERSION' | translate}} {{activity.version}} - . - {{ 'DMP-LISTING.GRANT' | translate }}: {{activity.grant}} -
-
{{'DMP-LISTING.CONTAINED-DESCRIPTIONS' | translate}}: ({{ getDatasets(activity).length }}) -
-
-
-
{{dataset.label}},
-
{{dataset.label}}
-
-
- -
{{'GENERAL.ACTIONS.SHOW-MORE' | translate}} - - - - - - - - - - - - - - -
-
-
- -
+
+ +
{{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}} @@ -170,109 +35,4 @@
-
- - - - +
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts index dab84b1c1..da4eca1ea 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts @@ -1,50 +1,20 @@ import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; -import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; -import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; +import { Component, Input, OnInit } from '@angular/core'; +import { UntypedFormBuilder, UntypedFormControl } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; -import { DmpBlueprintSectionFieldCategory } from '@app/core/common/enum/dmp-blueprint-section-field-category'; -import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; -import { RecentActivityType } from '@app/core/common/enum/recent-activity-type'; -import { Role } from '@app/core/common/enum/role'; -import { DataTableMultiTypeRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing'; -import { DatasetUrlListing } from '@app/core/model/dataset/dataset-url-listing'; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { RecentActivityModel } from '@app/core/model/recent-activity/recent-activity.model'; -import { RecentDatasetModel } from '@app/core/model/recent-activity/recent-dataset-activity.model'; -import { RecentDmpModel } from '@app/core/model/recent-activity/recent-dmp-activity.model'; -import { RecentActivityCriteria } from '@app/core/query/recent-activity/recent-activity-criteria'; +import { RecentActivityItem } from '@app/core/model/dashboard/recent-activity-item'; +import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; +import { Description } from '@app/core/model/description/description'; +import { Dmp, DmpUser } from '@app/core/model/dmp/dmp'; +import { DmpReference, Reference } from '@app/core/model/reference/reference'; +import { RecentActivityItemLookup } from '@app/core/query/recent-activity-item-lookup.lookup'; import { AuthService } from '@app/core/services/auth/auth.service'; import { DashboardService } from '@app/core/services/dashboard/dashboard.service'; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { LockService } from '@app/core/services/lock/lock.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { DatasetCopyDialogueComponent } from '@app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component'; -import { CloneDialogComponent } from '@app/ui/dmp/clone/clone-dialog/clone-dialog.component'; -import { DmpEditorModel } from '@app/ui/dmp/editor/dmp-editor.model'; -import { ExtraPropertiesFormModel } from '@app/ui/dmp/editor/general-tab/extra-properties-form.model'; -import { FunderFormModel } from '@app/ui/dmp/editor/grant-tab/funder-form-model'; -import { GrantTabModel } from '@app/ui/dmp/editor/grant-tab/grant-tab-model'; -import { ProjectFormModel } from '@app/ui/dmp/editor/grant-tab/project-form-model'; -import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; import { BaseComponent } from '@common/base/base.component'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { Guid } from '@common/types/guid'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { debounceTime, map, takeUntil } from 'rxjs/operators'; +import { debounceTime, takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; @Component({ @@ -54,21 +24,11 @@ import { nameof } from 'ts-simple-nameof'; }) export class RecentEditedActivityComponent extends BaseComponent implements OnInit { - @Output() totalCountRecentEdited: EventEmitter = new EventEmitter(); - - @ViewChild("results") resultsContainer; - allRecentActivities: RecentActivityModel[]; - recentActivityTypeEnum = RecentActivityType; - dmpModel: DmpEditorModel; - isDraft: boolean; - totalCount: number; - startIndex: number = 0; - dmpOffset: number = 0; - datasetOffset: number = 0; - offsetLess: number = 0; + lookup: RecentActivityItemLookup = new RecentActivityItemLookup(); pageSize: number = 5; - dmpFormGroup: UntypedFormGroup; - hasMoreActivity: boolean = true; + listingItems: RecentActivityItem[]; + + public formGroup = new UntypedFormBuilder().group({ like: new UntypedFormControl(), order: new UntypedFormControl() @@ -77,6 +37,9 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn order = RecentActivityOrder; + totalCount: number; + startIndex: number = 0; + offsetLess: number = 0; page: number = 1; @Input() isActive: boolean = false; @@ -85,39 +48,29 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn private router: Router, public enumUtils: EnumUtils, private authentication: AuthService, - private dmpService: DmpService, - private dmpBlueprintService: DmpBlueprintService, private dashboardService: DashboardService, - private language: TranslateService, - private dialog: MatDialog, - private uiNotificationService: UiNotificationService, - private datasetWizardService: DatasetWizardService, private location: Location, - private lockService: LockService, - private httpClient: HttpClient, - private matomoService: MatomoService, - private fileUtils: FileUtils + private matomoService: MatomoService ) { super(); } ngOnInit() { - this.matomoService.trackPageView('Recent Edited Activity'); + this.matomoService.trackPageView('Recent DMP Activity'); this.route.queryParams.subscribe(params => { if (this.isActive) { let page = (params['page'] === undefined) ? 1 : +params['page']; this.page = (page <= 0) ? 1 : page; - this.datasetOffset = (this.page - 1) * this.pageSize; - this.dmpOffset = (this.page - 1) * this.pageSize; + this.startIndex = (this.page - 1) * this.pageSize; if (this.page > 1) { this.offsetLess = (this.page - 2) * this.pageSize; } let order = params['order']; if (this.isAuthenticated()) { - if (order === undefined || (order != this.order.MODIFIED && order != this.order.LABEL && order != this.order.STATUS)) { - order = this.order.MODIFIED; + if (order === undefined || (order != this.order.UpdatedAt && order != this.order.Label && order != this.order.Status)) { + order = this.order.UpdatedAt; } } else { if (order === undefined || (order != this.order.PUBLISHED && order != this.order.LABEL)) { @@ -133,87 +86,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn } }); if (this.isAuthenticated()) { - if (!this.formGroup.get('order').value) { - this.formGroup.get('order').setValue(this.order.MODIFIED); - } - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - const allDataTableRequest: DataTableMultiTypeRequest = new DataTableMultiTypeRequest(this.dmpOffset, this.datasetOffset, 5, { fields: fields }); - allDataTableRequest.criteria = new RecentActivityCriteria(); - allDataTableRequest.criteria.like = this.formGroup.get('like').value; - allDataTableRequest.criteria.order = this.formGroup.get('order').value; - - this.dashboardService - .getRecentActivity(allDataTableRequest) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - this.allRecentActivities = response; - this.allRecentActivities.forEach(recentActivity => { - if (recentActivity.type === RecentActivityType.Dataset) { - // this.datasetOffset = this.datasetOffset + 1; - this.datasetOffset = this.page * this.pageSize; - } else if (recentActivity.type === RecentActivityType.Dmp) { - // this.dmpOffset = this.dmpOffset + 1; - this.dmpOffset = this.page * this.pageSize; - } - }); - this.totalCountRecentEdited.emit(this.allRecentActivities.length); - if (this.allRecentActivities.length == 0 && this.page > 1) { - let queryParams = { type: "recent", page: 1, order: this.formGroup.get("order").value }; - if (this.formGroup.get("like").value) { - queryParams['keyword'] = this.formGroup.get("like").value; - } - this.router.navigate(["/home"], { queryParams: queryParams }) - } - }); - this.formGroup.get('like').valueChanges - .pipe(takeUntil(this._destroyed), debounceTime(500)) - .subscribe(x => { - this.refresh() - }); - this.formGroup.get('order').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.refresh() - }); - } else { - this.publicMode = true; - if (!this.formGroup.get('order').value) { - this.formGroup.get('order').setValue(this.order.PUBLISHED); - } - const allDataTableRequest = this.setPublicDataTableRequest(); - this.dashboardService - .getRecentActivity(allDataTableRequest) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - this.allRecentActivities = response; - this.allRecentActivities.forEach(recentActivity => { - if (recentActivity.type === RecentActivityType.Dataset) { - // this.datasetOffset = this.datasetOffset + 1; - this.datasetOffset = this.page * this.pageSize; - } else if (recentActivity.type === RecentActivityType.Dmp) { - // this.dmpOffset = this.dmpOffset + 1; - this.dmpOffset = this.page * this.pageSize; - } - }); - this.totalCountRecentEdited.emit(this.allRecentActivities.length); - if (this.allRecentActivities.length == 0 && this.page > 1) { - let queryParams = { type: "recent", page: 1, order: this.formGroup.get("order").value }; - if (this.formGroup.get("like").value) { - queryParams['keyword'] = this.formGroup.get("like").value; - } - this.router.navigate(["/home"], { queryParams: queryParams }) - } - }); - this.formGroup.get('like').valueChanges - .pipe(takeUntil(this._destroyed), debounceTime(500)) - .subscribe(x => { - this.refresh() - }); - this.formGroup.get('order').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.refresh() - }); + this.refresh(); } } @@ -224,721 +97,92 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn } updateUrl() { - let parameters = ""; - parameters += (this.page != 1 ? "&page=" + this.page : ""); - parameters += (((this.formGroup.get("order").value != this.order.MODIFIED && !this.publicMode) || (this.formGroup.get("order").value != this.order.PUBLISHED && this.publicMode)) ? "&order=" + this.formGroup.get("order").value : ""); - parameters += (this.formGroup.get("like").value ? ("&keyword=" + this.formGroup.get("like").value) : ""); - if (parameters) { - parameters = "?type=recent" + parameters; - } + let parameters = "?type=dmps" + + (this.page != 1 ? "&page=" + this.page : "") + + (((this.formGroup.get("order").value != this.order.MODIFIED && !this.publicMode) || (this.formGroup.get("order").value != this.order.PUBLISHED && this.publicMode)) ? "&order=" + this.formGroup.get("order").value : "") + + (this.formGroup.get("like").value ? ("&keyword=" + this.formGroup.get("like").value) : ""); this.location.go(this.router.url.split('?')[0] + parameters); } - getDatasets(activity: RecentDmpModel): DatasetUrlListing[] { - return activity.datasets; - } - - getGroupId(activity: RecentDmpModel): string { - return activity.groupId; - } - - getDmp(activity: RecentDatasetModel): String { - return activity.dmp; - } - - getDmpId(activity: RecentDatasetModel): String { - return activity.dmpId; - } - - private setPublicDataTableRequest(fields?: Array): DataTableMultiTypeRequest { - const criteria = new RecentActivityCriteria(); - criteria.like = this.formGroup.get("like").value ? this.formGroup.get("like").value : ""; - if (!fields) { - fields = new Array('-publishedAt'); - } - const dataTableRequest: DataTableMultiTypeRequest = new DataTableMultiTypeRequest(this.dmpOffset, this.datasetOffset, this.pageSize, { fields: fields }); - dataTableRequest.criteria = criteria; - return dataTableRequest; - } - - // getPublic(activity: RecentDmpModel): boolean { - // return activity.isPublic; - // } - - // getUsers(activity: RecentDmpModel): UserInfoListingModel[] { - // return activity.users; - // } - public isAuthenticated(): boolean { return this.authentication.currentAccountIsAuthenticated(); } - isUserOwner(activity: DmpListingModel): boolean { - const principalId: string = this.authentication.userId()?.toString(); - if (principalId) return !!activity.users.find(x => (x.role === Role.Owner) && (principalId === x.id)); - } - - editClicked(dmp: DmpListingModel) { - this.router.navigate(['/plans/edit/' + dmp.id]); - } - - deleteDmpClicked(dmp: DmpListingModel) { - this.lockService.checkLockStatus(dmp.id).pipe(takeUntil(this._destroyed)) - .subscribe(lockStatus => { - if (!lockStatus) { - this.openDeleteDmpDialog(dmp); - } else { - this.openDmpLockedByUserDialog(); - } - }); - } - - cloneOrNewVersionClicked(dmp: RecentActivityModel, isNewVersion: boolean) { - this.dmpService.getSingle(dmp.id).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.dmpModel = new DmpEditorModel(); - this.dmpModel.grant = new GrantTabModel(); - this.dmpModel.project = new ProjectFormModel(); - this.dmpModel.funder = new FunderFormModel(); - this.dmpModel.extraProperties = new ExtraPropertiesFormModel(); - this.dmpModel.fromModel(data); - this.dmpModel.status = DmpStatus.Draft; - this.dmpFormGroup = this.dmpModel.buildForm(); - - if (!isNullOrUndefined(this.formGroup.get('profile').value)) { - this.getBlueprintDefinition(Guid.parse(this.formGroup.get('profile').value), result => { - this.checkForGrant(result.definition); - this.checkForFunder(result.definition); - this.checkForProject(result.definition); - }); - } - - if (!isNewVersion) { - this.dmpFormGroup.get('label').setValue(dmp.title + " New"); - } - this.openCloneDialog(isNewVersion); - }); - } - - - - private getBlueprintDefinition(blueprintId: Guid, successFunction) { - this.dmpBlueprintService.getSingle(blueprintId, [ - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), - - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - ] - ) - .pipe(map(data => data as DmpBlueprint), takeUntil(this._destroyed)) - .subscribe( - data => successFunction(data), - ); - } - - - private checkForGrant(blueprint: DmpBlueprintDefinition) { - let hasGrant = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.GRANT) { - hasGrant = true; - } - } - )); - if (!hasGrant) { - this.formGroup.removeControl('grant'); - } - } - - private checkForFunder(blueprint: DmpBlueprintDefinition) { - let hasFunder = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.FUNDER) { - hasFunder = true; - } - } - )); - if (!hasFunder) { - this.formGroup.removeControl('funder'); - } - } - - private checkForProject(blueprint: DmpBlueprintDefinition) { - let hasProject = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.PROJECT) { - hasProject = true; - } - } - )); - if (!hasProject) { - this.formGroup.removeControl('project'); - } - } - - openCloneDialog(isNewVersion: boolean) { - const dialogRef = this.dialog.open(CloneDialogComponent, { - maxWidth: '700px', - maxHeight: '80vh', - data: { - formGroup: this.dmpFormGroup, - datasets: this.dmpFormGroup.get('datasets').value, - isNewVersion: isNewVersion, - confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.SAVE'), - cancelButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CANCEL'), - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - if (!isNewVersion) { - this.dmpService.clone(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCloneOrNewVersionCallbackSuccess(complete), - error => this.onCloneOrNewVersionCallbackError(error) - ); - } else if (isNewVersion) { - this.dmpService.newVersion(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCloneOrNewVersionCallbackSuccess(complete), - error => this.onCloneOrNewVersionCallbackError(error) - ); - } - } - }); - } - - openDeleteDmpDialog(dmp: DmpListingModel) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.dmpService.delete(dmp.id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onDeleteCallbackSuccess(), - error => this.onDeleteCallbackError(error) - ); - } - }); - } - - openDmpLockedByUserDialog() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '400px', - restoreFocus: false, - data: { - message: this.language.instant('DMP-EDITOR.ACTIONS.LOCK') - } - }); - } - - openShareDialog(rowId: any, rowName: any) { - const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { - // height: '250px', - // width: '700px', - autoFocus: false, - restoreFocus: false, - data: { - dmpId: rowId, - dmpName: rowName - } - }); - } - - isDraftDmp(activity: DmpListingModel) { - return activity.status == DmpStatus.Draft; - } - - onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans']); - } - - reloadPage(): void { - const path = this.location.path(); - this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => { - this.router.navigate([path]); - }); - } - - onDeleteCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); - this.reloadPage(); - } - - onDeleteCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? this.language.instant(error.error.message) : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); - } - - onCloneOrNewVersionCallbackSuccess(dmpId: String): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans/edit/', dmpId]); - } - - onCloneOrNewVersionCallbackError(error: any) { - this.uiNotificationService.snackBarNotification(error.error.message ? this.language.instant(error.error.message) : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-CLONE'), SnackBarNotificationLevel.Error); - } - - redirect(id: string, type: RecentActivityType) { - switch (type) { - case RecentActivityType.Grant: { - this.router.navigate(["grants/edit/" + id]); - return; - } - case RecentActivityType.Dataset: { - if (this.isAuthenticated()) { - this.router.navigate(['../datasets/overview/' + id]); - } else { - this.router.navigate(['../explore/publicOverview', id]); - } - return; - } - case RecentActivityType.Dmp: { - if (this.isAuthenticated()) { - this.router.navigate(['../plans/overview/' + id]); - } else { - this.router.navigate(['../explore-plans/publicOverview', id]); - } - return; - } - default: - throw new Error("Unsupported Activity Type "); - } - } - - navigateToUrl(id: string, type: RecentActivityType): string[] { - switch (type) { - case RecentActivityType.Grant: { - return ["grants/edit/" + id]; - } - case RecentActivityType.Dataset: { - if (this.isAuthenticated()) { - return ['../datasets/overview/' + id]; - } else { - return ['../explore/publicOverview', id]; - } - } - case RecentActivityType.Dmp: { - if (this.isAuthenticated()) { - return ['../plans/overview/' + id]; - } else { - return ['../explore-plans/publicOverview', id]; - } - } - default: - throw new Error("Unsupported Activity Type "); - } - } - - roleDisplay(value: any) { - const principalId: string = this.authentication.userId()?.toString(); - let role: number; - if (principalId) { - value.forEach(element => { - if (principalId === element.id) { - role = element.role; - } - }); - } - if (role === 0) { - return this.language.instant('DMP-LISTING.OWNER'); - } - else if (role === 1) { - return this.language.instant('DMP-LISTING.MEMBER'); - } - else { - return this.language.instant('DMP-LISTING.OWNER'); - } - } - - // dmpBlueprintDisplay(value: any) { - // if (value != null) { - // return value; - // } - // else { - // return "--"; - // } - // } - - downloadXml(id: string) { - this.dmpService.downloadXML(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "xml", id); - }); - } - - downloadDocx(id: string) { - this.dmpService.downloadDocx(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "docx", id); - }); - } - - downloadPdf(id: string) { - this.dmpService.downloadPDF(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/pdf' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "pdf", id); - }); - } - - downloadJson(id: string) { - this.dmpService.downloadJson(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/json' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "json", id); - }, async error => { - this.onExportCallbackError(error); - }); - } - - async onExportCallbackError(error: any) { - const errorJsonText = await error.error.text(); - const errorObj = JSON.parse(errorJsonText); - this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error); - } - - downloadPDF(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadPDF(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/pdf' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "pdf", dataset.id); - }); - } - - downloadDOCX(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadDOCX(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "docx", dataset.id); - }); - - } - - downloadXML(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadXML(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "xml", dataset.id); - }); - } - - // newVersion(id: String, label: String) { - // let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }]); - // window.open(url.toString(), '_blank'); - // } - - viewVersions(rowId: String, rowLabel: String, activity: DmpListingModel) { - if (activity.public && !this.isUserOwner(activity)) { - let url = this.router.createUrlTree(['/explore-plans/versions/', rowId, { groupLabel: rowLabel }]); - window.open(url.toString(), '_blank'); - // this.router.navigate(['/explore-plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); - } else { - let url = this.router.createUrlTree(['/plans/versions/', rowId, { groupLabel: rowLabel }]); - window.open(url.toString(), '_blank'); - // this.router.navigate(['/plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); - } - } - - openDmpSearchDialogue(dataset: RecentDatasetModel) { - const formControl = new UntypedFormControl(); - const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, { - width: '500px', - restoreFocus: false, - data: { - formControl: formControl, - datasetId: dataset.id, - datasetProfileId: dataset.profile.id, - datasetProfileExist: false, - confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'), - cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL') - } - }); - - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result && result.datasetProfileExist) { - const newDmpId = result.formControl.value.id; - // let url = this.router.createUrlTree(['/datasets/copy/', result.datasetId, { newDmpId: newDmpId }]); - // window.open(url.toString(), '_blank'); - this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } }); - } - }); - } - - deleteDatasetClicked(id: string) { - this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed)) - .subscribe(lockStatus => { - if (!lockStatus) { - this.openDeleteDatasetDialog(id); - } else { - this.openDatasetLockedByUserDialog(); - } - }); - } - - openDeleteDatasetDialog(id: string): void { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetWizardService.delete(id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onDeleteCallbackSuccess(), - error => this.onDeleteCallbackError(error) - ); - } - }); - } - - openDatasetLockedByUserDialog() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '400px', - restoreFocus: false, - data: { - message: this.language.instant('DATASET-WIZARD.ACTIONS.LOCK') - } - }); - } - refresh(): void { - this.datasetOffset = 0; - this.dmpOffset = 0; - this.page = 1; - this.updateUrl(); + if (!this.formGroup.get('order').value) { + this.formGroup.get('order').setValue(this.order.UpdatedAt); + } + this.lookup.page = { size: this.pageSize, offset: 0 }; + this.lookup.orderField = this.formGroup.get('order').value; + this.lookup.like = this.formGroup.get('like').value; + this.lookup.project = { + + fields: [ + [nameof(x => x.dmp), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.label)].join('.'), + [nameof(x => x.dmp), nameof(x => x.status)].join('.'), + [nameof(x => x.dmp), nameof(x => x.accessType)].join('.'), + [nameof(x => x.dmp), nameof(x => x.version)].join('.'), + [nameof(x => x.dmp), nameof(x => x.groupId)].join('.'), + [nameof(x => x.dmp), nameof(x => x.updatedAt)].join('.'), + [nameof(x => x.dmp), nameof(x => x.descriptions), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.descriptions), nameof(x => x.label)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.user.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.role)].join('.'), + + [nameof(x => x.description), nameof(x => x.id)].join('.'), + [nameof(x => x.description), nameof(x => x.label)].join('.'), + [nameof(x => x.description), nameof(x => x.status)].join('.'), + [nameof(x => x.description), nameof(x => x.updatedAt)].join('.'), + [nameof(x => x.description), nameof(x => x.descriptionTemplate), nameof(x => x.id)].join('.'), + [nameof(x => x.description), nameof(x => x.descriptionTemplate), nameof(x => x.label)].join('.'), + [nameof(x => x.description), nameof(x => x.descriptionTemplate), nameof(x => x.groupId)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.id)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.label)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.accessType)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.id)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.user.id)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.role)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.id)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.id)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.label)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.type)].join('.'), + [nameof(x => x.description), nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.reference)].join('.'), + ] + }; - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - // const fields: Array = ["-modified"]; - this.startIndex = 0; - const allDataTableRequest: DataTableMultiTypeRequest = new DataTableMultiTypeRequest(0, 0, this.pageSize, { fields: fields }); - allDataTableRequest.criteria = new RecentActivityCriteria(); - allDataTableRequest.criteria.like = this.formGroup.get("like").value; - allDataTableRequest.criteria.order = this.formGroup.get("order").value; this.dashboardService - .getRecentActivity(allDataTableRequest) + .getMyRecentActivityItems(this.lookup) .pipe(takeUntil(this._destroyed)) .subscribe(response => { - this.allRecentActivities = response; - this.allRecentActivities.forEach(recentActivity => { - if (recentActivity.type === RecentActivityType.Dataset) { - // this.datasetOffset = this.datasetOffset + 1; - this.datasetOffset = this.page * this.pageSize; - } else if (recentActivity.type === RecentActivityType.Dmp) { - // this.dmpOffset = this.dmpOffset + 1; - this.dmpOffset = this.page * this.pageSize; - } - }); + this.listingItems = response; + //this.totalCount = response.totalCount; - if (response.length < this.pageSize) { - this.hasMoreActivity = false; - } else { - this.hasMoreActivity = true; - } - this.totalCountRecentEdited.emit(this.allRecentActivities.length); + + //this.totalCountDmps.emit(this.dmpActivities.length); + // if (this.totalCount > 0 && this.totalCount <= (this.page - 1) * this.pageSize && this.page > 1) { + // let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value }; + // if (this.formGroup.get("like").value) { + // queryParams['keyword'] = this.formGroup.get("like").value; + // } + // this.router.navigate(["/home"], { queryParams: queryParams }) + // } + // this.totalCount < this.pageSize ? this.totalCountDmps.emit(response.totalCount) : this.totalCountDmps.emit(this.pageSize); + // this.totalCountDmps.emit(this.totalCount); + // this.dmpActivities.forEach(dmpActivity => { + // const recentActivity: RecentActivity = { + // activityData: dmpActivity, + // activityType: RecentActivityType.Dmp + // }; + // this.allRecentActivities.push(recentActivity) + // }) }); + this.formGroup.get('like').valueChanges + .pipe(takeUntil(this._destroyed), debounceTime(500)) + .subscribe(x => this.refresh()); + this.formGroup.get('order').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => this.refresh()); } - - public loadNextOrPrevious(more: boolean = true) { - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - // const fields: Array = ["-modified"]; - let request; - if (more) { - request = new DataTableMultiTypeRequest(this.dmpOffset, this.datasetOffset, this.pageSize, { fields: fields }); - } else { - request = new DataTableMultiTypeRequest(this.offsetLess, this.offsetLess, this.pageSize, { fields: fields }); - } - request.criteria = new RecentActivityCriteria(); - request.criteria.like = this.formGroup.get("like").value ? this.formGroup.get("like").value : ""; - request.criteria.order = this.formGroup.get("order").value; - - this.dashboardService.getRecentActivity(request).pipe(takeUntil(this._destroyed)).subscribe(result => { - if (!result || result.length == 0) { - this.hasMoreActivity = false; - // return []; - } else { - this.page = this.page + (more ? 1 : -1); - this.updateUrl(); - // if(more) { - // result.forEach(recentActivity => { - // if (recentActivity.type === RecentActivityType.Dataset) { - // this.datasetOffset = this.datasetOffset + 1; - this.datasetOffset = this.page * this.pageSize; - // } else if (recentActivity.type === RecentActivityType.Dmp) { - // this.dmpOffset = this.dmpOffset + 1; - this.dmpOffset = this.page * this.pageSize; - // } - // }); - // } - if (this.page > 1) { - this.offsetLess = (this.page - 2) * this.pageSize; - } - - if (result.length < this.pageSize) { - this.hasMoreActivity = false; - } else { - this.hasMoreActivity = true; - } - - // this.allRecentActivities = this.allRecentActivities.concat(result); - // this.allRecentActivities = this.allRecentActivities.length > 0 ? this.mergeTwoSortedLists(this.allRecentActivities, result, this.formGroup.get('order').value) : result; - this.allRecentActivities = result; - this.totalCountRecentEdited.emit(this.allRecentActivities.length); - if (more) { - this.resultsContainer.nativeElement.scrollIntoView(); - } - } - }); - - } - - private mergeTwoSortedLists(arr1: RecentActivityModel[], arr2: RecentActivityModel[], order: string): RecentActivityModel[] { - let merged = []; - let index1 = 0; - let index2 = 0; - let current = 0; - - while (current < (arr1.length + arr2.length)) { - - let isArr1Depleted = index1 >= arr1.length; - let isArr2Depleted = index2 >= arr2.length; - - if (order === 'modified') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].modified) > new Date(arr2[index2].modified)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'created') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].created) > new Date(arr2[index2].created)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'label') { - if (!isArr1Depleted && (isArr2Depleted || (arr1[index1].title.localeCompare(arr2[index2].title)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'status') { - if (!isArr1Depleted && (isArr2Depleted || (arr1[index1].status < arr2[index2].status))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === "publishedAt") { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].publishedAt) > new Date(arr2[index2].publishedAt)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } - current++; - } - return merged; - } - - // advancedClicked(dmp: DmpListingModel) { - // const dialogRef = this.dialog.open(ExportMethodDialogComponent, { - // maxWidth: '500px', - // data: { - // message: "Download as:", - // XMLButton: "XML", - // documentButton: "Document", - // pdfButton: "PDF", - // jsonButton: "JSON" - - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result == "pdf") { - // this.downloadPDF(dmp.id); - // } else if (result == "xml") { - // this.downloadXml(dmp.id); - // } else if (result == "doc") { - // this.downloadDocx(dmp.id); - // } else if (result == "json") { - // this.downloadJson(dmp.id) - // } - // }); - // } } diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.html deleted file mode 100644 index d798c4845..000000000 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.html +++ /dev/null @@ -1,93 +0,0 @@ -
-
- - {{'DMP-LISTING.SORT-BY' | translate}}: - - - {{enumUtils.toRecentActivityOrderString(order.MODIFIED)}} - {{enumUtils.toRecentActivityOrderString(order.DATASETPUBLISHED)}} - {{enumUtils.toRecentActivityOrderString(order.LABEL)}} - {{enumUtils.toRecentActivityOrderString(order.STATUS)}} - - - - - - - search - - {{formGroup.get('like').getError('backendError').message}} - - -
-
- -
-
- -
-
- {{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}} -
-
- -
-
diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.ts deleted file mode 100644 index 80069e302..000000000 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.ts +++ /dev/null @@ -1,518 +0,0 @@ -import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; -import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; -import { UntypedFormBuilder, UntypedFormControl } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; -import { ActivatedRoute, Router } from '@angular/router'; -import { DatasetStatus } from '@app/core/common/enum/dataset-status'; -import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; -import { Role } from '@app/core/common/enum/role'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing'; -import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { ConfigurationService } from "@app/core/services/configuration/configuration.service"; -import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { LockService } from '@app/core/services/lock/lock.service'; -import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { DatasetCopyDialogueComponent } from '@app/ui/dataset/dataset-wizard/dataset-copy-dialogue/dataset-copy-dialogue.component'; -import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component'; -import { BaseComponent } from '@common/base/base.component'; -import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { debounceTime, takeUntil } from 'rxjs/operators'; - -@Component({ - selector: 'app-recent-edited-dataset-activity', - templateUrl: './recent-edited-dataset-activity.component.html', - styleUrls: ['./recent-edited-dataset-activity.component.scss'] -}) -export class RecentEditedDatasetActivityComponent extends BaseComponent implements OnInit { - - @Output() totalCountDatasets: EventEmitter = new EventEmitter(); - - @ViewChild("datasets") resultsContainer; - - datasetActivities: DatasetListingModel[]; - totalCount: number; - startIndex: number = 0; - offsetLess: number = 0; - hasMoreResults: boolean = true; - pageSize: number = 5; - public formGroup = new UntypedFormBuilder().group({ - like: new UntypedFormControl(), - order: new UntypedFormControl() - }); - publicMode = false; - - order = RecentActivityOrder; - - page: number = 1; - @Input() isActive: boolean = false; - - constructor( - private route: ActivatedRoute, - private authentication: AuthService, - private datasetService: DatasetService, - private language: TranslateService, - public enumUtils: EnumUtils, - public dialog: MatDialog, - public router: Router, - private datasetWizardService: DatasetWizardService, - private uiNotificationService: UiNotificationService, - private location: Location, - private lockService: LockService, - private httpClient: HttpClient, - private matomoService: MatomoService, - private configurationService: ConfigurationService, - private fileUtils: FileUtils - ) { - super(); - } - - ngOnInit() { - this.matomoService.trackPageView('Recent Dataset Activity'); - this.route.queryParams.subscribe(params => { - if (this.isActive) { - let page = (params['page'] === undefined) ? 1 : +params['page']; - this.page = (page <= 0) ? 1 : page; - - this.startIndex = (this.page - 1) * this.pageSize; - if (this.page > 1) { - this.offsetLess = (this.page - 2) * this.pageSize; - } - - let order = params['order']; - if (this.isAuthenticated()) { - if (order === undefined || (order != this.order.MODIFIED && order != this.order.LABEL && order != this.order.STATUS)) { - order = this.order.MODIFIED; - } - } else { - if (order === undefined || (order != this.order.DATASETPUBLISHED && order != this.order.LABEL)) { - order = this.order.DATASETPUBLISHED; - } - } - this.formGroup.get('order').setValue(order); - - let keyword = (params['keyword'] === undefined || params['keyword'].length <= 0) ? "" : params['keyword']; - this.formGroup.get("like").setValue(keyword); - - this.updateUrl(); - } - }); - if (this.isAuthenticated()) { - // const fields: Array = ["-modified"]; - if (!this.formGroup.get('order').value) { - this.formGroup.get('order').setValue(this.order.MODIFIED); - } - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - const datasetDataTableRequest: DataTableRequest = new DataTableRequest(this.startIndex, this.pageSize, { fields: fields }); - datasetDataTableRequest.criteria = new DatasetCriteria(); - datasetDataTableRequest.criteria.like = this.formGroup.get('like').value; - this.datasetService - .getPaged(datasetDataTableRequest) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - this.datasetActivities = response.data; - this.totalCount = response.totalCount; - this.totalCountDatasets.emit(this.datasetActivities.length) - if (this.totalCount > 0 && this.totalCount <= (this.page - 1) * this.pageSize && this.page > 1) { - let queryParams = { type: "datasets", page: 1, order: this.formGroup.get("order").value }; - if (this.formGroup.get("like").value) { - queryParams['keyword'] = this.formGroup.get("like").value; - } - this.router.navigate(["/home"], { queryParams: queryParams }) - } - }); - this.formGroup.get('like').valueChanges - .pipe(takeUntil(this._destroyed), debounceTime(500)) - .subscribe(x => this.refresh()); - this.formGroup.get('order').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.refresh()); - } else { - this.publicMode = true; - if (!this.formGroup.get('order').value) { - this.formGroup.get('order').setValue(this.order.DATASETPUBLISHED); - } - const dataTableRequest = this.setPublicDataTableRequest(); - this.datasetService.getPaged(dataTableRequest).pipe(takeUntil(this._destroyed)).subscribe(response => { - this.datasetActivities = response.data; - this.totalCount = response.totalCount; - this.totalCountDatasets.emit(this.datasetActivities.length); - if (this.totalCount > 0 && this.totalCount <= (this.page - 1) * this.pageSize && this.page > 1) { - let queryParams = { type: "datasets", page: 1, order: this.formGroup.get("order").value }; - if (this.formGroup.get("like").value) { - queryParams['keyword'] = this.formGroup.get("like").value; - } - this.router.navigate(["/home"], { queryParams: queryParams }) - } - }); - this.formGroup.get('like').valueChanges - .pipe(takeUntil(this._destroyed), debounceTime(500)) - .subscribe(x => this.refresh()); - this.formGroup.get('order').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.refresh()); - } - } - - ngOnChanges() { - if (this.isActive) { - this.updateUrl(); - } - } - - updateUrl() { - let parameters = "?type=datasets" + - (this.page != 1 ? "&page=" + this.page : "") + - (((this.formGroup.get("order").value != this.order.MODIFIED && !this.publicMode) || (this.formGroup.get("order").value != this.order.DATASETPUBLISHED && this.publicMode)) ? "&order=" + this.formGroup.get("order").value : "") + - (this.formGroup.get("like").value ? ("&keyword=" + this.formGroup.get("like").value) : ""); - this.location.go(this.router.url.split('?')[0] + parameters); - } - - setPublicDataTableRequest(fields?: Array, more: boolean = true): DataTableRequest { - const datasetCriteria = new DatasetCriteria(); - datasetCriteria.allVersions = false; - datasetCriteria.isPublic = true; - datasetCriteria.like = this.formGroup.get("like").value ? this.formGroup.get("like").value : ""; - if (!fields) { - fields = new Array('-dmp:publishedAt|join|'); - } - const dataTableRequest: DataTableRequest = more ? new DataTableRequest(this.startIndex, this.pageSize, { fields: fields }) : new DataTableRequest(this.offsetLess, this.pageSize, { fields: fields }); - dataTableRequest.criteria = datasetCriteria; - return dataTableRequest; - } - - refresh(): void { - this.startIndex = 0; - this.page = 1; - this.updateUrl(); - - - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - const datasetDataTableRequest = this.isAuthenticated() ? new DataTableRequest(this.startIndex, this.pageSize, { fields: fields }) : this.setPublicDataTableRequest(fields); - if (this.isAuthenticated()) { - datasetDataTableRequest.criteria = new DatasetCriteria(); - datasetDataTableRequest.criteria.like = this.formGroup.get("like").value ? this.formGroup.get("like").value : ""; - } - this.datasetService - .getPaged(datasetDataTableRequest) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - this.datasetActivities = response.data; - this.totalCount = response.totalCount; - this.totalCountDatasets.emit(this.datasetActivities.length); - if (response.data.length < this.pageSize) { - this.hasMoreResults = false; - } else { - this.hasMoreResults = true; - } - }); - } - - public loadNextOrPrevious(more: boolean = true) { - this.startIndex = this.startIndex + this.pageSize; - - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - let request; - this.startIndex = (this.page) * this.pageSize; - if (this.page > 1) { - this.offsetLess = (this.page - 2) * this.pageSize; - } - if (this.isAuthenticated()) { - if (more) { - request = new DataTableRequest(this.startIndex, this.pageSize, { fields: fields }); - } else { - request = new DataTableRequest(this.offsetLess, this.pageSize, { fields: fields }); - } - } else { - request = this.setPublicDataTableRequest(fields, more); - } - if (this.isAuthenticated()) { - request.criteria = new DatasetCriteria(); - request.criteria.like = this.formGroup.get("like").value ? this.formGroup.get("like").value : ""; - } - - this.datasetService.getPaged(request).pipe(takeUntil(this._destroyed)).subscribe(result => { - if (!result || !result.data || result.data.length == 0) { - this.hasMoreResults = false; - // return []; - } else { - this.page = this.page + (more ? 1 : -1); - this.updateUrl(); - // this.datasetActivities = this.datasetActivities.concat(result.data); - // this.datasetActivities = this.datasetActivities.length > 0 ? this.mergeTwoSortedLists(this.datasetActivities, result.data, this.formGroup.get('order').value) : result.data; - this.datasetActivities = result.data; - - if (result.data.length < this.pageSize) { - this.hasMoreResults = false; - } else { - this.hasMoreResults = true; - } - - this.totalCountDatasets.emit(this.datasetActivities.length); - if (more) { - this.resultsContainer.nativeElement.scrollIntoView(); - } - } - }); - } - - public isAuthenticated(): boolean { - return this.authentication.currentAccountIsAuthenticated(); - } - - isUserOwner(activity: DatasetListingModel): boolean { - const principalId: string = this.authentication.userId()?.toString(); - if (principalId) return !!activity.users.find(x => (x.role === Role.Owner) && (principalId === x.id)); - } - - goToOverview(id: string): string[] { - if (this.isAuthenticated()) { - return ['../datasets/overview/' + id]; - } else { - return ['../explore/publicOverview', id]; - } - } - - roleDisplay(value: any) { - const principalId: string = this.authentication.userId()?.toString(); - let role: number; - if (principalId) { - value.forEach(element => { - if (principalId === element.id) { - role = element.role; - } - }); - } - if (role === 0) { - return this.language.instant('DMP-LISTING.OWNER'); - } - else if (role === 1) { - return this.language.instant('DMP-LISTING.MEMBER'); - } - else { - return this.language.instant('DMP-LISTING.OWNER'); - } - } - - openDmpSearchDialogue(dataset: DatasetListingModel) { - const formControl = new UntypedFormControl(); - const dialogRef = this.dialog.open(DatasetCopyDialogueComponent, { - width: '500px', - restoreFocus: false, - data: { - formControl: formControl, - datasetId: dataset.id, - datasetProfileId: dataset.profile.id, - datasetProfileExist: false, - confirmButton: this.language.instant('DATASET-WIZARD.DIALOGUE.COPY'), - cancelButton: this.language.instant('DATASET-WIZARD.DIALOGUE.CANCEL') - } - }); - - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)) - .subscribe(result => { - if (result && result.datasetProfileExist) { - const newDmpId = result.formControl.value.id; - this.router.navigate(['/datasets/copy/' + result.datasetId], { queryParams: { newDmpId: newDmpId } }); - // let url = this.router.createUrlTree(['/datasets/copy/', result.datasetId, { newDmpId: newDmpId }]); - // window.open(url.toString(), '_blank'); - } - }); - } - - deleteClicked(id: string) { - this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed)) - .subscribe(lockStatus => { - if (!lockStatus) { - this.openDeleteDialog(id); - } else { - this.openLockedByUserDialog(); - } - }); - } - - openDeleteDialog(id: string): void { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetWizardService.delete(id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onDeleteCallbackSuccess(), - error => this.onDeleteCallbackError(error) - ); - } - }); - } - - openLockedByUserDialog() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '400px', - restoreFocus: false, - data: { - message: this.language.instant('DATASET-WIZARD.ACTIONS.LOCK') - } - }); - } - - openShareDialog(dmpRowId: any, dmpRowName: any, activity: any) { - const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { - // height: '250px', - // width: '700px', - autoFocus: false, - restoreFocus: false, - data: { - dmpId: dmpRowId, - dmpName: dmpRowName - } - }); - } - - downloadPDF(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadPDF(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/pdf' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "pdf", dataset.id); - }); - } - - downloadDOCX(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadDOCX(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "docx", dataset.id); - }); - - } - - downloadXML(dataset: DatasetListingModel): void { - this.datasetWizardService.downloadXML(dataset.id as string) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('datasets', "xml", dataset.id); - }); - } - - onCallbackSuccess(id?: String): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - id ? this.router.navigate(['/reload']).then(() => { this.router.navigate(['/datasets', 'edit', id]); }) : this.router.navigate(['/datasets']); - } - - onCallbackError(error: any) { - this.setErrorModel(error.error); - } - - reloadPage(): void { - const path = this.location.path(); - this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => { - this.router.navigate([path]); - }); - } - - onDeleteCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); - this.reloadPage(); - } - - onDeleteCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? this.language.instant(error.error.message) : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); - } - - public setErrorModel(validationErrorModel: ValidationErrorModel) { - } - - needsUpdate(activity: DatasetListingModel) { - if (activity.isProfileLatestVersion || (activity.status === DatasetStatus.Finalized) - || (activity.isProfileLatestVersion == undefined && activity.status == undefined)) { - return false; - } - else { - return true; - } - } - - private mergeTwoSortedLists(arr1: DatasetListingModel[], arr2: DatasetListingModel[], order: string): DatasetListingModel[] { - let merged = []; - let index1 = 0; - let index2 = 0; - let current = 0; - - while (current < (arr1.length + arr2.length)) { - let isArr1Depleted = index1 >= arr1.length; - let isArr2Depleted = index2 >= arr2.length; - if (order === 'modified') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].modified) > new Date(arr2[index2].modified)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'created') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].created) > new Date(arr2[index2].created)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'label') { - if (!isArr1Depleted && (isArr2Depleted || (arr1[index1].label.localeCompare(arr2[index2].label)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'status') { - if (!isArr1Depleted && (isArr2Depleted || (arr1[index1].status < arr2[index2].status))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'dmp:publishedAt|join|') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].dmpPublishedAt) > new Date(arr2[index2].dmpPublishedAt)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } - current++; - } - return merged; - } -} diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.html new file mode 100644 index 000000000..8da972d99 --- /dev/null +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.html @@ -0,0 +1,35 @@ +
+
+ + {{'DMP-LISTING.SORT-BY' | translate}}: + + + {{enumUtils.toRecentActivityOrderString(order.MODIFIED)}} + {{enumUtils.toRecentActivityOrderString(order.DATASETPUBLISHED)}} + {{enumUtils.toRecentActivityOrderString(order.LABEL)}} + {{enumUtils.toRecentActivityOrderString(order.STATUS)}} + + + + + + + search + + {{formGroup.get('like').getError('backendError').message}} + + +
+
+ +
+
+ +
+
+ {{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}} +
+
+ +
+
diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.scss b/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.scss similarity index 91% rename from dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.scss rename to dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.scss index 3c5f10947..402416656 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dataset-activity/recent-edited-dataset-activity.component.scss +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.scss @@ -10,7 +10,7 @@ } .dmp-card, -.dataset-card { +.description-card { min-width: 712px; /* min-height: 308px; */ background: #ffffff 0% 0% no-repeat padding-box; @@ -56,7 +56,7 @@ input[type="text"] { line-height: 2.4; } -.dataset-label { +.description-label { width: auto; height: 37px; background: var(--secondary-color) 0% 0% no-repeat padding-box; @@ -70,7 +70,7 @@ input[type="text"] { } .dmp-title, -.dataset-title { +.description-title { text-align: left; font-weight: 600; font-family: "Roboto", sans-serif; @@ -81,7 +81,7 @@ input[type="text"] { color: #212121; } -.dataset-subtitle, +.description-subtitle, .dmp-subtitle { display: flex; flex-direction: row; @@ -95,7 +95,7 @@ input[type="text"] { } .dmp-title-draft, -.dataset-title-draft { +.description-title-draft { text-align: left; font-weight: 600; font-family: "Roboto", sans-serif; @@ -114,7 +114,7 @@ input[type="text"] { } .dmp-subtitle, -.dataset-subtitle { +.description-subtitle { .icon-align { display: inline-flex; @@ -124,7 +124,7 @@ input[type="text"] { } } -.dataset-card-actions, +.description-card-actions, .dmp-card-actions { display: flex; flex-direction: row; @@ -133,25 +133,25 @@ input[type="text"] { color: #848484; } -.dataset-card-actions a, +.description-card-actions a, .dmp-card-actions a { color: #848484 !important; text-decoration: none !important; } -.dataset-card-actions a:hover, +.description-card-actions a:hover, .dmp-card-actions a:hover { color: var(--primary-color) !important; } -.dmp-dataset-descriptions-title { +.dmp-description-descriptions-title { color: #000000; opacity: 0.6; padding-top: 1.5rem; padding-bottom: 0.8rem; } -.dmp-dataset-descriptions-name { +.dmp-description-descriptions-name { color: #000000; opacity: 0.6; font-weight: 700; diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.ts new file mode 100644 index 000000000..8ae9d67ca --- /dev/null +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-description-activity/recent-edited-description-activity.component.ts @@ -0,0 +1,174 @@ +import { Location } from '@angular/common'; +import { Component, Input, OnInit } from '@angular/core'; +import { UntypedFormBuilder, UntypedFormControl } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; +import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; +import { Description } from '@app/core/model/description/description'; +import { Dmp, DmpUser } from '@app/core/model/dmp/dmp'; +import { DmpReference, Reference } from '@app/core/model/reference/reference'; +import { DescriptionLookup } from '@app/core/query/description.lookup'; +import { AuthService } from '@app/core/services/auth/auth.service'; +import { DescriptionService } from '@app/core/services/description/description.service'; +import { MatomoService } from '@app/core/services/matomo/matomo-service'; +import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; +import { BaseComponent } from '@common/base/base.component'; +import { debounceTime, takeUntil } from 'rxjs/operators'; +import { nameof } from 'ts-simple-nameof'; + +@Component({ + selector: 'app-recent-edited-description-activity', + templateUrl: './recent-edited-description-activity.component.html', + styleUrls: ['./recent-edited-description-activity.component.scss'] +}) +export class RecentEditedDescriptionActivityComponent extends BaseComponent implements OnInit { + + lookup: DescriptionLookup = new DescriptionLookup(); + pageSize: number = 5; + listingItems: Description[]; + + + public formGroup = new UntypedFormBuilder().group({ + like: new UntypedFormControl(), + order: new UntypedFormControl() + }); + publicMode = false; + + order = RecentActivityOrder; + + totalCount: number; + startIndex: number = 0; + offsetLess: number = 0; + page: number = 1; + @Input() isActive: boolean = false; + + constructor( + private route: ActivatedRoute, + private router: Router, + public enumUtils: EnumUtils, + private authentication: AuthService, + private descriptionService: DescriptionService, + private location: Location, + private matomoService: MatomoService + ) { + super(); + } + + ngOnInit() { + this.matomoService.trackPageView('Recent DMP Activity'); + this.route.queryParams.subscribe(params => { + if (this.isActive) { + let page = (params['page'] === undefined) ? 1 : +params['page']; + this.page = (page <= 0) ? 1 : page; + + this.startIndex = (this.page - 1) * this.pageSize; + if (this.page > 1) { + this.offsetLess = (this.page - 2) * this.pageSize; + } + + let order = params['order']; + if (this.isAuthenticated()) { + if (order === undefined || (order != this.order.UpdatedAt && order != this.order.Label && order != this.order.Status)) { + order = this.order.UpdatedAt; + } + } else { + if (order === undefined || (order != this.order.PUBLISHED && order != this.order.LABEL)) { + order = this.order.PUBLISHED; + } + } + this.formGroup.get('order').setValue(order); + + let keyword = (params['keyword'] === undefined || params['keyword'].length <= 0) ? "" : params['keyword']; + this.formGroup.get("like").setValue(keyword); + + this.updateUrl(); + } + }); + if (this.isAuthenticated()) { + this.refresh(); + } + } + + ngOnChanges() { + if (this.isActive) { + this.updateUrl(); + } + } + + updateUrl() { + let parameters = "?type=dmps" + + (this.page != 1 ? "&page=" + this.page : "") + + (((this.formGroup.get("order").value != this.order.MODIFIED && !this.publicMode) || (this.formGroup.get("order").value != this.order.PUBLISHED && this.publicMode)) ? "&order=" + this.formGroup.get("order").value : "") + + (this.formGroup.get("like").value ? ("&keyword=" + this.formGroup.get("like").value) : ""); + this.location.go(this.router.url.split('?')[0] + parameters); + } + + public isAuthenticated(): boolean { + return this.authentication.currentAccountIsAuthenticated(); + } + + refresh(): void { + if (!this.formGroup.get('order').value) { + this.formGroup.get('order').setValue(this.order.UpdatedAt); + } + this.lookup.page = { size: this.pageSize, offset: 0 }; + this.lookup.order = { items: ['-' + this.formGroup.get('order').value] }; + this.lookup.like = this.formGroup.get('like').value; + this.lookup.project = { + + fields: [ + [nameof(x => x.id)].join('.'), + [nameof(x => x.label)].join('.'), + [nameof(x => x.status)].join('.'), + [nameof(x => x.updatedAt)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.id)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.label)].join('.'), + [nameof(x => x.descriptionTemplate), nameof(x => x.groupId)].join('.'), + [nameof(x => x.dmp), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.label)].join('.'), + [nameof(x => x.dmp), nameof(x => x.accessType)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.user.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.role)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.label)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.type)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpReferences), nameof(x => x.reference), nameof(x => x.reference)].join('.'), + ] + }; + + this.descriptionService + .query(this.lookup) + .pipe(takeUntil(this._destroyed)) + .subscribe(response => { + this.listingItems = response.items; + this.totalCount = response.count; + + + //this.totalCountDmps.emit(this.dmpActivities.length); + // if (this.totalCount > 0 && this.totalCount <= (this.page - 1) * this.pageSize && this.page > 1) { + // let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value }; + // if (this.formGroup.get("like").value) { + // queryParams['keyword'] = this.formGroup.get("like").value; + // } + // this.router.navigate(["/home"], { queryParams: queryParams }) + // } + // this.totalCount < this.pageSize ? this.totalCountDmps.emit(response.totalCount) : this.totalCountDmps.emit(this.pageSize); + // this.totalCountDmps.emit(this.totalCount); + // this.dmpActivities.forEach(dmpActivity => { + // const recentActivity: RecentActivity = { + // activityData: dmpActivity, + // activityType: RecentActivityType.Dmp + // }; + // this.allRecentActivities.push(recentActivity) + // }) + }); + this.formGroup.get('like').valueChanges + .pipe(takeUntil(this._destroyed), debounceTime(500)) + .subscribe(x => this.refresh()); + this.formGroup.get('order').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => this.refresh()); + } +} diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.html index 5bc4c55fe..ff1282fcb 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.html +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.html @@ -1,4 +1,4 @@ -
+
{{'DMP-LISTING.SORT-BY' | translate}}: @@ -20,10 +20,13 @@
-
+
-
+
+ +
+ +
{{'GENERAL.ACTIONS.NO-MORE-AVAILABLE' | translate}}
-
+
-
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts index eb18bfd31..d0421106f 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts @@ -1,44 +1,20 @@ import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'; import { UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Router } from '@angular/router'; -import { DmpBlueprintSectionFieldCategory } from '@app/core/common/enum/dmp-blueprint-section-field-category'; -import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type'; -import { DmpStatus } from '@app/core/common/enum/dmp-status'; import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order'; -import { RecentActivityType } from '@app/core/common/enum/recent-activity-type'; -import { Role } from '@app/core/common/enum/role'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; +import { RecentActivityItem } from '@app/core/model/dashboard/recent-activity-item'; import { DatasetListingModel } from '@app/core/model/dataset/dataset-listing'; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; -import { DmpModel } from '@app/core/model/dmp/dmp'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; +import { Description } from '@app/core/model/description/description'; +import { Dmp, DmpUser } from '@app/core/model/dmp/dmp'; +import { RecentActivityItemLookup } from '@app/core/query/recent-activity-item-lookup.lookup'; import { AuthService } from '@app/core/services/auth/auth.service'; -import { DatasetService } from '@app/core/services/dataset/dataset.service'; -import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { LockService } from '@app/core/services/lock/lock.service'; +import { DashboardService } from '@app/core/services/dashboard/dashboard.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; -import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; -import { CloneDialogComponent } from '@app/ui/dmp/clone/clone-dialog/clone-dialog.component'; import { DmpEditorModel } from '@app/ui/dmp/editor/dmp-editor.model'; -import { ExtraPropertiesFormModel } from '@app/ui/dmp/editor/general-tab/extra-properties-form.model'; -import { FunderFormModel } from '@app/ui/dmp/editor/grant-tab/funder-form-model'; -import { GrantTabModel } from '@app/ui/dmp/editor/grant-tab/grant-tab-model'; -import { ProjectFormModel } from '@app/ui/dmp/editor/grant-tab/project-form-model'; -import { DmpInvitationDialogComponent } from '@app/ui/dmp/invitation/dmp-invitation-dialog.component'; -import { isNullOrUndefined } from '@app/utilities/enhancers/utils'; import { BaseComponent } from '@common/base/base.component'; -import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; -import { Guid } from '@common/types/guid'; -import { TranslateService } from '@ngx-translate/core'; -import * as FileSaver from 'file-saver'; -import { debounceTime, map, takeUntil } from 'rxjs/operators'; +import { debounceTime, takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; @Component({ @@ -48,21 +24,23 @@ import { nameof } from 'ts-simple-nameof'; }) export class RecentEditedDmpActivityComponent extends BaseComponent implements OnInit { + lookup: RecentActivityItemLookup = new RecentActivityItemLookup(); + pageSize: number = 5; + + @Output() totalCountDmps: EventEmitter = new EventEmitter(); @ViewChild("dmps") resultsContainer; - dmpActivities: DmpListingModel[]; + listingItems: RecentActivityItem[]; datasetActivities: DatasetListingModel[]; dmpModel: DmpEditorModel; - recentActivityTypeEnum = RecentActivityType; isDraft: boolean; totalCount: number; startIndex: number = 0; offsetLess: number = 0; hasMoreResults: boolean = true; - pageSize: number = 5; dmpFormGroup: UntypedFormGroup; public formGroup = new UntypedFormBuilder().group({ like: new UntypedFormControl(), @@ -80,17 +58,9 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O private router: Router, public enumUtils: EnumUtils, private authentication: AuthService, - private dmpService: DmpService, - private dmpBlueprintService: DmpBlueprintService, - private datasetService: DatasetService, - private language: TranslateService, - private dialog: MatDialog, - private uiNotificationService: UiNotificationService, + private dashboardService: DashboardService, private location: Location, - private lockService: LockService, - private httpClient: HttpClient, private matomoService: MatomoService, - private fileUtils: FileUtils ) { super(); } @@ -126,84 +96,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O } }); if (this.isAuthenticated()) { - // const fields: Array = ["-modified"]; - if (!this.formGroup.get('order').value) { - this.formGroup.get('order').setValue(this.order.MODIFIED); - } - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(this.startIndex, 5, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = this.formGroup.get('like').value; - this.dmpService - .getPaged(dmpDataTableRequest, "listing") - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - this.dmpActivities = response.data; - this.totalCount = response.totalCount; - this.totalCountDmps.emit(this.dmpActivities.length); - if (this.totalCount > 0 && this.totalCount <= (this.page - 1) * this.pageSize && this.page > 1) { - let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value }; - if (this.formGroup.get("like").value) { - queryParams['keyword'] = this.formGroup.get("like").value; - } - this.router.navigate(["/home"], { queryParams: queryParams }) - } - // this.totalCount < this.pageSize ? this.totalCountDmps.emit(response.totalCount) : this.totalCountDmps.emit(this.pageSize); - // this.totalCountDmps.emit(this.totalCount); - // this.dmpActivities.forEach(dmpActivity => { - // const recentActivity: RecentActivity = { - // activityData: dmpActivity, - // activityType: RecentActivityType.Dmp - // }; - // this.allRecentActivities.push(recentActivity) - // }) - }); - this.formGroup.get('like').valueChanges - .pipe(takeUntil(this._destroyed), debounceTime(500)) - .subscribe(x => this.refresh()); - this.formGroup.get('order').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.refresh()); - // const datasetDataTableRequest: DataTableRequest = new DataTableRequest(0, 5, { fields: fields }); - // datasetDataTableRequest.criteria = new DatasetCriteria(); - // datasetDataTableRequest.criteria.like = ""; - // this.datasetService - // .getPaged(datasetDataTableRequest) - // .subscribe(response => { - // this.datasetActivities = response.data; - // this.datasetActivities.forEach(datasetActivity => { - // const recentActivity: RecentActivity = { - // activityData: datasetActivity, - // activityType: RecentActivityType.Dataset - // }; - // this.allRecentActivities.push(recentActivity) - // }) - // }); - } else { - this.publicMode = true; - if (!this.formGroup.get('order').value) { - this.formGroup.get('order').setValue(this.order.PUBLISHED); - } - const dataTableRequest = this.setPublicDataTableRequest(); - this.dmpService.getPaged(dataTableRequest, "listing").pipe(takeUntil(this._destroyed)).subscribe(response => { - if (!response) { return []; } - this.dmpActivities = response.data; - this.totalCount = response.totalCount; - this.totalCountDmps.emit(this.dmpActivities.length); - if (this.totalCount > 0 && this.totalCount <= (this.page - 1) * this.pageSize && this.page > 1) { - let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value }; - if (this.formGroup.get("like").value) { - queryParams['keyword'] = this.formGroup.get("like").value; - } - this.router.navigate(["/home"], { queryParams: queryParams }) - } - }); - this.formGroup.get('like').valueChanges - .pipe(takeUntil(this._destroyed), debounceTime(500)) - .subscribe(x => this.refresh()); - this.formGroup.get('order').valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => this.refresh()); + this.refresh(); } } @@ -225,525 +118,76 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O return this.authentication.currentAccountIsAuthenticated(); } - private setPublicDataTableRequest(fields?: Array, more: boolean = true): DataTableRequest { - const dmpCriteria = new DmpCriteria(); - dmpCriteria.allVersions = false; - dmpCriteria.isPublic = true; - dmpCriteria.onlyPublic = true; - dmpCriteria.like = this.formGroup.get("like").value ? this.formGroup.get("like").value : ""; - if (!fields) { - fields = new Array('-publishedAt'); - } - const dataTableRequest: DataTableRequest = more ? new DataTableRequest(this.startIndex, this.pageSize, { fields: fields }) : new DataTableRequest(this.offsetLess, this.pageSize, { fields: fields }); - dataTableRequest.criteria = dmpCriteria; - return dataTableRequest; - } - - isUserOwner(activity: DmpListingModel): boolean { - const principalId: string = this.authentication.userId()?.toString(); - if (principalId) return !!activity.users.find(x => (x.role === Role.Owner) && (principalId === x.id)); - } - - editClicked(dmp: DmpListingModel) { - this.router.navigate(['/plans/edit/' + dmp.id]); - } - - cloneOrNewVersionClicked(dmp: DmpListingModel, isNewVersion: boolean) { - this.dmpService.getSingle(dmp.id).pipe(map(data => data as DmpModel)) - .pipe(takeUntil(this._destroyed)) - .subscribe(data => { - this.dmpModel = new DmpEditorModel(); - this.dmpModel.grant = new GrantTabModel(); - this.dmpModel.project = new ProjectFormModel(); - this.dmpModel.funder = new FunderFormModel(); - this.dmpModel.extraProperties = new ExtraPropertiesFormModel(); - this.dmpModel.fromModel(data); - this.dmpModel.status = DmpStatus.Draft; - this.dmpFormGroup = this.dmpModel.buildForm(); - - if (!isNullOrUndefined(this.formGroup.get('profile').value)) { - this.getBlueprintDefinition(Guid.parse(this.formGroup.get('profile').value), result => { - this.checkForGrant(result.definition); - this.checkForFunder(result.definition); - this.checkForProject(result.definition); - }); - } - - if (!isNewVersion) { - this.dmpFormGroup.get('label').setValue(dmp.label + " New"); - } - this.openCloneDialog(isNewVersion); - }); - } - - private getBlueprintDefinition(blueprintId: Guid, successFunction) { - this.dmpBlueprintService.getSingle(blueprintId, [ - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), - - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - ] - ) - .pipe(map(data => data as DmpBlueprint), takeUntil(this._destroyed)) - .subscribe( - data => successFunction(data), - ); - } - - private checkForGrant(blueprint: DmpBlueprintDefinition) { - let hasGrant = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.GRANT) { - hasGrant = true; - } - } - )); - if (!hasGrant) { - this.formGroup.removeControl('grant'); - } - } - - private checkForFunder(blueprint: DmpBlueprintDefinition) { - let hasFunder = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.FUNDER) { - hasFunder = true; - } - } - )); - if (!hasFunder) { - this.formGroup.removeControl('funder'); - } - } - - private checkForProject(blueprint: DmpBlueprintDefinition) { - let hasProject = false; - blueprint.sections.forEach(section => section.fields.forEach( - field => { - if (field.category as unknown === DmpBlueprintSectionFieldCategory.SYSTEM && field.systemFieldType === DmpBlueprintSystemFieldType.PROJECT) { - hasProject = true; - } - } - )); - if (!hasProject) { - this.formGroup.removeControl('project'); - } - } - - openCloneDialog(isNewVersion: boolean) { - const dialogRef = this.dialog.open(CloneDialogComponent, { - maxWidth: '700px', - maxHeight: '80vh', - data: { - formGroup: this.dmpFormGroup, - datasets: this.dmpFormGroup.get('datasets').value, - isNewVersion: isNewVersion, - confirmButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.SAVE'), - cancelButton: this.language.instant('DMP-EDITOR.CLONE-DIALOG.CANCEL'), - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - if (!isNewVersion) { - this.dmpService.clone(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCloneOrNewVersionCallbackSuccess(complete), - error => this.onCloneOrNewVersionCallbackError(error) - ); - } else if (isNewVersion) { - this.dmpService.newVersion(this.dmpFormGroup.getRawValue(), this.dmpFormGroup.get('id').value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCloneOrNewVersionCallbackSuccess(complete), - error => this.onCloneOrNewVersionCallbackError(error) - ); - } - } - }); - } - - deleteClicked(id: string) { - this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed)) - .subscribe(lockStatus => { - if (!lockStatus) { - this.openDeleteDialog(id); - } else { - this.openLockedByUserDialog(); - } - }); - } - - openDeleteDialog(id: string) { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '300px', - restoreFocus: false, - data: { - message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), - confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), - cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), - isDeleteConfirmation: true - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.dmpService.delete(id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onDeleteCallbackSuccess(), - error => this.onDeleteCallbackError(error) - ); - } - }); - } - - openLockedByUserDialog() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - maxWidth: '400px', - restoreFocus: false, - data: { - message: this.language.instant('DMP-EDITOR.ACTIONS.LOCK') - } - }); - } - - openShareDialog(rowId: any, rowName: any) { - const dialogRef = this.dialog.open(DmpInvitationDialogComponent, { - // height: '250px', - // width: '700px', - autoFocus: false, - restoreFocus: false, - data: { - dmpId: rowId, - dmpName: rowName - } - }); - } - - isDraftDmp(activity: DmpListingModel) { - return activity.status == DmpStatus.Draft; - } - - onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans']); - } - - reloadPage(): void { - const path = this.location.path(); - this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => { - this.router.navigate([path]); - }); - } - - onDeleteCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); - this.reloadPage(); - } - - onDeleteCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? this.language.instant(error.error.message) : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); - } - - onCloneOrNewVersionCallbackSuccess(dmpId: String): void { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/plans/edit/', dmpId]); - } - - onCloneOrNewVersionCallbackError(error: any) { - this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Error); - } - - redirect(id: string) { - if (this.isAuthenticated()) { - this.router.navigate(['../plans/overview/' + id]); - } else { - this.router.navigate(['../explore-plans/publicOverview', id]); - } - } - - navigateToUrl(id: string): string[] { - if (this.isAuthenticated()) { - return ['../plans/overview/' + id]; - } else { - return ['../explore-plans/publicOverview', id]; - } - } - - roleDisplay(value: any) { - const principalId: string = this.authentication.userId()?.toString(); - let role: number; - if (principalId) { - value.forEach(element => { - if (principalId === element.id) { - role = element.role; - } - }); - } - if (role === 0) { - return this.language.instant('DMP-LISTING.OWNER'); - } - else if (role === 1) { - return this.language.instant('DMP-LISTING.MEMBER'); - } - else { - return this.language.instant('DMP-LISTING.OWNER'); - } - } - - // dmpBlueprintDisplay(value: any) { - // if (value != null) { - // return value; - // } - // else { - // return "--"; - // } - // } - - downloadXml(id: string) { - this.dmpService.downloadXML(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/xml' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "xml", id); - }); - } - - downloadDocx(id: string) { - this.dmpService.downloadDocx(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/msword' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "docx", id); - }); - } - - downloadPDF(id: string) { - this.dmpService.downloadPDF(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/pdf' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "pdf", id); - }); - } - - downloadJson(id: string) { - this.dmpService.downloadJson(id) - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - const blob = new Blob([response.body], { type: 'application/json' }); - const filename = this.fileUtils.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); - FileSaver.saveAs(blob, filename); - this.matomoService.trackDownload('dmps', "json", id); - }, async error => { - this.onExportCallbackError(error); - }); - } - - async onExportCallbackError(error: any) { - const errorJsonText = await error.error.text(); - const errorObj = JSON.parse(errorJsonText); - this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error); - } - - // newVersion(id: String, label: String) { - // let url = this.router.createUrlTree(['/plans/new_version/', id, { dmpLabel: label }]); - // window.open(url.toString(), '_blank'); - // } - - viewVersions(rowId: String, rowLabel: String, activity: DmpListingModel) { - if (activity.public && !this.isUserOwner(activity)) { - let url = this.router.createUrlTree(['/explore-plans/versions/', rowId, { groupLabel: rowLabel }]); - window.open(url.toString(), '_blank'); - // this.router.navigate(['/explore-plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); - } else { - let url = this.router.createUrlTree(['/plans/versions/', rowId, { groupLabel: rowLabel }]); - window.open(url.toString(), '_blank'); - // this.router.navigate(['/plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } }); - } - } - refresh(): void { - this.page = 1; - this.updateUrl(); - - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - this.startIndex = 0; - const dmpDataTableRequest = this.isAuthenticated() ? new DataTableRequest(this.startIndex, this.pageSize, { fields: fields }) : this.setPublicDataTableRequest(fields); - if (this.isAuthenticated()) { - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = this.formGroup.get("like").value ? this.formGroup.get("like").value : ""; + if (!this.formGroup.get('order').value) { + this.formGroup.get('order').setValue(this.order.UpdatedAt); } - this.dmpService - .getPaged(dmpDataTableRequest, "listing") + this.lookup.page = { size: this.pageSize, offset: 0 }; + this.lookup.orderField = this.formGroup.get('order').value; + this.lookup.like = this.formGroup.get('like').value; + this.lookup.project = { + fields: [ + [nameof(x => x.dmp), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.label)].join('.'), + [nameof(x => x.dmp), nameof(x => x.status)].join('.'), + [nameof(x => x.dmp), nameof(x => x.accessType)].join('.'), + [nameof(x => x.dmp), nameof(x => x.version)].join('.'), + [nameof(x => x.dmp), nameof(x => x.groupId)].join('.'), + [nameof(x => x.dmp), nameof(x => x.updatedAt)].join('.'), + [nameof(x => x.dmp), nameof(x => x.descriptions), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.descriptions), nameof(x => x.label)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.user.id)].join('.'), + [nameof(x => x.dmp), nameof(x => x.dmpUsers), nameof(x => x.role)].join('.'), + ] + }; + + this.dashboardService + .getMyRecentActivityItems(this.lookup) + .pipe(takeUntil(this._destroyed)) .subscribe(response => { - this.dmpActivities = response.data; - this.totalCount = response.totalCount; - this.totalCountDmps.emit(this.dmpActivities.length); - if (response.data.length < this.pageSize) { - this.hasMoreResults = false; - } else { - this.hasMoreResults = true; - } + this.listingItems = response; + //this.totalCount = response.totalCount; + + + //this.totalCountDmps.emit(this.dmpActivities.length); + // if (this.totalCount > 0 && this.totalCount <= (this.page - 1) * this.pageSize && this.page > 1) { + // let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value }; + // if (this.formGroup.get("like").value) { + // queryParams['keyword'] = this.formGroup.get("like").value; + // } + // this.router.navigate(["/home"], { queryParams: queryParams }) + // } + // this.totalCount < this.pageSize ? this.totalCountDmps.emit(response.totalCount) : this.totalCountDmps.emit(this.pageSize); + // this.totalCountDmps.emit(this.totalCount); + // this.dmpActivities.forEach(dmpActivity => { + // const recentActivity: RecentActivity = { + // activityData: dmpActivity, + // activityType: RecentActivityType.Dmp + // }; + // this.allRecentActivities.push(recentActivity) + // }) }); + this.formGroup.get('like').valueChanges + .pipe(takeUntil(this._destroyed), debounceTime(500)) + .subscribe(x => this.refresh()); + this.formGroup.get('order').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => this.refresh()); + // const datasetDataTableRequest: DataTableRequest = new DataTableRequest(0, 5, { fields: fields }); + // datasetDataTableRequest.criteria = new DatasetCriteria(); + // datasetDataTableRequest.criteria.like = ""; + // this.datasetService + // .getPaged(datasetDataTableRequest) + // .subscribe(response => { + // this.datasetActivities = response.data; + // this.datasetActivities.forEach(datasetActivity => { + // const recentActivity: RecentActivity = { + // activityData: datasetActivity, + // activityType: RecentActivityType.Dataset + // }; + // this.allRecentActivities.push(recentActivity) + // }) + // }); } - - public loadNextOrPrevious(more: boolean = true) { - this.startIndex = this.startIndex + this.pageSize; - - const fields: Array = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value]; - let request; - this.startIndex = (this.page) * this.pageSize; - if (this.page > 1) { - this.offsetLess = (this.page - 2) * this.pageSize; - } - if (this.isAuthenticated()) { - if (more) { - request = new DataTableRequest(this.startIndex, this.pageSize, { fields: fields }) - } else { - request = new DataTableRequest(this.offsetLess, this.pageSize, { fields: fields }) - } - } else { - request = this.setPublicDataTableRequest(fields, more); - } - if (this.isAuthenticated()) { - request.criteria = new DmpCriteria(); - request.criteria.like = this.formGroup.get("like").value ? this.formGroup.get("like").value : ""; - } - - this.dmpService.getPaged(request, "listing").pipe(takeUntil(this._destroyed)).subscribe(result => { - if (!result || !result.data || result.data.length == 0) { - this.hasMoreResults = false; - // return []; - } else { - this.page = this.page + (more ? 1 : -1); - this.updateUrl(); - // this.dmpActivities = this.dmpActivities.concat(result.data); - // this.dmpActivities = this.dmpActivities.length > 0 ? this.mergeTwoSortedLists(this.dmpActivities, result.data, this.formGroup.get('order').value) : result.data; - this.dmpActivities = result.data; - - if (result.data.length < this.pageSize) { - this.hasMoreResults = false; - } else { - this.hasMoreResults = true; - } - - this.totalCountDmps.emit(this.dmpActivities.length); - if (more) { - this.resultsContainer.nativeElement.scrollIntoView(); - } - } - }); - - } - - private mergeTwoSortedLists(arr1: DmpListingModel[], arr2: DmpListingModel[], order: string): DmpListingModel[] { - let merged = []; - let index1 = 0; - let index2 = 0; - let current = 0; - - while (current < (arr1.length + arr2.length)) { - - let isArr1Depleted = index1 >= arr1.length; - let isArr2Depleted = index2 >= arr2.length; - - if (order === 'modified') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].modifiedTime) > new Date(arr2[index2].modifiedTime)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'created') { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].creationTime) > new Date(arr2[index2].creationTime)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'label') { - if (!isArr1Depleted && (isArr2Depleted || (arr1[index1].label.localeCompare(arr2[index2].label)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === 'status') { - if (!isArr1Depleted && (isArr2Depleted || (arr1[index1].status < arr2[index2].status))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } else if (order === "publishedAt") { - if (!isArr1Depleted && (isArr2Depleted || (new Date(arr1[index1].publishedAt) > new Date(arr2[index2].publishedAt)))) { - merged[current] = arr1[index1]; - index1++; - } else { - merged[current] = arr2[index2]; - index2++; - } - } - current++; - } - return merged; - } - - // advancedClicked(dmp: DmpListingModel) { - // const dialogRef = this.dialog.open(ExportMethodDialogComponent, { - // maxWidth: '500px', - // data: { - // message: "Download as:", - // XMLButton: "XML", - // documentButton: "Document", - // pdfButton: "PDF", - // jsonButton: "JSON" - - // } - // }); - // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - // if (result == "pdf") { - // this.downloadPDF(dmp.id); - // } else if (result == "xml") { - // this.downloadXml(dmp.id); - // } else if (result == "doc") { - // this.downloadDocx(dmp.id); - // } else if (result == "json") { - // this.downloadJson(dmp.id) - // } - // }); - // } } diff --git a/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.css b/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.css deleted file mode 100644 index cb5d9aee0..000000000 --- a/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.css +++ /dev/null @@ -1,22 +0,0 @@ -th { - text-transform: uppercase; -} - -.is-public { - padding-left: 5px; - padding-right: 5px; - border: 1px solid var(--primary-color-3)3b; - color: var(--primary-color-3); - background-color: var(--primary-color-3)0f; - border-radius: 10em; - text-align: center; -} - -.template-name { - padding-left: 0px; - border: 1px solid rgb(218, 227, 243); - color: rgb(43, 104, 209); - background-color: rgb(236, 241, 249); - border-radius: 10em; - text-align: center; -} diff --git a/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.html b/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.html deleted file mode 100644 index f42df0a1e..000000000 --- a/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.html +++ /dev/null @@ -1,63 +0,0 @@ -
-
-
-

- {{ 'RECENT-ACTIVITY.LAST-VISITED-DMP' | translate}} -

-

- {{ 'RECENT-ACTIVITY.LICENSE' | translate}} -

-
-
- {{ 'GENERAL.ACTIONS.VIEW-ALL' | translate}}
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{{ 'DATASET-PROFILE-LISTING.COLUMNS.NAME' | translate }}{{ 'DATASET-PROFILE-LISTING.COLUMNS.TEMPLATE' | translate }}{{ 'DATASET-PROFILE-LISTING.COLUMNS.GRANT' | translate }}{{ 'DATASET-PROFILE-LISTING.COLUMNS.ROLE' | translate }}{{ 'DATASET-PROFILE-LISTING.COLUMNS.ORGANIZATION' | translate }}{{ 'DATASET-PROFILE-LISTING.COLUMNS.STATUS' | translate }}{{ 'DATASET-PROFILE-LISTING.COLUMNS.VISITED' | translate }}
{{ activity.label }} -
- -- -
-
{{ activity.grant }}Role Name{{ activity.organisations }} -
- {{ enumUtils.toDmpStatusString(activity.status) }} -
-
- {{ enumUtils.toDmpStatusString(activity.status) }} - {{ activity.creationTime | date: "shortDate" }}more_horiz
more_horiz
-
-
diff --git a/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.ts deleted file mode 100644 index 900ab5ed4..000000000 --- a/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { Component, OnInit } from "@angular/core"; -import { Router } from '@angular/router'; -import { RecentActivityType } from '@app/core/common/enum/recent-activity-type'; -import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; -import { DmpListingModel } from '@app/core/model/dmp/dmp-listing'; -import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria'; -import { AuthService } from '@app/core/services/auth/auth.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; -import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { BaseComponent } from '@common/base/base.component'; -import { takeUntil } from "rxjs/operators"; - -@Component({ - selector: "app-recent-visited-activity", - templateUrl: "./recent-visited-activity.component.html", - styleUrls: ["./recent-visited-activity.component.css"] -}) -export class RecentVisitedActivityComponent extends BaseComponent - implements OnInit { - dmpActivities: DmpListingModel[]; - recentActivityItems: any[]; - recentActivityTypeEnum = RecentActivityType; - public: boolean = false; - - constructor( - private router: Router, - private authentication: AuthService, - private dmpService: DmpService, - public enumUtils: EnumUtils - ) { - super(); - } - - ngOnInit() { - if (this.isAuthenticated()) { - const fields: Array = ["-created"]; - const dmpDataTableRequest: DataTableRequest = new DataTableRequest(0, null, { fields: fields }); - dmpDataTableRequest.criteria = new DmpCriteria(); - dmpDataTableRequest.criteria.like = ""; - this.dmpService - .getPaged(dmpDataTableRequest, "listing") - .pipe(takeUntil(this._destroyed)) - .subscribe(response => { - this.dmpActivities = response.data; - }); - } - } - - redirect(id: string, type: RecentActivityType) { - switch (type) { - case RecentActivityType.Grant: { - this.router.navigate(["grants/edit/" + id]); - return; - } - case RecentActivityType.Dataset: { - this.router.navigate(["datasets/edit/" + id]); - return; - } - case RecentActivityType.Dmp: { - this.router.navigate(["plans/edit/" + id]); - return; - } - default: - throw new Error("Unsupported Activity Type "); - } - } - - public isAuthenticated(): boolean { - return this.authentication.currentAccountIsAuthenticated(); - } - - navigateToUrl() { } -} diff --git a/dmp-frontend/src/app/ui/dashboard/wizard/wizard.component.css b/dmp-frontend/src/app/ui/dashboard/wizard/wizard.component.css deleted file mode 100644 index 712bf267a..000000000 --- a/dmp-frontend/src/app/ui/dashboard/wizard/wizard.component.css +++ /dev/null @@ -1,10 +0,0 @@ -.clickable { - cursor: pointer; -} - -.play_circle { - display: flex; - align-self: center; - margin: 0px 10px 0px 0px; - font-size: 40px; -} diff --git a/dmp-frontend/src/app/ui/dashboard/wizard/wizard.component.html b/dmp-frontend/src/app/ui/dashboard/wizard/wizard.component.html deleted file mode 100644 index d262335be..000000000 --- a/dmp-frontend/src/app/ui/dashboard/wizard/wizard.component.html +++ /dev/null @@ -1,10 +0,0 @@ - -
-
-

{{ title }}

-

{{ subtitle }}

-
- {{ icon }} -
-
-
diff --git a/dmp-frontend/src/app/ui/dashboard/wizard/wizard.component.ts b/dmp-frontend/src/app/ui/dashboard/wizard/wizard.component.ts deleted file mode 100644 index b38486534..000000000 --- a/dmp-frontend/src/app/ui/dashboard/wizard/wizard.component.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; -import { Router } from "@angular/router"; - -@Component({ - selector: "app-wizard", - templateUrl: "./wizard.component.html", - styleUrls: ["./wizard.component.css"] -}) -export class WizardComponent { - @Input() title: string; - @Input() subtitle: string; - @Input() icon: string; - @Input() routerLink: string; - @Output() onClick: EventEmitter = new EventEmitter(); - - wizardItems: any[]; - - constructor(private router: Router) {} - - cardClicked() { - this.onClick.emit(); - } - navigateToCreate() { - this.router.navigate(["/quick-wizard"]); - } - - navigateToAdd() { - this.router.navigate(["/datasetcreatewizard"]); - } -} diff --git a/dmp-frontend/src/app/ui/dmp/dmp.module.ts b/dmp-frontend/src/app/ui/dmp/dmp.module.ts index 01f9f6132..555dd30b9 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp.module.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp.module.ts @@ -108,6 +108,9 @@ import { DmpEditorBlueprintComponent } from './dmp-editor-blueprint/dmp-editor-b LicenseInfoComponent, DatasetPreviewDialogComponent, DmpEditorBlueprintComponent - ] + ], + exports: [ + DmpListingItemComponent + ] }) export class DmpModule { } diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts index d6e78bd01..16606b9dc 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts @@ -18,6 +18,7 @@ import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service' // import { IBreadCrumbComponent } from '@app/ui/misc/breadcrumb/definition/IBreadCrumbComponent'; // import { BreadcrumbItem } from '@app/ui/misc/breadcrumb/definition/breadcrumb-item'; import { IsActive } from '@app/core/common/enum/is-active.enum'; +import { Description } from '@app/core/model/description/description'; import { Dmp, DmpUser } from '@app/core/model/dmp/dmp'; import { DmpLookup } from '@app/core/query/dmp.lookup'; import { BaseComponent } from '@common/base/base.component'; @@ -26,7 +27,6 @@ import { TranslateService } from '@ngx-translate/core'; import { NgDialogAnimationService } from "ng-dialog-animation"; import { debounceTime, takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; -import { Description } from '@app/core/model/description/description'; @Component({ selector: 'app-dmp-listing-component', @@ -37,30 +37,13 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr @ViewChild(MatPaginator, { static: true }) _paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; - // @ViewChild(DmpCriteriaComponent, { static: true }) criteria: DmpCriteriaComponent; - - // breadCrumbs: Observable = observableOf([{ parentComponentName: null, label: 'DMPs', url: "/plans" }]); - lookup: DmpLookup = new DmpLookup(); groupId: string; - - - // itemId: string; - // showGrant: boolean; - // titlePrefix: string; totalCount: number; listingItems: Dmp[] = []; - // allVersions: boolean = false; - // groupLabel: string; isPublic: boolean = false; - // public isVisible = true hasListingItems = null; - - // startIndex: number = 0; pageSize: number = 5; - - // criteria: DmpCriteria; - // criteriaFormGroup: UntypedFormGroup; public formGroup = new UntypedFormBuilder().group({ like: new UntypedFormControl(), order: new UntypedFormControl() @@ -68,8 +51,6 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr scrollbar: boolean; order = RecentActivityOrder; - // dmpText: string; - // datasetText: string; constructor( private dmpService: DmpService, diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts index 9c78c9e04..a96637829 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts @@ -6,10 +6,9 @@ import { Router } from '@angular/router'; import { DmpAccessType } from '@app/core/common/enum/dmp-access-type'; import { DmpUserRole } from '@app/core/common/enum/dmp-user-role'; import { ReferenceType } from '@app/core/common/enum/reference-type'; -import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint'; import { Dmp } from '@app/core/model/dmp/dmp'; import { DmpBlueprintService } from '@app/core/services/dmp/dmp-blueprint.service'; -import { DmpService } from '@app/core/services/dmp/dmp.service'; +import { DmpServiceNew } from '@app/core/services/dmp/dmp.service'; import { LockService } from '@app/core/services/lock/lock.service'; import { MatomoService } from '@app/core/services/matomo/matomo-service'; import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service'; @@ -20,8 +19,7 @@ import { BaseComponent } from '@common/base/base.component'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; import { Guid } from '@common/types/guid'; import { TranslateService } from '@ngx-translate/core'; -import { map, takeUntil } from 'rxjs/operators'; -import { nameof } from 'ts-simple-nameof'; +import { takeUntil } from 'rxjs/operators'; import { DmpStatus } from '../../../../core/common/enum/dmp-status'; import { AuthService } from '../../../../core/services/auth/auth.service'; @@ -48,7 +46,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { private dialog: MatDialog, private authentication: AuthService, public enumUtils: EnumUtils, - private dmpService: DmpService, + private dmpService: DmpServiceNew, private dmpBlueprintService: DmpBlueprintService, private language: TranslateService, private uiNotificationService: UiNotificationService, @@ -116,7 +114,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { isUserDMPRelated() { const principalId: Guid = this.authentication.userId(); - return this.dmp.dmpUsers.some(x => (x.user.id === principalId)); + return this.dmp.dmpUsers?.some(x => (x.user.id === principalId)); } cloneOrNewVersionClicked(dmp: Dmp, isNewVersion: boolean) { @@ -147,37 +145,6 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { // }); } - private getBlueprintDefinition(blueprintId: Guid, successFunction) { - this.dmpBlueprintService.getSingle(blueprintId, [ - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), - - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), - - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), - [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), - ] - ) - .pipe(map(data => data as DmpBlueprint), takeUntil(this._destroyed)) - .subscribe( - data => successFunction(data), - ); - } - openCloneDialog(isNewVersion: boolean) { // TODO: fix this // const dialogRef = this.dialog.open(CloneDialogComponent, { @@ -271,8 +238,8 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { // this.uiNotificationService.snackBarNotification(errorObj.message, SnackBarNotificationLevel.Error); // } - deleteClicked(id: string) { - this.lockService.checkLockStatus(id).pipe(takeUntil(this._destroyed)) + deleteClicked(id: Guid) { + this.lockService.checkLockStatus(id.toString()).pipe(takeUntil(this._destroyed)) .subscribe(lockStatus => { if (!lockStatus) { this.openDeleteDialog(id); @@ -282,7 +249,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { }); } - openDeleteDialog(id: string) { + openDeleteDialog(id: Guid) { const dialogRef = this.dialog.open(ConfirmationDialogComponent, { maxWidth: '300px', restoreFocus: false, @@ -351,6 +318,6 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit { isUserOwner(dmp: Dmp): boolean { const principalId: Guid = this.authentication.userId(); - if (principalId) return !!dmp.dmpUsers.find(x => (x.role === DmpUserRole.Owner) && (principalId === x.id)); + if (principalId) return !!dmp.dmpUsers?.find(x => (x.role === DmpUserRole.Owner) && (principalId === x.id)); } } diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index 72d2f18e3..7211cba13 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -175,7 +175,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { setIsUserOwner() { if (this.dmp) { const principalId: Guid = this.authentication.userId(); - if (principalId) this.isUserOwner = !!this.dmp.dmpUsers.find(x => (x.role === DmpUserRole.Owner) && (principalId === x.id)); + if (principalId) this.isUserOwner = !!this.dmp.dmpUsers?.find(x => (x.role === DmpUserRole.Owner) && (principalId === x.id)); } } @@ -403,7 +403,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { isUserDmpRelated(): boolean { const principalId: Guid = this.authentication.userId(); - return this.dmp.dmpUsers.some(x => (x.user.id === principalId)); + return this.dmp.dmpUsers?.some(x => (x.user.id === principalId)); } isDraftDmp(dmp: Dmp) {