From fb4e24a3ded36b2add93064847fcd6e7c0f0ca16 Mon Sep 17 00:00:00 2001 From: Paul Rangger Date: Mon, 21 Oct 2024 16:38:30 +0200 Subject: [PATCH 1/5] Created new component and added to user lists --- src/main/webapp/app/admin/admin.module.ts | 2 + .../user-management.component.html | 15 ++++++ .../tutorial-group-detail.component.html | 17 +++--- .../tutorial-group-detail.component.scss | 19 ------- .../tutorial-group-detail.component.ts | 6 --- .../shared/tutorial-groups-shared.module.ts | 3 +- .../course-conversations.module.ts | 2 + .../conversation-member-row.component.html | 20 +++---- .../conversation-member-row.component.scss | 19 ------- .../conversation-member-row.component.ts | 10 ++-- .../course-group/course-group.component.html | 19 +++++++ .../course-group/course-group.module.ts | 3 +- .../app/shared/metis/metis.component.scss | 46 ---------------- .../webapp/app/shared/metis/metis.module.ts | 2 + .../answer-post-header.component.html | 40 ++++---------- .../post-header/post-header.component.html | 40 ++++---------- .../posting-header.directive.ts | 6 --- .../profile-picture.component.html | 25 +++++++++ .../profile-picture.component.scss | 29 +++++++++++ .../profile-picture.component.ts | 50 ++++++++++++++++++ src/main/webapp/i18n/de/course.json | 3 +- src/main/webapp/i18n/de/user-management.json | 3 +- src/main/webapp/i18n/en/course.json | 3 +- src/main/webapp/i18n/en/user-management.json | 3 +- .../profile-picture.component.spec.ts | 52 +++++++++++++++++++ 25 files changed, 254 insertions(+), 183 deletions(-) create mode 100644 src/main/webapp/app/shared/profile-picture/profile-picture.component.html create mode 100644 src/main/webapp/app/shared/profile-picture/profile-picture.component.scss create mode 100644 src/main/webapp/app/shared/profile-picture/profile-picture.component.ts create mode 100644 src/test/javascript/spec/component/shared/profile-picture/profile-picture.component.spec.ts diff --git a/src/main/webapp/app/admin/admin.module.ts b/src/main/webapp/app/admin/admin.module.ts index 92118d36ea07..28283dd58512 100644 --- a/src/main/webapp/app/admin/admin.module.ts +++ b/src/main/webapp/app/admin/admin.module.ts @@ -47,6 +47,7 @@ import { KnowledgeAreaTreeComponent } from 'app/shared/standardized-competencies import { StandardizedCompetencyFilterComponent } from 'app/shared/standardized-competencies/standardized-competency-filter.component'; import { StandardizedCompetencyDetailComponent } from 'app/shared/standardized-competencies/standardized-competency-detail.component'; import { DeleteUsersButtonComponent } from 'app/admin/user-management/delete-users-button.component'; +import { ProfilePictureComponent } from 'app/shared/profile-picture/profile-picture.component'; const ENTITY_STATES = [...adminState]; @@ -73,6 +74,7 @@ const ENTITY_STATES = [...adminState]; StandardizedCompetencyFilterComponent, StandardizedCompetencyDetailComponent, DeleteUsersButtonComponent, + ProfilePictureComponent, ], declarations: [ AuditsComponent, diff --git a/src/main/webapp/app/admin/user-management/user-management.component.html b/src/main/webapp/app/admin/user-management/user-management.component.html index 129f30d67feb..ff9f71708500 100644 --- a/src/main/webapp/app/admin/user-management/user-management.component.html +++ b/src/main/webapp/app/admin/user-management/user-management.component.html @@ -91,6 +91,9 @@

+ + + @@ -147,6 +150,18 @@

{{ user.id }} + + + + diff --git a/src/main/webapp/app/course/tutorial-groups/shared/tutorial-group-detail/tutorial-group-detail.component.html b/src/main/webapp/app/course/tutorial-groups/shared/tutorial-group-detail/tutorial-group-detail.component.html index 26607ec88597..aa3e591fcb37 100644 --- a/src/main/webapp/app/course/tutorial-groups/shared/tutorial-group-detail/tutorial-group-detail.component.html +++ b/src/main/webapp/app/course/tutorial-groups/shared/tutorial-group-detail/tutorial-group-detail.component.html @@ -10,13 +10,16 @@

{{ tutorialGroup.title }}

