show detailed display at first, fix range date values in table

This commit is contained in:
Tykayn 2021-09-09 09:59:02 +02:00 committed by tykayn
parent 5798f6d24e
commit 94ef23e3a3
9 changed files with 133 additions and 27 deletions

View File

@ -10,6 +10,7 @@ import { NavigationEnd, Route, Router, RouterOutlet } from '@angular/router';
import { slideInAnimation } from './shared/animations/main'; import { slideInAnimation } from './shared/animations/main';
import { FramaKeyboardShortcuts } from './shared/shortcuts/main'; import { FramaKeyboardShortcuts } from './shared/shortcuts/main';
import { ShortcutEventOutput, ShortcutInput } from 'ng-keyboard-shortcuts'; import { ShortcutEventOutput, ShortcutInput } from 'ng-keyboard-shortcuts';
import { PollService } from './core/services/poll.service';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -33,6 +34,7 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
private router: Router, private router: Router,
private titleService: Title, private titleService: Title,
private themeService: ThemeService, private themeService: ThemeService,
private pollService: PollService,
private languageService: LanguageService // private mockingService: MockingService private languageService: LanguageService // private mockingService: MockingService
) {} ) {}
@ -50,6 +52,8 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
ngOnInit(): void { ngOnInit(): void {
this.printpath('', this.router.config); this.printpath('', this.router.config);
this.router.events.subscribe((evt) => { this.router.events.subscribe((evt) => {
console.log('route changed', evt);
if (!(evt instanceof NavigationEnd)) { if (!(evt instanceof NavigationEnd)) {
return; return;
} }
@ -59,7 +63,10 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
if (!environment.production) { if (!environment.production) {
this.appTitle += ' [DEV]'; this.appTitle += ' [DEV]';
} }
this.titleService.setTitle(this.appTitle);
const loadedPoll = this.pollService._poll.getValue();
this.titleService.setTitle(this.appTitle + ' - ' + loadedPoll.title);
this.languageService.configureAndInitTranslations(); this.languageService.configureAndInitTranslations();
this.themeSubscription = this.themeService.theme.subscribe((theme: Theme) => { this.themeSubscription = this.themeService.theme.subscribe((theme: Theme) => {
switch (theme) { switch (theme) {

View File

@ -92,11 +92,12 @@
Detailed Detailed
</button> </button>
</div> </div>
<div class="pseudo-land"> <div class="pseudo-land" *ngIf="isCompactMode">
<label for="vote_pseudo_vote_stack"> <label for="vote_pseudo_vote_stack">
Votre pseudo: Votre pseudo:
</label> </label>
<input <input
class="is-block"
type="text" type="text"
id="vote_pseudo_vote_stack" id="vote_pseudo_vote_stack"
placeholder="votre pseudo" placeholder="votre pseudo"

View File

@ -15,8 +15,8 @@ import { ToastService } from '../../core/services/toast.service';
styleUrls: ['./consultation.component.scss'], styleUrls: ['./consultation.component.scss'],
}) })
export class ConsultationComponent implements OnInit, OnDestroy { export class ConsultationComponent implements OnInit, OnDestroy {
// public isCompactMode = false; public isCompactMode = false;
public isCompactMode = true; // public isCompactMode = true;
public poll: Poll; public poll: Poll;
public pollSlug: string; public pollSlug: string;
public pass_hash: string; public pass_hash: string;

View File

@ -9,13 +9,49 @@
<span class="label" *ngIf="poll.kind == 'text'"> <span class="label" *ngIf="poll.kind == 'text'">
{{ choice.name }} {{ choice.name }}
</span> </span>
<span class="label" *ngIf="poll.kind == 'date'"> <span class="label" *ngIf="poll.kind == 'date' && choice.name.indexOf('>>>') === -1">
{{ make_date(choice.name) | date: 'fullDate':'Europe/Paris':'fr_FR' }} {{ make_date(choice.name) | date: 'fullDate':'Europe/Paris':'fr_FR' }}
</span> </span>
<span class="label" *ngIf="poll.kind == 'date' && choice.name.indexOf('>>>') !== -1">
{{ make_display_range_time(choice.name) }}
</span>
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr class="stats">
<td>
Ajouter votre vote
<div>
<input
class="is-block"
type="text"
id="vote_pseudo_vote_stack_detailed"
placeholder="votre pseudo"
[(ngModel)]="storageService.vote_stack.pseudo"
/>
<button
class="btn btn-block submit-votestack is-primary"
(click)="addVoteStack()"
*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>
</td>
<td *ngFor="let choice of poll.choices">
<app-choice-button [poll]="poll" [choice]="choice" [answerKind]="'YES'"></app-choice-button>
</td>
</tr>
<tr class="stats"> <tr class="stats">
<td> <td>
Score Score
@ -49,7 +85,7 @@
{{ stack.pseudo }} {{ stack.pseudo }}
</div> </div>
<div class="date"> <div class="date">
<sub> le {{ stack.created_at | date: 'short':'Europe/Paris':'fr_FR' }} </sub> <sub> le {{ make_date(stack.created_at) | date: 'short':'Europe/Paris':'fr_FR' }} </sub>
</div> </div>
</td> </td>
<ng-container *ngFor="let vote of stack.votes"> <ng-container *ngFor="let vote of stack.votes">

View File

@ -1,7 +1,10 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input } from '@angular/core';
import { Poll } from '../../../core/models/poll.model'; import { Poll } from '../../../core/models/poll.model';
import { PollService } from '../../../core/services/poll.service'; import { PollService } from '../../../core/services/poll.service';
import { StorageService } from '../../../core/services/storage.service';
import { ToastService } from '../../../core/services/toast.service';
import { ApiService } from '../../../core/services/api.service';
@Component({ @Component({
selector: 'app-poll-results-detailed', selector: 'app-poll-results-detailed',
@ -11,7 +14,12 @@ import { PollService } from '../../../core/services/poll.service';
export class PollResultsDetailedComponent { export class PollResultsDetailedComponent {
@Input() public poll: Poll; @Input() public poll: Poll;
constructor(private pollService: PollService) {} constructor(
private pollService: PollService,
private storageService: StorageService,
private api: ApiService,
private toastService: ToastService
) {}
stackHasVotesForChoice(stack, choice: any) { stackHasVotesForChoice(stack, choice: any) {
return undefined !== stack.votes[choice]; return undefined !== stack.votes[choice];
@ -24,9 +32,67 @@ export class PollResultsDetailedComponent {
return null; return null;
} }
/**
* create a new vote stack
*/
addVoteStack(): void {
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.toastService.display('bien enregistré');
// reload stack
})
// eslint-disable-next-line @typescript-eslint/unbound-method
.catch(this.api.ousideHandleError);
}
/**
* update existing vote stack
* @param Stack
*/
updateVoteStack(): void {
const vote_stack = this.storageService.vote_stack;
vote_stack.poll_custom_url = this.poll.custom_url;
console.log('updateVoteStack vote_stack.votes', vote_stack.votes.length, vote_stack.votes);
const handlingError = this.api.ousideHandleError;
this.api
.sendUpdateVoteStack(vote_stack)
.then((resp) => {
console.log('sendUpdateVoteStack updated resp', resp);
this.storeVoteStackAndReloadPoll(resp);
this.toastService.display('vote bien mis à jour', 'success');
})
.catch(handlingError);
}
/**
* store the updated vote stack
* @param voteStack
*/
storeVoteStackAndReloadPoll(voteStack: any) {
if (voteStack.status == 200) {
this.storageService.mapVotes(voteStack.data);
this.pollService.enrichVoteStackWithCurrentPollChoicesDefaultVotes(this.storageService.vote_stack);
// if (this.pass_hash) {
// this.pollService.loadPollBycustom_urlWithPasswordHash(this.poll.custom_url, this.pass_hash);
// } else {
this.pollService.loadPollBycustom_url(this.poll.custom_url);
// }
} else {
this.toastService.display('erreur à l enregistrement');
}
}
make_date(name: string) { make_date(name: string) {
name = name.substr(0, 24); name = name.substr(0, 30);
console.log('name.length', name.length, name);
return new Date(name); return new Date(name);
} }
make_display_range_time(name: string) {
return name.replace('>>>', 'de ');
}
} }

View File

@ -1,14 +1,15 @@
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: 'https://localhost:8000/api/v1', // local: 'https://localhost:8000/api/v1',
remote: 'https://localhost:8000/api/v1', local: 'https://framadate-api.cipherbliss.com/api/v1',
// remote: 'https://framadate-api.cipherbliss.com/api/v1', // remote: 'https://localhost:8000/api/v1',
remote: 'https://framadate-api.cipherbliss.com/api/v1',
}; };
export const apiV1 = { export const apiV1 = {
baseHref: 'https://localhost:8000/api/v1', // baseHref: 'https://localhost:8000/api/v1',
// baseHref: 'http://tktest.lan/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}',
api_new_vote_stack: '/vote-stack', api_new_vote_stack: '/vote-stack',

View File

@ -18,7 +18,7 @@ export const environment = {
interval_days_default: 7, interval_days_default: 7,
expiresDaysDelay: 60, expiresDaysDelay: 60,
maxCountOfAnswers: 150, maxCountOfAnswers: 150,
appTitle: 'funky', appTitle: 'Framadate Funky',
appVersion: '0.6.0', appVersion: '0.6.0',
appLogo: 'assets/img/logo.png', appLogo: 'assets/img/logo.png',
api: endpoints, api: endpoints,

View File

@ -1,10 +1,10 @@
@media (min-width: $widescreen) { @media (min-width: $widescreen) {
select, //select,
input, //input,
label + select, //label + select,
label { //label {
width: 45%; // width: 45%;
} //}
.date-choice > input:first-of-type { .date-choice > input:first-of-type {
width: 75%; width: 75%;
} }

View File

@ -2150,11 +2150,6 @@ amdefine@>=0.0.4:
resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
integrity sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU= integrity sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=
angular-date-value-accessor@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/angular-date-value-accessor/-/angular-date-value-accessor-1.0.2.tgz#96277a794fe0ab5760ceba3e7aeb3a05a63388a1"
integrity sha512-Jkx6xQI0jDux45RnVQUcncxSPOvnQUwKfC48E4D4YTfzibEEDC5zebW1tkpwmDMpAVVloxcUv7Yh6rak2Rn7ww==
ansi-align@^3.0.0: ansi-align@^3.0.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-3.0.0.tgz#b536b371cf687caaef236c18d3e21fe3797467cb" resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-3.0.0.tgz#b536b371cf687caaef236c18d3e21fe3797467cb"