reformat all files + move routes.ts to AppRoutingModule

archived-develop
seraph 3 years ago
parent ad5b2ff72c
commit 18a7d4781a

@ -6,7 +6,6 @@
"ng": "ng",
"start": "ng serve",
"compodoc": "compodoc -p tsconfig.json",
"serve": "ng serve",
"build": "ng build --crossOrigin=anonymous --prod",
"package": "cat dist/framadate/*.js > dist/framadate/framadate-scripts-bundled.js && ls -l dist/framadate",
"bld:pkg": "npm run build && npm run package",

@ -1,12 +1,48 @@
import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AdminComponent } from './pages/admin/admin.component';
import { AnswersComponent } from './pages/answers/answers.component';
import { BaseComponent } from './pages/base-page/base.component';
import { CreateOrRetrieveComponent } from './pages/create-or-retrieve/create-or-retrieve.component';
import { DatesComponent } from './pages/dates/dates.component';
import { EndConfirmationComponent } from './pages/end-confirmation/end-confirmation.component';
import { HomeComponent } from './pages/home/home.component';
import { KindComponent } from './pages/kind/kind.component';
import { PasswordComponent } from './pages/password/password.component';
import { PicturesComponent } from './pages/pictures/pictures.component';
import { PollDisplayComponent } from './pages/poll-display/poll-display.component';
import { ResumeComponent } from './pages/resume/resume.component';
import { VisibilityComponent } from './pages/visibility/visibility.component';
import { VotingChoiceComponent } from './pages/voting/voting-choice/voting-choice.component';
import { VotingComponent } from './pages/voting/voting.component';
import { PollGraphicComponent } from './poll-graphic/poll-graphic.component';
const routes: Routes = [];
const routes: Routes = [
{ path: '', redirectTo: 'step/creation', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'base', component: BaseComponent },
{ path: 'step/base', component: BaseComponent },
{ path: 'step/creation', component: CreateOrRetrieveComponent },
{ path: 'step/date', component: DatesComponent },
{ path: 'step/kind', component: KindComponent },
{ path: 'step/answers', component: AnswersComponent },
{ path: 'step/admin', component: AdminComponent },
{ path: 'step/pictures', component: PicturesComponent },
{ path: 'step/visibility', component: VisibilityComponent },
{ path: 'step/resume', component: ResumeComponent },
{ path: 'step/end', component: EndConfirmationComponent },
{ path: 'graphic/:poll', component: PollGraphicComponent },
{ path: 'vote/poll/id/:poll', component: PollDisplayComponent },
{ path: 'vote/poll/slug/:pollSlug', component: PollDisplayComponent },
{ path: 'votingchoice', component: VotingChoiceComponent },
{ path: 'voting', component: VotingComponent },
{ path: 'step/password', component: PasswordComponent },
{ path: '**', redirectTo: '/home', pathMatch: 'full' },
];
@NgModule({
imports: [RouterModule.forRoot(routes, {useHash: true, anchorScrolling: 'enabled',})],
exports: [RouterModule]
imports: [RouterModule.forRoot(routes, { useHash: true, anchorScrolling: 'enabled' })],
exports: [RouterModule],
})
export class AppRoutingModule {
}
export class AppRoutingModule {}

@ -1,47 +1,31 @@
<div
id='big_container'
class={{this.config.preferences.themeClass}}
>
<header class='big-header'>
<div class='container'>
<div class='columns'>
<div class='column'>
<div id="big_container" class="{{ this.config.preferences.themeClass }}">
<header class="big-header">
<div class="container">
<div class="columns">
<div class="column">
<framadate-master-head></framadate-master-head>
</div>
<div class='column'>
<div class="column">
<framadate-language></framadate-language>
</div>
</div>
</div>
</header>
<main>
<div class="container">
<div class="columns">
<div class="column is-one-quarter">
<framadate-theme-selector></framadate-theme-selector>
<framadate-navigation
*ngIf="config.menuVisible"
[step]="step"
></framadate-navigation>
<framadate-debugger
*ngIf="isDevelopmentEnv"
></framadate-debugger>
<framadate-navigation *ngIf="config.menuVisible" [step]="step"></framadate-navigation>
<framadate-debugger *ngIf="isDevelopmentEnv"></framadate-debugger>
<p-toast position="top-right"></p-toast>
</div>
<div class="column">
<router-outlet></router-outlet>
</div>
</div>
</div>
</main>
</div>

