mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
refacto routing with pass
This commit is contained in:
parent
16c527d649
commit
5a75685b0a
@ -6,7 +6,7 @@ import { environment } from '../environments/environment';
|
|||||||
import { Theme } from './core/enums/theme.enum';
|
import { Theme } from './core/enums/theme.enum';
|
||||||
import { LanguageService } from './core/services/language.service';
|
import { LanguageService } from './core/services/language.service';
|
||||||
import { ThemeService } from './core/services/theme.service';
|
import { ThemeService } from './core/services/theme.service';
|
||||||
import { NavigationEnd, Router, RouterOutlet } from '@angular/router';
|
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';
|
||||||
@ -36,7 +36,19 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
private languageService: LanguageService // private mockingService: MockingService
|
private languageService: LanguageService // private mockingService: MockingService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
printpath(parent: string, config: Route[]) {
|
||||||
|
for (let i = 0; i < config.length; i++) {
|
||||||
|
const route = config[i];
|
||||||
|
console.info(parent + '/' + route.path);
|
||||||
|
if (route.children) {
|
||||||
|
const currentPath = route.path ? parent + '/' + route.path : parent;
|
||||||
|
this.printpath(currentPath, route.children);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
this.printpath('', this.router.config);
|
||||||
this.router.events.subscribe((evt) => {
|
this.router.events.subscribe((evt) => {
|
||||||
if (!(evt instanceof NavigationEnd)) {
|
if (!(evt instanceof NavigationEnd)) {
|
||||||
return;
|
return;
|
||||||
|
@ -30,7 +30,6 @@ import { CipheringComponent } from './features/shared/components/ui/static-pages
|
|||||||
import { ErrorsListComponent } from './features/shared/components/ui/form/errors-list/errors-list.component';
|
import { ErrorsListComponent } from './features/shared/components/ui/form/errors-list/errors-list.component';
|
||||||
import { KeyboardShortcutsModule } from 'ng-keyboard-shortcuts';
|
import { KeyboardShortcutsModule } from 'ng-keyboard-shortcuts';
|
||||||
import { AdministrationModule } from './features/administration/administration.module';
|
import { AdministrationModule } from './features/administration/administration.module';
|
||||||
import { ShortcutsHelpComponent } from './features/shared/components/ui/shortcuts-help/shortcuts-help.component';
|
|
||||||
registerLocaleData(localeEn, 'en-EN');
|
registerLocaleData(localeEn, 'en-EN');
|
||||||
registerLocaleData(localeFr, 'fr-FR');
|
registerLocaleData(localeFr, 'fr-FR');
|
||||||
|
|
||||||
|
@ -61,13 +61,9 @@
|
|||||||
voici des liens de démonstration issus des fixtures Doctrine de date-poll-api.
|
voici des liens de démonstration issus des fixtures Doctrine de date-poll-api.
|
||||||
<div class="padded">
|
<div class="padded">
|
||||||
<div class="">
|
<div class="">
|
||||||
<a
|
<a class="navbar-item" [routerLink]="['/poll/demo/consultation']" routerLinkActive="is-primary">
|
||||||
class="navbar-item"
|
|
||||||
[routerLink]="['/poll/le-titre-de-demo-oh-oh/consultation']"
|
|
||||||
routerLinkActive="is-primary"
|
|
||||||
>
|
|
||||||
<em>
|
<em>
|
||||||
le-titre-de-demo-oh-oh
|
demo
|
||||||
</em> </a
|
</em> </a
|
||||||
><a
|
><a
|
||||||
class="navbar-item"
|
class="navbar-item"
|
||||||
@ -90,9 +86,22 @@
|
|||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
class="navbar-item"
|
class="navbar-item"
|
||||||
[routerLink]="['/poll/citron/consultation/1c01ed9c94fc640a1be864f197ff808c']"
|
[routerLink]="[
|
||||||
|
'/admin/9S75b70ECXI5J5xDc058d3H40H9r2CHfO0Kj8T02EK2U8rY8fYTn-eS659j2Dhp794Oa6R1b9V70e3WGaE30iD9h45zwdm76C85SWB4LcUCrc7e0Ncc0'
|
||||||
|
]"
|
||||||
routerLinkActive="is-primary"
|
routerLinkActive="is-primary"
|
||||||
>
|
>
|
||||||
|
<i class="fa fa-gears"></i> administrer le sondage
|
||||||
|
<em>
|
||||||
|
aujourdhui-ou-demain
|
||||||
|
</em>
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
class="navbar-item"
|
||||||
|
[routerLink]="['/poll/citron/consultation/secure/9199bdd9e0d4b29deafbf3463c0727fc']"
|
||||||
|
routerLinkActive="is-primary"
|
||||||
|
>
|
||||||
|
<i class="fa fa-key-modern"></i>
|
||||||
<em>
|
<em>
|
||||||
citron
|
citron
|
||||||
</em>
|
</em>
|
||||||
|
@ -104,7 +104,7 @@ export class PollService implements Resolve<Poll> {
|
|||||||
this.titleService.setTitle(`☑️ ${poll.title} - ${environment.appTitle}`);
|
this.titleService.setTitle(`☑️ ${poll.title} - ${environment.appTitle}`);
|
||||||
} else {
|
} else {
|
||||||
this.toastService.display(`sondage ${custom_url} non trouvé`);
|
this.toastService.display(`sondage ${custom_url} non trouvé`);
|
||||||
this.router.navigate(['page-not-found']);
|
// this.router.navigate(['page-not-found']);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.toastService.display(`sondage sans custom url : ${custom_url}`);
|
this.toastService.display(`sondage sans custom url : ${custom_url}`);
|
||||||
|
@ -2,14 +2,17 @@ import { NgModule } from '@angular/core';
|
|||||||
import { RouterModule, Routes } from '@angular/router';
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
|
||||||
import { ConsultationComponent } from './consultation.component';
|
import { ConsultationComponent } from './consultation.component';
|
||||||
|
import { WipTodoComponent } from '../../shared/components/ui/wip-todo/wip-todo.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
|
{ path: 'secure/:pass_hash', component: ConsultationComponent },
|
||||||
|
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: ConsultationComponent,
|
component: ConsultationComponent,
|
||||||
children: [
|
children: [
|
||||||
{ path: '/', component: ConsultationComponent },
|
{ path: 'simple', component: WipTodoComponent },
|
||||||
{ path: '/:pass_hash', component: ConsultationComponent },
|
{ path: 'table', component: WipTodoComponent },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
|
||||||
<!-- actions-->
|
<!-- actions-->
|
||||||
|
|
||||||
<!-- affichage des possibilités de réponse -->
|
<!-- affichage des possibilités de réponse -->
|
||||||
@ -115,10 +117,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
class="btn btn-block submit-votestack"
|
class="btn btn-block submit-votestack is-primary"
|
||||||
(click)="addVoteStack()"
|
(click)="addVoteStack()"
|
||||||
[disabled]="!myTempVoteStack"
|
|
||||||
[ngClass]="{ 'btn--primary': myTempVoteStack }"
|
|
||||||
*ngIf="!storageService.vote_stack || !storageService.vote_stack.id"
|
*ngIf="!storageService.vote_stack || !storageService.vote_stack.id"
|
||||||
>
|
>
|
||||||
<i class="fa fa-paper-plane" aria-hidden="true"></i> Envoyer
|
<i class="fa fa-paper-plane" aria-hidden="true"></i> Envoyer
|
||||||
@ -145,8 +145,6 @@
|
|||||||
<button
|
<button
|
||||||
class="btn btn-block submit-votestack"
|
class="btn btn-block submit-votestack"
|
||||||
(click)="addVoteStack()"
|
(click)="addVoteStack()"
|
||||||
[disabled]="!myTempVoteStack"
|
|
||||||
[ngClass]="{ 'btn--primary': myTempVoteStack }"
|
|
||||||
*ngIf="!storageService.vote_stack || !storageService.vote_stack.id"
|
*ngIf="!storageService.vote_stack || !storageService.vote_stack.id"
|
||||||
>
|
>
|
||||||
<i class="fa fa-paper-plane" aria-hidden="true"></i> Envoyer
|
<i class="fa fa-paper-plane" aria-hidden="true"></i> Envoyer
|
||||||
|
@ -2,17 +2,12 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
|
|||||||
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
|
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
|
||||||
import { Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { Poll } from '../../core/models/poll.model';
|
import { Poll } from '../../core/models/poll.model';
|
||||||
import { ModalService } from '../../core/services/modal.service';
|
|
||||||
import { PollService } from '../../core/services/poll.service';
|
import { PollService } from '../../core/services/poll.service';
|
||||||
import { DateService } from '../../core/services/date.service';
|
import { DateService } from '../../core/services/date.service';
|
||||||
import { PollUtilitiesService } from '../../core/services/poll.utilities.service';
|
import { PollUtilitiesService } from '../../core/services/poll.utilities.service';
|
||||||
import { StorageService } from '../../core/services/storage.service';
|
import { StorageService } from '../../core/services/storage.service';
|
||||||
import { ApiService } from '../../core/services/api.service';
|
import { ApiService } from '../../core/services/api.service';
|
||||||
import { Stack } from '../../core/models/stack.model';
|
|
||||||
import { environment } from '../../../environments/environment';
|
|
||||||
import { ToastService } from '../../core/services/toast.service';
|
import { ToastService } from '../../core/services/toast.service';
|
||||||
import { AxiosResponse } from 'axios';
|
|
||||||
import { HttpResponse } from '@angular/common/http';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-consultation',
|
selector: 'app-consultation',
|
||||||
@ -26,13 +21,8 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
public passHash: string;
|
public passHash: string;
|
||||||
public fetching = true;
|
public fetching = true;
|
||||||
public isArchived: boolean;
|
public isArchived: boolean;
|
||||||
|
public isAdmin: boolean;
|
||||||
|
|
||||||
public myVoteStack: any = {
|
|
||||||
id: '',
|
|
||||||
};
|
|
||||||
public myTempVoteStack: any = {
|
|
||||||
id: '',
|
|
||||||
};
|
|
||||||
private routeSubscription: Subscription;
|
private routeSubscription: Subscription;
|
||||||
window: any;
|
window: any;
|
||||||
|
|
||||||
@ -57,6 +47,7 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
if (newpoll) {
|
if (newpoll) {
|
||||||
this.isArchived = new Date(newpoll.expiracy_date) < new Date();
|
this.isArchived = new Date(newpoll.expiracy_date) < new Date();
|
||||||
this.poll.is_archived = this.isArchived;
|
this.poll.is_archived = this.isArchived;
|
||||||
|
this.isAdmin = this.poll.admin_key !== null;
|
||||||
this.poll.choices_grouped.map((elem) => (elem.subSetToYes = false));
|
this.poll.choices_grouped.map((elem) => (elem.subSetToYes = false));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -66,14 +57,14 @@ export class ConsultationComponent implements OnInit, OnDestroy {
|
|||||||
this.pollSlug = params.get('custom_url');
|
this.pollSlug = params.get('custom_url');
|
||||||
this.passHash = params.get('pass_hash');
|
this.passHash = params.get('pass_hash');
|
||||||
|
|
||||||
// if (this.passHash) {
|
if (this.passHash) {
|
||||||
// this.pollService.loadPollBycustom_urlWithPasswordHash(this.pollSlug, this.passHash);
|
this.pollService.loadPollBycustom_urlWithPasswordHash(this.pollSlug, this.passHash);
|
||||||
// } else {
|
} else {
|
||||||
this.pollService.loadPollBycustom_url(this.pollSlug).then((resp) => {
|
this.pollService.loadPollBycustom_url(this.pollSlug).then((resp) => {
|
||||||
console.log('resp', resp);
|
console.log('resp', resp);
|
||||||
this.fetching = false;
|
this.fetching = false;
|
||||||
});
|
});
|
||||||
// }
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ export const routes: Routes = [
|
|||||||
// resolve: { poll: PollService },
|
// resolve: { poll: PollService },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'poll/:custom_url/administration',
|
path: 'admin/:admin_key',
|
||||||
loadChildren: () =>
|
loadChildren: () =>
|
||||||
import('./features/administration/administration.module').then((m) => m.AdministrationModule),
|
import('./features/administration/administration.module').then((m) => m.AdministrationModule),
|
||||||
// resolve: { poll: PollService },
|
// resolve: { poll: PollService },
|
||||||
@ -33,11 +33,6 @@ export const routes: Routes = [
|
|||||||
loadChildren: () => import('./features/consultation/consultation.module').then((m) => m.ConsultationModule),
|
loadChildren: () => import('./features/consultation/consultation.module').then((m) => m.ConsultationModule),
|
||||||
// resolve: { poll: PollService },
|
// resolve: { poll: PollService },
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: 'poll/:custom_url/participation',
|
|
||||||
loadChildren: () => import('./features/participation/participation.module').then((m) => m.ParticipationModule),
|
|
||||||
// resolve: { poll: PollService },
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: 'success',
|
path: 'success',
|
||||||
component: SuccessComponent,
|
component: SuccessComponent,
|
||||||
|
Loading…
Reference in New Issue
Block a user