Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import {Injectable} from '@angular/core';
import {IAdapter} from './i-adapter';

@Injectable()
export class AnyAdapter implements IAdapter<any> {
adaptToModel(resp: any): any {
return resp;
}
adaptFromModel(data: any): any {
return data;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
// sonarignore:start
export interface IAdapter<T, R = T> {
adaptToModel(resp: any): T;
adaptFromModel(data: Partial<R>): any;
}
// sonarignore:end

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './i-adapter';
export * from './any-adapter.service';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {CUSTOM_ELEMENTS_SCHEMA, Injector, NgModule} from '@angular/core';
import {AiAssistantComponent} from './ai-assistant.component';
import {createCustomElement} from '@angular/elements';
import { createCustomElement } from '@angular/elements';
import {
CoPilotComponent,
CoPilotHeaderComponent,
Expand All @@ -27,13 +27,15 @@ import {ReactiveFormsModule} from '@angular/forms';
import {LocalizationPipe} from './pipes/localization.pipe';
import {MatTooltipModule} from '@angular/material/tooltip';
import {DeepChatUtilService} from './services/deep-chat-util.service';
import {CoPilotVideoService, DeepChatCommsService} from './services';
import {ApiService, CoPilotVideoService, DeepChatCommsService, DownloadService} from './services';
import {SseService} from './services/sse.service';
import {ImageStoreService} from './services/image-store.service';
import {CoPilotImageViewerComponent} from './components/co-pilot-image-viewer/co-pilot-image-viewer.component';
import {HttpClientModule} from '@angular/common/http';
import {DragDropModule} from '@angular/cdk/drag-drop'; // Import DragDropModule
import {MatFormFieldModule} from '@angular/material/form-field';
import { DeepChatFacadeService } from './facades';
import { AnyAdapter } from './adapters';

@NgModule({
declarations: [
Expand Down Expand Up @@ -81,6 +83,10 @@ import {MatFormFieldModule} from '@angular/material/form-field';
CoPilotVideoService,
SseService,
ImageStoreService,
AnyAdapter,
ApiService,
DeepChatFacadeService,
DownloadService
],
})
export class AiAssistantModule {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {HttpHeaders, HttpParams} from '@angular/common/http';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';

import {IAdapter} from '../adapters/i-adapter';
import {ICommand} from './i-command';
import { ApiService } from '../services';
declare type HttpObserve = 'body' | 'events' | 'response';

export abstract class DelAPICommand<T> implements ICommand {
constructor(
protected readonly apiService: ApiService,
protected readonly adapter: IAdapter<T>,
protected readonly uri: string,
) {}

parameters?: {
data?: object;
query?: HttpParams;
headers?: HttpHeaders;
observe?: HttpObserve;
};

execute(): Observable<T> {
let options: any;
if (this.parameters) {
options = {};
options.observe = this.parameters.observe || 'body';
if (this.parameters.headers) {
options.headers = this.parameters.headers;
}

if (this.parameters.query) {
options.params = this.parameters.query;
}

if (this.parameters.data) {
options.body = this.parameters.data;
}
}
return this.apiService
.delete(this.uri, options)
.pipe(map(resp => this.adapter.adaptToModel(resp)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { IAdapter } from "../adapters";
import { ApiService } from "../services";
import { DelAPICommand } from "./delete-api.command";


export class DeleteFeedbackCommand<T> extends DelAPICommand<T> {
constructor(apiService: ApiService, adapter: IAdapter<T>, url:string, id: string) {
super(
apiService,
adapter,
`${url}/${id}`,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { IAdapter } from "../adapters";
import { ApiService } from "../services";
import { GetAPICommand } from "./get-api.command";


export class DownloadAIFile<T> extends GetAPICommand<T> {
constructor(
apiService: ApiService,
anyAdapter: IAdapter<T>,
url: string,
fileKey: string,
) {
super(
apiService,
anyAdapter,
`${url}/${fileKey}`,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {HttpHeaders, HttpParams} from '@angular/common/http';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {ICommand} from './i-command';
import { ApiService } from '../services';
import { IAdapter } from '../adapters';

declare type HttpObserve = 'body' | 'events' | 'response';
declare type ResponseType = 'arraybuffer' | 'blob' | 'json' | 'text';

export abstract class GetAPICommand<T, R = T> implements ICommand {
constructor(
protected readonly apiService: ApiService,
protected readonly adapter: IAdapter<T, R>,
protected readonly uri: string,
) {}

parameters?: {
query?: HttpParams;
headers?: HttpHeaders;
observe?: HttpObserve;
responseType?: ResponseType;
};

execute(): Observable<T> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let options: any;
if (this.parameters) {
options = {};
options.observe = this.parameters.observe || 'body';

if (this.parameters.headers) {
options.headers = this.parameters.headers;
}

if (this.parameters.query) {
options.params = this.parameters.query;
}

if (this.parameters.responseType) {
options.responseType = this.parameters.responseType;
}
}
return this.apiService
.get(this.uri, options)
.pipe(map(resp => this.adapter.adaptToModel(resp)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import {Observable} from 'rxjs';

export interface ICommand {
parameters?: any;
execute(): Observable<any>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export * from './get-api.command';
export * from './i-command';
export * from './download-file.command';
export * from './patch-api.command';
export * from './post-api.command';
export * from './delete-api.command';
export * from './save-feedback.command';
export * from './update-feedback.command';
export * from './delete-feedback.command';
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {HttpHeaders, HttpParams} from '@angular/common/http';
import {Observable, throwError} from 'rxjs';
import {map} from 'rxjs/operators';

import {IAdapter} from '../adapters/i-adapter';
import {ICommand} from './i-command';
import { ApiService } from '../services';

declare type HttpObserve = 'body' | 'events' | 'response';

export class PatchAPICommand<T> implements ICommand {
constructor(
protected readonly apiService: ApiService,
protected readonly adapter: IAdapter<T>,
protected readonly uri: string,
) {}

parameters!: {
data: Partial<T>;
headers?: HttpHeaders;
observe?: HttpObserve;
query?: HttpParams;
};

execute(): Observable<T> {
if (!this.parameters) {
throwError(`Parameters missing for PATCH ${this.uri}`);
}

// sonarignore:start
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const options: any = {observe: this.parameters.observe || 'body'};
if (this.parameters.headers) {
options.headers = this.parameters.headers;
}
// sonarignore:end

if (this.parameters.query) {
options.params = this.parameters.query;
}
return this.apiService
.patch(
this.uri,
this.adapter.adaptFromModel(this.parameters.data),
options,
)
.pipe(map(resp => this.adapter.adaptToModel(resp)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {HttpHeaders, HttpParams} from '@angular/common/http';
import {Observable, throwError} from 'rxjs';
import {map} from 'rxjs/operators';
import {IAdapter} from '../adapters/i-adapter';
import {ICommand} from './i-command';
import { ApiService } from '../services';

declare type HttpObserve = 'body' | 'events' | 'response';

export class PostAPICommand<T, R = T> implements ICommand {
constructor(
protected readonly apiService: ApiService,
protected readonly adapter: IAdapter<T, R>,
protected readonly uri: string,
) {}

parameters!: {
data: R;
headers?: HttpHeaders;
observe?: HttpObserve;
query?: HttpParams;
reportProgress?: boolean;
};

execute(): Observable<T> {
if (!this.parameters) {
throwError(`Parameters missing for POST ${this.uri}`);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const options: any = {};
options.observe = this.parameters.observe || 'body';
options.reportProgress = this.parameters.reportProgress;
if (this.parameters.headers) {
options.headers = this.parameters.headers;
}
if (this.parameters.query) {
options.params = this.parameters.query;
}
return this.apiService
.post(
this.uri,
this.adapter.adaptFromModel(this.parameters.data),
options,
)
.pipe(
map(resp => {
if (!options.reportProgress) {
return this.adapter.adaptToModel(resp);
} else {
return resp;
}
}),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { PostAPICommand } from ".";
import { IAdapter } from "../adapters";
import { ApiService } from "../services";


export class SaveFeedbackCommand<T> extends PostAPICommand<T> {
constructor(apiService: ApiService, anyAdapter: IAdapter<T>, url: string) {
super(apiService, anyAdapter, `${url}`);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { PatchAPICommand } from ".";
import { IAdapter } from "../adapters";
import { ApiService } from "../services";

export class UpdateFeedbackCommand<T> extends PatchAPICommand<T> {
constructor(apiService: ApiService, anyAdapter: IAdapter<T>, url: string, id: string) {
super(
apiService,
anyAdapter,
`${url}/${id}`,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
>
<div class="co-pilot-header">
<div class="co-pilot-header-title">
<svg width="40" height="41" viewBox="0 0 40 41" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M21.5568 10.9863L21.5814 11.0356L29.3063 26.1151C30.0467 27.4725 29.9973 29.052 29.2075 30.3847C28.4178 31.7174 27.011 32.5072 25.4562 32.5072H25.4315L16.1025 32.4578L6.89688 32.5072C5.34204 32.5072 3.95997 31.7421 3.14553 30.4341C2.35577 29.126 2.28173 27.5465 2.97277 26.1891L10.821 11.1097C11.7588 9.234 13.8073 8.02468 16.1272 8H16.2259C18.5211 8 20.5449 9.13528 21.5568 10.9863ZM25.4562 29.0767C25.9251 29.0767 26.1719 28.7558 26.246 28.6324C26.3447 28.4843 26.4681 28.1635 26.32 27.818L26.2953 27.7686L18.5705 12.6645C18.1016 11.8007 17.065 11.4799 16.2506 11.5046C15.4361 11.5046 14.3996 11.8501 13.9553 12.7385L6.10712 27.818C5.93436 28.1882 6.05776 28.509 6.15648 28.6571C6.23052 28.7805 6.45264 29.0767 6.92156 29.0767L16.1272 29.0273L25.4562 29.0767Z" fill="black"/>
<path d="M34.0448 8.39483H37.5V32.5565H34.0448V8.39483Z" fill="black"/>
</svg>
<span class="co-pilot-header-title-text">{{
'coPilotLbl' | translate
}}</span>
<div class="powered-by-ai-container">
<div class="powered-by-ai-container" *ngIf="showPoweredAiText">
<span class="co-pilot-header-ai-title-powered">
{{ 'poweredByAILbl' | translate }}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
height: $hw-24;
display: flex;
gap: 12.8px;
align-items: center;
.co-pilot-header-title-text {
font-weight: $font-wt-md;
font-size: $font-18;
Expand All @@ -36,6 +37,10 @@
display: flex;
}
}
.co-pilot-icon {
font-size: 24px;
color: #4d4d4d;
}
}

.co-pilot-header-icons {
Expand All @@ -48,6 +53,8 @@
margin-top: $mp-4;
}
.co-pilot-header-icon-reset {
display: flex;
align-items: center;
.blue-icon {
color: $blue-icon;
height: $hw-24;
Expand All @@ -62,7 +69,6 @@
font-size: $font-16;
height: $font-16;
position: relative;
top: 2.8px;
}
}

Expand Down
Loading