123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- import { AuthServiceService } from './auth-service.service';
- import { HttpClient } from '@angular/common/http';
- import { Injectable } from '@angular/core';
- import { ToastrService } from 'ngx-toastr';
- import { NgxSpinnerService } from 'ngx-spinner';
- @Injectable({
- providedIn: 'root'
- })
- export class UserService {
- constructor(private http: HttpClient,
- private authService: AuthServiceService,
- private toastr: ToastrService,
- private spinner: NgxSpinnerService) { }
- //get profile data
- getUserDataProfile() {
- this.http.get(this.authService.pathApi + '/profile').subscribe(
- (responce) => {
- this.authService.setDataUser(responce);
- },
- (error) => {console.log(error)},
- );
- }
- //get services data user
- getServicesData(id) {
- return this.http.get(this.authService.pathApi + '/get_user_services/' + id);
- }
- //get services of user
- getPagesPermetiotns(userId, serviceId){
- return this.http.get(this.authService.pathApi + '/get_user_pages_permissions/' + userId + '/' + serviceId);
- }
- //get adminstration
- getAdministration(){
- return this.http.get(this.authService.pathApi + '/adminstrations_list');
- }
- //get month
- getMonth(){
- return this.http.get(this.authService.pathApi + '/months_list');
- }
- getDepartments(adminstrationId) {
- return this.http.get(this.authService.pathApi + '/admin_departments/' + adminstrationId);
- }
- //get nationality
- getNationality() {
- return this.http.get(this.authService.pathApi + '/countries_list');
- }
- //get list data of page
- getPageData(id:number, currentPage, dataPageNumber) {
- console.log(this.authService.pathApi + '/page_list/' + id + '/' + currentPage + '/' + dataPageNumber + '/all');
- return this.http.get(this.authService.pathApi + '/page_list/' + id + '/' + currentPage + '/' + dataPageNumber + '/all');
- }
- //get job titile
- getJobTitle() {
- return this.http.get(this.authService.pathApi + '/job_titles_list');
- }
- //get contract list
- getContract(){
- return this.http.get(this.authService.pathApi + '/contract_types_list');
- }
- //get staff list
- getStaff(){
- return this.http.get(this.authService.pathApi + '/staff_list');
- }
- //get specialization
- getSpecialization() {
- return this.http.get(this.authService.pathApi + '/specialization_list');
- }
- //add user
- addUser(userForm, typePage: string){
- if(typePage == 'user'){
- return this.http.post(this.authService.pathApi + '/add_user', userForm);
- } else if(typePage == 'joinUs') {
- return this.http.post(this.authService.pathApi + '/add_join_us_user', userForm);
- }
- }
- //get user data
- onGetUserData(idUser:number, typePage: string){
- if(typePage == 'editUs') {
- return this.http.get(this.authService.pathApi + '/get_user/' + idUser);
- } else if(typePage == 'editJo') {
- return this.http.get(this.authService.pathApi + '/get_join_us_user/' + idUser);
- }
- }
- //edit data of user
- onEditUser(editDataUser, typePage: string){
- console.log(editDataUser);
- if(typePage == 'user'){
- return this.http.post(this.authService.pathApi + '/edit_user', editDataUser);
- } else if(typePage == 'joinUs') {
- return this.http.post(this.authService.pathApi + '/edit_join_us_user', editDataUser);
- }
- }
- onEditProfile(dataProfile) {
- return this.http.post(this.authService.pathApi + '/edit_profile', dataProfile);
- }
- //get data of pagenation
- getUserListPagenation(pageNumber:number , pageId: number) {
- const page = pageNumber;
- const pageID = pageId;
- return this.http.get(this.authService.pathApi + '/page_list/' + pageID + '/' + page);
- }
- //get data user from searchBar
- getDataUSerSearchBar(data, pageId, pagenationNumber, dataPageNumber) {
- console.log('url', this.authService.pathApi + '/page_list' + '/' + pageId + '/' + pagenationNumber + '/' + dataPageNumber + '/all/' + data);
- return this.http.get(this.authService.pathApi + '/page_list' + '/' + pageId + '/' + pagenationNumber + '/' + dataPageNumber + '/all/' + data);
- }
- //delete user
- deleteUser(userIds, typePageId) {
- if(typePageId == 1){
- console.log(userIds);
- return this.http.post(this.authService.pathApi + '/delete_user' , {'users_id' : userIds});
- } else if(typePageId == 9) {
- console.log(userIds);
- return this.http.post(this.authService.pathApi + '/delete_join_us_users' , {'users_id' : userIds});
- }
- }
- //get permission list
- getPermissionList() {
- return this.http.get(this.authService.pathApi + '/permissions_list');
- }
- //get roles list
- getRolesList() {
- return this.http.get(this.authService.pathApi + '/roles_list');
- }
- //get report data
- onGetReportData(user_id:number) {
- return this.http.get(this.authService.pathApi + '/report_user_permissions/' + user_id);
- }
- //get indetities
- onGetIdentities() {
- return this.http.get(this.authService.pathApi + '/identities_list');
- }
- }
|