Skip to content

Commit

Permalink
Remove preql from user searches.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartcaunt committed Nov 28, 2024
1 parent 07f4d19 commit 06dad47
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 124 deletions.
28 changes: 7 additions & 21 deletions src/app/admin/components/users/users.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {ClrDatagridSortOrder, ClrDatagridStateInterface} from '@clr/angular';
import {Apollo} from 'apollo-angular';
import {UserConnection} from 'app/core/graphql/types';
import {UserConnection, UserFilterInput} from 'app/core/graphql/types';
import gql from 'graphql-tag';
import {Observable, Subject} from 'rxjs';
import {filter, map, take, takeUntil, tap} from 'rxjs/operators';
Expand Down Expand Up @@ -112,7 +112,7 @@ export class UsersComponent implements OnInit, OnDestroy {
this.loading = true;
this.apollo.query<any>({
query: gql`
query allUsers($filter: QueryFilter, $orderBy: OrderBy, $pagination: Pagination!) {
query allUsers($filter: UserFilterInput, $orderBy: OrderBy, $pagination: Pagination!) {
users(filter: $filter, pagination: $pagination, orderBy: $orderBy) {
pageInfo {
currentPage
Expand Down Expand Up @@ -266,13 +266,6 @@ export class UsersComponent implements OnInit, OnDestroy {
});
}

private createFilter(): FilterProvider {
return new FilterProvider({
userId: new FilterAttribute('id', 'userId', '='),
role: new FilterAttribute('role', 'role', '='),
});
}

private updateUrl(): void {
const currentState = this.currentState;
this.router.navigate([],
Expand All @@ -290,19 +283,12 @@ export class UsersComponent implements OnInit, OnDestroy {
);
}

private processFilters(): any {
const provider = this.createFilter();
const query = provider.createQuery();
Object.entries(this.currentState.filters).map(([key, value]) => {
if (value) {
query.setParameter(key, value);
}
});

if (this.currentState.filters.activated) {
query.addFixedQuery('activatedAt IS NOT NULL');
private processFilters(): UserFilterInput {
return {
id: this.currentState.filters.userId,
role: this.currentState.filters.role,
activated: this.currentState.filters.activated ? true : null,
}
return query.execute();
}

}
109 changes: 6 additions & 103 deletions src/app/core/graphql/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,109 +433,6 @@ export type Query = {
};


export type QueryPlansArgs = {
filter?: Maybe<QueryFilter>;
orderBy?: Maybe<OrderBy>;
pagination: Pagination;
};


export type QueryExperimentsArgs = {
filter?: Maybe<QueryFilter>;
orderBy?: Maybe<OrderBy>;
pagination: Pagination;
};


export type QueryCountExperimentsArgs = {
filter?: Maybe<QueryFilter>;
};


export type QueryFlavoursArgs = {
filter?: Maybe<QueryFilter>;
orderBy?: Maybe<OrderBy>;
pagination: Pagination;
};


export type QueryCountFlavoursArgs = {
filter?: Maybe<QueryFilter>;
};


export type QueryImagesArgs = {
filter?: Maybe<QueryFilter>;
orderBy?: Maybe<OrderBy>;
pagination: Pagination;
};


export type QueryCountImagesArgs = {
filter?: Maybe<QueryFilter>;
};


export type QueryInstancesArgs = {
filter?: Maybe<QueryFilter>;
orderBy?: Maybe<OrderBy>;
pagination: Pagination;
};


export type QueryCountInstancesArgs = {
filter?: Maybe<QueryFilter>;
};


export type QueryInstanceArgs = {
id: Scalars['Int'];
};


export type QueryRecentInstancesArgs = {
pagination: Pagination;
};


export type QueryCountInstancesForStateArgs = {
state: InstanceState;
};


export type QueryCountInstancesForStatesArgs = {
states?: Maybe<Array<Maybe<InstanceState>>>;
};


export type QueryUsersArgs = {
filter?: Maybe<QueryFilter>;
orderBy?: Maybe<OrderBy>;
pagination: Pagination;
};


export type QueryCountUsersArgs = {
filter?: Maybe<QueryFilter>;
};


export type QueryUserArgs = {
id: Scalars['Int'];
};


export type QuerySessionsArgs = {
filter?: Maybe<QueryFilter>;
orderBy?: Maybe<OrderBy>;
pagination: Pagination;
};

export type QueryFilter = {
query: Scalars['String'];
parameters?: Maybe<Array<Maybe<Parameter>>>;
};

export type InstanceFilterInput = {
id: Maybe<Scalars['Int']>;
nameLike: Maybe<Scalars['String']>;
Expand All @@ -551,6 +448,12 @@ export type ExperimentFilterInput = {
proposalLike: Maybe<Scalars['String']>;
}

export type UserFilterInput = {
id: Maybe<Scalars['String']>;
role: Maybe<Scalars['String']>;
activated: Maybe<Scalars['Boolean']>;
}

export type Role = {
__typename?: 'Role';
id: Scalars['Int'];
Expand Down

0 comments on commit 06dad47

Please sign in to comment.