From 2be8eb61bb7a908965e36f9a331094b30f360917 Mon Sep 17 00:00:00 2001 From: Max Ehrlicher-Schmidt Date: Mon, 14 Dec 2020 16:07:12 +0100 Subject: [PATCH] Add actionLog service --- src/app/graphqlOperations/actionLog.graphql | 12 ++++ .../fragments/actionlog.graphql | 10 +++ src/app/services/actionLog.service.ts | 25 +++++++ src/generated/graphql.ts | 67 +++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100644 src/app/graphqlOperations/actionLog.graphql create mode 100644 src/app/graphqlOperations/fragments/actionlog.graphql create mode 100644 src/app/services/actionLog.service.ts diff --git a/src/app/graphqlOperations/actionLog.graphql b/src/app/graphqlOperations/actionLog.graphql new file mode 100644 index 0000000..dcc3ff2 --- /dev/null +++ b/src/app/graphqlOperations/actionLog.graphql @@ -0,0 +1,12 @@ +query GetActionLog { + actionLogAll { + ...ActionLogFields + } +} + +query GetActionLogByUserId($id: ID!) { + actionLogByUser(id: $id) { + ...ActionLogFields + } +} + diff --git a/src/app/graphqlOperations/fragments/actionlog.graphql b/src/app/graphqlOperations/fragments/actionlog.graphql new file mode 100644 index 0000000..b691b40 --- /dev/null +++ b/src/app/graphqlOperations/fragments/actionlog.graphql @@ -0,0 +1,10 @@ +fragment ActionLogFields on ActionLog { + id + action + date + entity + entriesNew + entriesOld + userId +} + diff --git a/src/app/services/actionLog.service.ts b/src/app/services/actionLog.service.ts new file mode 100644 index 0000000..9c22d42 --- /dev/null +++ b/src/app/services/actionLog.service.ts @@ -0,0 +1,25 @@ +import { Injectable } from '@angular/core'; +import { BehaviorSubject, Subject } from 'rxjs'; +import { + GetActionLogByUserIdGQL, + GetActionLogByUserIdQueryVariables, + GetActionLogGQL, +} from '../../generated/graphql'; + +@Injectable({ + providedIn: 'root', +}) +export class PersonsService { + constructor( + private getActionLogGQL: GetActionLogGQL, + private getActionLogByUserIdGQL: GetActionLogByUserIdGQL + ) {} + + getActionLogAll() { + return this.getActionLogGQL.fetch(); + } + + getActionLogByUserId(variables: GetActionLogByUserIdQueryVariables) { + return this.getActionLogByUserIdGQL.fetch(variables); + } +} diff --git a/src/generated/graphql.ts b/src/generated/graphql.ts index f3218db..c0ad443 100644 --- a/src/generated/graphql.ts +++ b/src/generated/graphql.ts @@ -1795,6 +1795,24 @@ export enum CacheControlScope { } +export type GetActionLogQueryVariables = Exact<{ [key: string]: never; }>; + + +export type GetActionLogQuery = { __typename?: 'Query', actionLogAll?: Maybe> }; + +export type GetActionLogByUserIdQueryVariables = Exact<{ + id: Scalars['ID']; +}>; + + +export type GetActionLogByUserIdQuery = { __typename?: 'Query', actionLogByUser?: Maybe> }; + export type GetCargoBikesQueryVariables = Exact<{ [key: string]: never; }>; @@ -2285,6 +2303,8 @@ export type DeleteEquipmentTypeMutationVariables = Exact<{ export type DeleteEquipmentTypeMutation = { __typename?: 'Mutation', deleteEquipmentType: boolean }; +export type ActionLogFieldsFragment = { __typename?: 'ActionLog', id: string, action: string, date: any, entity: string, entriesNew: string, entriesOld: string, userId: string }; + export type AddressFieldsFragment = { __typename?: 'Address', street: string, number: string, zip: string, city?: Maybe }; export type CargoBikeFieldsForTableFragment = { __typename?: 'CargoBike', id: string, group: Group, name: string, modelName?: Maybe, state?: Maybe, numberOfChildren?: Maybe, numberOfWheels?: Maybe, forCargo?: Maybe, forChildren?: Maybe, stickerBikeNameState?: Maybe, note?: Maybe, isLocked: boolean, isLockedByMe: boolean, lockedBy?: Maybe, lockedUntil?: Maybe, insuranceData?: Maybe<{ __typename?: 'InsuranceData', billing?: Maybe, hasFixedRate?: Maybe, name?: Maybe, benefactor?: Maybe, noPnP?: Maybe, maintenanceResponsible?: Maybe, maintenanceBenefactor?: Maybe, maintenanceAgreement?: Maybe, fixedRate?: Maybe, projectAllowance?: Maybe, notes?: Maybe }>, dimensionsAndLoad?: Maybe<{ __typename?: 'DimensionsAndLoad', bikeLength?: Maybe, bikeWeight?: Maybe, bikeHeight?: Maybe, bikeWidth?: Maybe, hasCoverBox?: Maybe, lockable?: Maybe, maxWeightBox?: Maybe, maxWeightLuggageRack?: Maybe, maxWeightTotal?: Maybe, boxHeightRange?: Maybe<{ __typename?: 'NumRange', max?: Maybe, min?: Maybe }>, boxLengthRange?: Maybe<{ __typename?: 'NumRange', min?: Maybe, max?: Maybe }>, boxWidthRange?: Maybe<{ __typename?: 'NumRange', min?: Maybe, max?: Maybe }> }>, security?: Maybe<{ __typename?: 'Security', frameNumber?: Maybe, adfcCoding?: Maybe, keyNumberAXAChain?: Maybe, keyNumberFrameLock?: Maybe, policeCoding?: Maybe }>, technicalEquipment?: Maybe<{ __typename?: 'TechnicalEquipment', bicycleShift?: Maybe, isEBike?: Maybe, hasLightSystem?: Maybe, specialFeatures?: Maybe }>, taxes?: Maybe<{ __typename?: 'Taxes', costCenter?: Maybe, organisationArea?: Maybe }>, provider?: Maybe<( @@ -3085,6 +3105,17 @@ export type DeleteWorkshopTypeMutationVariables = Exact<{ export type DeleteWorkshopTypeMutation = { __typename?: 'Mutation', deleteWorkshopType: boolean }; +export const ActionLogFieldsFragmentDoc = gql` + fragment ActionLogFields on ActionLog { + id + action + date + entity + entriesNew + entriesOld + userId +} + `; export const PersonFieldsGeneralFragmentDoc = gql` fragment PersonFieldsGeneral on Person { id @@ -3722,6 +3753,42 @@ export const WorkshopTypeFieldsFragmentDoc = gql` lockedUntil } ${WorkshopTypefieldsGeneralFragmentDoc}`; +export const GetActionLogDocument = gql` + query GetActionLog { + actionLogAll { + ...ActionLogFields + } +} + ${ActionLogFieldsFragmentDoc}`; + + @Injectable({ + providedIn: 'root' + }) + export class GetActionLogGQL extends Apollo.Query { + document = GetActionLogDocument; + + constructor(apollo: Apollo.Apollo) { + super(apollo); + } + } +export const GetActionLogByUserIdDocument = gql` + query GetActionLogByUserId($id: ID!) { + actionLogByUser(id: $id) { + ...ActionLogFields + } +} + ${ActionLogFieldsFragmentDoc}`; + + @Injectable({ + providedIn: 'root' + }) + export class GetActionLogByUserIdGQL extends Apollo.Query { + document = GetActionLogByUserIdDocument; + + constructor(apollo: Apollo.Apollo) { + super(apollo); + } + } export const GetCargoBikesDocument = gql` query GetCargoBikes { cargoBikes {