- @if (tutorialGroup.teachingAssistantImageUrl) { - - } @else { - {{ - tutorInitials - }} - } + +
diff --git a/src/main/webapp/app/course/tutorial-groups/shared/tutorial-group-detail/tutorial-group-detail.component.scss b/src/main/webapp/app/course/tutorial-groups/shared/tutorial-group-detail/tutorial-group-detail.component.scss index 0a2501554636..3e484a84165b 100644 --- a/src/main/webapp/app/course/tutorial-groups/shared/tutorial-group-detail/tutorial-group-detail.component.scss +++ b/src/main/webapp/app/course/tutorial-groups/shared/tutorial-group-detail/tutorial-group-detail.component.scss @@ -1,5 +1,3 @@ -$tutor-image-size: 4.5rem; - .tutorial-group-detail { .scrollbar { position: relative; @@ -15,20 +13,3 @@ $tutor-image-size: 4.5rem; margin-bottom: -1rem; } } - -.tutorial-group-detail-tutor-image { - width: $tutor-image-size; - height: $tutor-image-size; - object-fit: cover; -} - -.tutorial-group-detail-tutor-default-image { - width: $tutor-image-size; - height: $tutor-image-size; - font-size: 2rem; - display: inline-flex; - align-items: center; - justify-content: center; - background-color: var(--gray-400); - color: var(--white); -} diff --git a/src/main/webapp/app/course/tutorial-groups/shared/tutorial-group-detail/tutorial-group-detail.component.ts b/src/main/webapp/app/course/tutorial-groups/shared/tutorial-group-detail/tutorial-group-detail.component.ts index 2d2624ac55a4..2b3adc91f4e3 100644 --- a/src/main/webapp/app/course/tutorial-groups/shared/tutorial-group-detail/tutorial-group-detail.component.ts +++ b/src/main/webapp/app/course/tutorial-groups/shared/tutorial-group-detail/tutorial-group-detail.component.ts @@ -9,8 +9,6 @@ import { TranslateService } from '@ngx-translate/core'; import { faCircle, faCircleInfo, faCircleXmark, faPercent, faQuestionCircle, faUserCheck } from '@fortawesome/free-solid-svg-icons'; import dayjs from 'dayjs/esm'; import { SortService } from 'app/shared/service/sort.service'; -import { getInitialsFromString } from 'app/utils/text.utils'; -import { getBackgroundColorHue } from 'app/utils/color.utils'; @Component({ selector: 'jhi-tutorial-group-detail', @@ -34,9 +32,7 @@ export class TutorialGroupDetailComponent implements OnChanges { sessions: TutorialGroupSession[] = []; - tutorInitials: string; tutorialTimeslotString: string | undefined; - tutorDefaultProfilePictureHue: string; isMessagingEnabled: boolean; utilization: number | undefined; @@ -91,8 +87,6 @@ export class TutorialGroupDetailComponent implements OnChanges { getTutorialDetail() { const tutorialGroup = this.tutorialGroup; - this.tutorDefaultProfilePictureHue = getBackgroundColorHue(tutorialGroup.teachingAssistantId ? tutorialGroup.teachingAssistantId.toString() : 'default'); - this.tutorInitials = getInitialsFromString(tutorialGroup.teachingAssistantName ?? 'NA'); this.isMessagingEnabled = isMessagingEnabled(this.course); if (tutorialGroup.averageAttendance && tutorialGroup.capacity) { this.utilization = Math.round((tutorialGroup.averageAttendance / tutorialGroup.capacity) * 100); diff --git a/src/main/webapp/app/course/tutorial-groups/shared/tutorial-groups-shared.module.ts b/src/main/webapp/app/course/tutorial-groups/shared/tutorial-groups-shared.module.ts index 072ea574195e..3c1417c6a2b6 100644 --- a/src/main/webapp/app/course/tutorial-groups/shared/tutorial-groups-shared.module.ts +++ b/src/main/webapp/app/course/tutorial-groups/shared/tutorial-groups-shared.module.ts @@ -14,9 +14,10 @@ import { RemoveSecondsPipe } from 'app/course/tutorial-groups/shared/remove-seco import { MeetingPatternPipe } from 'app/course/tutorial-groups/shared/meeting-pattern.pipe'; import { DetailModule } from 'app/detail-overview-list/detail.module'; import { IconCardComponent } from 'app/shared/icon-card/icon-card.component'; +import { ProfilePictureComponent } from 'app/shared/profile-picture/profile-picture.component'; @NgModule({ - imports: [ArtemisSharedModule, RouterModule, ArtemisSidePanelModule, VerticalProgressBarModule, DetailModule, IconCardComponent], + imports: [ArtemisSharedModule, RouterModule, ArtemisSidePanelModule, VerticalProgressBarModule, DetailModule, IconCardComponent, ProfilePictureComponent], declarations: [ TutorialGroupsTableComponent, TutorialGroupDetailComponent, diff --git a/src/main/webapp/app/overview/course-conversations/course-conversations.module.ts b/src/main/webapp/app/overview/course-conversations/course-conversations.module.ts index 0d593728c9f2..2f6e01364f58 100644 --- a/src/main/webapp/app/overview/course-conversations/course-conversations.module.ts +++ b/src/main/webapp/app/overview/course-conversations/course-conversations.module.ts @@ -31,6 +31,7 @@ import { ArtemisMarkdownModule } from 'app/shared/markdown.module'; import { CourseConversationsCodeOfConductComponent } from 'app/overview/course-conversations/code-of-conduct/course-conversations-code-of-conduct.component'; import { CourseWideSearchComponent } from 'app/overview/course-conversations/course-wide-search/course-wide-search.component'; import { ArtemisSidebarModule } from 'app/shared/sidebar/sidebar.module'; +import { ProfilePictureComponent } from 'app/shared/profile-picture/profile-picture.component'; const routes: Routes = [ { @@ -54,6 +55,7 @@ const routes: Routes = [ ArtemisSidebarModule, InfiniteScrollModule, CourseUsersSelectorModule, + ProfilePictureComponent, ], declarations: [ CourseConversationsComponent, diff --git a/src/main/webapp/app/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.html b/src/main/webapp/app/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.html index 47eff1257e65..34454b54a61c 100644 --- a/src/main/webapp/app/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.html +++ b/src/main/webapp/app/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.html @@ -1,16 +1,16 @@ @if (activeConversation && course) {
- @if (userImageUrl) { - - } @else { - {{ userInitials }} - } + + @if (isChannel(activeConversation) && conversationMember?.isChannelModerator) { } diff --git a/src/main/webapp/app/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.scss b/src/main/webapp/app/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.scss index a2f66745bed6..28814b8391f5 100644 --- a/src/main/webapp/app/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.scss +++ b/src/main/webapp/app/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.scss @@ -1,5 +1,3 @@ -$profile-picture-height: 2rem; - .conversation-member-row { min-height: 3rem; @@ -16,21 +14,4 @@ $profile-picture-height: 2rem; .dropdown-toggle::after { content: none; } - - .conversation-member-row-default-profile-picture { - font-size: 0.8rem; - display: inline-flex; - align-items: center; - justify-content: center; - } - - .conversation-member-row-profile-picture, - .conversation-member-row-default-profile-picture { - width: $profile-picture-height; - height: $profile-picture-height; - max-width: $profile-picture-height; - max-height: $profile-picture-height; - background-color: var(--gray-400); - color: var(--white); - } } diff --git a/src/main/webapp/app/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.ts b/src/main/webapp/app/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.ts index 39a712c64424..da22826776da 100644 --- a/src/main/webapp/app/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.ts +++ b/src/main/webapp/app/overview/course-conversations/dialogs/conversation-detail-dialog/tabs/conversation-members/conversation-member-row/conversation-member-row.component.ts @@ -20,8 +20,6 @@ import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; import { getAsGroupChatDTO, isGroupChatDTO } from 'app/entities/metis/conversation/group-chat.model'; import { GroupChatService } from 'app/shared/metis/conversations/group-chat.service'; import { catchError } from 'rxjs/operators'; -import { getBackgroundColorHue } from 'app/utils/color.utils'; -import { getInitialsFromString } from 'app/utils/text.utils'; @Component({ // eslint-disable-next-line @angular-eslint/component-selector @@ -58,9 +56,9 @@ export class ConversationMemberRowComponent implements OnInit, OnDestroy { canBeRevokedChannelModeratorRole = false; userLabel: string; + userName: string | undefined; + userId: number | undefined; userImageUrl: string | undefined; - userDefaultPictureHue: string; - userInitials: string; // icons userIcon: IconProp = faUser; userTooltip = ''; @@ -94,9 +92,9 @@ export class ConversationMemberRowComponent implements OnInit, OnDestroy { } this.userImageUrl = this.conversationMember.imageUrl; + this.userId = this.conversationMember.id; + this.userName = this.conversationMember.name; this.userLabel = getUserLabel(this.conversationMember); - this.userInitials = getInitialsFromString(this.conversationMember.name ?? 'NA'); - this.userDefaultPictureHue = getBackgroundColorHue(this.conversationMember.id ? this.conversationMember.id.toString() : 'default'); this.setUserAuthorityIconAndTooltip(); // the creator of a channel can not be removed from the channel this.canBeRemovedFromConversation = !this.isCurrentUser && this.canRemoveUsersFromConversation(this.activeConversation); diff --git a/src/main/webapp/app/shared/course-group/course-group.component.html b/src/main/webapp/app/shared/course-group/course-group.component.html index a399e667e360..bdfe9046d82f 100644 --- a/src/main/webapp/app/shared/course-group/course-group.component.html +++ b/src/main/webapp/app/shared/course-group/course-group.component.html @@ -64,6 +64,25 @@

} + + + + + + + + + + + diff --git a/src/main/webapp/app/shared/course-group/course-group.module.ts b/src/main/webapp/app/shared/course-group/course-group.module.ts index 6e25d333e3f5..0c145b7ad00c 100644 --- a/src/main/webapp/app/shared/course-group/course-group.module.ts +++ b/src/main/webapp/app/shared/course-group/course-group.module.ts @@ -5,9 +5,10 @@ import { UserImportModule } from 'app/shared/user-import/user-import.module'; import { NgxDatatableModule } from '@siemens/ngx-datatable'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { RouterModule } from '@angular/router'; +import { ProfilePictureComponent } from 'app/shared/profile-picture/profile-picture.component'; @NgModule({ - imports: [ArtemisDataTableModule, UserImportModule, NgxDatatableModule, ArtemisSharedModule, RouterModule], + imports: [ArtemisDataTableModule, UserImportModule, NgxDatatableModule, ArtemisSharedModule, RouterModule, ProfilePictureComponent], declarations: [CourseGroupComponent], exports: [CourseGroupComponent], }) diff --git a/src/main/webapp/app/shared/metis/metis.component.scss b/src/main/webapp/app/shared/metis/metis.component.scss index 50c9db5f3588..8b835a234d01 100644 --- a/src/main/webapp/app/shared/metis/metis.component.scss +++ b/src/main/webapp/app/shared/metis/metis.component.scss @@ -1,5 +1,3 @@ -$profile-picture-height: 2.15rem; - .post-result-information { font-size: small; font-style: italic; @@ -31,54 +29,10 @@ $profile-picture-height: 2.15rem; margin-left: 2.65rem; } -.post-profile-picture { - width: $profile-picture-height; - height: $profile-picture-height; - font-size: 0.9rem; - display: inline-flex; - align-items: center; - justify-content: center; - background-color: var(--gray-400); - color: var(--white); -} - -.post-profile-picture-wrap { - width: $profile-picture-height; - height: $profile-picture-height; - position: relative; -} - -.post-edit-profile-picture-overlay { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - background-color: rgba(#000, 0.6); - opacity: 0; - color: var(--white); -} - -.post-edit-profile-picture-overlay:hover { - opacity: 1; -} - .post-authority-icon-student { display: none; } -.post-profile-picture-student { - background-color: var(--cyan); -} - -.post-profile-picture-tutor { - background-color: var(--orange); -} - -.post-profile-picture-instructor { - background-color: var(--graph-red); -} - .reference { font-weight: 200; display: inline-flex; diff --git a/src/main/webapp/app/shared/metis/metis.module.ts b/src/main/webapp/app/shared/metis/metis.module.ts index 82214acaca79..f116f5b965d0 100644 --- a/src/main/webapp/app/shared/metis/metis.module.ts +++ b/src/main/webapp/app/shared/metis/metis.module.ts @@ -42,6 +42,7 @@ import { LinkPreviewModule } from 'app/shared/link-preview/link-preview.module'; import { LinkPreviewComponent } from 'app/shared/link-preview/components/link-preview/link-preview.component'; import { LinkPreviewContainerComponent } from 'app/shared/link-preview/components/link-preview-container/link-preview-container.component'; import { MetisConversationService } from 'app/shared/metis/metis-conversation.service'; +import { ProfilePictureComponent } from 'app/shared/profile-picture/profile-picture.component'; @NgModule({ imports: [ @@ -63,6 +64,7 @@ import { MetisConversationService } from 'app/shared/metis/metis-conversation.se MatFormFieldModule, MatDialogModule, LinkPreviewModule, + ProfilePictureComponent, ], declarations: [ PostingThreadComponent, diff --git a/src/main/webapp/app/shared/metis/posting-header/answer-post-header/answer-post-header.component.html b/src/main/webapp/app/shared/metis/posting-header/answer-post-header/answer-post-header.component.html index b869f78d9258..08c7c2a410c3 100644 --- a/src/main/webapp/app/shared/metis/posting-header/answer-post-header/answer-post-header.component.html +++ b/src/main/webapp/app/shared/metis/posting-header/answer-post-header/answer-post-header.component.html @@ -2,35 +2,17 @@