Compare commits

...

7 Commits

Author SHA1 Message Date
Tykayn 5798f6d24e remove duplicate env var in prod 2021-06-10 14:43:08 +02:00
Tykayn 1bcd21317d add prod envs 2021-06-10 14:38:40 +02:00
Tykayn 6638ba1060 remove lib date value accessor, start date interval form 2021-06-10 14:12:57 +02:00
Tykayn 075d434c6f fix display of vote stacks detailed 2021-06-10 12:48:46 +02:00
Tykayn adc7c255d8 display detailled array of answers 2021-06-10 12:35:14 +02:00
Tykayn 13dbe0f89b update links proposal 2021-06-10 12:23:33 +02:00
Tykayn 06dbef8040 prompt page pass 2021-06-10 12:20:28 +02:00
22 changed files with 229 additions and 56 deletions

View File

@ -45,12 +45,11 @@
"@fullcalendar/core": "^4.4.0",
"@ngx-translate/core": "^12.1.2",
"@ngx-translate/http-loader": "^5.0.0",
"angular-date-value-accessor": "^1.0.2",
"axios": "^0.19.2",
"bulma": "^0.9.0",
"bulma-switch": "^2.0.0",
"chart.js": "^2.9.3",
"crypto": "^1.0.1",
"crypto-js": "^4.0.0",
"fork-awesome": "^1.1.7",
"ng-keyboard-shortcuts": "^10.1.17",
"ng2-charts": "^2.3.0",
@ -78,6 +77,7 @@
"@compodoc/compodoc": "^1.1.11",
"@types/jest": "^26.0.0",
"@types/node": "^14.0.1",
"@types/crypto-js": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^3.0.0",
"@typescript-eslint/parser": "^3.0.0",
"babel-jest": "^26.0.0",

View File

@ -62,6 +62,7 @@
<div class="padded">
<div class="">
<a class="navbar-item" [routerLink]="['/poll/demo/consultation']" routerLinkActive="is-primary">
<i class="fa fa-file-epub"></i>
<em>
demo
</em> </a
@ -70,6 +71,7 @@
[routerLink]="['/poll/dessin-anime/consultation']"
routerLinkActive="is-primary"
>
<i class="fa fa-picture-o"></i>
<em>
dessin-anime
</em>
@ -79,7 +81,7 @@
[routerLink]="['/poll/aujourdhui-ou-demain/consultation']"
routerLinkActive="is-primary"
>
consulter le sondage
<i class="fa fa-clock-o"></i>
<em>
aujourdhui-ou-demain
</em>
@ -96,6 +98,17 @@
aujourdhui-ou-demain
</em>
</a>
<a
class="navbar-item"
[routerLink]="['/poll/citron/consultation/prompt']"
routerLinkActive="is-primary"
>
<i class="fa fa-key"></i>
<em>
citron
</em>
écran de saisie de mot de passe
</a>
<a
class="navbar-item"
[routerLink]="['/poll/citron/consultation/secure/1c01ed9c94fc640a1be864f197ff808c']"
@ -105,7 +118,7 @@
<em>
citron
</em>
+ pass
+ pass intégré sans saisie
</a>
</div>
</div>

View File

@ -171,6 +171,8 @@ export class ApiService {
} catch (error) {
if (error.response?.status === 404) {
return undefined;
} else if (error.response?.status === 403) {
return error;
} else {
ApiService.handleError(error);
}

View File

@ -8,7 +8,7 @@ export class ToastService {
constructor(private _snackBar: MatSnackBar) {}
public display(message: string, action?: string): void {
const config: MatSnackBarConfig = { duration: 2000 };
const config: MatSnackBarConfig = { duration: 4000, verticalPosition: 'top' };
this._snackBar.open(message, action, config);
}
}

View File

@ -9,7 +9,6 @@ import { AdministrationComponent } from './administration.component';
import { StepperComponent } from './stepper/stepper.component';
import { NamingComponent } from './naming/naming.component';
import { FormComponent } from './form/form.component';
import { DateValueAccessorModule } from 'angular-date-value-accessor';
import { SuccessComponent } from './success/success.component';
import { DateSelectComponent } from './form/date-select/date-select.component';
import { TextSelectComponent } from './form/text-select/text-select.component';
@ -47,7 +46,6 @@ import { TimeListComponent } from './form/date/list/time/time-list.component';
SharedModule,
FormsModule,
TranslateModule.forChild({ extend: true }),
DateValueAccessorModule,
DragDropModule,
],
})

