/** Angular Imports */ import { Injectable } from '@angular/core' ; import { HttpClient , HttpParams } from '@angular/common/http' ; /** rxjs Imports */ import { Observable } from 'rxjs' ; /**
 * Groups service.
 */ @ Injectable ( { providedIn : 'root' } ) export class GroupsService { param { HttpClient } http constructor ( private http ) { } param { any } filterBy param { string } orderBy param { string } sortOrder param { number } offset param { number } limit returns { Observable < any > } getGroups ( filterBy , orderBy , sortOrder , offset ? , limit ? ) { let httpParams = new HttpParams ( ) . set ( 'offset' , offset . toString ( ) ) . set ( 'limit' , limit . toString ( ) ) . set ( 'sortOrder' , sortOrder ) . set ( 'orderBy' , orderBy ) . set ( 'paged' , 'true' ) ; filterBy . forEach ( function ( filter ) { if ( filter . value ) { httpParams = httpParams . set ( filter . type , filter . value ) ; } } ) ; return this . http . get ( '/groups' , { params : httpParams } ) ; } param { string } orderBy param { string } sortOrder param { string } name param { any } officeId param { any } orphansOnly returns { Observable < any > } getFilteredGroups ( orderBy , sortOrder , name , officeId ? , orphansOnly ? ) { let httpParams = new HttpParams ( ) . set ( 'name' , name ) . set ( 'sortOrder' , sortOrder ) . set ( 'orderBy' , orderBy ) ; if ( officeId ) { httpParams = httpParams . set ( 'officeId' , officeId ) ; } httpParams = orphansOnly ? httpParams . set ( 'orphansOnly' , orphansOnly ) : httpParams ; return this . http . get ( '/groups' , { params : httpParams } ) ; } param { number } officeId returns { Observable < any > } getGroupsByOfficeId ( officeId ) { const httpParams = new HttpParams ( ) . set ( 'officeId' , officeId . toString ( ) ) ; return this . http . get ( '/groups' , { params : httpParams } ) ; } param { string } groupId param { string } template returns { Observable < any > } getGroupData ( groupId , template ? ) { let httpParams = new HttpParams ( ) . set ( 'associations' , 'all' ) ; httpParams = template ? httpParams . set ( 'template' , template ) : httpParams ; return this . http . get ( `/groups/${ groupId }` , { params : httpParams } ) ; } param groupId returns { Observable < any > } getGroupSummary ( groupId ) { const httpParams = new HttpParams ( ) . set ( 'R_groupId' , groupId ) . set ( 'genericResultSet' , 'false' ) ; return this . http . get ( `/runreports/GroupSummaryCounts` , { params : httpParams } ) ; } param groupId returns { Observable < any > } getGroupAccountsData ( groupId ) { return this . http . get ( `/groups/${ groupId }/accounts` ) ; } param groupId returns { Observable < any > } getGroupNotes ( groupId ) { return this . http . get ( `/groups/${ groupId }/notes` ) ; } param groupId param noteData returns { Observable < any > } createGroupNote ( groupId , noteData ) { return this . http . post ( `/groups/${ groupId }/notes` , noteData ) ; } param groupId param noteId param noteData returns { Observable < any > } editGroupNote ( groupId , noteId , noteData ) { return this . http . put ( `/groups/${ groupId }/notes/${ noteId }` , noteData ) ; } param groupId param noteId returns { Observable < any > } deleteGroupNote ( groupId , noteId ) { return this . http . delete ( `/groups/${ groupId }/notes/${ noteId }` ) ; } returns { Observable < any > } getGroupDatatables ( ) { const httpParams = new HttpParams ( ) . set ( 'apptable' , 'm_group' ) ; return this . http . get ( `/datatables` , { params : httpParams } ) ; } param groupId param datatableName returns { Observable < any > } getGroupDatatable ( groupId , datatableName ) { const httpParams = new HttpParams ( ) . set ( 'genericResultSet' , 'true' ) ; return this . http . get ( `/datatables/${ datatableName }/${ groupId }` , { params : httpParams } ) ; } param groupId param datatableName param data returns { Observable < any > } addGroupDatatableEntry ( groupId , datatableName , data ) { const httpParams = new HttpParams ( ) . set ( 'genericResultSet' , 'true' ) ; return this . http . post ( `/datatables/${ datatableName }/${ groupId }` , data , { params : httpParams } ) ; } param groupId param datatableName param data returns { Observable < any > } editGroupDatatableEntry ( groupId , datatableName , data ) { const httpParams = new HttpParams ( ) . set ( 'genericResultSet' , 'true' ) ; return this . http . put ( `/datatables/${ datatableName }/${ groupId }` , data , { params : httpParams } ) ; } param groupId param datatableName returns { Observable < any > } deleteDatatableContent ( groupId , datatableName ) { const httpParams = new HttpParams ( ) . set ( 'genericResultSet' , 'true' ) ; return this . http . delete ( `/datatables/${ datatableName }/${ groupId }` , { params : httpParams } ) ; } param { any } command returns { Observable < any > } getGroupCommandTemplate ( command ) { const httpParams = new HttpParams ( ) . set ( 'command' , command ) ; return this . http . get ( `/groups/template` , { params : httpParams } ) ; } param { string } groupId param { string } command param { any } data returns { Observable < any > } executeGroupCommand ( groupId , command , data ) { const httpParams = new HttpParams ( ) . set ( 'command' , command ) ; return this . http . post ( `/groups/${ groupId }` , data , { params : httpParams } ) ; } param { string } groupId param { any } roleId returns { Observable < any > } unAssignRoleCommand ( groupId , roleId ) { const httpParams = new HttpParams ( ) . set ( 'command' , 'unassignRole' ) . set ( 'roleId' , roleId ) ; return this . http . post ( `/groups/${ groupId }` , { } , { params : httpParams } ) ; } param { any } group returns { Observable < any > } createGroup ( group ) { return this . http . post ( '/groups' , group ) ; } param { any } group param { any } groupId returns { Observable < any > } updateGroup ( group , groupId ) { return this . http . put ( `/groups/${ groupId }` , group ) ; } param { string } groupId returns { Observable < any > } deleteGroup ( groupId ) { return this . http . delete ( `/groups/${ groupId }` ) ; } param { any } groupId returns { Observable < any > } getGroupCalendarTemplate ( groupId ) { return this . http . get ( `/groups/${ groupId }/calendars/template` ) ; } param { any } groupId param { any } calendarId returns { Observable < any > } getGroupCalendarAndTemplate ( groupId , calendarId ) { const httpParams = new HttpParams ( ) . set ( 'template' , 'true' ) ; return this . http . get ( `/groups/${ groupId }/calendars/${ calendarId }` , { params : httpParams } ) ; } param { any } groupId param { any } data returns { Observable < any > } createGroupMeeting ( groupId , data ) { return this . http . post ( `/groups/${ groupId }/calendars` , data ) ; } param { any } groupId param { any } data param { any } calendarId returns { Observable < any > } updateGroupMeeting ( groupId , data , calendarId ) { return this . http . put ( `/groups/${ groupId }/calendars/${ calendarId }` , data ) ; } param { any } groupId param { any } calendarId returns { Observable < any > } getMeetingsTemplate ( groupId , calendarId ) { const httpParams = new HttpParams ( ) . set ( 'calenderId' , calendarId ) ; return this . http . get ( `/groups/${ groupId }/meetings/template` , { params : httpParams } ) ; } param { any } groupId param { any } calendarId param { any } data returns { Observable < any > } assignGroupAttendance ( groupId , calendarId , data ) { const httpParams = new HttpParams ( ) . set ( 'calenderId' , calendarId ) ; return this . http . post ( `/groups/${ groupId }/meetings` , data , { params : httpParams } ) ; } param { number } id returns { Observable < any > } getStaff ( id ) { const httpParams = new HttpParams ( ) . set ( 'officeId' , id . toString ( ) ) . set ( 'staffInSelectedOfficeOnly' , 'true' ) ; return this . http . get ( '/groups/template' , { params : httpParams } ) ; } }