@ -3,33 +3,29 @@ import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
}).compileComponents();
}));
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule],
declarations: [AppComponent],
}).compileComponents();
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'framadate'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('framadate');
});
it(`should have as title 'framadate'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('framadate');
});
it('should render title in a h1 tag', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to framadate!');
});
it('should render title in a h1 tag', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to framadate!');
});
});

@ -1,46 +1,43 @@
import {Component, Inject} from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
import {NavigationStart, Router} from '@angular/router';
import {DOCUMENT} from '@angular/common';
import {filter} from 'rxjs/operators';
import {ConfigService} from './services/config.service';
import {environment} from '../environments/environment';
import { Component, Inject } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { NavigationStart, Router } from '@angular/router';
import { DOCUMENT } from '@angular/common';
import { filter } from 'rxjs/operators';
import { ConfigService } from './services/config.service';
import { environment } from '../environments/environment';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
step: string;
isDevelopmentEnv=false;
constructor(private translate: TranslateService,
public config: ConfigService,
@Inject(DOCUMENT) private document,
private route: Router) {
isDevelopmentEnv = false;
constructor(
private translate: TranslateService,
public config: ConfigService,
@Inject(DOCUMENT) private document,
private route: Router
) {
this.detectCurrentTabOnRouteChange();
this.isDevelopmentEnv = !environment.production
this.isDevelopmentEnv = !environment.production;
}
detectCurrentTabOnRouteChange() {
this.route.events.subscribe((event: any) => {
});
this.route.events.pipe(filter(event => event instanceof NavigationStart)).subscribe((event: NavigationStart) => {
this.scrollGoToTop();
this.updateCurrentTab(event);
// only if there is a poll ID
this.config.fetchPollFromRoute(event);
})
this.route.events.subscribe((event: any) => {});
this.route.events
.pipe(filter((event) => event instanceof NavigationStart))
.subscribe((event: NavigationStart) => {
this.scrollGoToTop();
this.updateCurrentTab(event);
// only if there is a poll ID
this.config.fetchPollFromRoute(event);
});
}
scrollGoToTop() {
this.document.documentElement.scrollTop = 0;
}
@ -55,6 +52,4 @@ export class AppComponent {
}
}
}
}

@ -1,65 +1,63 @@
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {AppRoutingModule} from './app-routing.module';
import {AppComponent} from './app.component';
import {BaseComponent} from './pages/base-page/base.component';
import {KindComponent} from './pages/kind/kind.component';
import {HeaderComponent} from './header/header.component';
import {FormsModule} from '@angular/forms';
import {NavigationComponent} from './ui/navigation/navigation.component';
import {RouterModule} from '@angular/router';
import {Routes} from './config/Routes';
import {CommonModule, registerLocaleData} from '@angular/common';
import {DatesComponent} from './pages/dates/dates.component';
import {DebuggerComponent} from './debugger/debugger.component';
import {VisibilityComponent} from './pages/visibility/visibility.component';
import {ResumeComponent} from './pages/resume/resume.component';
import {PicturesComponent} from './pages/pictures/pictures.component';
import {AnswersComponent} from './pages/answers/answers.component';
import {EndConfirmationComponent} from './pages/end-confirmation/end-confirmation.component';
import {CreateOrRetrieveComponent} from './pages/create-or-retrieve/create-or-retrieve.component';
import localeFr from '@angular/common/locales/fr';
import { CommonModule, registerLocaleData } from '@angular/common';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import localeEn from '@angular/common/locales/en';
import {VotingSummaryComponent} from './pages/voting/voting-summary/voting-summary.component';
import {VotingGraphComponent} from './pages/voting/voting-graph/voting-graph.component';
import {VotingChoiceComponent} from './pages/voting/voting-choice/voting-choice.component';
import {PasswordComponent} from './pages/password/password.component';
import {HomeComponent} from './pages/home/home.component';
import {HttpClient, HttpClientModule} from '@angular/common/http';
import {MarkdownModule} from 'ngx-markdown';
import localeFr from '@angular/common/locales/fr';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {
MissingTranslationHandler,
MissingTranslationHandlerParams,
TranslateLoader,
TranslateModule,
TranslateService
TranslateService,
} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {PollGraphicComponent} from './poll-graphic/poll-graphic.component';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { ClipboardModule } from 'ngx-clipboard';
import { MarkdownModule } from 'ngx-markdown';
import { ConfirmationService, MessageModule, MessageService } from 'primeng';
import { ConfirmDialogModule } from 'primeng/confirmdialog';
import { DialogModule } from 'primeng/dialog';
import { ToastModule } from 'primeng/toast';
import {AdminComponent} from './pages/admin/admin.component';
import {SelectorComponent} from './ui/selector/selector.component';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {ConfigService} from './services/config.service';
import {PollService} from './services/poll.service';
import {ToastModule} from 'primeng/toast';
import {ConfirmationService, MessageModule, MessageService} from 'primeng';
import {PollDisplayComponent} from './pages/poll-display/poll-display.component';
import {VotingComponent} from './pages/voting/voting.component';
import {VotingCommentComponent} from './pages/voting/voting-comment/voting-comment.component';
import {ResettableInputDirective} from './ui/directives/resettable-input.directive';
import {ClipboardModule} from 'ngx-clipboard';
import {ErasableInputComponent} from './ui/erasable-input/erasable-input.component';
import {ConfirmDialogModule} from 'primeng/confirmdialog';
import {DialogModule} from 'primeng/dialog';
import {DateValueAccessorModule} from './custom-lib/date-value-accessor';
import {CopyTextComponent} from './ui/copy-text/copy-text.component';
import {CommentsListComponent} from './pages/voting/comments-list/comments-list.component';
import {ChoicesListComponent} from './pages/voting/choices-list/choices-list.component';
import {VotingNavigationComponent} from './pages/voting/voting-navigation/voting-navigation.component';
import { ThemeSelectorComponent } from './ui/theme-selector/theme-selector.component';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { DateValueAccessorModule } from './custom-lib/date-value-accessor';
import { DebuggerComponent } from './debugger/debugger.component';
import { HeaderComponent } from './header/header.component';
import { AdminComponent } from './pages/admin/admin.component';
import { AnswersComponent } from './pages/answers/answers.component';
import { BaseComponent } from './pages/base-page/base.component';
import { CreateOrRetrieveComponent } from './pages/create-or-retrieve/create-or-retrieve.component';
import { DatesComponent } from './pages/dates/dates.component';
import { EndConfirmationComponent } from './pages/end-confirmation/end-confirmation.component';
import { HomeComponent } from './pages/home/home.component';
import { KindComponent } from './pages/kind/kind.component';
import { PasswordComponent } from './pages/password/password.component';
import { PicturesComponent } from './pages/pictures/pictures.component';
import { PollDisplayComponent } from './pages/poll-display/poll-display.component';
import { ResumeComponent } from './pages/resume/resume.component';
import { VisibilityComponent } from './pages/visibility/visibility.component';
import { ChoicesListComponent } from './pages/voting/choices-list/choices-list.component';
import { CommentsListComponent } from './pages/voting/comments-list/comments-list.component';
import { VotingChoiceComponent } from './pages/voting/voting-choice/voting-choice.component';
import { VotingCommentComponent } from './pages/voting/voting-comment/voting-comment.component';
import { VotingGraphComponent } from './pages/voting/voting-graph/voting-graph.component';
import { VotingNavigationComponent } from './pages/voting/voting-navigation/voting-navigation.component';
import { VotingSummaryComponent } from './pages/voting/voting-summary/voting-summary.component';
import { VotingComponent } from './pages/voting/voting.component';
import { PollGraphicComponent } from './poll-graphic/poll-graphic.component';
import { ConfigService } from './services/config.service';
import { PollService } from './services/poll.service';
import { CopyTextComponent } from './ui/copy-text/copy-text.component';
import { ResettableInputDirective } from './ui/directives/resettable-input.directive';
import { ErasableInputComponent } from './ui/erasable-input/erasable-input.component';
import { MasterHeadComponent } from './ui/navigation/master-head/master-head.component';
import { NavigationComponent } from './ui/navigation/navigation.component';
import { LanguageComponent } from './ui/selector/language/language.component';
import { SelectorComponent } from './ui/selector/selector.component';
import { ThemeSelectorComponent } from './ui/theme-selector/theme-selector.component';
export class MyMissingTranslationHandler implements MissingTranslationHandler {
handle(params: MissingTranslationHandlerParams) {
@ -70,7 +68,7 @@ export class MyMissingTranslationHandler implements MissingTranslationHandler {
registerLocaleData(localeFr, 'fr');
registerLocaleData(localeEn, 'en');
export function HttpLoaderFactory(http: HttpClient) {
export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader {
return new TranslateHttpLoader(http);
}
@ -109,7 +107,6 @@ export function HttpLoaderFactory(http: HttpClient) {
ThemeSelectorComponent,
MasterHeadComponent,
LanguageComponent,
],
imports: [
ConfirmDialogModule,
@ -132,15 +129,13 @@ export function HttpLoaderFactory(http: HttpClient) {
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
deps: [HttpClient],
},
}),
HttpClientModule,
FormsModule,
RouterModule.forRoot(Routes, {useHash: true})
],
providers: [TranslateService, ConfigService, PollService, MessageService, ConfirmationService],
bootstrap: [AppComponent]
bootstrap: [AppComponent],
})
export class AppModule {
}
export class AppModule {}

@ -1,10 +1,9 @@
import {Injectable} from "@angular/core";
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class DateUtilities {
/**
* add some days to a date, to compute intervals
* @param days
@ -14,7 +13,7 @@ export class DateUtilities {
date = new Date(date.valueOf());
date.setDate(date.getDate() + days);
return date;
};
}
/**
*
@ -29,9 +28,9 @@ export class DateUtilities {
while (+d1 < +d2) {
dates.push({
literal: this.formateDate(d1),
date_object: d1
date_object: d1,
});
d1.setDate(d1.getDate() + interval)
d1.setDate(d1.getDate() + interval);
}
return dates.slice(0);
}
@ -42,7 +41,7 @@ export class DateUtilities {
* @param d2
*/
dayDiff(d1: Date, d2: Date): Number {
return Number(((d2.getTime()) - (d1.getTime()) / 31536000000));
return Number(d2.getTime() - d1.getTime() / 31536000000);
}
/**
@ -55,10 +54,10 @@ export class DateUtilities {
date.getFullYear(),
this.getDoubleDigits(date.getMonth() + 1),
this.getDoubleDigits(date.getDate()),
].join('-')
].join('-');
}
getDoubleDigits(str) {
return ("00" + str).slice(-2);
return ('00' + str).slice(-2);
}
}

@ -1,8 +1,8 @@
/**
* une option de date dans les sondages spรฉciaux
*/
import {environment} from '../../environments/environment';
import {DateChoice, defaultAnswers, otherDefaultDates, PollAnswer} from './defaultConfigs';
import { environment } from '../../environments/environment';
import { DateChoice, defaultAnswers, otherDefaultDates, PollAnswer } from './defaultConfigs';
export interface DateOption {
timeList: any;
@ -18,22 +18,17 @@ const baseConfigValues = {
myEmail: '',
};
/**
* configuration of the poll, add new fields at will
*/
export class PollConfig {
menuVisible = true;
expiracyDateDefaultInDays = 60;
deletionDateAfterLastModification = 180;
step = 0; // step in the progress of creating a poll
stepMax = 3; // step max in the progress of creating a poll
pollType = 'dates';// classic or dates
pollType = 'dates'; // classic or dates
title: string = environment.production ? '' : 'titre';
description: string = environment.production ? '' : 'ma description';
@ -43,7 +38,7 @@ export class PollConfig {
myVoteStack: any;
myTempVoteStack = 0;
myEmail: string = environment.production ? '' : 'tktest@tktest.com';
myPolls: any = [];// list of retrieved polls from the backend api
myPolls: any = []; // list of retrieved polls from the backend api
/*
date specific poll, we have the choice to setup different hours (timeList) for all possible dates (dateList), or use the same hours for all dates
*/
@ -66,9 +61,9 @@ export class PollConfig {
urlAdmin = environment.baseHref + '/#/admin/d65es45fd45sdf45sd345f312sdf31sgfd345';
adminKey = ''; // key to change config of the poll
owner_modifier_token = ''; // key to change a vote stack
canModifyAnswers = true;// bool for the frontend selector
whoModifiesAnswers = 'everybody';// everybody, self, nobody (= just admin)
whoCanChangeAnswers = 'everybody';// everybody, self, nobody (= just admin)
canModifyAnswers = true; // bool for the frontend selector
whoModifiesAnswers = 'everybody'; // everybody, self, nobody (= just admin)
whoCanChangeAnswers = 'everybody'; // everybody, self, nobody (= just admin)
dateList: any = otherDefaultDates; // sets of days as strings, config to set identical time for days in a special days poll
timeList: DateChoice[] = otherDefaultDates; // ranges of time expressed as strings

@ -1,9 +1,9 @@
import {HttpHeaders} from "@angular/common/http";
import {PollConfig} from "./PollConfig";
import {Injectable} from "@angular/core";
import { HttpHeaders } from '@angular/common/http';
import { PollConfig } from './PollConfig';
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
providedIn: 'root',
})
export class PollUtilities {
// utils functions
@ -12,7 +12,8 @@ export class PollUtilities {
*/
makeUuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
var r = (Math.random() * 16) | 0,
v = c == 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}
@ -23,18 +24,28 @@ export class PollUtilities {
*/
makeSlug(config: PollConfig) {
let str = '';
str = config.creationDate.getFullYear() + '_' + (config.creationDate.getMonth() + 1) + '_' + config.creationDate.getDate() + '_' + config.myName + '_' + config.title;
str =
config.creationDate.getFullYear() +
'_' +
(config.creationDate.getMonth() + 1) +
'_' +
config.creationDate.getDate() +
'_' +
config.myName +
'_' +
config.title;
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap รฑ for n, etc
var from = "ร รกรครขรจรฉรซรชรฌรญรฏรฎรฒรณรถรดรนรบรผรปรฑรงยท/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
var from = 'ร รกรครขรจรฉรซรชรฌรญรฏรฎรฒรณรถรดรนรบรผรปรฑรงยท/_,:;';
var to = 'aaaaeeeeiiiioooouuuunc------';
for (var i = 0, l = from.length; i < l; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
str = str
.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
.replace(/\s+/g, '-') // collapse whitespace and replace by -
.replace(/-+/g, '-'); // collapse dashes
@ -46,18 +57,17 @@ export class PollUtilities {
* @param bodyContent
*/
makeHeaders(bodyContent?: any) {
const headerDict = {
'Charset': 'UTF-8',
Charset: 'UTF-8',
'Content-Type': 'application/json',
'Accept': 'application/json',
Accept: 'application/json',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Origin': '*'
'Access-Control-Allow-Origin': '*',
};
const requestOptions = {
headers: new HttpHeaders(headerDict),
body: bodyContent
body: bodyContent,
};
return requestOptions;

@ -1,45 +1,42 @@
import {KindComponent} from '../pages/kind/kind.component';
import {DatesComponent} from '../pages/dates/dates.component';
import {VisibilityComponent} from '../pages/visibility/visibility.component';
import {ResumeComponent} from '../pages/resume/resume.component';
import {PicturesComponent} from '../pages/pictures/pictures.component';
import {EndConfirmationComponent} from '../pages/end-confirmation/end-confirmation.component';
import {AnswersComponent} from '../pages/answers/answers.component';
import {AdminComponent} from '../pages/admin/admin.component';
import {CreateOrRetrieveComponent} from '../pages/create-or-retrieve/create-or-retrieve.component';
import {BaseComponent} from '../pages/base-page/base.component';
import {HomeComponent} from "../pages/home/home.component";
import {PollGraphicComponent} from '../poll-graphic/poll-graphic.component';
import {PollDisplayComponent} from "../pages/poll-display/poll-display.component";
import {VotingComponent} from "../pages/voting/voting.component";
import {PasswordComponent} from "../pages/password/password.component";
import {VotingChoiceComponent} from "../pages/voting/voting-choice/voting-choice.component";
import { AdminComponent } from '../pages/admin/admin.component';
import { AnswersComponent } from '../pages/answers/answers.component';
import { BaseComponent } from '../pages/base-page/base.component';
import { CreateOrRetrieveComponent } from '../pages/create-or-retrieve/create-or-retrieve.component';
import { DatesComponent } from '../pages/dates/dates.component';
import { EndConfirmationComponent } from '../pages/end-confirmation/end-confirmation.component';
import { HomeComponent } from '../pages/home/home.component';
import { KindComponent } from '../pages/kind/kind.component';
import { PasswordComponent } from '../pages/password/password.component';
import { PicturesComponent } from '../pages/pictures/pictures.component';
import { PollDisplayComponent } from '../pages/poll-display/poll-display.component';
import { ResumeComponent } from '../pages/resume/resume.component';
import { VisibilityComponent } from '../pages/visibility/visibility.component';
import { VotingChoiceComponent } from '../pages/voting/voting-choice/voting-choice.component';
import { VotingComponent } from '../pages/voting/voting.component';
import { PollGraphicComponent } from '../poll-graphic/poll-graphic.component';
/**
* each step in the form is a component
*/
export const Routes =
[
{path: '', redirectTo: 'step/creation', pathMatch: 'full'},
{path: 'home', component: HomeComponent},
{path: 'base', component: BaseComponent},
{path: 'step/base', component: BaseComponent},
{path: 'step/creation', component: CreateOrRetrieveComponent},
{path: 'step/date', component: DatesComponent},
{path: 'step/kind', component: KindComponent},
{path: 'step/answers', component: AnswersComponent},
{path: 'step/admin', component: AdminComponent},
{path: 'step/pictures', component: PicturesComponent},
{path: 'step/visibility', component: VisibilityComponent},
{path: 'step/resume', component: ResumeComponent},
{path: 'step/end', component: EndConfirmationComponent},
{path: 'graphic/:poll', component: PollGraphicComponent},
{path: 'vote/poll/id/:poll', component: PollDisplayComponent},
{path: 'vote/poll/slug/:pollSlug', component: PollDisplayComponent},
{path: 'votingchoice', component: VotingChoiceComponent},
{path: 'voting', component: VotingComponent},
{path: 'step/password', component: PasswordComponent},
{path: '**', redirectTo: '/home', pathMatch: 'full'},
]
;
export const Routes = [
{ path: '', redirectTo: 'step/creation', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'base', component: BaseComponent },
{ path: 'step/base', component: BaseComponent },
{ path: 'step/creation', component: CreateOrRetrieveComponent },
{ path: 'step/date', component: DatesComponent },
{ path: 'step/kind', component: KindComponent },
{ path: 'step/answers', component: AnswersComponent },
{ path: 'step/admin', component: AdminComponent },
{ path: 'step/pictures', component: PicturesComponent },
{ path: 'step/visibility', component: VisibilityComponent },
{ path: 'step/resume', component: ResumeComponent },
{ path: 'step/end', component: EndConfirmationComponent },
{ path: 'graphic/:poll', component: PollGraphicComponent },
{ path: 'vote/poll/id/:poll', component: PollDisplayComponent },
{ path: 'vote/poll/slug/:pollSlug', component: PollDisplayComponent },
{ path: 'votingchoice', component: VotingChoiceComponent },
{ path: 'voting', component: VotingComponent },
{ path: 'step/password', component: PasswordComponent },
{ path: '**', redirectTo: '/home', pathMatch: 'full' },
];

@ -1,106 +1,107 @@
export interface DateChoice {
literal: string,
timeList: TimeSlices[],
date_object: Date
literal: string;
timeList: TimeSlices[];
date_object: Date;
}
export interface TimeSlices {
literal: string
literal: string;
}
export interface PollAnswer {
id: number,
text: string,
url: string,
file: string,
literal: string,
date_object: Date,
timeList: TimeSlices[]
id: number;
text: string;
url: string;
file: string;
literal: string;
date_object: Date;
timeList: TimeSlices[];
}
const currentYear = new Date().getFullYear();
const currentMonth = new Date().getMonth();
const currentDay = new Date().getDate();
export const basicSlicesOfDay: TimeSlices[] = [
{literal: 'matin'},
{literal: 'midi'},
{literal: 'soir'}
];
export const basicSlicesOfDay: TimeSlices[] = [{ literal: 'matin' }, { literal: 'midi' }, { literal: 'soir' }];
export const otherSlicesOfDay: TimeSlices[] = [
{literal: 'aux aurores'},
{literal: 'au petit dej'},
{literal: 'au deuxiรจme petit dej des hobbits'}
{ literal: 'aux aurores' },
{ literal: 'au petit dej' },
{ literal: 'au deuxiรจme petit dej des hobbits' },
];
export const defaultTimeOfDay: TimeSlices[] = (() => {
return [...basicSlicesOfDay]
return [...basicSlicesOfDay];
})();
export const otherTimeOfDay: TimeSlices[] = (() => {
return [...otherSlicesOfDay]
return [...otherSlicesOfDay];
})();
export const moreTimeOfDay: TimeSlices[] = (() => {
return [...otherSlicesOfDay]
return [...otherSlicesOfDay];
})();
export const defaultDates: DateChoice[] = [
{
literal: `${currentYear}-${currentMonth}-${currentDay}`,
date_object: new Date(),
timeList: defaultTimeOfDay
timeList: defaultTimeOfDay,
},
{
literal: `${currentYear}-${currentMonth}-${currentDay + 1}`,
date_object: new Date(),
timeList: defaultTimeOfDay
timeList: defaultTimeOfDay,
},
{
literal: `${currentYear}-${currentMonth}-${currentDay + 2}`,
date_object: new Date(),
timeList: defaultTimeOfDay
}
timeList: defaultTimeOfDay,
},
];
export const otherDefaultDates: DateChoice[] = [
{
literal: `${currentYear}-${currentMonth}-${currentDay}`,
date_object: new Date(),
timeList: defaultTimeOfDay
timeList: defaultTimeOfDay,
},
{
literal: `${currentYear}-${currentMonth}-${currentDay + 1}`,
date_object: new Date(currentYear, currentMonth, currentDay + 1),
timeList: otherTimeOfDay
timeList: otherTimeOfDay,
},
{
literal: `${currentYear}-${currentMonth}-${currentDay + 2}`,
date_object: new Date(),
timeList: moreTimeOfDay
}
timeList: moreTimeOfDay,
},
];
export const defaultAnswers: PollAnswer[] = [{
id: 0,
text: 'rรฉponse de dรฉmo 1',
file: '',
url: 'https://mastodon.cipherbliss.com/system/media_attachments/files/001/439/118/original/6fcf149bd902841b.png?1579471574',
literal: `${currentYear}-${currentMonth}-${currentDay}`,
date_object: new Date(),
timeList: otherSlicesOfDay
},
export const defaultAnswers: PollAnswer[] = [
{
id: 0,
text: 'rรฉponse de dรฉmo 1',
file: '',
url:
'https://mastodon.cipherbliss.com/system/media_attachments/files/001/439/118/original/6fcf149bd902841b.png?1579471574',
literal: `${currentYear}-${currentMonth}-${currentDay}`,
date_object: new Date(),
timeList: otherSlicesOfDay,
},
{
id: 1,
text: 'rรฉponse 2',
file: '',
url: 'https://mastodon.cipherbliss.com/system/media_attachments/files/001/439/118/original/6fcf149bd902841b.png?1579471574',
url:
'https://mastodon.cipherbliss.com/system/media_attachments/files/001/439/118/original/6fcf149bd902841b.png?1579471574',
literal: `${currentYear}-${currentMonth}-${currentDay + 1}`,
date_object: new Date(),
timeList: basicSlicesOfDay
timeList: basicSlicesOfDay,
},
{
id: 2,
text: 'la rรฉponse D',
file: '',
url: 'https://mastodon.cipherbliss.com/system/media_attachments/files/001/439/118/original/6fcf149bd902841b.png?1579471574',
url:
'https://mastodon.cipherbliss.com/system/media_attachments/files/001/439/118/original/6fcf149bd902841b.png?1579471574',
literal: `${currentYear}-${currentMonth}-${currentDay + 2}`,
date_object: new Date(),
timeList: otherSlicesOfDay
}];
timeList: otherSlicesOfDay,
},
];

@ -1,24 +1,24 @@
export var graphOptions = {
legend: {display: false},
legend: { display: false },
scales: {
xAxes: [
{
gridLines: {drawBorder: false, display: false},
gridLines: { drawBorder: false, display: false },
display: false,
stacked: true,
ticks: {
beginAtZero: true,
maxRotation: 0,
minRotation: 0
}
}
minRotation: 0,
},
},
],
yAxes: [
{
gridLines: {drawBorder: true, display: false},
gridLines: { drawBorder: true, display: false },
display: true,
stacked: true
}
]
}
stacked: true,
},
],
},
};

@ -1,11 +1,11 @@
export const mockChoice = {
"id": 11,
"date": {
"date": "2020-01-30 12:25:13.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
export const mockChoice = {
id: 11,
date: {
date: '2020-01-30 12:25:13.000000',
timezone_type: 3,
timezone: 'Europe/Berlin',
},
"text": "Les mondes engloutis",
"url": null,
"answer": null,
text: 'Les mondes engloutis',
url: null,
answer: null,
};

@ -1,20 +1,21 @@
export const mockComments = [
{
pseudo: "Bulbizarre",
"date": {
"date": "2020-01-22 16:00:22.000000",
"timezone_type": 3,
"timezone": "Europe/Paris"
pseudo: 'Bulbizarre',
date: {
date: '2020-01-22 16:00:22.000000',
timezone_type: 3,
timezone: 'Europe/Paris',
},
text: "Pokem ipsum dolor sit amet Electric Cottonee Scratch Leech Life Ice Berry Ducklett. Leaf Green Durant Zoroark\n" +
" Skitty Rock Luxio Surskit. Glacier Badge",
text:
'Pokem ipsum dolor sit amet Electric Cottonee Scratch Leech Life Ice Berry Ducklett. Leaf Green Durant Zoroark\n' +
' Skitty Rock Luxio Surskit. Glacier Badge',
},
{
pseudo: "Marylin",
"date": {
"date": "2020-01-22 16:00:22.000000",
"timezone_type": 3,
"timezone": "Europe/Paris"
pseudo: 'Marylin',
date: {
date: '2020-01-22 16:00:22.000000',
timezone_type: 3,
timezone: 'Europe/Paris',
},
text: "j'ai vu de la lumiรจre o_o",
},

@ -1,52 +1,52 @@
export const mockGraphConfig = {
step: 0,
stepMax: 3,
pollType: "special dates",
title: "",
description: "",
myName: "",
visibility: "link_only",
pollType: 'special dates',
title: '',
description: '',
myName: '',
visibility: 'link_only',
// date specific poll
allowSeveralHours: "true",
dateLgfgfgfgist: ["jeudi", "vendredi", "samedi"], // sets of days as strings
timeList: ["08:00", "08:30", "09:00"], // ranges of time expressed as strings
allowSeveralHours: 'true',
dateLgfgfgfgist: ['jeudi', 'vendredi', 'samedi'], // sets of days as strings
timeList: ['08:00', '08:30', '09:00'], // ranges of time expressed as strings
answers: [
{
id: 0,
text: "no"
text: 'no',
},
{
id: 1,
text: "yes"
text: 'yes',
},
{
id: 2,
text: "maybe"
text: 'maybe',
},
{
id: 3,
text: "maybe"
text: 'maybe',
},
{
id: 4,
text: "maybe"
text: 'maybe',
},
{
id: 5,
text: "maybe"
text: 'maybe',
},
{
id: 6,
text: "maybe"
text: 'maybe',
},
{
id: 7,
text: "maybe"
text: 'maybe',
},
{
id: 8,
text: "maybe"
}
]
text: 'maybe',
},
],
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,43 +1,44 @@
export const mockMyPolls =
[{
"id": 1000001,
"title": "blehehehe heh hehhe e test1",
"customUrl": null,
"description": "maaaaaaaaaaah",
"creationDate": {"date": "2020-01-20 14:21:16.270157", "timezone_type": 3, "timezone": "Europe/Paris"},
"expiracyDate": {"date": "2020-01-20 14:21:16.270178", "timezone_type": 3, "timezone": "Europe/Paris"},
"owner": null,
"kind": "text",
"allowedAnswers": ["yes"],
"modificationPolicy": "nobody",
"mailOnComment": null,
"mailOnVote": null,
"hideResults": null,
"showResultEvenIfPasswords": null,
"votes": {},
"stacksOfVotes": {},
"choices": {},
"comments": {},
"defaultExpiracyDaysFromNow": 60
}, {
"id": 1000002,
"title": "bleh z zr erth tuyjikioy yylil test2",
"customUrl": null,
"description": "maaaaaaaaaaah 2",
"creationDate": {"date": "2020-01-20 14:21:16.270157", "timezone_type": 3, "timezone": "Europe/Paris"},
"expiracyDate": {"date": "2020-01-20 14:21:16.270178", "timezone_type": 3, "timezone": "Europe/Paris"},
"owner": null,
"kind": "text",
"allowedAnswers": ["yes"],
"modificationPolicy": "nobody",
"mailOnComment": null,
"mailOnVote": null,
"hideResults": null,
"showResultEvenIfPasswords": null,
"votes": {},
"stacksOfVotes": {},
"choices": {},
"comments": {},
"defaultExpiracyDaysFromNow": 60
}]
;
export const mockMyPolls = [
{
id: 1000001,
title: 'blehehehe heh hehhe e test1',
customUrl: null,
description: 'maaaaaaaaaaah',
creationDate: { date: '2020-01-20 14:21:16.270157', timezone_type: 3, timezone: 'Europe/Paris' },
expiracyDate: { date: '2020-01-20 14:21:16.270178', timezone_type: 3, timezone: 'Europe/Paris' },
owner: null,
kind: 'text',
allowedAnswers: ['yes'],
modificationPolicy: 'nobody',
mailOnComment: null,
mailOnVote: null,
hideResults: null,
showResultEvenIfPasswords: null,
votes: {},
stacksOfVotes: {},
choices: {},
comments: {},
defaultExpiracyDaysFromNow: 60,
},
{
id: 1000002,
title: 'bleh z zr erth tuyjikioy yylil test2',
customUrl: null,
description: 'maaaaaaaaaaah 2',
creationDate: { date: '2020-01-20 14:21:16.270157', timezone_type: 3, timezone: 'Europe/Paris' },
expiracyDate: { date: '2020-01-20 14:21:16.270178', timezone_type: 3, timezone: 'Europe/Paris' },
owner: null,
kind: 'text',
allowedAnswers: ['yes'],
modificationPolicy: 'nobody',
mailOnComment: null,
mailOnVote: null,
hideResults: null,
showResultEvenIfPasswords: null,
votes: {},
stacksOfVotes: {},
choices: {},
comments: {},
defaultExpiracyDaysFromNow: 60,
},
];

@ -1,10 +1,10 @@
import {Directive, ElementRef, forwardRef, HostListener, Renderer2} from '@angular/core';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import { Directive, ElementRef, forwardRef, HostListener, Renderer2 } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
export const DATE_VALUE_ACCESSOR: any = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => DateValueAccessor),
multi: true
multi: true,
};
/**
@ -19,17 +19,13 @@ export const DATE_VALUE_ACCESSOR: any = {
// this selector is an opt-in version
selector: '[useValueAsDate]',
providers: [DATE_VALUE_ACCESSOR]
providers: [DATE_VALUE_ACCESSOR],
})
export class DateValueAccessor implements ControlValueAccessor {
@HostListener('input', ['$event.target.valueAsDate']) onChange = (_: any) => {};
@HostListener('blur', []) onTouched = () => {};
@HostListener('input', ['$event.target.valueAsDate']) onChange = (_: any) => {
};
@HostListener('blur', []) onTouched = () => {
};
constructor(private _renderer: Renderer2, private _elementRef: ElementRef) {
}
constructor(private _renderer: Renderer2, private _elementRef: ElementRef) {}
writeValue(value: Date): void {
if (!value) {

@ -1,3 +1,2 @@
export * from './module';
export * from './date-value-accessor';

@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';
import { DateValueAccessor } from './date-value-accessor';
@NgModule({
declarations: [DateValueAccessor],
exports: [DateValueAccessor]
declarations: [DateValueAccessor],
exports: [DateValueAccessor],
})
export class DateValueAccessorModule { }
export class DateValueAccessorModule {}

@ -1,52 +1,30 @@
<div class="well debug" >
<strong >
<h2 i18n >
<div class="well debug">
<strong>
<h2 i18n>
infos de debug - environement de Dev
</h2 >
<span class="demo" >
{{"config.demo"|translate}}
</span >
</strong >
<ul >
<li >
รฉtape actuelle {{config.step}} / {{config.stepMax}}
</li >
<li >
formulaire valide : {{formIsValid}}
</li >
<li >
type de formulaire: {{config.pollType}}
</li >
</ul >
<button
class="btn btn--primary"
i18n
(click)="config.createPoll()"
>
</h2>
<span class="demo">
{{ 'config.demo' | translate }}
</span>
</strong>
<ul>
<li>รฉtape actuelle {{ config.step }} / {{ config.stepMax }}</li>
<li>formulaire valide : {{ formIsValid }}</li>
<li>type de formulaire: {{ config.pollType }}</li>
</ul>
<button class="btn btn--primary" i18n (click)="config.createPoll()">
Envoyer le formulaire
</button >
<button
class="btn btn--primary"
i18n
(click)="config.getPollById( '1', 'example password')"
>
</button>
<button class="btn btn--primary" i18n (click)="config.getPollById('1', 'example password')">
get poll 1
</button >
<button
class="btn btn--primary"
i18n
(click)="config.getMyPolls( 'tktest@tktest.com')"
>
</button>
<button class="btn btn--primary" i18n (click)="config.getMyPolls('tktest@tktest.com')">
get my polls
</button >
<button
class="btn btn--success"
(click)="launchToast()" >
</button>
<button class="btn btn--success" (click)="launchToast()">
launch success toast
</button >
<a
[routerLink]="'/vote/poll/id/3'"
class="btn btn--success" >
</button>
<a [routerLink]="'/vote/poll/id/3'" class="btn btn--success">
See example of vote page
</a >
</div >
</a>
</div>

@ -3,23 +3,22 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DebuggerComponent } from './debugger.component';
describe('DebuggerComponent', () => {
let component: DebuggerComponent;
let fixture: ComponentFixture<DebuggerComponent>;
let component: DebuggerComponent;
let fixture: ComponentFixture<DebuggerComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DebuggerComponent ]
})
.compileComponents();
}));
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [DebuggerComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DebuggerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
beforeEach(() => {
fixture = TestBed.createComponent(DebuggerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -1,19 +1,17 @@
import {Component, OnInit} from '@angular/core';
import {ConfigService} from '../services/config.service';
import { Component, OnInit } from '@angular/core';
import { ConfigService } from '../services/config.service';
@Component({
selector: 'framadate-debugger',
templateUrl: './debugger.component.html',
styleUrls: ['./debugger.component.scss']
styleUrls: ['./debugger.component.scss'],
})
export class DebuggerComponent implements OnInit {
formIsValid = true;
constructor(public config: ConfigService) {
}
constructor(public config: ConfigService) {}
ngOnInit() {
}
ngOnInit() {}
selectOption(key: string, val: any) {
if (!this.config[key]) {
@ -25,6 +23,6 @@ export class DebuggerComponent implements OnInit {
}
launchToast() {
this.config.handleError({message: "hop"})
this.config.handleError({ message: 'hop' });
}
}

@ -3,23 +3,22 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HeaderComponent } from './header.component';
describe('HeaderComponent', () => {
let component: HeaderComponent;
let fixture: ComponentFixture<HeaderComponent>;
let component: HeaderComponent;
let fixture: ComponentFixture<HeaderComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HeaderComponent ]
})
.compileComponents();
}));
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [HeaderComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HeaderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
beforeEach(() => {