mirror of
https://framagit.org/framasoft/framadate/funky-framadate-front.git
synced 2023-08-25 13:53:14 +02:00
variabilize local dev domain name
This commit is contained in:
parent
684d710003
commit
d4ab56483d
@ -1,11 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import axios, { AxiosInstance, AxiosResponse } from 'axios';
|
||||
import { AxiosInstance, AxiosResponse } from 'axios';
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
import { Answer } from '../enums/answer.enum';
|
||||
import { Poll } from '../models/poll.model';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { ToastService } from './toast.service';
|
||||
import { LoaderService } from './loader.service';
|
||||
import { Stack } from '../models/stack.model';
|
||||
@ -15,6 +15,7 @@ const currentApiRoutes = environment.api.version[apiVersion];
|
||||
const apiBaseHref = environment.api.version[apiVersion].baseHref;
|
||||
|
||||
const apiEndpoints = environment.api.endpoints;
|
||||
let axios = require('axios');
|
||||
|
||||
class PollDTO {}
|
||||
|
||||
@ -67,7 +68,7 @@ export class ApiService {
|
||||
Charset: 'UTF-8',
|
||||
// 'Content-Type': 'application/json',
|
||||
// Accept: 'application/json',
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Origin': '^https?://(localhost|127.0.0.1)(:[0-9]+)?$',
|
||||
'Content-Type': 'application/json',
|
||||
// mode: 'no-cors',
|
||||
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
||||
@ -82,17 +83,23 @@ export class ApiService {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* create a new poll
|
||||
* @param poll
|
||||
*/
|
||||
public async createPoll(poll: PollDTO): Promise<Subscription> {
|
||||
// this.loaderService.setStatus(true);
|
||||
|
||||
let axiosConf = {
|
||||
method: 'post',
|
||||
url: `${this.baseHref}${currentApiRoutes['api_new_poll']}`,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: JSON.stringify(poll),
|
||||
};
|
||||
console.log('apiservice createPoll config', poll);
|
||||
return this.axiosInstance.post(
|
||||
`${this.baseHref}${currentApiRoutes['api_new_poll']}`,
|
||||
poll
|
||||
// ApiService.makeHeaders()
|
||||
);
|
||||
|
||||
return this.axiosInstance.post(`${this.baseHref}${currentApiRoutes['api_new_poll']}`, poll);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,9 +250,11 @@ export class ApiService {
|
||||
ApiService.handleError(error);
|
||||
}
|
||||
}
|
||||
|
||||
public findMyPollsByEmail(email: string): Promise<any> {
|
||||
return this.axiosInstance.get<any>(`${this.baseHref}/poll/owner/${email}`);
|
||||
}
|
||||
|
||||
public async updateAnswer(slug: string, choiceLabel: string, pseudo: string, answer: Answer): Promise<string> {
|
||||
try {
|
||||
return await this.axiosInstance.patch(`${this.baseHref}/${slug}${this.answersEndpoint}`, {
|
||||
@ -257,6 +266,7 @@ export class ApiService {
|
||||
ApiService.handleError(error);
|
||||
}
|
||||
}
|
||||
|
||||
////////////
|
||||
// DELETE //
|
||||
|
||||
@ -317,6 +327,7 @@ export class ApiService {
|
||||
console.log(error.config);
|
||||
// this.loaderService.setStatus(false);
|
||||
}
|
||||
|
||||
public ousideHandleError(error) {
|
||||
// this.loaderService.setStatus(true);
|
||||
if (error.response) {
|
||||
|
@ -608,10 +608,10 @@ export class PollService implements Resolve<Poll> {
|
||||
if (this._poll && this._poll.getValue) {
|
||||
const polltemp = this._poll.getValue();
|
||||
if (polltemp) {
|
||||
url = `${environment.frontDomain}#/poll/${polltemp.custom_url}/consultation`;
|
||||
url = `${environment.frontDomain}/#/poll/${polltemp.custom_url}/consultation`;
|
||||
}
|
||||
} else {
|
||||
url = `${environment.frontDomain}#/poll/${this.form.value.custom_url}/consultation`;
|
||||
url = `${environment.frontDomain}/#/poll/${this.form.value.custom_url}/consultation`;
|
||||
}
|
||||
|
||||
// TODO handle pass access
|
||||
@ -625,10 +625,10 @@ export class PollService implements Resolve<Poll> {
|
||||
if (this._poll && this._poll.getValue) {
|
||||
const polltemp = this._poll.getValue();
|
||||
if (polltemp) {
|
||||
url = `${environment.frontDomain}#/admin/${polltemp.admin_key}`;
|
||||
url = `${environment.frontDomain}/#/admin/${polltemp.admin_key}`;
|
||||
}
|
||||
} else {
|
||||
url = `${environment.frontDomain}#/admin/${this.form.value.admin_key}`;
|
||||
url = `${environment.frontDomain}/#/admin/${this.form.value.admin_key}`;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
@ -1,15 +1,18 @@
|
||||
export const backendApiUrlsInDev = {
|
||||
// local: 'http://tktest.lan/api/v1',
|
||||
// remote: 'http://tktest.lan/api/v1',
|
||||
local: 'http://localhost:8000/api/v1',
|
||||
// local: 'http://localhost:8000/api/v1',
|
||||
local: 'http://www.tk.lan/index.php/api/v1',
|
||||
// local: 'https://framadate-api.cipherbliss.com/api/v1',
|
||||
remote: 'http://localhost:8000/api/v1',
|
||||
// remote: 'http://localhost:8000/api/v1',
|
||||
remote: 'http://www.tk.lan/index.php/api/v1',
|
||||
// remote: 'https://framadate-api.cipherbliss.com/api/v1',
|
||||
};
|
||||
export const apiV1 = {
|
||||
baseHref: 'http://localhost:8000/api/v1',
|
||||
// baseHref: 'http://localhost:8000/api/v1', // local "symfony serve" live server
|
||||
baseHref: 'http://www.tk.lan/index.php/api/v1', // local apache2 server
|
||||
// baseHref: 'http://tktest.lan/api/v1',
|
||||
// baseHref: 'https://framadate-api.cipherbliss.com/api/v1',
|
||||
// baseHref: 'https://framadate-api.cipherbliss.com/api/v1', // demo preprod
|
||||
api_new_poll: '/poll/',
|
||||
api_get_poll: '/poll/{id}',
|
||||
api_new_vote_stack: '/vote-stack',
|
||||
|
@ -1,18 +1,21 @@
|
||||
const productionBaseUrl = 'https://framadate-api.cipherbliss.com'; // set this to your production domain
|
||||
const apiVersion = 'v1';
|
||||
|
||||
const backendApiUrlsInDev = {
|
||||
local: '/api/v1',
|
||||
remote: 'https://framadate-api.cipherbliss.com/api/v1',
|
||||
local: `/api/${apiVersion}`,
|
||||
remote: `${productionBaseUrl}/api/${apiVersion}`,
|
||||
};
|
||||
const apiV1 = {
|
||||
baseHref: 'https://framadate-api.cipherbliss.com/api/v1',
|
||||
baseHref: `${productionBaseUrl}/api/${apiVersion}`,
|
||||
api_new_poll: '/poll/',
|
||||
api_get_poll: '/poll/{id}',
|
||||
api_new_vote_stack: '/vote-stack',
|
||||
'api_test-mail-poll': '/api/v1/poll/mail/test-mail-poll/{emailChoice}',
|
||||
'api_test-mail-poll': `/api/${apiVersion}/poll/mail/test-mail-poll/{emailChoice}`,
|
||||
'app.swagger': '/api/doc.json',
|
||||
};
|
||||
|
||||
export const environment = {
|
||||
frontDomain: 'https://framadate-api.cipherbliss.com',
|
||||
frontDomain: productionBaseUrl,
|
||||
production: true,
|
||||
display_routes: false,
|
||||
showDemoWarning: false,
|
||||
|
@ -10,13 +10,13 @@ endpoints.baseHref = apiV1.baseHref;
|
||||
export const environment = {
|
||||
frontDomain: 'http://127.0.0.1:4200',
|
||||
production: false,
|
||||
display_routes: true, // demo paths to test polls
|
||||
display_routes: false, // demo paths to test polls
|
||||
autofill_creation: true,
|
||||
advanced_options_display: false,
|
||||
autofill_participation: false,
|
||||
showDemoWarning: false,
|
||||
autoSendNewPoll: false,
|
||||
showStepperShortcuts: false,
|
||||
autoSendNewPoll: true,
|
||||
showStepperShortcuts: true,
|
||||
interval_days_default: 7,
|
||||
expiresDaysDelay: 60,
|
||||
maxCountOfAnswers: 300,
|
||||
|
Loading…
Reference in New Issue
Block a user