disposition entête

This commit is contained in:
Tykayn 2021-06-07 12:36:49 +02:00 committed by tykayn
parent 748eb48125
commit 5ce3984dc9
5 changed files with 115 additions and 59 deletions

View File

@ -287,4 +287,24 @@ export class ApiService {
console.log(error.config); console.log(error.config);
// this.loaderService.setStatus(false); // this.loaderService.setStatus(false);
} }
public ousideHandleError(error) {
// this.loaderService.setStatus(true);
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.error('Error response data', error.response.data);
console.error('Error response status', error.response.status);
console.error('Error response headers', error.response.headers);
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.log('ErrorRequest', error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
console.log(error.config);
// this.loaderService.setStatus(false);
}
} }

View File

@ -61,10 +61,9 @@ export class StorageService {
} }
setChoicesForVoteStack(choices_list: Choice[]) { setChoicesForVoteStack(choices_list: Choice[]) {
this.vote_stack.votes = [];
// text choices // text choices
if (!this.vote_stack.id) { if (!this.vote_stack.id) {
this.vote_stack.votes = [];
for (const choice of choices_list) { for (const choice of choices_list) {
if (environment.autofill) { if (environment.autofill) {
console.log('autofill au hasard des votes à ce sondage'); console.log('autofill au hasard des votes à ce sondage');

View File

@ -2,72 +2,75 @@
<section class="poll_loaded padded" *ngIf="!fetching && poll"> <section class="poll_loaded padded" *ngIf="!fetching && poll">
<!-- messages--> <!-- messages-->
<article class="message is-warning" *ngIf="isArchived"> <div class="message is-warning" *ngIf="isArchived">
<div class="message-body"> <div class="message-body">
⚰️ Ce sondage a expiré, il n'est plus possible d'y ajouter de votes ou de commentaires ⚰️ Ce sondage a expiré, il n'est plus possible d'y ajouter de votes ou de commentaires
</div> </div>
</article> </div>
<article class="message is-info" *ngIf="poll.stacks.length == 0">
<div class="message-body"> <div class="message is-info" *ngIf="poll.modification_policy == 'self'">
aucun vote pour le moment
</div>
</article>
<article class="message is-info" *ngIf="poll.modification_policy == 'self'">
<div class="message-body"> <div class="message-body">
Vous ne pouvez modifier que votre propre vote à ce sondage Vous ne pouvez modifier que votre propre vote à ce sondage
</div> </div>
</article> </div>
<!-- actions--> <!-- actions-->
<div id="export_and_share">
<div class="sharing" *ngIf="poll">
<div class="margin-top-x8">
Partager le sondage
<i class="fa fa-share" aria-hidden="true"></i>
</div>
<p class="nobold text-14" for="copyLink">
<a href="{{ pollService.getParticipationUrl() }}">
{{ pollService.getParticipationUrl() }}
</a>
</p>
<app-copy-text [textToCopy]="pollService.getParticipationUrl()"></app-copy-text>
<div class="ui-card-subtitle">
Exporter/Imprimer
</div>
<button class="replicate duplicate btn" (click)="duplicate()">
<i class="fa fa-copy" aria-hidden="true"></i>
Dupliquer
</button>
<button class="export export-csv btn" (click)="exportCSV()">
<i class="fa fa-file-calc-o" aria-hidden="true"></i>
Exporter en .csv
</button>
<button class="export export-json btn" (click)="exportJson()">
<i class="fa fa-file-archive-o" aria-hidden="true"></i>
export json
</button>
<button class="export export-print btn" (click)="print()">
<i class="fa fa-print"></i>
Imprimer le sondage
</button>
</div>
</div>
<!-- affichage des possibilités de réponse --> <!-- affichage des possibilités de réponse -->
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
<div class="card"> <div class="card">
<header class="card-header"> <header class="card-header padded">
<p class="card-header-title is-1 title">{{ poll.title }}</p> <div class="columns">
<div class="voters-count padded"><i class="fa fa-users"></i> {{ poll.stacks.length }} votants</div> <div class="column">
<!-- <p class="card-header-icon">author : {{ poll.owner?.pseudo }}</p>--> <p class="card-header-title is-1 title">{{ poll.title }}</p>
<p class="descr">{{ poll.description }}</p>
<div class="voters-count padded">
<i class="fa fa-users"></i> {{ poll.stacks.length }} votants
</div>
<p class="card-header-icon" *ngIf="poll.owner">author : {{ poll.owner?.pseudo }}</p>
</div>
<div class="column">
<button class="export export-print btn" (click)="print()">
<i class="fa fa-print"></i>
Imprimer le sondage
</button>
<button class="export export-csv btn" (click)="exportCSV()">
<i class="fa fa-file-calc-o" aria-hidden="true"></i>
Exporter en .csv
</button>
<button class="export export-json btn" (click)="exportJson()">
<i class="fa fa-file-archive-o" aria-hidden="true"></i>
export json
</button>
<button class="replicate duplicate btn" (click)="duplicate()">
<i class="fa fa-copy" aria-hidden="true"></i>
Dupliquer
</button>
<div id="export_and_share">
<div class="sharing" *ngIf="poll">
<div class="margin-top-x8">
Partager le sondage
<i class="fa fa-share" aria-hidden="true"></i>
</div>
<p class="nobold text-14" for="copyLink">
<a href="{{ pollService.getParticipationUrl() }}">
{{ pollService.getParticipationUrl() }} </a
><app-copy-text
[textToCopy]="pollService.getParticipationUrl()"
></app-copy-text>
</p>
</div>
</div>
</div>
</div>
</header> </header>
<div class="card-content"> <div class="card-content">
<div class="content"> <div class="content">
<p class="descr">{{ poll.description }}</p>
<button <button
class="btn is-info" class="btn is-info"
(click)="isCompactMode = !isCompactMode" (click)="isCompactMode = !isCompactMode"
@ -87,12 +90,41 @@
<app-poll-results-detailed *ngIf="!isCompactMode" [poll]="poll"></app-poll-results-detailed> <app-poll-results-detailed *ngIf="!isCompactMode" [poll]="poll"></app-poll-results-detailed>
</div> </div>
</div> </div>
<!-- static buttons-->
<div class="padded">
<div class="message is-info" *ngIf="poll.stacks.length == 0">
<div class="message-body">
aucun vote pour le moment
</div>
</div>
<button
class="btn btn-block submit-votestack"
(click)="addVoteStack()"
[disabled]="!myTempVoteStack"
[ngClass]="{ 'btn--primary': myTempVoteStack }"
*ngIf="!storageService.vote_stack || !storageService.vote_stack.id"
>
<i class="fa fa-paper-plane" aria-hidden="true"></i> Envoyer
<!-- {{ storageService.vote_stack.votes.length }} réponses-->
</button>
<button
class="btn btn--primary btn-block submit-votestack update"
(click)="updateVoteStack()"
*ngIf="storageService.vote_stack && storageService.vote_stack.id"
>
<i class="fa fa-edit" aria-hidden="true"></i> Mettre à jour
</button>
</div>
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
<app-comments [poll]="poll" [vote_stack]="storageService.vote_stack"></app-comments> <app-comments [poll]="poll" [vote_stack]="storageService.vote_stack"></app-comments>
</div> </div>
</div> </div>
<!-- fixed bottom buttons-->
<div class="bar-votestack" *ngIf="!isArchived"> <div class="bar-votestack" *ngIf="!isArchived">
<button <button
class="btn btn-block submit-votestack" class="btn btn-block submit-votestack"
@ -103,7 +135,7 @@
> >
<i class="fa fa-paper-plane" aria-hidden="true"></i> Envoyer <i class="fa fa-paper-plane" aria-hidden="true"></i> Envoyer
{{ storageService.vote_stack.votes.length }} réponses <!-- {{ storageService.vote_stack.votes.length }} réponses-->
</button> </button>
<button <button
class="btn btn--primary btn-block submit-votestack update" class="btn btn--primary btn-block submit-votestack update"

View File

@ -109,12 +109,14 @@ export class ConsultationComponent implements OnInit, OnDestroy {
this.storageService.vote_stack.poll_custom_url = this.poll.custom_url; this.storageService.vote_stack.poll_custom_url = this.poll.custom_url;
this.toastService.display('envoi du vote ....'); this.toastService.display('envoi du vote ....');
this.api.sendNewVoteStackOfPoll(this.storageService.vote_stack).then((resp: any) => { this.api
console.log('sendNewVoteStackOfPoll resp', resp); .sendNewVoteStackOfPoll(this.storageService.vote_stack)
this.storeVoteStackAndReloadPoll(resp); .then((resp: any) => {
}); console.log('sendNewVoteStackOfPoll resp', resp);
// eslint-disable-next-line @typescript-eslint/unbound-method this.storeVoteStackAndReloadPoll(resp);
// .catch(this.api.handleError); })
// eslint-disable-next-line @typescript-eslint/unbound-method
.catch(this.api.ousideHandleError);
} }
/** /**

View File

@ -1,10 +1,13 @@
export const backendApiUrlsInDev = { export const backendApiUrlsInDev = {
local: 'http://tktest.lan/api/v1', local: 'http://tktest.lan/api/v1',
remote: 'http://tktest.lan/api/v1', // remote: 'http://tktest.lan/api/v1',
// local: 'http://localhost:8000/api/v1',
remote: 'http://localhost:8000/api/v1',
// remote: 'https://framadate-api.cipherbliss.com/api/v1', // remote: 'https://framadate-api.cipherbliss.com/api/v1',
}; };
export const apiV1 = { export const apiV1 = {
baseHref: 'http://localhost:8000/api/v1', baseHref: 'http://localhost:8000/api/v1',
// baseHref: 'http://tktest.lan/api/v1',
// baseHref: 'https://framadate-api.cipherbliss.com/api/v1', // baseHref: 'https://framadate-api.cipherbliss.com/api/v1',
api_new_poll: '/poll/', api_new_poll: '/poll/',
api_get_poll: '/poll/{id}', api_get_poll: '/poll/{id}',