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
</strong>
</button>
<button class="btn is-primary" routerLink="/poll/citron/consultation/9199bdd9e0d4b29deafbf3463c0727fc">
<button class="btn is-primary" routerLink="/poll/citron/consultation/1c01ed9c94fc640a1be864f197ff808c">
consulter le sondage
<strong>

View File

@ -41,8 +41,13 @@ export class ApiService {
this.axiosInstance.defaults.headers.post['Content-Type'] = 'application/json';
this.axiosInstance.defaults.headers.post['Accept'] = 'application/json';
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['Referrer-Policy'] = 'origin-when-cross-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);
}
@ -116,11 +121,11 @@ export class ApiService {
console.log('vote_stack', vote_stack);
console.log('this.baseHref', this.baseHref);
let headers = ApiService.makeHeaders(vote_stack);
const headers = ApiService.makeHeaders(vote_stack);
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,
method: 'POST',
body: vote_stack,

View File

@ -75,7 +75,11 @@ export class PollService implements Resolve<Poll> {
if (slug) {
const poll: Poll | undefined = await this.apiService.getPollBySlug(slug);
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> {

View File

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

View File

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

View File

@ -9,6 +9,7 @@ import { PollUtilities } from '../old-stuff/config/PollUtilities';
import { Comment } from '../../core/models/comment.model';
import { StorageService } from '../../core/services/storage.service';
import { ApiService } from '../../core/services/api.service';
import { Stack } from '../../core/models/stack.model';
@Component({
selector: 'app-consultation',
@ -74,7 +75,7 @@ export class ConsultationComponent implements OnInit, OnDestroy {
}
}
updateVote() {
updateVote(votestack: Stack) {
alert('TODO');
}

View File

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

View File

@ -4,12 +4,12 @@
const backendApiUrlsInDev = {
local: '/api/v1',
// remote: 'http://localhost:8000/api/v1',
remote: 'https://framadate-api.cipherbliss.com/api/v1',
remote: 'http://localhost:8000/api/v1',
// remote: 'https://framadate-api.cipherbliss.com/api/v1',
};
const apiV1 = {
// baseHref: 'http://localhost:8000/api/v1',
baseHref: 'https://framadate-api.cipherbliss.com/api/v1',
baseHref: 'http://localhost:8000/api/v1',
// baseHref: 'https://framadate-api.cipherbliss.com/api/v1',
api_new_poll: '/poll/',
api_get_poll: '/poll/{id}',
api_new_vote_stack: '/poll/{id}/answer',