-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Gravatar images on user accounts [#684]
* Changed the user icon in the sidebar with their gravatar image. * Added the gravatar image to the account edit page.
- Loading branch information
Showing
15 changed files
with
250 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
comixed-web/src/app/user/components/user-card/user-card.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<img | ||
ngxGravatar | ||
[alt]="user.email" | ||
[email]="user.email" | ||
[size]="imageSize" | ||
[round]="false" | ||
/> |
Empty file.
46 changes: 46 additions & 0 deletions
46
comixed-web/src/app/user/components/user-card/user-card.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* ComiXed - A digital comic book library management application. | ||
* Copyright (C) 2021, The ComiXed Project | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses> | ||
*/ | ||
|
||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { UserCardComponent } from './user-card.component'; | ||
import { LoggerModule } from '@angular-ru/logger'; | ||
import { USER_READER } from '@app/user/user.fixtures'; | ||
import { GravatarModule } from 'ngx-gravatar'; | ||
|
||
describe('UserCardComponent', () => { | ||
const USER = USER_READER; | ||
|
||
let component: UserCardComponent; | ||
let fixture: ComponentFixture<UserCardComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [UserCardComponent], | ||
imports: [LoggerModule.forRoot(), GravatarModule] | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(UserCardComponent); | ||
component = fixture.componentInstance; | ||
component.user = USER; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
35 changes: 35 additions & 0 deletions
35
comixed-web/src/app/user/components/user-card/user-card.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* ComiXed - A digital comic book library management application. | ||
* Copyright (C) 2021, The ComiXed Project | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses> | ||
*/ | ||
|
||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { User } from '@app/user/models/user'; | ||
import { LoggerService } from '@angular-ru/logger'; | ||
|
||
@Component({ | ||
selector: 'cx-user-card', | ||
templateUrl: './user-card.component.html', | ||
styleUrls: ['./user-card.component.scss'] | ||
}) | ||
export class UserCardComponent implements OnInit { | ||
@Input() user: User; | ||
@Input() imageSize = 'auto'; | ||
|
||
constructor(private logger: LoggerService) {} | ||
|
||
ngOnInit(): void {} | ||
} |
188 changes: 97 additions & 91 deletions
188
comixed-web/src/app/user/pages/account-edit-page/account-edit-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,107 @@ | ||
<mat-toolbar class="cx-light-dark-background"> | ||
<div class="cx-spacer"></div> | ||
<button | ||
id="save-button" | ||
class="cx-action-button" | ||
mat-icon-button | ||
color="primary" | ||
[disabled]="!userForm.valid" | ||
(click)="onSaveChanges()" | ||
> | ||
<mat-icon>save</mat-icon> | ||
</button> | ||
<button | ||
id="reset-button" | ||
class="cx-action-button" | ||
mat-icon-button | ||
color="warn" | ||
[disabled]="!userForm.dirty" | ||
(click)="onResetChanges()" | ||
> | ||
<mat-icon>undo</mat-icon> | ||
</button> | ||
</mat-toolbar> | ||
<form [formGroup]="userForm"> | ||
<mat-card *ngIf="!!user"> | ||
<mat-card-title> | ||
{{ "user.edit-current-user.page-title" | translate }} | ||
</mat-card-title> | ||
<mat-card-subtitle>{{ user.email }}</mat-card-subtitle> | ||
<mat-card-content> | ||
<mat-form-field class="cx-width-100" appearance="fill"> | ||
<mat-label> | ||
{{ "user.edit-current-user.label.email" | translate }} | ||
</mat-label> | ||
<input | ||
id="email-input" | ||
matInput | ||
type="email" | ||
formControlName="email" | ||
required | ||
/> | ||
</mat-form-field> | ||
<mat-form-field class="cx-width-100" appearance="fill"> | ||
<mat-label> | ||
{{ "user.edit-current-user.label.password" | translate }} | ||
</mat-label> | ||
<input | ||
id="password-input" | ||
matInput | ||
type="password" | ||
formControlName="password" | ||
(keyup)="onPasswordChanged()" | ||
/> | ||
<mat-error> | ||
<span *ngIf="userForm.controls.password.errors?.minLength"> | ||
{{ | ||
"validation.value-too-short" | ||
| translate | ||
: { | ||
length: | ||
userForm.controls.password.errors.minLength | ||
.requiredLength | ||
} | ||
}} | ||
</span> | ||
<span *ngIf="userForm.controls.password.errors?.maxLength"> | ||
{{ | ||
"validation.value-too-long" | ||
| translate | ||
: { | ||
length: | ||
userForm.controls.password.errors.maxLength | ||
.requiredLength | ||
} | ||
}} | ||
</span> | ||
</mat-error> | ||
</mat-form-field> | ||
<mat-form-field class="cx-width-100" appearance="fill"> | ||
<mat-label> | ||
{{ "user.edit-current-user.label.password-verify" | translate }} | ||
</mat-label> | ||
<input | ||
id="password-verify-input" | ||
matInput | ||
type="password" | ||
formControlName="passwordVerify" | ||
/> | ||
<mat-error> | ||
<span *ngIf="userForm.errors?.passwordsDontMatch"> | ||
{{ | ||
"user.edit-current-user.validation.passwords-dont-match" | ||
| translate | ||
}} | ||
</span> | ||
</mat-error> | ||
</mat-form-field> | ||
<div class="cx-horizontal-container"> | ||
<div class="cx-grow-1 cx-padding-5"> | ||
<mat-form-field class="cx-width-100" appearance="fill"> | ||
<mat-label> | ||
{{ "user.edit-current-user.label.email" | translate }} | ||
</mat-label> | ||
<input | ||
id="email-input" | ||
matInput | ||
type="email" | ||
formControlName="email" | ||
required | ||
/> | ||
</mat-form-field> | ||
<mat-form-field class="cx-width-100" appearance="fill"> | ||
<mat-label> | ||
{{ "user.edit-current-user.label.password" | translate }} | ||
</mat-label> | ||
<input | ||
id="password-input" | ||
matInput | ||
type="password" | ||
formControlName="password" | ||
(keyup)="onPasswordChanged()" | ||
/> | ||
<mat-error> | ||
<span *ngIf="userForm.controls.password.errors?.minLength"> | ||
{{ | ||
"validation.value-too-short" | ||
| translate | ||
: { | ||
length: | ||
userForm.controls.password.errors.minLength | ||
.requiredLength | ||
} | ||
}} | ||
</span> | ||
<span *ngIf="userForm.controls.password.errors?.maxLength"> | ||
{{ | ||
"validation.value-too-long" | ||
| translate | ||
: { | ||
length: | ||
userForm.controls.password.errors.maxLength | ||
.requiredLength | ||
} | ||
}} | ||
</span> | ||
</mat-error> | ||
</mat-form-field> | ||
<mat-form-field class="cx-width-100" appearance="fill"> | ||
<mat-label> | ||
{{ "user.edit-current-user.label.password-verify" | translate }} | ||
</mat-label> | ||
<input | ||
id="password-verify-input" | ||
matInput | ||
type="password" | ||
formControlName="passwordVerify" | ||
/> | ||
<mat-error> | ||
<span *ngIf="userForm.errors?.passwordsDontMatch"> | ||
{{ | ||
"user.edit-current-user.validation.passwords-dont-match" | ||
| translate | ||
}} | ||
</span> | ||
</mat-error> | ||
</mat-form-field> | ||
</div> | ||
<div class="cx-grow-0 cx-border-primary-1 cx-padding-5"> | ||
<cx-user-card [user]="user" [imageSize]="imageSize"></cx-user-card> | ||
</div> | ||
</div> | ||
</mat-card-content> | ||
<mat-card-actions> | ||
<button | ||
id="save-button" | ||
class="cx-action-button" | ||
mat-raised-button | ||
color="primary" | ||
[disabled]="!userForm.valid" | ||
(click)="onSaveChanges()" | ||
> | ||
<mat-icon>save</mat-icon> | ||
<mat-label>{{ "button.save" | translate }}</mat-label> | ||
</button> | ||
<button | ||
id="reset-button" | ||
class="cx-action-button" | ||
mat-raised-button | ||
color="warn" | ||
[disabled]="!userForm.dirty" | ||
(click)="onResetChanges()" | ||
> | ||
<mat-icon>undo</mat-icon> | ||
<mat-label>{{ "button.reset" | translate }}</mat-label> | ||
</button> | ||
</mat-card-actions> | ||
</mat-card> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.