add good hash in route

This commit is contained in:
Tykayn 2021-04-29 10:17:13 +02:00 committed by tykayn
parent b2b8056b7e
commit d5bc5777b7
8 changed files with 30 additions and 18 deletions

View File

@ -45,7 +45,7 @@
dessin-anime dessin-anime
</strong> </strong>
</button> </button>
<button class="btn is-primary" routerLink="/poll/citron/consultation/9199bdd9e0d4b29deafbf3463c0727fc"> <button class="btn is-primary" routerLink="/poll/citron/consultation/1c01ed9c94fc640a1be864f197ff808c">
consulter le sondage consulter le sondage
<strong> <strong>

View File

@ -41,8 +41,13 @@ export class ApiService {
this.axiosInstance.defaults.headers.post['Content-Type'] = 'application/json'; this.axiosInstance.defaults.headers.post['Content-Type'] = 'application/json';
this.axiosInstance.defaults.headers.post['Accept'] = 'application/json'; this.axiosInstance.defaults.headers.post['Accept'] = 'application/json';
this.axiosInstance.defaults.headers.post['Charset'] = 'UTF-8'; this.axiosInstance.defaults.headers.post['Charset'] = 'UTF-8';
this.axiosInstance.defaults.headers.post['Accept-Charset'] = 'UTF-8';
this.axiosInstance.defaults.headers.post['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'; this.axiosInstance.defaults.headers.post['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS';
this.axiosInstance.defaults.headers.post['Referrer-Policy'] = 'origin-when-cross-origin';
this.axiosInstance.defaults.headers.post['Access-Control-Allow-Origin'] = '*'; this.axiosInstance.defaults.headers.post['Access-Control-Allow-Origin'] = '*';
this.axiosInstance.defaults.headers.post['Allow-Origin'] = '*';
this.axiosInstance.defaults.headers.post['Access-Control-Allow-Headers'] =
'Origin, X-Requested-With, Content-Type, Accept';
console.log('this.axiosInstance.defaults.headers', this.axiosInstance.defaults.headers); console.log('this.axiosInstance.defaults.headers', this.axiosInstance.defaults.headers);
} }
@ -116,11 +121,11 @@ export class ApiService {
console.log('vote_stack', vote_stack); console.log('vote_stack', vote_stack);
console.log('this.baseHref', this.baseHref); console.log('this.baseHref', this.baseHref);
let headers = ApiService.makeHeaders(vote_stack); const headers = ApiService.makeHeaders(vote_stack);
console.log('headers', headers); console.log('headers', headers);
let url = `${this.baseHref}/poll/${poll.custom_url}/answer`; const url = `${this.baseHref}/poll/${poll.custom_url}/answer`;
let axiosconf = { const axiosconf = {
url, url,
method: 'POST', method: 'POST',
body: vote_stack, body: vote_stack,

View File

@ -75,7 +75,11 @@ export class PollService implements Resolve<Poll> {
if (slug) { if (slug) {
const poll: Poll | undefined = await this.apiService.getPollBySlug(slug); const poll: Poll | undefined = await this.apiService.getPollBySlug(slug);
console.log({ loadPollBySlugResponse: poll }); console.log({ loadPollBySlugResponse: poll });
this.updateCurrentPoll(poll); if (poll) {
this.updateCurrentPoll(poll);
} else {
this.toastService.display(`sondage ${slug} non trouvé`);
}
} }
} }
public async loadPollBySlugWithPasswordHash(slug: string, hash: string): Promise<void> { public async loadPollBySlugWithPasswordHash(slug: string, hash: string): Promise<void> {

View File

@ -4,10 +4,12 @@ import { RouterModule, Routes } from '@angular/router';
import { ConsultationComponent } from './consultation.component'; import { ConsultationComponent } from './consultation.component';
const routes: Routes = [ const routes: Routes = [
{ path: '', component: ConsultationComponent }, {
{ path: '/:hash', component: ConsultationComponent }, path: '/',
component: ConsultationComponent,
children: [{ path: '/:hash', component: ConsultationComponent }],
},
]; ];
@NgModule({ @NgModule({
imports: [RouterModule.forChild(routes)], imports: [RouterModule.forChild(routes)],
exports: [RouterModule], exports: [RouterModule],

View File

@ -103,14 +103,14 @@
(click)="addVoteStack()" (click)="addVoteStack()"
[disabled]="!myTempVoteStack" [disabled]="!myTempVoteStack"
[ngClass]="{ 'btn--primary': myTempVoteStack }" [ngClass]="{ 'btn--primary': myTempVoteStack }"
*ngIf="!myVoteStack || !myVoteStack.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
</button> </button>
<button <button
class="btn btn--primary btn-block submit-votestack update" class="btn btn--primary btn-block submit-votestack update"
(click)="updateVote(myVoteStack)" (click)="updateVote(storageService.vote_stack)"
*ngIf="myVoteStack && myVoteStack.id" *ngIf="storageService.vote_stack && storageService.vote_stack.id"
> >
<i class="fa fa-edit" aria-hidden="true"></i> Mettre à jour <i class="fa fa-edit" aria-hidden="true"></i> Mettre à jour
</button> </button>

View File

@ -9,6 +9,7 @@ import { PollUtilities } from '../old-stuff/config/PollUtilities';
import { Comment } from '../../core/models/comment.model'; import { Comment } from '../../core/models/comment.model';
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';
@Component({ @Component({
selector: 'app-consultation', selector: 'app-consultation',
@ -74,7 +75,7 @@ export class ConsultationComponent implements OnInit, OnDestroy {
} }
} }
updateVote() { updateVote(votestack: Stack) {
alert('TODO'); alert('TODO');
} }

View File

@ -25,7 +25,7 @@ export const routes: Routes = [
path: 'poll/:slug/administration', path: 'poll/:slug/administration',
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 },
}, },
{ {
path: 'poll/:slug/consultation', path: 'poll/:slug/consultation',
@ -35,7 +35,7 @@ export const routes: Routes = [
{ {
path: 'poll/:slug/participation', path: 'poll/:slug/participation',
loadChildren: () => import('./features/participation/participation.module').then((m) => m.ParticipationModule), loadChildren: () => import('./features/participation/participation.module').then((m) => m.ParticipationModule),
resolve: { poll: PollService }, // resolve: { poll: PollService },
}, },
{ {
path: 'oldstuff', path: 'oldstuff',

View File

@ -4,12 +4,12 @@
const backendApiUrlsInDev = { const backendApiUrlsInDev = {
local: '/api/v1', local: '/api/v1',
// remote: 'http://localhost:8000/api/v1', remote: 'http://localhost:8000/api/v1',
remote: 'https://framadate-api.cipherbliss.com/api/v1', // remote: 'https://framadate-api.cipherbliss.com/api/v1',
}; };
const apiV1 = { const apiV1 = {
// baseHref: 'http://localhost:8000/api/v1', baseHref: 'http://localhost:8000/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: '/poll/{id}/answer', api_new_vote_stack: '/poll/{id}/answer',