Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General: Add profile pictures to course user list and user administration #9553

Merged
merged 7 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/webapp/app/admin/admin.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -73,6 +74,7 @@ const ENTITY_STATES = [...adminState];
StandardizedCompetencyFilterComponent,
StandardizedCompetencyDetailComponent,
DeleteUsersButtonComponent,
ProfilePictureComponent,
],
declarations: [
AuditsComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ <h2>
<span jhiTranslate="global.field.id"></span>
<fa-icon [icon]="faSort" />
</th>
<th>
<span jhiTranslate="artemisApp.userManagement.profilePicture"></span>
</th>
<th jhiSortBy="login">
<span jhiTranslate="artemisApp.userManagement.login"></span>
<fa-icon [icon]="faSort" />
Expand Down Expand Up @@ -147,6 +150,18 @@ <h2>
<td>
<a [routerLink]="['./', user.login]">{{ user.id }}</a>
</td>
<td>
<jhi-profile-picture
imageSizeInRem="1.5"
fontSizeInRem="0.6"
imageId="user-profile-picture"
defaultPictureId="user-default-profile-picture"
[authorId]="user.id"
[authorName]="user.name"
[imageUrl]="user.imageUrl"
>
</jhi-profile-picture>
</td>
<td>
<ngb-highlight [result]="user.login" [term]="searchTerm" />
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ <h2>{{ tutorialGroup.title }}</h2>
<jhi-icon-card [headerIcon]="faUserCheck" headline="artemisApp.entities.tutorialGroup.teachingAssistant">
<div class="text-center">
<div class="mb-2">
@if (tutorialGroup.teachingAssistantImageUrl) {
<img class="tutorial-group-detail-tutor-image rounded-3" [alt]="tutorialGroup.teachingAssistantName" [src]="tutorialGroup.teachingAssistantImageUrl" />
} @else {
<strong class="tutorial-group-detail-tutor-default-image rounded-3" [ngStyle]="{ 'background-color': tutorDefaultProfilePictureHue }">{{
tutorInitials
}}</strong>
}
<jhi-profile-picture
imageSizeInRem="4.5"
fontSizeInRem="2"
imageId="tutor-profile-picture"
defaultPictureId="tutor-default-profile-picture"
[authorId]="tutorialGroup.teachingAssistantId"
[authorName]="tutorialGroup.teachingAssistantName"
[imageUrl]="tutorialGroup.teachingAssistantImageUrl"
>
</jhi-profile-picture>
</div>

<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$tutor-image-size: 4.5rem;

.tutorial-group-detail {
.scrollbar {
position: relative;
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -34,9 +32,7 @@ export class TutorialGroupDetailComponent implements OnChanges {

sessions: TutorialGroupSession[] = [];

tutorInitials: string;
tutorialTimeslotString: string | undefined;
tutorDefaultProfilePictureHue: string;
isMessagingEnabled: boolean;
utilization: number | undefined;

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand All @@ -54,6 +55,7 @@ const routes: Routes = [
ArtemisSidebarModule,
InfiniteScrollModule,
CourseUsersSelectorModule,
ProfilePictureComponent,
],
declarations: [
CourseConversationsComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
@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">
@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>
}
<jhi-profile-picture
imageSizeInRem="2"
fontSizeInRem="0.8"
imageId="user-profile-picture"
defaultPictureId="user-default-profile-picture"
[authorId]="userId"
[authorName]="userName"
[imageUrl]="userImageUrl"
>
</jhi-profile-picture>
@if (isChannel(activeConversation) && conversationMember?.isChannelModerator) {
<fa-icon [icon]="faUserGear" [ngbTooltip]="'artemisApp.dialogs.conversationDetail.memberTab.memberRow.channelModeratorTooltip' | artemisTranslate" />
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$profile-picture-height: 2rem;

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

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = '';
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,25 @@ <h2 class="mb-1">
}
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column prop="" [minWidth]="100" [width]="120" [maxWidth]="120">
<ng-template ngx-datatable-header-template>
<span class="datatable-header-cell-wrapper">
<span class="datatable-header-cell-label bold sortable" jhiTranslate="artemisApp.course.courseGroup.profilePicture"></span>
</span>
</ng-template>
<ng-template ngx-datatable-cell-template let-value="value">
<jhi-profile-picture
imageSizeInRem="1.5"
fontSizeInRem="0.6"
imageId="user-profile-picture"
defaultPictureId="user-default-profile-picture"
[authorId]="value.id"
[authorName]="value.name"
[imageUrl]="value.imageUrl"
>
</jhi-profile-picture>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column prop="login" [minWidth]="150" [width]="200" [maxWidth]="200">
<ng-template ngx-datatable-header-template>
<span class="datatable-header-cell-wrapper" (click)="controls.onSort('login')">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
})
Expand Down
46 changes: 0 additions & 46 deletions src/main/webapp/app/shared/metis/metis.component.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$profile-picture-height: 2.15rem;

.post-result-information {
font-size: small;
font-style: italic;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/main/webapp/app/shared/metis/metis.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -63,6 +64,7 @@ import { MetisConversationService } from 'app/shared/metis/metis-conversation.se
MatFormFieldModule,
MatDialogModule,
LinkPreviewModule,
ProfilePictureComponent,
PaRangger marked this conversation as resolved.
Show resolved Hide resolved
],
declarations: [
PostingThreadComponent,
Expand Down
Loading
Loading