Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Prevent duplicate registration now that dashboards is a opce

Oliver Günthera20d00989b7e
diff --git a/frontend/src/app/shared/components/grids/openproject-grids.module.ts b/frontend/src/app/shared/components/grids/openproject-grids.module.ts
index 75f8a1fd7d2..170920750df 100644
--- a/frontend/src/app/shared/components/grids/openproject-grids.module.ts
+++ b/frontend/src/app/shared/components/grids/openproject-grids.module.ts
@@ -26,9 +26,8 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import { CUSTOM_ELEMENTS_SCHEMA, Injector, NgModule } from '@angular/core';
+import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { DynamicModule } from 'ng-dynamic-component';
-import { HookService } from 'core-app/features/plugins/hook-service';
import { OpSharedModule } from 'core-app/shared/shared.module';
import { OpenprojectModalModule } from 'core-app/shared/components/modal/modal.module';
import { OpenprojectCalendarModule } from 'core-app/features/calendar/openproject-calendar.module';
@@ -56,7 +55,6 @@ import {
import {
OpenprojectWorkPackageGraphsModule,
} from 'core-app/shared/components/work-package-graphs/openproject-work-package-graphs.module';
-import { I18nService } from 'core-app/core/i18n/i18n.service';
import {
WidgetProjectDescriptionComponent,
} from 'core-app/shared/components/grids/widgets/project-description/project-description.component';
@@ -80,7 +78,6 @@ import { OpenprojectTimeEntriesModule } from 'core-app/shared/components/time_en
import {
WidgetTimeEntriesCurrentUserMenuComponent,
} from 'core-app/shared/components/grids/widgets/time-entries/current-user/time-entries-current-user-menu.component';
-import { ApiV3FilterBuilder } from 'core-app/shared/helpers/api-v3/api-v3-filter-builder';
import {
TimeEntriesCurrentUserConfigurationModalComponent,
} from './widgets/time-entries/current-user/configuration-modal/configuration.modal';
@@ -153,215 +150,4 @@ import { OpenprojectEnterpriseModule } from 'core-app/features/enterprise/openpr
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class OpenprojectGridsModule {
- constructor(injector:Injector) {
- registerWidgets(injector);
- }
-}
-
-export function registerWidgets(injector:Injector) {
- const hookService = injector.get(HookService);
- const i18n = injector.get(I18nService);
-
- hookService.register('gridWidgets', () => {
- const defaultColumns = ['id', 'project', 'type', 'subject'];
-
- const assignedFilters = new ApiV3FilterBuilder();
- assignedFilters.add('assignee', '=', ['me']);
- assignedFilters.add('status', 'o', []);
-
- const assignedProps = {
- 'columns[]': defaultColumns,
- filters: assignedFilters.toJson(),
- };
-
- const accountableFilters = new ApiV3FilterBuilder();
- accountableFilters.add('responsible', '=', ['me']);
- accountableFilters.add('status', 'o', []);
-
- const accountableProps = {
- 'columns[]': defaultColumns,
- filters: accountableFilters.toJson(),
- };
-
- const createdFilters = new ApiV3FilterBuilder();
- createdFilters.add('author', '=', ['me']);
- createdFilters.add('status', 'o', []);
-
- const createdProps = {
- 'columns[]': defaultColumns,
- filters: createdFilters.toJson(),
- };
-
- const watchedFilters = new ApiV3FilterBuilder();
- watchedFilters.add('watcher', '=', ['me']);
- watchedFilters.add('status', 'o', []);
-
- const watchedProps = {
- 'columns[]': defaultColumns,
- filters: watchedFilters.toJson(),
- };
-
- return [
- {
- identifier: 'work_packages_assigned',
- component: WidgetWpTableQuerySpaceComponent,
- title: i18n.t('js.grid.widgets.work_packages_assigned.title'),
- properties: {
- queryProps: assignedProps,
- name: i18n.t('js.grid.widgets.work_packages_assigned.title'),
- },
- },
- {
- identifier: 'work_packages_accountable',
- component: WidgetWpTableQuerySpaceComponent,
- title: i18n.t('js.grid.widgets.work_packages_accountable.title'),
- properties: {
- queryProps: accountableProps,
- name: i18n.t('js.grid.widgets.work_packages_accountable.title'),
- },
- },
- {
- identifier: 'work_packages_created',
- component: WidgetWpTableQuerySpaceComponent,
- title: i18n.t('js.grid.widgets.work_packages_created.title'),
- properties: {
- queryProps: createdProps,
- name: i18n.t('js.grid.widgets.work_packages_created.title'),
- },
- },
- {
- identifier: 'work_packages_watched',
- component: WidgetWpTableQuerySpaceComponent,
- title: i18n.t('js.grid.widgets.work_packages_watched.title'),
- properties: {
- queryProps: watchedProps,
- name: i18n.t('js.grid.widgets.work_packages_watched.title'),
- },
- },
- {
- identifier: 'work_packages_table',
- component: WidgetWpTableQuerySpaceComponent,
- title: i18n.t('js.grid.widgets.work_packages_table.title'),
- properties: {
- name: i18n.t('js.grid.widgets.work_packages_table.title'),
- },
- },
- {
- identifier: 'work_packages_graph',
- component: WidgetWpGraphComponent,
- title: i18n.t('js.grid.widgets.work_packages_graph.title'),
- properties: {
- name: i18n.t('js.grid.widgets.work_packages_graph.title'),
- },
- },
- {
- identifier: 'work_packages_calendar',
- component: WidgetWpCalendarComponent,
- title: i18n.t('js.grid.widgets.work_packages_calendar.title'),
- properties: {
- name: i18n.t('js.grid.widgets.work_packages_calendar.title'),
- },
- },
- {
- identifier: 'work_packages_overview',
- component: WidgetWpOverviewComponent,
- title: i18n.t('js.grid.widgets.work_packages_overview.title'),
- properties: {
- name: i18n.t('js.grid.widgets.work_packages_overview.title'),
- },
- },
- {
- identifier: 'time_entries_current_user',
- component: WidgetTimeEntriesCurrentUserComponent,
- title: i18n.t('js.grid.widgets.time_entries_current_user.title'),
- properties: {
- name: i18n.t('js.grid.widgets.time_entries_current_user.title'),
- days: [true, true, true, true, true, true, true],
- },
- },
- {
- identifier: 'time_entries_list',
- component: WidgetTimeEntriesProjectComponent,
- title: i18n.t('js.grid.widgets.time_entries_list.title'),
- properties: {
- name: i18n.t('js.grid.widgets.time_entries_list.title'),
- },
- },
- {
- identifier: 'documents',
- component: WidgetDocumentsComponent,
- title: i18n.t('js.grid.widgets.documents.title'),
- properties: {
- name: i18n.t('js.grid.widgets.documents.title'),
- },
- },
- {
- identifier: 'members',
- component: WidgetMembersComponent,
- title: i18n.t('js.grid.widgets.members.title'),
- properties: {
- name: i18n.t('js.grid.widgets.members.title'),
- },
- },
- {
- identifier: 'news',
- component: WidgetNewsComponent,
- title: i18n.t('js.grid.widgets.news.title'),
- properties: {
- name: i18n.t('js.grid.widgets.news.title'),
- },
- },
- {
- identifier: 'project_description',
- component: WidgetProjectDescriptionComponent,
- title: i18n.t('js.grid.widgets.project_description.title'),
- properties: {
- name: i18n.t('js.grid.widgets.project_description.title'),
- },
- },
- {
- identifier: 'custom_text',
- component: WidgetCustomTextComponent,
- title: i18n.t('js.grid.widgets.custom_text.title'),
- properties: {
- name: i18n.t('js.grid.widgets.custom_text.title'),
- text: {
- raw: '',
- },
- },
- },
- {
- identifier: 'project_status',
- component: WidgetProjectStatusComponent,
- title: i18n.t('js.grid.widgets.project_status.title'),
- properties: {
- name: i18n.t('js.grid.widgets.project_status.title'),
- },
- },
- {
- identifier: 'project_status_beta',
- component: WidgetProjectStatusBetaComponent,
- title: i18n.t('js.grid.widgets.project_status_beta.title'),
- properties: {
- name: i18n.t('js.grid.widgets.project_status_beta.title'),
- },
- },
- {
- identifier: 'subprojects',
- component: WidgetSubprojectsComponent,
- title: i18n.t('js.grid.widgets.subprojects.title'),
- properties: {
- name: i18n.t('js.grid.widgets.subprojects.title'),
- },
- },
- {
- identifier: 'project_favorites',
- component: WidgetProjectFavoritesComponent,
- title: i18n.t('js.grid.widgets.project_favorites.title'),
- properties: {
- name: i18n.t('js.grid.widgets.project_favorites.title'),
- },
- },
- ];
- });
}
diff --git a/frontend/src/app/shared/components/grids/widgets/widgets.service.ts b/frontend/src/app/shared/components/grids/widgets/widgets.service.ts
index 89068a98f36..ab2b465f402 100644
--- a/frontend/src/app/shared/components/grids/widgets/widgets.service.ts
+++ b/frontend/src/app/shared/components/grids/widgets/widgets.service.ts
@@ -1,13 +1,51 @@
-import { Injectable } from '@angular/core';
+import { inject, Injectable } from '@angular/core';
import { WidgetRegistration } from 'core-app/shared/components/grids/grid/grid.component';
import { HookService } from 'core-app/features/plugins/hook-service';
+import { ApiV3FilterBuilder } from 'core-app/shared/helpers/api-v3/api-v3-filter-builder';
+import {
+ WidgetWpTableQuerySpaceComponent,
+} from 'core-app/shared/components/grids/widgets/wp-table/wp-table-qs.component';
+import { WidgetWpGraphComponent } from 'core-app/shared/components/grids/widgets/wp-graph/wp-graph.component';
+import { WidgetWpCalendarComponent } from 'core-app/shared/components/grids/widgets/wp-calendar/wp-calendar.component';
+import { WidgetWpOverviewComponent } from 'core-app/shared/components/grids/widgets/wp-overview/wp-overview.component';
+import {
+ WidgetTimeEntriesCurrentUserComponent,
+} from 'core-app/shared/components/grids/widgets/time-entries/current-user/time-entries-current-user.component';
+import {
+ WidgetTimeEntriesProjectComponent,
+} from 'core-app/shared/components/grids/widgets/time-entries/project/time-entries-project.component';
+import { WidgetDocumentsComponent } from 'core-app/shared/components/grids/widgets/documents/documents.component';
+import { WidgetMembersComponent } from 'core-app/shared/components/grids/widgets/members/members.component';
+import { WidgetNewsComponent } from 'core-app/shared/components/grids/widgets/news/news.component';
+import {
+ WidgetProjectDescriptionComponent,
+} from 'core-app/shared/components/grids/widgets/project-description/project-description.component';
+import { WidgetCustomTextComponent } from 'core-app/shared/components/grids/widgets/custom-text/custom-text.component';
+import {
+ WidgetProjectStatusComponent,
+} from 'core-app/shared/components/grids/widgets/project-status/project-status.component';
+import {
+ WidgetProjectStatusBetaComponent,
+} from 'core-app/shared/components/grids/widgets/project-status-beta/project-status-beta.component';
+import { WidgetSubprojectsComponent } from 'core-app/shared/components/grids/widgets/subprojects/subprojects.component';
+import {
+ WidgetProjectFavoritesComponent,
+} from 'core-app/shared/components/grids/widgets/project-favorites/widget-project-favorites.component';
+import { I18nService } from 'core-app/core/i18n/i18n.service';
@Injectable()
export class GridWidgetsService {
- constructor(private Hook:HookService) {}
+ private Hook = inject(HookService);
+ private I18n = inject(I18nService);
+
+ private registeredWidgets = this.buildWidgets();
public get registered() {
- let registeredWidgets:WidgetRegistration[] = [];
+ return this.registeredWidgets;
+ }
+
+ private buildWidgets() {
+ let registeredWidgets:WidgetRegistration[] = this.buildDefaultWidgets();
_.each(this.Hook.call('gridWidgets'), (registration:WidgetRegistration[]) => {
registeredWidgets = registeredWidgets.concat(registration);
@@ -15,4 +53,207 @@ export class GridWidgetsService {
return registeredWidgets;
}
+
+ private buildDefaultWidgets():WidgetRegistration[] {
+ const defaultColumns = ['id', 'project', 'type', 'subject'];
+
+ const assignedFilters = new ApiV3FilterBuilder();
+ assignedFilters.add('assignee', '=', ['me']);
+ assignedFilters.add('status', 'o', []);
+
+ const assignedProps = {
+ 'columns[]': defaultColumns,
+ filters: assignedFilters.toJson(),
+ };
+
+ const accountableFilters = new ApiV3FilterBuilder();
+ accountableFilters.add('responsible', '=', ['me']);
+ accountableFilters.add('status', 'o', []);
+
+ const accountableProps = {
+ 'columns[]': defaultColumns,
+ filters: accountableFilters.toJson(),
+ };
+
+ const createdFilters = new ApiV3FilterBuilder();
+ createdFilters.add('author', '=', ['me']);
+ createdFilters.add('status', 'o', []);
+
+ const createdProps = {
+ 'columns[]': defaultColumns,
+ filters: createdFilters.toJson(),
+ };
+
+ const watchedFilters = new ApiV3FilterBuilder();
+ watchedFilters.add('watcher', '=', ['me']);
+ watchedFilters.add('status', 'o', []);
+
+ const watchedProps = {
+ 'columns[]': defaultColumns,
+ filters: watchedFilters.toJson(),
+ };
+
+ return [
+ {
+ identifier: 'work_packages_assigned',
+ component: WidgetWpTableQuerySpaceComponent,
+ title: this.I18n.t('js.grid.widgets.work_packages_assigned.title'),
+ properties: {
+ queryProps: assignedProps,
+ name: this.I18n.t('js.grid.widgets.work_packages_assigned.title'),
+ },
+ },
+ {
+ identifier: 'work_packages_accountable',
+ component: WidgetWpTableQuerySpaceComponent,
+ title: this.I18n.t('js.grid.widgets.work_packages_accountable.title'),
+ properties: {
+ queryProps: accountableProps,
+ name: this.I18n.t('js.grid.widgets.work_packages_accountable.title'),
+ },
+ },
+ {
+ identifier: 'work_packages_created',
+ component: WidgetWpTableQuerySpaceComponent,
+ title: this.I18n.t('js.grid.widgets.work_packages_created.title'),
+ properties: {
+ queryProps: createdProps,
+ name: this.I18n.t('js.grid.widgets.work_packages_created.title'),
+ },
+ },
+ {
+ identifier: 'work_packages_watched',
+ component: WidgetWpTableQuerySpaceComponent,
+ title: this.I18n.t('js.grid.widgets.work_packages_watched.title'),
+ properties: {
+ queryProps: watchedProps,
+ name: this.I18n.t('js.grid.widgets.work_packages_watched.title'),
+ },
+ },
+ {
+ identifier: 'work_packages_table',
+ component: WidgetWpTableQuerySpaceComponent,
+ title: this.I18n.t('js.grid.widgets.work_packages_table.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.work_packages_table.title'),
+ },
+ },
+ {
+ identifier: 'work_packages_graph',
+ component: WidgetWpGraphComponent,
+ title: this.I18n.t('js.grid.widgets.work_packages_graph.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.work_packages_graph.title'),
+ },
+ },
+ {
+ identifier: 'work_packages_calendar',
+ component: WidgetWpCalendarComponent,
+ title: this.I18n.t('js.grid.widgets.work_packages_calendar.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.work_packages_calendar.title'),
+ },
+ },
+ {
+ identifier: 'work_packages_overview',
+ component: WidgetWpOverviewComponent,
+ title: this.I18n.t('js.grid.widgets.work_packages_overview.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.work_packages_overview.title'),
+ },
+ },
+ {
+ identifier: 'time_entries_current_user',
+ component: WidgetTimeEntriesCurrentUserComponent,
+ title: this.I18n.t('js.grid.widgets.time_entries_current_user.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.time_entries_current_user.title'),
+ days: [true, true, true, true, true, true, true],
+ },
+ },
+ {
+ identifier: 'time_entries_list',
+ component: WidgetTimeEntriesProjectComponent,
+ title: this.I18n.t('js.grid.widgets.time_entries_list.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.time_entries_list.title'),
+ },
+ },
+ {
+ identifier: 'documents',
+ component: WidgetDocumentsComponent,
+ title: this.I18n.t('js.grid.widgets.documents.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.documents.title'),
+ },
+ },
+ {
+ identifier: 'members',
+ component: WidgetMembersComponent,
+ title: this.I18n.t('js.grid.widgets.members.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.members.title'),
+ },
+ },
+ {
+ identifier: 'news',
+ component: WidgetNewsComponent,
+ title: this.I18n.t('js.grid.widgets.news.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.news.title'),
+ },
+ },
+ {
+ identifier: 'project_description',
+ component: WidgetProjectDescriptionComponent,
+ title: this.I18n.t('js.grid.widgets.project_description.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.project_description.title'),
+ },
+ },
+ {
+ identifier: 'custom_text',
+ component: WidgetCustomTextComponent,
+ title: this.I18n.t('js.grid.widgets.custom_text.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.custom_text.title'),
+ text: {
+ raw: '',
+ },
+ },
+ },
+ {
+ identifier: 'project_status',
+ component: WidgetProjectStatusComponent,
+ title: this.I18n.t('js.grid.widgets.project_status.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.project_status.title'),
+ },
+ },
+ {
+ identifier: 'project_status_beta',
+ component: WidgetProjectStatusBetaComponent,
+ title: this.I18n.t('js.grid.widgets.project_status_beta.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.project_status_beta.title'),
+ },
+ },
+ {
+ identifier: 'subprojects',
+ component: WidgetSubprojectsComponent,
+ title: this.I18n.t('js.grid.widgets.subprojects.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.subprojects.title'),
+ },
+ },
+ {
+ identifier: 'project_favorites',
+ component: WidgetProjectFavoritesComponent,
+ title: this.I18n.t('js.grid.widgets.project_favorites.title'),
+ properties: {
+ name: this.I18n.t('js.grid.widgets.project_favorites.title'),
+ },
+ },
+ ];
+ }
}