All GET methods for the module Publications have been integrated.

- Create new folder for publications have been integrated.
- Adicional touch to display the data in a more friendly way added.
This commit is contained in:
Tiago Kayaya
2020-12-09 12:10:19 +01:00
parent 793eeb8249
commit 21cb7d5e96
121 changed files with 2689 additions and 116 deletions
+110
View File
@@ -0,0 +1,110 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { AuthService } from '../services/auth.service';
import { User } from '../models/user.model';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class PublicationsService {
authheader = {};
loggeduser: User;
headers: HttpHeaders;
constructor(private http: HttpClient, user: AuthService) {
this.loggeduser = user.ValidatedUser;
this.headers = new HttpHeaders();
this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey);
}
GetPublicationFolderList(){
const geturl = environment.apiURL + 'presidentialActions';
let options = {
headers: this.headers,
};
return this.http.get<any>(`${geturl}`, options);
}
GetPublicationFolderById(id:any){
const geturl = environment.apiURL + 'presidentialActions';
let params = new HttpParams();
params = params.set("id", id);
let options = {
headers: this.headers,
params: params
};
return this.http.get<any>(`${geturl}`, options);
}
CreatePublicationFolder(body:any){
const geturl = environment.apiURL + 'presidentialActions';
let options = {
headers: this.headers,
};
return this.http.post<any>(`${geturl}`, body, options).toPromise().then(res =>{
console.log(res);
});
}
UpdatePublicationFolder(body:any){
const geturl = environment.apiURL + 'presidentialActions';
let options = {
headers: this.headers,
};
return this.http.put<any>(`${geturl}`, body, options).toPromise().then(res =>{
console.log(res);
});
}
DeletePublicationFolderById(id:any){
const geturl = environment.apiURL + 'presidentialActions';
let params = new HttpParams();
params = params.set("id", id);
let options = {
headers: this.headers,
params: params
};
return this.http.delete<any>(`${geturl}`, options);
}
GetPublications(id:any){
const geturl = environment.apiURL + 'presidentialActions/'+ id +'/posts';
let params = new HttpParams();
params = params.set("folderId", id);
let options = {
headers: this.headers,
params: params
};
return this.http.get<any>(`${geturl}`, options);
}
GetPublicationById(folderId:any, publicationId:any){
const geturl = environment.apiURL + 'presidentialActions/'+ folderId +'/posts/'+ publicationId;
let params = new HttpParams();
params = params.set("folderId", folderId);
params = params.set("id", publicationId);
console.log(params);
let options = {
headers: this.headers,
params: params
};
return this.http.get<any>(`${geturl}`, options);
}
}