Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.4.0.3 #469

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export class AppComponent implements OnInit {
// initialise Pusher
await this.pusherService.initialise();
this.apolloService.initiateCoreClient();
this.apolloService.initiateChatClient();
});
}
}
22 changes: 11 additions & 11 deletions src/app/chat/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class ChatService {
const response = this.demo.getChats();
return of(this._normaliseChatListResponse(response.data)).pipe(delay(1000));
}
return this.apollo.chatGraphQLQuery(
return this.apollo.graphQLFetch(
`query getChannels {
channels{
uuid
Expand Down Expand Up @@ -224,7 +224,7 @@ export class ChatService {
if (!data.scheduledOnly) {
delete params.scheduledOnly;
}
return this.apollo.chatGraphQLQuery(
return this.apollo.graphQLFetch(
`query getChannellogs($uuid:String!, $cursor:String!, $size:Int!, $scheduledOnly:Boolean) {
channel(uuid:$uuid){
chatLogsConnection(cursor:$cursor, size:$size, scheduledOnly:$scheduledOnly){
Expand Down Expand Up @@ -307,7 +307,7 @@ export class ChatService {
const response = this.demo.getMembers(channelId);
return of(this._normaliseChatMembersResponse(response.data)).pipe(delay(1000));
}
return this.apollo.chatGraphQLQuery(
return this.apollo.graphQLFetch(
`query getChannelmembers($uuid:String!) {
channel(uuid:$uuid){
members{
Expand Down Expand Up @@ -349,7 +349,7 @@ export class ChatService {
const response = this.demo.getPusherChannels();
return of(this._normalisePusherChannelsResponse(response.data)).pipe(delay(1000));
}
return this.apollo.chatGraphQLQuery(
return this.apollo.graphQLFetch(
`query getPusherChannels {
channels {
pusherChannel
Expand Down Expand Up @@ -379,7 +379,7 @@ export class ChatService {
if (environment.demo) {
return of({}).pipe(delay(1000));
}
return this.apollo.chatGraphQLMutate(
return this.apollo.graphQLMutate(
`mutation markAsSeen($uuids: [String]!) {
readChatLogs(uuids: $uuids) {
success
Expand All @@ -400,7 +400,7 @@ export class ChatService {
const response = this.demo.getNewMessage(data);
return of(this._normalisePostMessageResponse(response.data)).pipe(delay(1000));
}
return this.apollo.chatGraphQLMutate(
return this.apollo.graphQLMutate(
`mutation createChatLogs($channelUuid: String!, $message: String, $file: String, $scheduled: String) {
createChatLog(channelUuid: $channelUuid, message: $message, file: $file, scheduled: $scheduled) {
uuid
Expand Down Expand Up @@ -481,7 +481,7 @@ export class ChatService {
const response = this.demo.getNewChannel(data);
return of(this._normaliseCreateChannelResponse(response.data)).pipe(delay(1000));
}
return this.apollo.chatGraphQLMutate(
return this.apollo.graphQLMutate(
`mutation createChannel($name: String, $isAnnouncement: Boolean, $roles: [String], $members: [MemberInput]!){
createChannel(name: $name, isAnnouncement: $isAnnouncement, roles: $roles, members: $members) {
uuid
Expand Down Expand Up @@ -545,7 +545,7 @@ export class ChatService {
if (environment.demo) {
return of({}).pipe(delay(1000));
}
return this.apollo.chatGraphQLMutate(
return this.apollo.graphQLMutate(
`mutation deleteChannel($uuid: String!){
deleteChannel(uuid: $uuid) {
success
Expand All @@ -562,7 +562,7 @@ export class ChatService {
const response = this.demo.getEditedChannel(data);
return of(this._normaliseEditChannelResponse(response.data)).pipe(delay(1000));
}
return this.apollo.chatGraphQLMutate(
return this.apollo.graphQLMutate(
`mutation editChannel($uuid: String!, $name: String, $isAnnouncement: Boolean, $roles: [String]){
editChannel(uuid: $uuid, name: $name, isAnnouncement: $isAnnouncement, roles: $roles) {
uuid
Expand Down Expand Up @@ -686,7 +686,7 @@ export class ChatService {
if (environment.demo) {
return of({}).pipe(delay(1000));
}
return this.apollo.chatGraphQLMutate(
return this.apollo.graphQLMutate(
`mutation deletechatMessage($uuid: String!) {
deleteChatLog(uuid: $uuid) {
success
Expand All @@ -702,7 +702,7 @@ export class ChatService {
if (environment.demo) {
return of({}).pipe(delay(1000));
}
return this.apollo.chatGraphQLMutate(
return this.apollo.graphQLMutate(
`mutation edichatMessage($uuid: String!, $message: String, $file: String, $scheduled: String) {
editChatLog(uuid: $uuid, message: $message, file: $file, scheduled: $scheduled) {
success
Expand Down
1 change: 1 addition & 0 deletions src/app/metrics/metric-detail/metric-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class MetricDetailComponent implements OnInit {
}).then(modal => {
modal.present();
modal.onDidDismiss().then(() => {
this.fetchMetrics();
this.dismissModal();
});
});
Expand Down
71 changes: 7 additions & 64 deletions src/app/shared/apollo/apollo.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@ import { RequestService } from '../request/request.service';
import { catchError, concatMap, map } from 'rxjs/operators';
import { HttpErrorResponse } from '@angular/common/http';

enum ClientType {
core = 'CORE',
chat = 'CHAT'
}

@Injectable({
providedIn: 'root'
})
export class ApolloService {
private apolloInstance: Apollo;
private _url = {
core: '',
chat: '',
};
private _url = '';

constructor(
private apollo: Apollo,
Expand All @@ -30,7 +22,7 @@ export class ApolloService {
) {}

initiateCoreClient(): Apollo {
if (this._hasInitiated(environment.graphQL, ClientType.core)) {
if (this._hasInitiated()) {
return this.apolloInstance;
}

Expand All @@ -55,45 +47,26 @@ export class ApolloService {
});

this.apolloInstance = this.apollo;
this._url.core = environment.graphQL;
this._url = environment.graphQL;

return this.apolloInstance;
}

/**
* skip if apollo already created for an URI
* pairing conditions: URL & ClientType
* pairing conditions: URL
* - core grahpql domain & 'core'
* - chat grahpql domain & 'chat'
*
* @returns boolean
*/
private _hasInitiated(url: string, type: ClientType = ClientType.core): boolean {
if (type === ClientType.core
&& this.apollo.client
&& this._url.core === environment.graphQL) {
private _hasInitiated(): boolean {
if (this.apollo.client
&& this._url === environment.graphQL) {
return true;
} else if (type === ClientType.chat
&& this.apollo.use('chat')
&& this._url.chat === environment.chatGraphQL) {
return true;
}
return false;
}

initiateChatClient() {
if (this._hasInitiated(environment.chatGraphQL, ClientType.chat)) {
return;
}
this.apollo.createNamed('chat', {
link: this.httpLink.create({
uri: environment.chatGraphQL
}),
cache: new InMemoryCache(),
});
this._url.chat = environment.chatGraphQL;
}

getClient() {
return this.apollo.client;
}
Expand Down Expand Up @@ -190,34 +163,4 @@ export class ApolloService {
catchError((error: HttpErrorResponse) => of({ error }))
);
}

/*
* Valid options:
* noCache: Boolean default false. If set to false, will not cache the result
*/
chatGraphQLQuery(query: string, variables: any = {}) {
const watch = this.apollo.use('chat').query({
query: gql(query),
variables,
fetchPolicy: 'no-cache' // always retrieve a fresh one
});
return watch.pipe(
concatMap(response => {
return of(response);
}),
catchError((error) => this.requestService.handleError(error))
);
}

chatGraphQLMutate(query: string, variables = {}): Observable<any> {
return this.apollo.use('chat').mutate({
mutation: gql(query),
variables: variables
}).pipe(
concatMap(response => {
return of(response);
}),
catchError((error) => this.requestService.handleError(error))
);
}
}
2 changes: 1 addition & 1 deletion src/app/shared/pusher/pusher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class PusherService {
}

getChatChannels(): Observable<any> {
return this.apollo.chatGraphQLQuery(
return this.apollo.graphQLFetch(
`query getPusherChannels {
channels {
pusherChannel
Expand Down
1 change: 0 additions & 1 deletion src/environments/environment.custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const environment = {
APIEndpointOld: '<CUSTOM_APIENDPOINTOLD>',
Practera: '<CUSTOM_PRACTERCORE>',
graphQL: '<CUSTOM_GEAPHQLENDPOINT>',
chatGraphQL: '<CUSTOM_CHATGEAPHQLENDPOINT>',
filestack: {
key: '<CUSTOM_FILESTACK_KEY>',
s3Config: {
Expand Down
1 change: 0 additions & 1 deletion src/environments/environment.demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const environment = {
APIEndpointOld: 'http://127.0.0.1:8080/',
Practera: 'http://127.0.0.1:8080',
graphQL: 'http://127.0.0.1:8000/',
chatGraphQL: 'http://localhost:3000/local/graphql/',
filestack: {
key: 'AO6F4C72uTPGRywaEijdLz',
s3Config: {
Expand Down
1 change: 0 additions & 1 deletion src/environments/environment.local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const environment = {
APIEndpointOld: 'http://127.0.0.1:8080/',
Practera: 'http://127.0.0.1:8080',
graphQL: 'http://127.0.0.1:8000/',
chatGraphQL: 'http://localhost:3000/local/graphql/',
filestack: {
key: 'AO6F4C72uTPGRywaEijdLz',
s3Config: {
Expand Down
1 change: 0 additions & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const environment = {
APIEndpointOld: 'https://api.practera.com/',
Practera: 'https://my.practera.com',
graphQL: 'https://kixs5acl6j.execute-api.ap-southeast-2.amazonaws.com/sandbox/',
chatGraphQL: 'https://antkrqcqa6.execute-api.ap-southeast-2.amazonaws.com/dev/graphql',
filestack: {
key: 'AO6F4C72uTPGRywaEijdLz',
s3Config: {
Expand Down
1 change: 0 additions & 1 deletion src/environments/environment.sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const environment = {
APIEndpointOld: 'https://sandbox.practera.com/',
Practera: 'https://sandbox.practera.com',
graphQL: 'https://kixs5acl6j.execute-api.ap-southeast-2.amazonaws.com/sandbox/',
chatGraphQL: 'https://antkrqcqa6.execute-api.ap-southeast-2.amazonaws.com/dev/graphql',
filestack: {
key: 'AO6F4C72uTPGRywaEijdLz',
s3Config: {
Expand Down
Loading