Skip to content

Commit

Permalink
Communication: Add profile pictures to channel member overview (#9450)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaRangger authored Oct 11, 2024
1 parent 6e5e558 commit 51a4ff0
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class UserPublicInfoDTO {

private String lastName;

private String imageUrl;

private Boolean isInstructor;

private Boolean isEditor;
Expand All @@ -43,6 +45,7 @@ public UserPublicInfoDTO(User user) {
this.name = user.getName();
this.firstName = user.getFirstName();
this.lastName = user.getLastName();
this.imageUrl = user.getImageUrl();
}

/**
Expand Down Expand Up @@ -101,6 +104,14 @@ public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getImageUrl() {
return imageUrl;
}

public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}

public Boolean getIsInstructor() {
return isInstructor;
}
Expand Down Expand Up @@ -152,6 +163,7 @@ public int hashCode() {
@Override
public String toString() {
return "UserPublicInfoDTO{" + "id=" + id + ", login='" + login + '\'' + ", name='" + name + '\'' + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\''
+ ", isInstructor=" + isInstructor + ", isEditor=" + isEditor + ", isTeachingAssistant=" + isTeachingAssistant + ", isStudent=" + isStudent + '}';
+ ", imageUrl='" + imageUrl + '\'' + ", isInstructor=" + isInstructor + ", isEditor=" + isEditor + ", isTeachingAssistant=" + isTeachingAssistant + ", isStudent="
+ isStudent + '}';
}
}
1 change: 1 addition & 0 deletions src/main/webapp/app/core/user/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class UserPublicInfoDTO {
public firstName?: string;
public lastName?: string;
public email?: string;
public imageUrl?: string;
public isInstructor?: boolean;
public isEditor?: boolean;
public isTeachingAssistant?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<div>
<h4 class="d-inline-block rounded p-1 info">
@if (!courseWideSearchConfig.searchTerm) {
All Messages
<span jhiTranslate="artemisApp.metis.overview.allPublicMessages"></span>
} @else {
Search Results for "{{ courseWideSearchConfig.searchTerm }}"
<span jhiTranslate="artemisApp.metis.overview.searchResults" [translateValues]="{ search: courseWideSearchConfig.searchTerm }"></span>
}
</h4>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
@if (activeConversation && course) {
<div class="d-flex justify-content-between align-items-center conversation-member-row" (mouseleave)="$event.stopPropagation(); userDropdown.close()">
<span class="d-inline-block">
<fa-icon [icon]="userIcon" [ngbTooltip]="userTooltip" />
@if (userImageUrl) {
<img
[alt]="userLabel"
class="conversation-member-row-profile-picture rounded-3 me-1"
[src]="userImageUrl"
[ngStyle]="{ 'background-color': userDefaultPictureHue }"
/>
} @else {
<strong class="conversation-member-row-default-profile-picture rounded-3 me-1" [ngStyle]="{ 'background-color': userDefaultPictureHue }">{{ userInitials }}</strong>
}
@if (isChannel(activeConversation) && conversationMember?.isChannelModerator) {
<fa-icon [icon]="faUserGear" [ngbTooltip]="'artemisApp.dialogs.conversationDetail.memberTab.memberRow.channelModeratorTooltip' | artemisTranslate" />
}
{{ userLabel }}
@if (!conversationMember.isStudent) {
<fa-icon class="ms-1 text-secondary" [icon]="userIcon" [ngbTooltip]="userTooltip" />
}
</span>
<div ngbDropdown class="d-inline-block" #userDropdown="ngbDropdown">
@if (canBeRemovedFromConversation || canBeGrantedChannelModeratorRole || canBeRevokedChannelModeratorRole) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$profile-picture-height: 2rem;

.conversation-member-row {
min-height: 3rem;

Expand All @@ -14,4 +16,21 @@
.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);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, EventEmitter, HostBinding, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { faChalkboardTeacher, faEllipsis, faUser, faUserCheck, faUserGear } from '@fortawesome/free-solid-svg-icons';
import { faEllipsis, faUser, faUserCheck, faUserGear, faUserGraduate } from '@fortawesome/free-solid-svg-icons';
import { User } from 'app/core/user/user.model';
import { ConversationDTO } from 'app/entities/metis/conversation/conversation.model';
import { AccountService } from 'app/core/auth/account.service';
Expand All @@ -20,6 +20,8 @@ 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
Expand Down Expand Up @@ -56,6 +58,9 @@ export class ConversationMemberRowComponent implements OnInit, OnDestroy {
canBeRevokedChannelModeratorRole = false;

userLabel: string;
userImageUrl: string | undefined;
userDefaultPictureHue: string;
userInitials: string;
// icons
userIcon: IconProp = faUser;
userTooltip = '';
Expand Down Expand Up @@ -88,7 +93,10 @@ export class ConversationMemberRowComponent implements OnInit, OnDestroy {
this.isCreator = true;
}

this.userImageUrl = this.conversationMember.imageUrl;
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);
Expand Down Expand Up @@ -242,7 +250,7 @@ export class ConversationMemberRowComponent implements OnInit, OnDestroy {
const toolTipTranslationPath = 'artemisApp.metis.userAuthorityTooltips.';
// highest authority is displayed
if (this.conversationMember.isInstructor) {
this.userIcon = faChalkboardTeacher;
this.userIcon = faUserGraduate;
this.userTooltip = this.translateService.instant(toolTipTranslationPath + 'instructor');
} else if (this.conversationMember.isEditor || this.conversationMember.isTeachingAssistant) {
this.userIcon = faUserCheck;
Expand Down
4 changes: 3 additions & 1 deletion src/main/webapp/i18n/de/metis.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
"TECH_SUPPORT": "Technische Hilfe",
"ORGANIZATION": "Organisation",
"RANDOM": "Sonstiges",
"ANNOUNCEMENT": "Ankündigung"
"ANNOUNCEMENT": "Ankündigung",
"allPublicMessages": "Alle öffentlichen Nachrichten",
"searchResults": "Suchergebnisse für {{ search }}"
},
"post": {
"context": "Kontext",
Expand Down
4 changes: 3 additions & 1 deletion src/main/webapp/i18n/en/metis.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
"TECH_SUPPORT": "Tech Support",
"ORGANIZATION": "Organization",
"RANDOM": "Random",
"ANNOUNCEMENT": "Announcement"
"ANNOUNCEMENT": "Announcement",
"allPublicMessages": "All Public Messages",
"searchResults": "Search Results for '{{ search }}'"
},
"post": {
"context": "Context",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ import { BehaviorSubject } from 'rxjs';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { MessageInlineInputComponent } from 'app/shared/metis/message/message-inline-input/message-inline-input.component';
import { PostCreateEditModalComponent } from 'app/shared/metis/posting-create-edit-modal/post-create-edit-modal/post-create-edit-modal.component';
import { MockComponent, MockPipe, MockProvider } from 'ng-mocks';
import { MockComponent, MockDirective, MockPipe, MockProvider } from 'ng-mocks';
import { PostSortCriterion, SortDirection } from 'app/shared/metis/metis.util';
import { metisExamChannelDTO, metisExerciseChannelDTO, metisGeneralChannelDTO, metisLectureChannelDTO } from '../../../helpers/sample/metis-sample-data';
import { getElement } from '../../../helpers/utils/general.utils';
import { NgbTooltipMocksModule } from '../../../helpers/mocks/directive/ngbTooltipMocks.module';
import { TranslateDirective } from 'app/shared/language/translate.directive';

@Directive({
// eslint-disable-next-line @angular-eslint/directive-selector
Expand Down Expand Up @@ -68,6 +69,7 @@ describe('CourseWideSearchComponent', () => {
MockComponent(PostingThreadComponent),
MockComponent(MessageInlineInputComponent),
MockComponent(PostCreateEditModalComponent),
MockDirective(TranslateDirective),
],
providers: [MockProvider(MetisConversationService), MockProvider(MetisService), MockProvider(NgbModal)],
}).compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { of } from 'rxjs';
import { isGroupChatDTO } from 'app/entities/metis/conversation/group-chat.model';
import { By } from '@angular/platform-browser';
import { NgbDropdownMocksModule } from '../../../../../../../../helpers/mocks/directive/ngbDropdownMocks.module';
import { getElement } from '../../../../../../../../helpers/utils/general.utils';

const memberTemplate = {
id: 1,
Expand Down Expand Up @@ -167,6 +168,11 @@ examples.forEach((activeConversation) => {
}
}));

it('should display default profile picture', () => {
fixture.detectChanges();
expect(getElement(fixture.debugElement, '.conversation-member-row-default-profile-picture')).not.toBeNull();
});

function checkGrantModeratorButton(shouldExist: boolean) {
const grantModeratorRoleButton = fixture.debugElement.query(By.css('.grant-moderator'));
if (shouldExist) {
Expand Down

0 comments on commit 51a4ff0

Please sign in to comment.