added colorpicker
This commit is contained in:
parent
e7b950c246
commit
6b6d6e553f
9 changed files with 108 additions and 50 deletions
14
package-lock.json
generated
14
package-lock.json
generated
|
|
@ -19,6 +19,7 @@
|
||||||
"@angular/router": "^17.2.0",
|
"@angular/router": "^17.2.0",
|
||||||
"@ngx-translate/core": "^15.0.0",
|
"@ngx-translate/core": "^15.0.0",
|
||||||
"@ngx-translate/http-loader": "^8.0.0",
|
"@ngx-translate/http-loader": "^8.0.0",
|
||||||
|
"ngx-color-picker": "^16.0.0",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
"zone.js": "~0.14.3"
|
"zone.js": "~0.14.3"
|
||||||
|
|
@ -9367,6 +9368,19 @@
|
||||||
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/ngx-color-picker": {
|
||||||
|
"version": "16.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ngx-color-picker/-/ngx-color-picker-16.0.0.tgz",
|
||||||
|
"integrity": "sha512-Dk2FvcbebD6STZSVzkI5oFHOlTrrNC5bOHh+YVaFgaWuWrVUdVIJm68ocUvTgr/qxTEJjrfcnRnS4wi7BJ2hKg==",
|
||||||
|
"dependencies": {
|
||||||
|
"tslib": "^2.3.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@angular/common": ">=9.0.0",
|
||||||
|
"@angular/core": ">=9.0.0",
|
||||||
|
"@angular/forms": ">=9.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/nice-napi": {
|
"node_modules/nice-napi": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/nice-napi/-/nice-napi-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/nice-napi/-/nice-napi-1.0.2.tgz",
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
"@angular/router": "^17.2.0",
|
"@angular/router": "^17.2.0",
|
||||||
"@ngx-translate/core": "^15.0.0",
|
"@ngx-translate/core": "^15.0.0",
|
||||||
"@ngx-translate/http-loader": "^8.0.0",
|
"@ngx-translate/http-loader": "^8.0.0",
|
||||||
|
"ngx-color-picker": "^16.0.0",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
"zone.js": "~0.14.3"
|
"zone.js": "~0.14.3"
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,23 @@
|
||||||
@if (currentUserId) {
|
@if (currentUserId) { @for (user of
|
||||||
|
firebaseService.getUserDataFromId(currentUserId); track user) {
|
||||||
<section>
|
<section>
|
||||||
<div class="dialog">
|
<div class="dialog">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<img src="./../../../../assets/img/logo.svg" alt="" />
|
<img src="./../../../../assets/img/logo.svg" alt="" />
|
||||||
<p>{{ "contacts.editContact" | translate }}</p>
|
<p>{{ "contacts.editContact" | translate }}</p>
|
||||||
<app-btn-close [isEditContactDialogOpen]="false"></app-btn-close>
|
<app-btn-close [isContactDialogOpen]="false"></app-btn-close>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="badge">
|
<div class="badge">
|
||||||
<div
|
<div class="picker">
|
||||||
class="circle"
|
<input
|
||||||
[ngStyle]="{
|
[(colorPicker)]="currentColor"
|
||||||
'background-color': firebaseService.getUserDetails(
|
[style.background]="newColor === '' ? user.color : newColor"
|
||||||
currentUserId,
|
(colorPickerChange)="updateColor($event)"
|
||||||
'color'
|
/>
|
||||||
)
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<div class="initials">
|
<div class="initials">
|
||||||
@if (!userInitials) {
|
@if (!userInitials) {
|
||||||
{{ firebaseService.getUserDetails(currentUserId, "initials") }} }
|
{{ user.initials }} } @else {
|
||||||
@else {
|
|
||||||
{{ userInitials }}
|
{{ userInitials }}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -30,27 +27,28 @@
|
||||||
<app-contact-form
|
<app-contact-form
|
||||||
(inititalsEmitter)="inititalsEmitter($event)"
|
(inititalsEmitter)="inititalsEmitter($event)"
|
||||||
[currentUserId]="currentUserId"
|
[currentUserId]="currentUserId"
|
||||||
|
[newColor]="newColor"
|
||||||
></app-contact-form>
|
></app-contact-form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
} @else {
|
} } @else {
|
||||||
<section>
|
<section>
|
||||||
<div class="dialog">
|
<div class="dialog">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<img src="./../../../../assets/img/logo.svg" alt="" />
|
<img src="./../../../../assets/img/logo.svg" alt="" />
|
||||||
<p>{{ "contacts.addContact" | translate }}</p>
|
<p>{{ "contacts.addContact" | translate }}</p>
|
||||||
<app-btn-close [isEditContactDialogOpen]="false"></app-btn-close>
|
<app-btn-close [isContactDialogOpen]="false"></app-btn-close>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="badge">
|
<div class="badge">
|
||||||
<div
|
<div class="picker">
|
||||||
class="circle"
|
<input
|
||||||
[ngStyle]="{
|
[(colorPicker)]="randomColor"
|
||||||
'background-color': randomColor
|
[style.background]="randomColor"
|
||||||
}"
|
(colorPickerSelect)="updateColor($event)"
|
||||||
>
|
/>
|
||||||
<div class="initials">{{ userInitials }}</div>
|
<div class="initials">{{ userInitials }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -58,6 +56,7 @@
|
||||||
<app-contact-form
|
<app-contact-form
|
||||||
(inititalsEmitter)="inititalsEmitter($event)"
|
(inititalsEmitter)="inititalsEmitter($event)"
|
||||||
[randomColor]="randomColor"
|
[randomColor]="randomColor"
|
||||||
|
[newColor]="newColor"
|
||||||
></app-contact-form>
|
></app-contact-form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,19 @@ section {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
min-height: 332px;
|
min-height: 332px;
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
.circle {
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
position: relative;
|
||||||
|
width: 30%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.picker {
|
||||||
|
input {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
@ -54,20 +66,22 @@ section {
|
||||||
height: 120px;
|
height: 120px;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
border: 2px solid var(--white);
|
border: 2px solid var(--white);
|
||||||
.initials {
|
z-index: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.initials {
|
||||||
|
position: absolute;
|
||||||
|
top: 30%;
|
||||||
|
left: 35%;
|
||||||
|
width: fit-content;
|
||||||
|
height: fit-content;
|
||||||
font-size: 47px;
|
font-size: 47px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: var(--white);
|
color: var(--white);
|
||||||
text-shadow: 1px 1px 2px var(--black);
|
text-shadow: 1px 1px 2px var(--black);
|
||||||
}
|
z-index: 2;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.badge {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
width: 30%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.form {
|
.form {
|
||||||
|
|
@ -85,7 +99,7 @@ section {
|
||||||
|
|
||||||
.badge {
|
.badge {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 125px;
|
top: 105px;
|
||||||
right: 40px;
|
right: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,6 +107,11 @@ section {
|
||||||
flex-direction: column-reverse;
|
flex-direction: column-reverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.initials {
|
||||||
|
font-size: 42px;
|
||||||
|
left: 33%;
|
||||||
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
height: 42px;
|
height: 42px;
|
||||||
img {
|
img {
|
||||||
|
|
@ -118,16 +137,23 @@ section {
|
||||||
.content {
|
.content {
|
||||||
flex-direction: column-reverse;
|
flex-direction: column-reverse;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
.circle {
|
}
|
||||||
|
|
||||||
|
.picker {
|
||||||
|
position: absolute;
|
||||||
|
top: -5px;
|
||||||
|
left: 0;
|
||||||
|
input {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
height: 80px;
|
height: 80px;
|
||||||
|
border-radius: 100%;
|
||||||
|
border: 2px solid var(--white);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.initials {
|
.initials {
|
||||||
font-size: 32px;
|
font-size: 32px;
|
||||||
font-weight: 500;
|
left: 28%;
|
||||||
color: var(--white);
|
|
||||||
text-shadow: 1px 1px 2px var(--black);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { FirebaseService } from '../../../services/firebase.service';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { ContactFormComponent } from './contact-form/contact-form.component';
|
import { ContactFormComponent } from './contact-form/contact-form.component';
|
||||||
import { SharedService } from '../../../services/shared.service';
|
import { SharedService } from '../../../services/shared.service';
|
||||||
import { User } from '../../../interfaces/user.interface';
|
import { ColorPickerModule } from 'ngx-color-picker';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-contact-edit',
|
selector: 'app-contact-edit',
|
||||||
|
|
@ -15,14 +15,18 @@ import { User } from '../../../interfaces/user.interface';
|
||||||
ContactFormComponent,
|
ContactFormComponent,
|
||||||
BtnCloseComponent,
|
BtnCloseComponent,
|
||||||
TranslateModule,
|
TranslateModule,
|
||||||
|
ColorPickerModule,
|
||||||
],
|
],
|
||||||
templateUrl: './contact-edit-new.component.html',
|
templateUrl: './contact-edit-new.component.html',
|
||||||
styleUrl: './contact-edit-new.component.scss',
|
styleUrl: './contact-edit-new.component.scss',
|
||||||
})
|
})
|
||||||
export class ContactEditNewComponent implements OnInit {
|
export class ContactEditNewComponent implements OnInit {
|
||||||
@Input() currentUserId: string = '';
|
@Input() currentUserId: string = '';
|
||||||
|
@Input() currentColor: string = '';
|
||||||
|
|
||||||
randomColor: string = '';
|
randomColor: string = '';
|
||||||
userInitials: string = '';
|
userInitials: string = '';
|
||||||
|
newColor: string = '';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public firebaseService: FirebaseService,
|
public firebaseService: FirebaseService,
|
||||||
|
|
@ -33,6 +37,10 @@ export class ContactEditNewComponent implements OnInit {
|
||||||
this.userInitials = emitter;
|
this.userInitials = emitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateColor(newColor: string) {
|
||||||
|
this.newColor = newColor;
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.randomColor = this.sharedService.generateRandomColor();
|
this.randomColor = this.sharedService.generateRandomColor();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import { User } from '../../../../interfaces/user.interface';
|
||||||
export class ContactFormComponent implements OnInit, OnChanges {
|
export class ContactFormComponent implements OnInit, OnChanges {
|
||||||
@Input() currentUserId: string = '';
|
@Input() currentUserId: string = '';
|
||||||
@Input() randomColor: string = '';
|
@Input() randomColor: string = '';
|
||||||
|
@Input() newColor: string = '';
|
||||||
@Output() inititalsEmitter = new EventEmitter<string>();
|
@Output() inititalsEmitter = new EventEmitter<string>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|
@ -39,6 +40,7 @@ export class ContactFormComponent implements OnInit, OnChanges {
|
||||||
email: '',
|
email: '',
|
||||||
phone: '',
|
phone: '',
|
||||||
initials: '',
|
initials: '',
|
||||||
|
color: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
userData: User = {
|
userData: User = {
|
||||||
|
|
@ -152,15 +154,17 @@ export class ContactFormComponent implements OnInit, OnChanges {
|
||||||
onSubmit(ngForm: NgForm) {
|
onSubmit(ngForm: NgForm) {
|
||||||
if (ngForm.submitted && ngForm.form.valid) {
|
if (ngForm.submitted && ngForm.form.valid) {
|
||||||
if (this.currentUserId) {
|
if (this.currentUserId) {
|
||||||
|
this.contactData.color = this.newColor;
|
||||||
this.firebaseService.updateUserData(
|
this.firebaseService.updateUserData(
|
||||||
this.currentUserId,
|
this.currentUserId,
|
||||||
this.contactData
|
this.contactData
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
this.userData.color = this.newColor;
|
||||||
const { id, ...taskWithoutIds } = this.userData;
|
const { id, ...taskWithoutIds } = this.userData;
|
||||||
this.firebaseService.addNewUser(taskWithoutIds);
|
this.firebaseService.addNewUser(taskWithoutIds);
|
||||||
}
|
}
|
||||||
this.closeEditDialog();
|
this.closeDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -169,8 +173,9 @@ export class ContactFormComponent implements OnInit, OnChanges {
|
||||||
this.sharedService.isAnyDialogOpen = false;
|
this.sharedService.isAnyDialogOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
closeEditDialog() {
|
closeDialog() {
|
||||||
this.sharedService.isEditContactDialogOpen = false;
|
|
||||||
this.sharedService.isAnyDialogOpen = false;
|
this.sharedService.isAnyDialogOpen = false;
|
||||||
|
this.sharedService.isEditContactDialogOpen = false;
|
||||||
|
this.sharedService.isNewContactDialogOpen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,11 @@ export class FirebaseService implements OnDestroy {
|
||||||
return this.getAllUsers().filter((user) => user.initials !== 'G');
|
return this.getAllUsers().filter((user) => user.initials !== 'G');
|
||||||
}
|
}
|
||||||
|
|
||||||
checkUserUID(userUid: string): User[] {
|
getUserDataFromId(userId: string): User[] {
|
||||||
|
return this.getAllUsers().filter((user) => user.id === userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
getUserDataFromUid(userUid: string): User[] {
|
||||||
return this.getAllUsers().filter((user) => user.uId === userUid);
|
return this.getAllUsers().filter((user) => user.uId === userUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ export class LoginService {
|
||||||
signInWithEmailAndPassword(getAuth(), loginData.mail, loginData.password)
|
signInWithEmailAndPassword(getAuth(), loginData.mail, loginData.password)
|
||||||
.then((userCredential) => {
|
.then((userCredential) => {
|
||||||
const user = userCredential.user;
|
const user = userCredential.user;
|
||||||
const userData = this.firebaseService.checkUserUID(user.uid);
|
const userData = this.firebaseService.getUserDataFromUid(user.uid);
|
||||||
if (userData.length > 0 && userData[0].id) {
|
if (userData.length > 0 && userData[0].id) {
|
||||||
this.getUserIdInLocalStorage(userData[0].id);
|
this.getUserIdInLocalStorage(userData[0].id);
|
||||||
this.updateUserOnlineStatus(userData[0].id);
|
this.updateUserOnlineStatus(userData[0].id);
|
||||||
|
|
@ -161,7 +161,7 @@ export class LoginService {
|
||||||
}
|
}
|
||||||
|
|
||||||
ifExistUser(user: string) {
|
ifExistUser(user: string) {
|
||||||
const userData = this.firebaseService.checkUserUID(user);
|
const userData = this.firebaseService.getUserDataFromUid(user);
|
||||||
if (userData.length > 0 && userData[0].id) {
|
if (userData.length > 0 && userData[0].id) {
|
||||||
this.getUserIdInLocalStorage(userData[0].id);
|
this.getUserIdInLocalStorage(userData[0].id);
|
||||||
this.updateUserOnlineStatus(userData[0].id);
|
this.updateUserOnlineStatus(userData[0].id);
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,13 @@ import { SharedService } from '../../../../services/shared.service';
|
||||||
styleUrl: './btn-close.component.scss',
|
styleUrl: './btn-close.component.scss',
|
||||||
})
|
})
|
||||||
export class BtnCloseComponent {
|
export class BtnCloseComponent {
|
||||||
@Input() isEditContactDialogOpen: boolean = false;
|
@Input() isContactDialogOpen: boolean = false;
|
||||||
|
|
||||||
constructor(private sharedService: SharedService) {}
|
constructor(private sharedService: SharedService) {}
|
||||||
|
|
||||||
closeClicked() {
|
closeClicked() {
|
||||||
this.sharedService.isAnyDialogOpen = false;
|
this.sharedService.isAnyDialogOpen = false;
|
||||||
this.sharedService.isEditContactDialogOpen = this.isEditContactDialogOpen;
|
this.sharedService.isEditContactDialogOpen = this.isContactDialogOpen;
|
||||||
|
this.sharedService.isNewContactDialogOpen = this.isContactDialogOpen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue