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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
color code events
ulferts32dac846e017
diff --git a/frontend/src/app/components/user/user-avatar/user-avatar.component.ts b/frontend/src/app/components/user/user-avatar/user-avatar.component.tsindex 3db3063906c..a2a9f771c9d 100644--- a/frontend/src/app/components/user/user-avatar/user-avatar.component.ts+++ b/frontend/src/app/components/user/user-avatar/user-avatar.component.ts@@ -39,6 +39,7 @@ import {} from "@angular/core";import {DynamicBootstrapper} from "core-app/globals/dynamic-bootstrapper";import {PathHelperService} from "core-app/modules/common/path-helper/path-helper.service";+import {ColorsService} from "core-app/modules/common/colors/colors.service";@Component({selector: 'user-avatar',@@ -60,7 +61,8 @@ export class UserAvatarComponent implements AfterViewInit {constructor(protected elementRef:ElementRef,protected ref:ChangeDetectorRef,- protected pathHelper:PathHelperService) {+ protected pathHelper:PathHelperService,+ protected colors:ColorsService) {}public ngAfterViewInit() {@@ -87,12 +89,12 @@ export class UserAvatarComponent implements AfterViewInit {this.useFallback = element.dataset.useFallback!;this.userAvatarUrl = this.pathHelper.api.v3.users.id(this.userId).avatar.toString();this.userInitials = this.getInitials(this.userName);- this.colorCode = this.computeColor(this.userName);+ this.colorCode = this.colors.forString(this.userName);this.ref.detectChanges();}private getInitials(name:string) {- var names = name.split(' '),+ let names = name.split(' '),initials = names[0].substring(0, 1).toUpperCase();if (names.length > 1) {@@ -101,17 +103,6 @@ export class UserAvatarComponent implements AfterViewInit {return initials;}-- private computeColor(name:string) {- let hash = 0;- for (var i = 0; i < name.length; i++) {- hash = name.charCodeAt(i) + ((hash << 5) - hash);- }-- let h = hash % 360;-- return 'hsl(' + h + ', 50%, 50%)';- }}DynamicBootstrapper.register({ selector: 'user-avatar', cls: UserAvatarComponent });diff --git a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sass b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sassindex 6fb65d4314e..96b82721b7c 100644--- a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sass+++ b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.sass@@ -2,6 +2,9 @@.fc-headdisplay: table-footer-group+ .fc-event+ border-radius: 0+.fc-head-containerborder-color: white@@ -20,3 +23,4 @@color: #000000text-align: centerfont-size: 1em+ font-weight: bolddiff --git a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.tsindex d3e226e2d8f..82cc33443f5 100644--- a/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts+++ b/frontend/src/app/modules/calendar/te-calendar/te-calendar.component.ts@@ -22,6 +22,7 @@ import interactionPlugin from '@fullcalendar/interaction';import {HalResourceEditingService} from "core-app/modules/fields/edit/services/hal-resource-editing.service";import {TimeEntryEditService} from "core-app/modules/time_entries/edit/edit.service";import {TimeEntryCreateService} from "core-app/modules/time_entries/create/create.service";+import {ColorsService} from "core-app/modules/common/colors/colors.service";interface CalendarViewEvent {@@ -93,7 +94,8 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewIprivate timezone:TimezoneService,private timeEntryEdit:TimeEntryEditService,private timeEntryCreate:TimeEntryCreateService,- private timeEntryCache:TimeEntryCacheService) { }+ private timeEntryCache:TimeEntryCacheService,+ private colors:ColorsService) { }ngOnInit() {this.initializeCalendar();@@ -167,11 +169,15 @@ export class TimeEntryCalendarComponent implements OnInit, OnDestroy, AfterViewIhoursDistribution[entry.spentOn] = start;+ const color = this.colors.forString(this.entryName(entry));+return {title: hours < 0.5 ? '' : this.entryName(entry),startEditable: !!entry.update,start: start.format(),end: end.format(),+ backgroundColor: color,+ borderColor: color,entry: entry};}) as EventInput[];diff --git a/frontend/src/app/modules/common/colors/colors.service.ts b/frontend/src/app/modules/common/colors/colors.service.tsnew file mode 100644index 00000000000..e1414f05fe5--- /dev/null+++ b/frontend/src/app/modules/common/colors/colors.service.ts@@ -0,0 +1,15 @@+import { Injectable } from '@angular/core';++@Injectable()+export class ColorsService {+ public forString(value:string) {+ let hash = 0;+ for (var i = 0; i < value.length; i++) {+ hash = value.charCodeAt(i) + ((hash << 5) - hash);+ }++ let h = hash % 360;++ return 'hsl(' + h + ', 50%, 50%)';+ }+}\ No newline at end of filediff --git a/frontend/src/app/modules/common/openproject-common.module.ts b/frontend/src/app/modules/common/openproject-common.module.tsindex 34d2f1559b3..986f55f973c 100644--- a/frontend/src/app/modules/common/openproject-common.module.ts+++ b/frontend/src/app/modules/common/openproject-common.module.ts@@ -98,6 +98,7 @@ import {NgOptionHighlightModule} from "@ng-select/ng-option-highlight";import {CurrentProjectService} from "core-components/projects/current-project.service";import {CurrentUserService} from "core-components/user/current-user.service";import {WorkPackageAutocompleterComponent} from "core-app/modules/common/autocomplete/wp-autocompleter.component";+import {ColorsService} from "core-app/modules/common/colors/colors.service";export function bootstrapModule(injector:Injector) {return () => {@@ -333,6 +334,7 @@ export function bootstrapModule(injector:Injector) {GonService,BackRoutingService,HideSectionService,+ ColorsService]})export class OpenprojectCommonModule { }