diff --git a/src/frontend/app/profile/profile.component.ts b/src/frontend/app/profile/profile.component.ts index b80408431e58e0a1f71f08f2ad8e3edff74e2b06..96cbdc2d006f7836383da2463456394222f881a8 100644 --- a/src/frontend/app/profile/profile.component.ts +++ b/src/frontend/app/profile/profile.component.ts @@ -9,8 +9,9 @@ import * as EXIF from 'exif-js'; import { TranslateService } from '@ngx-translate/core'; import { FiltersService } from '../service/filters.service'; import { Router } from '@angular/router'; -import { finalize } from 'rxjs/operators'; +import { finalize, tap, exhaustMap, filter, catchError } from 'rxjs/operators'; import { AuthService } from '../service/auth.service'; +import { of } from 'rxjs'; @Component({ selector: 'app-my-profile', @@ -202,57 +203,49 @@ export class ProfileComponent implements OnInit { profileToSend['pictureOrientation'] = orientation.replace(/\"/g, ''); } - this.http.put('../rest/users/' + this.authService.user.id, profileToSend) - .subscribe((data: any) => { - + this.http.put('../rest/users/' + this.authService.user.id, profileToSend).pipe( + tap((data: any) => { this.authService.user.picture = data.user.picture; - this.profileInfo.picture = data.user.picture; - - this.http.put('../rest/users/' + this.authService.user.id + '/preferences', profileToSend.preferences) - .pipe( - finalize(() => { - this.disableState = false; - this.msgButton = 'lang.validate'; - this.closeProfile(); - }) - ) - .subscribe(() => { - this.setLang(this.authService.user.preferences.lang); - this.cookieService.set('maarchParapheurLang', this.authService.user.preferences.lang); - - $('.avatarProfile').css({ 'transform': 'rotate(0deg)' }); - if (this.showPassword) { - const headers = new HttpHeaders({ - 'Authorization': 'Bearer ' + this.authService.getToken() - }); - - this.http.put('../rest/users/' + this.authService.user.id + '/password', this.password, { observe: 'response', headers: headers }) - .subscribe((dataPass: any) => { - this.authService.saveTokens(dataPass.headers.get('Token'), dataPass.headers.get('Refresh-Token')); - - this.password.newPassword = ''; - this.password.passwordConfirmation = ''; - this.password.currentPassword = ''; - this.notificationService.success('lang.profileUpdated'); - }, (err) => { - if (err.status === 401) { - this.notificationService.error('lang.wrongPassword'); - } else { - this.notificationService.handleErrors(err); - } - }); - } - - if (!this.showPassword) { - this.notificationService.success('lang.profileUpdated'); - } - - this.authService.updateUserInfoWithTokenRefresh(); - + }), + exhaustMap(() => this.http.put('../rest/users/' + this.authService.user.id + '/preferences', profileToSend.preferences)), + tap(() => { + this.disableState = false; + this.msgButton = 'lang.validate'; + this.setLang(this.authService.user.preferences.lang); + this.cookieService.set('maarchParapheurLang', this.authService.user.preferences.lang); + $('.avatarProfile').css({ 'transform': 'rotate(0deg)' }); + this.authService.updateUserInfoWithTokenRefresh(); + }), + exhaustMap(() => { + if (!this.showPassword) { + this.closeProfile(); + this.notificationService.success('lang.profileUpdated'); + return of(false); + } else { + const headers = new HttpHeaders({ + 'Authorization': 'Bearer ' + this.authService.getToken() }); - - }); + return this.http.put('../rest/users/' + this.authService.user.id + '/password', this.password, { observe: 'response', headers: headers }); + } + }), + filter(data => !!data), + tap((dataPass: any) => { + this.authService.saveTokens(dataPass.headers.get('Token'), dataPass.headers.get('Refresh-Token')); + this.password.newPassword = ''; + this.password.passwordConfirmation = ''; + this.password.currentPassword = ''; + this.notificationService.success('lang.profileUpdated'); + }), + catchError(err => { + if (err.status === 401) { + this.notificationService.error('lang.wrongPassword'); + } else { + this.notificationService.handleErrors(err); + } + return of(false); + }) + ).subscribe(); } selectSubstitute(ev: any) { diff --git a/src/frontend/js/sign.js b/src/frontend/js/sign.js index 28d9f6768664a86a572165ecb198b7b65386efeb..97aae9f2ba1d5cb0946890405c99d3bf24d6de1c 100644 --- a/src/frontend/js/sign.js +++ b/src/frontend/js/sign.js @@ -122,16 +122,18 @@ jQuery(document).ready(function (e) { y: mousePosition.y, break: false }); + + canvas.on('touchmove mousemove', function (e) { + + if (holdClick) { + var mousePosition = getMousePosition(canvas, e); + draw(context, mousePosition.x, mousePosition.y); + } + + return false; + }); } - return false; - }).on('touchmove mousemove', function (e) { - if (detectMode(params.mode, e)) { - if (holdClick) { - var mousePosition = getMousePosition(canvas, e); - draw(context, mousePosition.x, mousePosition.y); - } - } return false; }).on('touchend mouseup', function (e) { e.preventDefault(); @@ -139,6 +141,8 @@ jQuery(document).ready(function (e) { if (points.length > 0) { points[points.length - 1].break = true; } + canvas.unbind('mousemove'); + canvas.unbind('touchmove'); return false; });