1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import { Injectable } from '@angular/core';
- import { HttpClient } from '@angular/common/http';
- import { SharedService } from './shared.service';
- import { ToastrService } from 'ngx-toastr';
- import { Location } from '@angular/common';
- @Injectable({
- providedIn: 'root'
- })
- export class PagesService {
- constructor(
- private http: HttpClient,
- private auth: SharedService,
- private toster: ToastrService,
- private location: Location,
- ) { }
- getListData(currentPage: number ,perPage: number, type: any, pageName){
- if(pageName == 'system-admins'){
- console.log(this.auth.pathApi + '/users_list/' + currentPage+ '/' + '/' + perPage+ '/' + type );
- return this.http.get(this.auth.pathApi + '/users_list/' + currentPage+ '/' + perPage+ '/' + type );
- }else if(pageName == 'customers'){
- console.log(this.auth.pathApi + '/companies_list/' + currentPage+ '/' + '/' + perPage+ '/' + type );
- return this.http.get(this.auth.pathApi + '/companies_list/' + currentPage+ '/' + perPage+ '/' + type );
- }
- }
- addItem(data, pageName){
- if(pageName == 'system-admins')
- {
- return this.http.post(this.auth.pathApi + '/register_new_user', data);
- }
- }
- //edit event
- editItem(editId,dataEdit,pageName){
- const editData = dataEdit;
- console.log(editId);
- editData['id'] = editId;
- console.log(dataEdit);
- if(pageName == 'system-admins'){
- return this.http.post(this.auth.pathApi + '/edit_current_user' ,editData);
- }
- }
- getItemData(pageId: number, pageName: String)
- {
- console.log('pageId', pageId);
- if(pageName == 'system-admins')
- return this.http.get(this.auth.pathApi + '/get_user_by_id/' + pageId);
-
- }
- //previous back locarion
- perviousLocation() {
- this.location.back();
- }
- //delete event
- deleteItem(dataIds, pageName) {
- console.log(dataIds);
- console.log(pageName);
- console.log(this.auth.pathApi+ '/delete_current_users');
-
- if(pageName == 'system-admins') {
- return this.http.post(this.auth.pathApi+ '/delete_current_users', {'users_id':dataIds});
- }else if (pageName == 'customers' ) {
-
- }
-
- }
-
- }
|