Browse Source

disposition entête

up-stack-of-votes
Tykayn 1 year ago committed by tykayn
parent
commit
5ce3984dc9
  1. 20
      src/app/core/services/api.service.ts
  2. 3
      src/app/core/services/storage.service.ts
  3. 132
      src/app/features/consultation/consultation.component.html
  4. 14
      src/app/features/consultation/consultation.component.ts
  5. 5
      src/environments/endpoints.ts

20
src/app/core/services/api.service.ts

@ -287,4 +287,24 @@ export class ApiService {
console.log(error.config);
// 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);
}
}

3
src/app/core/services/storage.service.ts

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

132
src/app/features/consultation/consultation.component.html

@ -2,72 +2,75 @@
<section class="poll_loaded padded" *ngIf="!fetching && poll">
<!-- messages-->
<article class="message is-warning" *ngIf="isArchived">
<div class="message is-warning" *ngIf="isArchived">
<div class="message-body">
Ce sondage a expiré, il n'est plus possible d'y ajouter de votes ou de commentaires
</div>
</article>
<article class="message is-info" *ngIf="poll.stacks.length == 0">
<div class="message-body">
aucun vote pour le moment
</div>
</article>
<article class="message is-info" *ngIf="poll.modification_policy == 'self'">
</div>
<div class="message is-info" *ngIf="poll.modification_policy == 'self'">
<div class="message-body">
Vous ne pouvez modifier que votre propre vote à ce sondage
</div>
</article>
</div>
<!-- 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 -->
<div class="columns">
<div class="column">
<div class="card">
<header class="card-header">
<p class="card-header-title is-1 title">{{ poll.title }}</p>
<div class="voters-count padded"><i class="fa fa-users"></i> {{ poll.stacks.length }} votants</div>
<!-- <p class="card-header-icon">author : {{ poll.owner?.pseudo }}</p>-->
<header class="card-header padded">
<div class="columns">
<div class="column">
<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>
<div class="card-content">
<div class="content">
<p class="descr">{{ poll.description }}</p>
<button
class="btn is-info"
(click)="isCompactMode = !isCompactMode"
@ -87,12 +90,41 @@
<app-poll-results-detailed *ngIf="!isCompactMode" [poll]="poll"></app-poll-results-detailed>
</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="column">
<app-comments [poll]="poll" [vote_stack]="storageService.vote_stack"></app-comments>
</div>
</div>
<!-- fixed bottom buttons-->
<div class="bar-votestack" *ngIf="!isArchived">
<button
class="btn btn-block submit-votestack"
@ -103,7 +135,7 @@
>
<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
class="btn btn--primary btn-block submit-votestack update"

14
src/app/features/consultation/consultation.component.ts

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

5
src/environments/endpoints.ts

@ -1,10 +1,13 @@
export const backendApiUrlsInDev = {
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',
};
export const apiV1 = {
baseHref: 'http://localhost:8000/api/v1',
// baseHref: 'http://tktest.lan/api/v1',
// baseHref: 'https://framadate-api.cipherbliss.com/api/v1',
api_new_poll: '/poll/',
api_get_poll: '/poll/{id}',

Loading…
Cancel
Save