forked from tykayn/funky-framadate-front
⚡ add administration key after creation
This commit is contained in:
parent
01bddc842d
commit
7bc53e198d
@ -31,6 +31,7 @@ export class PollConfig {
|
|||||||
myName: string = 'mon pseudo';
|
myName: string = 'mon pseudo';
|
||||||
myComment: string = 'wouah trop bien framadate!';
|
myComment: string = 'wouah trop bien framadate!';
|
||||||
isAdmin: boolean = true;
|
isAdmin: boolean = true;
|
||||||
|
myVoteStack: any;
|
||||||
myEmail: string = "tktest@tktest.com";
|
myEmail: string = "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
|
// 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
|
||||||
|
@ -46,52 +46,25 @@
|
|||||||
{{config.currentPoll.choices.length}} choix,
|
{{config.currentPoll.choices.length}} choix,
|
||||||
</div >
|
</div >
|
||||||
</div >
|
</div >
|
||||||
<div
|
|
||||||
*ngIf='config.isAdmin'
|
|
||||||
class='col-xs-6 admin-actions' >
|
|
||||||
<button
|
|
||||||
class='btn btn--primary btn--outline btn--full'
|
|
||||||
|
|
||||||
(click)='config.todo()' >
|
|
||||||
<i class='fa fa-pencil' ></i >
|
|
||||||
Je veux modifier le vote de quelqu'un
|
|
||||||
</button >
|
|
||||||
<button
|
|
||||||
(click)='config.deleteComments()'
|
|
||||||
class='btn btn--danger btn--outline' >
|
|
||||||
<i class='fa fa-comments-o' ></i >
|
|
||||||
Supprimer tous les commentaires
|
|
||||||
</button >
|
|
||||||
<button
|
|
||||||
(click)='config.deleteVotes()'
|
|
||||||
class='btn btn--danger btn--outline' >
|
|
||||||
<i class='fa fa-stack' ></i >
|
|
||||||
Supprimer tous les votes
|
|
||||||
</button >
|
|
||||||
<button
|
|
||||||
(click)='config.deletePoll()'
|
|
||||||
class='btn btn--danger btn--outline' >
|
|
||||||
<i class='fa fa-trash' ></i >
|
|
||||||
Supprimer ce sondage entièrement
|
|
||||||
</button >
|
|
||||||
<button
|
|
||||||
(click)='config.checkIfSlugIsUniqueInDatabase()'
|
|
||||||
class='btn btn--primary btn--outline' >
|
|
||||||
<i class='fa fa-file-text' ></i >
|
|
||||||
vérifier la disponibilité de l'url personnalisée
|
|
||||||
</button >
|
|
||||||
|
|
||||||
</div >
|
|
||||||
</div >
|
</div >
|
||||||
|
|
||||||
</div >
|
</div >
|
||||||
<section class="name" >
|
<section class="name" >
|
||||||
<label for="name" >Votre nom :</label >
|
<label for="name" >
|
||||||
|
<i class='fa fa-user' ></i >
|
||||||
|
Votre nom :</label >
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
name="name"
|
name="name"
|
||||||
id="name"
|
id="name"
|
||||||
[(ngModel)]="config.myName" >
|
[(ngModel)]="config.myName" >
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="name"
|
||||||
|
id="email"
|
||||||
|
[(ngModel)]="config.myEmail" >
|
||||||
|
<i class='fa fa-envelope' ></i >
|
||||||
</section >
|
</section >
|
||||||
<div
|
<div
|
||||||
*ngIf='config.currentPoll'
|
*ngIf='config.currentPoll'
|
||||||
@ -106,9 +79,16 @@
|
|||||||
</div >
|
</div >
|
||||||
<button
|
<button
|
||||||
class='btn btn--primary btn-block'
|
class='btn btn--primary btn-block'
|
||||||
(click)='config.addVote()' >
|
(click)='config.addVote()'
|
||||||
|
*ngIf='!config.myVoteStack || !config.myVoteStack.id' >
|
||||||
<i class='fa fa-paper-plane' ></i > Envoyer
|
<i class='fa fa-paper-plane' ></i > Envoyer
|
||||||
</button >
|
</button >
|
||||||
|
<button
|
||||||
|
class='btn btn--primary btn-block'
|
||||||
|
(click)='config.updateVote(config.myVoteStack)'
|
||||||
|
*ngIf='config.myVoteStack && config.myVoteStack.id' >
|
||||||
|
<i class='fa fa-pencil' ></i > Mettre à jour
|
||||||
|
</button >
|
||||||
<hr >
|
<hr >
|
||||||
<div id='graph' >
|
<div id='graph' >
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ export class PollDisplayComponent extends BaseComponent implements OnInit {
|
|||||||
// store it in the poll property here
|
// store it in the poll property here
|
||||||
this.config.getPollById(id).subscribe(
|
this.config.getPollById(id).subscribe(
|
||||||
(res: any) => {
|
(res: any) => {
|
||||||
console.log('res', res)
|
console.log('res', res);
|
||||||
|
|
||||||
this.config.currentPoll = res;
|
this.config.currentPoll = res;
|
||||||
this.config.loading = false;
|
this.config.loading = false;
|
||||||
|
@ -285,19 +285,21 @@ export class ConfigService extends PollConfig {
|
|||||||
*/
|
*/
|
||||||
createPollFromConfig(config: any) {
|
createPollFromConfig(config: any) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
console.log('config', config)
|
||||||
return this.http.post(`${this.baseHref}/poll`,
|
return this.http.post(`${this.baseHref}/poll`,
|
||||||
config,
|
config,
|
||||||
this.makeHeaders())
|
this.makeHeaders())
|
||||||
.subscribe((res: any) => {
|
.subscribe((res: any) => {
|
||||||
// redirect to the page to administrate the new poll
|
// redirect to the page to administrate the new poll
|
||||||
this.messageService.add({severity: 'success', summary: 'Sondage Créé',});
|
this.messageService.add({severity: 'success', summary: 'Sondage Créé',});
|
||||||
this.currentPoll = res;
|
this.currentPoll = res.data;
|
||||||
this.pollId = res.pollId;
|
this.currentPoll.admin_key = res.admin_key;
|
||||||
|
this.pollId = res.data.id;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
if (!this.myPolls) {
|
if (!this.myPolls) {
|
||||||
this.myPolls = [];
|
this.myPolls = [];
|
||||||
}
|
}
|
||||||
this.myPolls.push(config);
|
this.myPolls.push(res);
|
||||||
this.router.navigate(['step/end']);
|
this.router.navigate(['step/end']);
|
||||||
// TODO save new poll to localstorage
|
// TODO save new poll to localstorage
|
||||||
// reset all fields in current config
|
// reset all fields in current config
|
||||||
@ -336,14 +338,19 @@ export class ConfigService extends PollConfig {
|
|||||||
votes: this.convertChoicesAnsweredToSend(this.currentPoll.choices),
|
votes: this.convertChoicesAnsweredToSend(this.currentPoll.choices),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('voteStack', voteStack)
|
this.myVoteStack = voteStack;
|
||||||
|
|
||||||
this.http.post(
|
this.http.post(
|
||||||
`${this.baseHref}/poll/${this.currentPoll.id}/vote`,
|
`${this.baseHref}/poll/${this.pollId}/vote`,
|
||||||
voteStack,
|
voteStack,
|
||||||
this.makeHeaders())
|
this.makeHeaders())
|
||||||
.subscribe((res: any) => {
|
.subscribe((res: any) => {
|
||||||
|
|
||||||
this.messageService.add({severity: 'success', summary: 'Vote ajouté'});
|
this.messageService.add({severity: 'success', summary: 'Vote ajouté'});
|
||||||
|
|
||||||
|
// save modifier token
|
||||||
|
voteStack['modifier_token'] = res.modifier_token;
|
||||||
|
voteStack['id'] = res.vote_stack.id;
|
||||||
this.currentPoll = res;
|
this.currentPoll = res;
|
||||||
}, (e) => {
|
}, (e) => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
@ -356,9 +363,15 @@ export class ConfigService extends PollConfig {
|
|||||||
* /api/v1/poll/{id}/vote
|
* /api/v1/poll/{id}/vote
|
||||||
* @param voteStack
|
* @param voteStack
|
||||||
*/
|
*/
|
||||||
updateVote(voteStack: any) {
|
updateVote(voteStack?: any) {
|
||||||
|
if (!this.myVoteStack) {
|
||||||
|
return;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
voteStack = this.myVoteStack;
|
||||||
|
}
|
||||||
this.http.put(
|
this.http.put(
|
||||||
`${this.baseHref}/vote-stack/${voteStack.id}`,
|
`${this.baseHref}/vote-stack/${voteStack.id}/token/${voteStack.modifierToken}`,
|
||||||
voteStack,
|
voteStack,
|
||||||
this.makeHeaders())
|
this.makeHeaders())
|
||||||
.subscribe((res: any) => {
|
.subscribe((res: any) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user