View File

@ -6,7 +6,7 @@
{{ 'dates.add' | translate }}
<!-- interval-->
<!-- <app-date-interval></app-date-interval>-->
<app-date-interval [form]="form"></app-date-interval>
</form>
<div class="dates-list">
<!-- différentes horaires-->

View File

@ -11,6 +11,7 @@ import { DateChoice, defaultTimeOfDay, TimeSlices } from '../../../../../../mock
import { TranslateService } from '@ngx-translate/core';
import { StorageService } from '../../../../core/services/storage.service';
import { environment } from '../../../../../environments/environment';
@Component({
selector: 'app-date-select',
@ -26,7 +27,7 @@ export class DateSelectComponent implements OnInit {
today = new Date();
endDateInterval: string;
intervalDaysDefault = 7;
intervalDaysDefault = environment.interval_days_default;
dateChoices: DateChoice[] = []; // sets of dateChoices as strings, config to set identical time for dateChoices in a special dateChoices poll
timeSlices: TimeSlices[] = []; // ranges of time expressed as strings

View File

@ -13,11 +13,36 @@
<fieldset *ngIf="showDateInterval" class="date-interval form-row is-boxed">
<div class="columns">
<div class="column">
<app-wip-todo></app-wip-todo>
{{ 'dates.interval_propose' | translate }}
<input type="text" formControlName="natural_lang_interval" />
<sub>
exemple "du 10 au 17", ou "lundi à samedi"
</sub>
<button (click)="addNaturalInstruction()" class="btn btn-block btn--primary">
interpréter
</button>
</div>
</div>
<div class="columns">
<div class="column">
<!-- <mat-form-field appearance="fill">-->
<!-- <mat-label>Enter a date range</mat-label>-->
<!-- <mat-date-range-input [formGroup]="form" [rangePicker]="picker">-->
<!-- <input matStartDate formControlName="startDateInterval" placeholder="Start date">-->
<!-- <input matEndDate formControlName="endDateInterval" placeholder="End date">-->
<!-- </mat-date-range-input>-->
<!-- <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>-->
<!-- <mat-date-range-picker #picker></mat-date-range-picker>-->
<!-- <mat-error *ngIf="form.controls.startDateInterval.hasError('matStartDateInvalid')">Invalid start date</mat-error>-->
<!-- <mat-error *ngIf="form.controls.endDateInterval.hasError('matEndDateInvalid')">Invalid end date</mat-error>-->
<!-- </mat-form-field>-->
</div>
<div class="column">
<label for="start_interval" class="hidden">start</label>
<input id="start_interval" (change)="countDays()" formControlName="startDateInterval" type="date" />
{{ form.value.startDateInterval }}
<input id="start_interval" formControlName="startDateInterval" type="date" />
</div>
</div>
<div class="columns">
@ -27,12 +52,19 @@
<div class="column">
<label for="end_interval" class="hidden">end</label>
<input id="end_interval" formControlName="endDateInterval" type="date" />
<div class="well">
{{ form.value.endDateInterval }}
{{ form.value.endDateInterval }}
<div class="span resume">
<div class="well">
Du
{{ form.value.startDateInterval | date: 'EEEE d':'Europe/Paris':'fr_FR' }}
au
{{ form.value.endDateInterval | date: 'EEEE d':'Europe/Paris':'fr_FR' }}
, soit {{ intervalDays }} jours.
</div>
</div>
</div>
</div>
<div class="span resume">soit {{ intervalDays }} jours.</div>
<button (click)="addIntervalOfDates()" class="btn btn-block btn--primary">
<i class="fa fa-plus" aria-hidden="true"></i>
{{ 'dates.interval_button' | translate }}

View File

@ -22,19 +22,42 @@ export class IntervalComponent implements OnInit {
endDateIntervalString: string;
dateList: DateChoice[]; // sets of dateChoices as strings, config to set identical time for dateChoices in a special dateChoices poll
dateCalendarEnum: Date[] = [new Date('02/09/2021')];
natural_lang_interval: string;
constructor(public dateUtilities: DateUtilitiesService, private toastService: ToastService) {}
ngOnInit(): void {
this.form.get('startDateInterval').valueChanges.subscribe((val) => {
console.log('val', val);
if (typeof val === typeof String) {
this.startDateIntervalString = val;
this.countDays();
} else {
this.startDateInterval = val;
}
});
this.form.get('endDateInterval').valueChanges.subscribe((val) => {
console.log('val', val);
if (typeof val === typeof String) {
this.endDateIntervalString = val;
this.countDays();
}
// this.endDateInterval = val;
// this.countDays();
});
this.setDefaultDatesForInterval();
}
countDays(): void {
this.intervalDays = this.dateUtilities.countDays(
this.dateUtilities.parseInputDateToDateObject(this.startDateInterval),
this.dateUtilities.parseInputDateToDateObject(this.endDateInterval)
);
// this.cd.detectChanges();
this.intervalDays = this.dateUtilities.countDays(
this.startDateInterval,
this.endDateInterval
// this.dateUtilities.parseInputDateToDateObject(this.startDateIntervalString),
// this.dateUtilities.parseInputDateToDateObject(this.endDateIntervalString)
);
console.log('this.intervalDays ', this.intervalDays);
}
/**
@ -90,4 +113,9 @@ export class IntervalComponent implements OnInit {
this.countDays();
}
}
addNaturalInstruction() {
this.toastService.display(`TODO addNaturalInstruction`);
console.log('TODO', this.natural_lang_interval);
}
}

View File

@ -31,7 +31,7 @@ export class DayListComponent {
@Inject(DOCUMENT) private document: any,
private storageService: StorageService
) {
this.setDemoTextChoices();
// this.setDemoTextChoices();
}
reinitChoices(): void {
@ -45,7 +45,6 @@ export class DayListComponent {
}
dropDayItem(event: any): void {
// moveItemInArray(this.timeSlices, event.previousIndex, event.currentIndex);
if (event.previousContainer === event.container) {
moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
} else {
@ -134,8 +133,6 @@ export class DayListComponent {
date_object: new Date(),
});
// this.cd.detectChanges();
this.focusOnChoice(this.storageService.dateChoices.length - 1);
}

View File

@ -10,6 +10,7 @@ import { environment } from '../../../../environments/environment';
import { PollUtilitiesService } from '../../../core/services/poll.utilities.service';
import { StorageService } from '../../../core/services/storage.service';
import { DateUtilitiesService } from '../../../core/services/date.utilities.service';
import { formatDate } from '@angular/common';
@Component({
selector: 'app-admin-form',
@ -87,6 +88,7 @@ export class FormComponent implements OnInit, AfterViewInit {
allowComments: [true, [Validators.required]],
password: ['', []],
voterEmailList: ['', []],
natural_lang_interval: ['', []],
dateCreated: [creationDate, [Validators.required]],
hasSeveralHours: [false, [Validators.required]],
hasMaxCountOfAnswers: [true, [Validators.required, Validators.min(1)]],
@ -109,12 +111,9 @@ export class FormComponent implements OnInit, AfterViewInit {
}
setDefaultFormValues(): void {
const dateStart = this.dateUtils.formateDateToInputStringNg(new Date());
const dateEnd = this.dateUtils.formateDateToInputStringNg(this.dateUtils.addDaysToDate(5, new Date()));
this.form.patchValue({
creatorPseudo: 'Anne Onyme',
creatorEmail: '',
creatorEmail: 'anne_onyme@anonymous_email.com',
description: 'RSVP',
isAboutDate: true,
hasSeveralHours: false,
@ -130,12 +129,19 @@ export class FormComponent implements OnInit, AfterViewInit {
isZeroKnoledge: true,
areResultsPublic: true,
allowComments: true,
expiresDaysDelay: 60,
maxCountOfAnswers: 150,
expiresDaysDelay: environment.expiresDaysDelay,
maxCountOfAnswers: environment.maxCountOfAnswers,
allowNewDateTime: false,
startDateInterval: dateStart,
endDateInterval: dateEnd,
// startDateInterval: formatDate(new Date(), 'yyyy-MM-dd', 'fr_FR'),
endDateInterval: formatDate(
this.dateUtils.addDaysToDate(environment.interval_days_default, new Date()),
'yyyy-MM-dd',
'fr_FR'
),
});
console.log("this.form.controls['startDateInterval']", this.form.controls['startDateInterval']);
this.form.controls['startDateInterval'].setValue(formatDate(new Date(), 'yyyy-MM-dd', 'fr_FR'));
console.log("this.form.controls['startDateInterval']", this.form.controls['startDateInterval']);
this.automaticSlug();
}
@ -147,17 +153,12 @@ export class FormComponent implements OnInit, AfterViewInit {
this.form.patchValue({ creatorPseudo: 'Chuck Norris', creatorEmail: 'chucknorris@example.com' });
const dateStart = this.dateUtils.formateDateToInputStringNg(new Date());
const dateEnd = this.dateUtils.formateDateToInputStringNg(this.dateUtils.addDaysToDate(5, new Date()));
this.form.patchValue({
title: title,
custom_url: this.pollUtilitiesService.makeSlugFromString(title),
description: 'répondez SVP <3 ! *-*',
creatorPseudo: 'Chuck Norris',
creatorEmail: 'chucknorris@example.com',
dateStart,
dateEnd,
});
}

View File

@ -3,16 +3,17 @@ import { RouterModule, Routes } from '@angular/router';
import { ConsultationComponent } from './consultation.component';
import { WipTodoComponent } from '../../shared/components/ui/wip-todo/wip-todo.component';
import { PasswordPromptComponent } from './password/password-prompt/password-prompt.component';
const routes: Routes = [
{ path: 'secure/:pass_hash', component: ConsultationComponent },
{ path: 'prompt', component: PasswordPromptComponent },
{ path: 'simple', component: WipTodoComponent },
{ path: 'table', component: WipTodoComponent },
{
path: '',
component: ConsultationComponent,
children: [
{ path: 'simple', component: WipTodoComponent },
{ path: 'table', component: WipTodoComponent },
],
children: [],
},
];
@NgModule({

View File

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

View File

@ -8,6 +8,7 @@ import { ConsultationComponent } from './consultation.component';
import { PollResultsCompactComponent } from './poll-results-compact/poll-results-compact.component';
import { PollResultsDetailedComponent } from './poll-results-detailed/poll-results-detailed.component';
import { ChoiceButtonComponent } from '../../shared/components/choice-item/choice-button.component';
import { PasswordPromptComponent } from './password/password-prompt/password-prompt.component';
@NgModule({
declarations: [
@ -15,6 +16,7 @@ import { ChoiceButtonComponent } from '../../shared/components/choice-item/choic
PollResultsCompactComponent,
PollResultsDetailedComponent,
ChoiceButtonComponent,
PasswordPromptComponent,
],
imports: [CommonModule, ConsultationRoutingModule, SharedModule, TranslateModule.forChild({ extend: true })],
})

View File

@ -0,0 +1,29 @@
<div class="padded">
<h1>
<i class="fa fa-key"></i>
Sondage protégé
</h1>
<p>Pour accéder au sondage {{ custom_url }} il vous faut saisir la phrase de passe.</p>
<input type="text" [(ngModel)]="password" *ngIf="display_pass" />
<input type="password" [(ngModel)]="password" *ngIf="!display_pass" />
<br />
<button (click)="display_pass = !display_pass">voir</button>
<br />
Méthode de chiffrement 1:
<select name="ciphering_method" id="ciphering_method">
<option value="MD5">MD5</option>
</select>
Méthode de chiffrement 2:
<select name="ciphering_method_2" id="ciphering_method_2">
<option value="MD5">MD5</option>
</select>
steak haché:
{{ cipherPass() }}
<br />
<button class="is-primary button is-large" (click)="redirectToConsultationPage()">
Allons-y
</button>
</div>

View File

@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PasswordPromptComponent } from './password-prompt.component';
describe('PasswordPromptComponent', () => {
let component: PasswordPromptComponent;
let fixture: ComponentFixture<PasswordPromptComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [PasswordPromptComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PasswordPromptComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,34 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { MD5, enc } from 'crypto-js';
@Component({
selector: 'app-password-prompt',
templateUrl: './password-prompt.component.html',
styleUrls: ['./password-prompt.component.scss'],
})
export class PasswordPromptComponent implements OnInit {
password = 'le pass woute woute';
method = 'md5';
display_pass = true;
custom_url = '';
password_ciphered: string;
constructor(private router: Router, private _Activatedroute: ActivatedRoute) {}
ngOnInit(): void {
this._Activatedroute.paramMap.subscribe((params: ParamMap) => {
this.custom_url = params.get('custom_url');
});
}
cipherPass() {
this.password_ciphered = MD5(this.password).toString(enc.Hex);
this.password_ciphered = MD5(this.password_ciphered).toString(enc.Hex);
return this.password_ciphered;
}
redirectToConsultationPage() {
this.router.navigate(['/poll/' + this.custom_url + '/consultation/secure/' + this.password_ciphered]);
}
}

View File

@ -6,7 +6,9 @@
</th>
<th *ngFor="let choice of poll.choices">
<!-- {{choice.id}}-->
<span class="label" *ngIf="poll.kind == 'text'">{{ choice.name }} </span>
<span class="label" *ngIf="poll.kind == 'text'">
{{ choice.name }}
</span>
<span class="label" *ngIf="poll.kind == 'date'">
{{ make_date(choice.name) | date: 'fullDate':'Europe/Paris':'fr_FR' }}
</span>
@ -26,8 +28,11 @@
<td>
Favori
</td>
<td *ngFor="let choice of poll.choices">
<span class="max_score" *ngIf="poll.max_score > 0 && choice.score == poll.max_score">
<td
*ngFor="let choice of poll.choices"
[ngClass]="{ 'background-yes': poll.max_score > 0 && choice.score == poll.max_score }"
>
<span class="max_score background-yes" *ngIf="poll.max_score > 0 && choice.score == poll.max_score">
<i class="fa fa-star fa-2x"></i>
</span>
</td>
@ -47,13 +52,9 @@
<sub> le {{ stack.created_at | date: 'short':'Europe/Paris':'fr_FR' }} </sub>
</div>
</td>
<ng-container *ngFor="let item of poll.choices">
<td *ngIf="!stackHasVotesForChoice(stack, item.id)"></td>
<td
*ngIf="stackHasVotesForChoice(stack, item.id)"
class="stack-vote background-{{ getValue(stack, item.id) }}"
>
{{ getValue(stack, item.id) }}
<ng-container *ngFor="let vote of stack.votes">
<td class="stack-vote background-{{ vote.value }}">
{{ vote.value }}
</td>
</ng-container>
</tr>

View File

@ -18,6 +18,9 @@ export const environment = {
showDemoWarning: true,
autofill: false,
autoSendNewPoll: false,
interval_days_default: 7,
expiresDaysDelay: 60,
maxCountOfAnswers: 150,
appTitle: 'FramaDate Funky',
appVersion: '2.1.0',
appLogo: 'assets/img/logo.png',
@ -54,7 +57,6 @@ export const environment = {
},
},
},
interval_days_default: 7,
poll: {
defaultConfig: {
maxCountOfAnswers: 150,

View File

@ -11,11 +11,13 @@ export const environment = {
frontDomain: 'http://127.0.0.1:4200',
production: false,
display_routes: true,
// autofill: true,
autofill: false,
autofill: true,
// autofill: false,
showDemoWarning: true,
autoSendNewPoll: false,
interval_days_default: 7,
expiresDaysDelay: 60,
maxCountOfAnswers: 150,
appTitle: 'funky',
appVersion: '0.6.0',
appLogo: 'assets/img/logo.png',

View File

@ -1678,6 +1678,11 @@
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
"@types/crypto-js@^4.0.0":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-4.0.1.tgz#3a4bd24518b0e6c5940da4e2659eeb2ef0806963"
integrity sha512-6+OPzqhKX/cx5xh+yO8Cqg3u3alrkhoxhE5ZOdSEv0DOzJ13lwJ6laqGU0Kv6+XDMFmlnGId04LtY22PsFLQUw==
"@types/eslint-visitor-keys@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
@ -3745,16 +3750,16 @@ crypto-js@^3.1.9-1:
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.3.0.tgz#846dd1cce2f68aacfa156c8578f926a609b7976b"
integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q==
crypto-js@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.0.0.tgz#2904ab2677a9d042856a2ea2ef80de92e4a36dcc"
integrity sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg==
crypto-random-string@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5"
integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==
crypto@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/crypto/-/crypto-1.0.1.tgz#2af1b7cad8175d24c8a1b0778255794a21803037"
integrity sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==
css-color-names@0.0.4, css-color-names@^0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/css-color-names/-/css-color-names-0.0.4.tgz#808adc2e79cf84738069b646cb20ec27beb629e0"