Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async deleteForm(groupName, formId) {
console.log(groupName)
console.log(formId)
let confirmation = confirm('Are you sure you would like to remove this form?')
if (!confirmation) return
let formsJson = await this.http.get>(`/editor/${groupName}/content/forms.json`).toPromise()
let newFormsJson = formsJson.filter(formInfo => formInfo.id !== formId)
console.log(newFormsJson)
await this.http.post('/editor/file/save', {
groupId: groupName,
filePath: './forms.json',
fileContents: JSON.stringify(newFormsJson)
}).toPromise()
await this.http.delete('/editor/file/save', {params: new HttpParams()
.set('groupId', groupName)
.set('filePath', `./${formId}`)
}).toPromise()
this.forms = await this.groupsService.getFormsList(this.groupName);
}
}
private createEndSessionUrl(
end_session_endpoint: string,
id_token_hint: string
) {
const urlParts = end_session_endpoint.split('?');
const authorizationEndsessionUrl = urlParts[0];
let params = new HttpParams({
fromString: urlParts[1],
encoder: new UriEncoder()
});
params = params.set('id_token_hint', id_token_hint);
params = params.append(
'post_logout_redirect_uri',
this.authConfiguration.post_logout_redirect_uri
);
return `${authorizationEndsessionUrl}?${params}`;
}
fetchActionMap(publisher: string, process: string, state: string, apiVersion?: string) {
let params: HttpParams;
if (apiVersion) params = new HttpParams().set("apiVersion", apiVersion);
return this.httpClient.get(`${this.thirdsUrl}/${publisher}/${process}/${state}/actions`, {
params,
responseType: 'text'
}).pipe(map((json: string) => {
const obj = JSON.parse(json);
return new Map(Object.entries(obj));
}));
}
}
getSuggestions(type: string, text: string): Observable {
if (text && text.length > 0) {
const params = new HttpParams().set('type', type).set('text', text);
const url = `${CONFIG_MGMT_URL}/suggestions`;
return this.httpClient.get(url, {params}).pipe(map((suggestions: Chicklet[]) =>
suggestions.map(item => item.text)));
} else {
return observableOf([]);
}
}
public loadAlbumContainsPhoto(photoid: string): Observable {
let headers = new HttpHeaders();
headers = headers.append('Content-Type', 'application/json')
.append('Accept', 'application/json')
.append('Authorization', 'Bearer ' + this._authService.authSubject.getValue().getAccessToken());
let params: HttpParams = new HttpParams();
params = params.append('photoid', photoid);
return this._http.get(environment.AlbumAPIUrl, {
headers: headers,
params: params,
});
}
httpGet(method: string, params?: any): Observable {
params = params || {};
if (!params.auth_token) {
return this.storage.get('token').pipe(switchMap(token => {
if (!token) {
observableThrow(new Error('No API token!'));
}
params.auth_token = token;
return this.httpGet(method, params);
}));
}
params.format = 'json';
const httpParams = Object.entries(params).reduce(
(params: HttpParams, [key, value]: [string, string]) =>
params.set(key, value), new HttpParams({encoder: paramsEncoder}));
return this.http.get(
apiUrl + method, {params: httpParams});
}
getParamsFromData(data) {
return Object.keys(data)
.reduce(
(params, key) => params.set(key, typeof data[key] === 'object' ? JSON.stringify(data[key]) : data[key]),
new HttpParams()
);
}
if (currentPage !== undefined) {
strParams === ''
? (strParams = strParams + 'currentPage=' + currentPage)
: (strParams = strParams + '¤tPage=' + currentPage);
}
if (pageSize !== undefined) {
strParams = strParams + '&pageSize=' + pageSize;
}
if (sort !== undefined) {
strParams = strParams + '&sort=' + sort;
}
return this.http
.post(this.getBaseEndPoint() + `/components`, idList, {
headers: this.headers,
params: new HttpParams({
fromString: strParams
})
})
.pipe(catchError((error: any) => observableThrowError(error.json())));
}
private getSearchParams(term: string): HttpParams {
const limit = this.options.limit === undefined ? 5 : this.options.limit;
const type =
this.options.type ||
'adresse,code_postal,route,municipalite,mrc,region_administrative';
return new HttpParams({
fromObject: {
q: term,
type: type,
limit: String(limit),
geometries: 'geom'
}
});
}