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 { Injectable } from '@angular/core';
|
||||||
import axios, { AxiosInstance, AxiosResponse } from 'axios';
|
import { AxiosInstance, AxiosResponse } from 'axios';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
|
|
||||||
import { Answer } from '../enums/answer.enum';
|
import { Answer } from '../enums/answer.enum';
|
||||||
import { Poll } from '../models/poll.model';
|
import { Poll } from '../models/poll.model';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Observable, Subscription } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { ToastService } from './toast.service';
|
import { ToastService } from './toast.service';
|
||||||
import { LoaderService } from './loader.service';
|
import { LoaderService } from './loader.service';
|
||||||
import { Stack } from '../models/stack.model';
|
import { Stack } from '../models/stack.model';
|
||||||
@ -15,6 +15,7 @@ const currentApiRoutes = environment.api.version[apiVersion];
|
|||||||
const apiBaseHref = environment.api.version[apiVersion].baseHref;
|
const apiBaseHref = environment.api.version[apiVersion].baseHref;
|
||||||
|
|
||||||
const apiEndpoints = environment.api.endpoints;
|
const apiEndpoints = environment.api.endpoints;
|
||||||
|
let axios = require('axios');
|
||||||
|
|
||||||
class PollDTO {}
|
class PollDTO {}
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ export class ApiService {
|
|||||||
Charset: 'UTF-8',
|
Charset: 'UTF-8',
|
||||||
// 'Content-Type': 'application/json',
|
// 'Content-Type': 'application/json',
|
||||||
// Accept: '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',
|
'Content-Type': 'application/json',
|
||||||
// mode: 'no-cors',
|
// mode: 'no-cors',
|
||||||
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
||||||
@ -82,17 +83,23 @@ export class ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* create a new poll
|
||||||
* @param poll
|
* @param poll
|
||||||
*/
|
*/
|
||||||
public async createPoll(poll: PollDTO): Promise<Subscription> {
|
public async createPoll(poll: PollDTO): Promise<Subscription> {
|
||||||
// this.loaderService.setStatus(true);
|
// 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);
|
console.log('apiservice createPoll config', poll);
|
||||||
return this.axiosInstance.post(
|
|
||||||
`${this.baseHref}${currentApiRoutes['api_new_poll']}`,
|
return this.axiosInstance.post(`${this.baseHref}${currentApiRoutes['api_new_poll']}`, poll);
|
||||||
poll
|
|
||||||
// ApiService.makeHeaders()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -243,9 +250,11 @@ export class ApiService {
|
|||||||
ApiService.handleError(error);
|
ApiService.handleError(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public findMyPollsByEmail(email: string): Promise<any> {
|
public findMyPollsByEmail(email: string): Promise<any> {
|
||||||
return this.axiosInstance.get<any>(`${this.baseHref}/poll/owner/${email}`);
|
return this.axiosInstance.get<any>(`${this.baseHref}/poll/owner/${email}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateAnswer(slug: string, choiceLabel: string, pseudo: string, answer: Answer): Promise<string> {
|
public async updateAnswer(slug: string, choiceLabel: string, pseudo: string, answer: Answer): Promise<string> {
|
||||||
try {
|
try {
|
||||||
return await this.axiosInstance.patch(`${this.baseHref}/${slug}${this.answersEndpoint}`, {
|
return await this.axiosInstance.patch(`${this.baseHref}/${slug}${this.answersEndpoint}`, {
|
||||||
@ -257,6 +266,7 @@ export class ApiService {
|
|||||||
ApiService.handleError(error);
|
ApiService.handleError(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////
|
////////////
|
||||||
// DELETE //
|
// DELETE //
|
||||||
|
|
||||||
@ -317,6 +327,7 @@ export class ApiService {
|
|||||||
console.log(error.config);
|
console.log(error.config);
|
||||||
// this.loaderService.setStatus(false);
|
// this.loaderService.setStatus(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ousideHandleError(error) {
|
public ousideHandleError(error) {
|
||||||
// this.loaderService.setStatus(true);
|
// this.loaderService.setStatus(true);
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
|
@ -608,10 +608,10 @@ export class PollService implements Resolve<Poll> {
|
|||||||
if (this._poll && this._poll.getValue) {
|
if (this._poll && this._poll.getValue) {
|
||||||
const polltemp = this._poll.getValue();
|
const polltemp = this._poll.getValue();
|
||||||
if (polltemp) {
|
if (polltemp) {
|
||||||
url = `${environment.frontDomain}#/poll/${polltemp.custom_url}/consultation`;
|
url = `${environment.frontDomain}/#/poll/${polltemp.custom_url}/consultation`;
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
// TODO handle pass access
|
||||||
@ -625,10 +625,10 @@ export class PollService implements Resolve<Poll> {
|
|||||||
if (this._poll && this._poll.getValue) {
|
if (this._poll && this._poll.getValue) {
|
||||||
const polltemp = this._poll.getValue();
|
const polltemp = this._poll.getValue();
|
||||||
if (polltemp) {
|
if (polltemp) {
|
||||||
url = `${environment.frontDomain}#/admin/${polltemp.admin_key}`;
|
url = `${environment.frontDomain}/#/admin/${polltemp.admin_key}`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
url = `${environment.frontDomain}#/admin/${this.form.value.admin_key}`;
|
url = `${environment.frontDomain}/#/admin/${this.form.value.admin_key}`;
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
export const backendApiUrlsInDev = {
|
export const backendApiUrlsInDev = {
|
||||||
// local: 'http://tktest.lan/api/v1',
|
// local: 'http://tktest.lan/api/v1',
|
||||||
// remote: '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',
|
// 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',
|
// remote: 'https://framadate-api.cipherbliss.com/api/v1',
|
||||||
};
|
};
|
||||||
export const apiV1 = {
|
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: '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_new_poll: '/poll/',
|
||||||
api_get_poll: '/poll/{id}',
|
api_get_poll: '/poll/{id}',
|
||||||
api_new_vote_stack: '/vote-stack',
|
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 = {
|
const backendApiUrlsInDev = {
|
||||||
local: '/api/v1',
|
local: `/api/${apiVersion}`,
|
||||||
remote: 'https://framadate-api.cipherbliss.com/api/v1',
|
remote: `${productionBaseUrl}/api/${apiVersion}`,
|
||||||
};
|
};
|
||||||
const apiV1 = {
|
const apiV1 = {
|
||||||
baseHref: 'https://framadate-api.cipherbliss.com/api/v1',
|
baseHref: `${productionBaseUrl}/api/${apiVersion}`,
|
||||||
api_new_poll: '/poll/',
|
api_new_poll: '/poll/',
|
||||||
api_get_poll: '/poll/{id}',
|
api_get_poll: '/poll/{id}',
|
||||||
api_new_vote_stack: '/vote-stack',
|
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',
|
'app.swagger': '/api/doc.json',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
frontDomain: 'https://framadate-api.cipherbliss.com',
|
frontDomain: productionBaseUrl,
|
||||||
production: true,
|
production: true,
|
||||||
display_routes: false,
|
display_routes: false,
|
||||||
showDemoWarning: false,
|
showDemoWarning: false,
|
||||||
|
@ -10,13 +10,13 @@ endpoints.baseHref = apiV1.baseHref;
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
frontDomain: 'http://127.0.0.1:4200',
|
frontDomain: 'http://127.0.0.1:4200',
|
||||||
production: false,
|
production: false,
|
||||||
display_routes: true, // demo paths to test polls
|
display_routes: false, // demo paths to test polls
|
||||||
autofill_creation: true,
|
autofill_creation: true,
|
||||||
advanced_options_display: false,
|
advanced_options_display: false,
|
||||||
autofill_participation: false,
|
autofill_participation: false,
|
||||||
showDemoWarning: false,
|
showDemoWarning: false,
|
||||||
autoSendNewPoll: false,
|
autoSendNewPoll: true,
|
||||||
showStepperShortcuts: false,
|
showStepperShortcuts: true,
|
||||||
interval_days_default: 7,
|
interval_days_default: 7,
|
||||||
expiresDaysDelay: 60,
|
expiresDaysDelay: 60,
|
||||||
maxCountOfAnswers: 300,
|
maxCountOfAnswers: 300,
|
||||||
|
Loading…
Reference in New Issue
Block a user