mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
146 lines
3.9 KiB
TypeScript
146 lines
3.9 KiB
TypeScript
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/'+id;
|
|
|
|
let options = {
|
|
headers: this.headers,
|
|
};
|
|
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( publicationId:any){
|
|
const geturl = environment.apiURL + 'presidentialActions/posts/'+ publicationId;
|
|
let params = new HttpParams();
|
|
|
|
/* params = params.set("id", publicationId); */
|
|
|
|
|
|
console.log(params);
|
|
|
|
|
|
let options = {
|
|
headers: this.headers,
|
|
/* params: params */
|
|
};
|
|
return this.http.get<any>(`${geturl}`, options);
|
|
}
|
|
|
|
CreatePublication(folderId:any,body:any){
|
|
const geturl = environment.apiURL + 'presidentialActions/'+folderId+'/posts';
|
|
let params = new HttpParams();
|
|
params = params.set("folderId", folderId);
|
|
let options = {
|
|
headers: this.headers,
|
|
/* params: params */
|
|
};
|
|
return this.http.post<any>(`${geturl}`, body, options).toPromise().then(res =>{
|
|
console.log(res);
|
|
});
|
|
}
|
|
|
|
UpdatePublication(folderId:any,body:any){
|
|
const geturl = environment.apiURL + 'presidentialActions/'+folderId+'/posts';
|
|
let params = new HttpParams();
|
|
params = params.set("folderId", folderId);
|
|
let options = {
|
|
headers: this.headers,
|
|
/* params: params */
|
|
};
|
|
return this.http.put<any>(`${geturl}`, body, options).toPromise().then(res =>{
|
|
console.log(res);
|
|
});
|
|
}
|
|
|
|
DeletePublication(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);
|
|
let options = {
|
|
headers: this.headers,
|
|
/* params: params */
|
|
};
|
|
return this.http.delete(`${geturl}`, options).toPromise();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|