mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
save
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { SignalRService } from 'src/app/infra/socket/signalR/signal-r.service';
|
||||
import { ISignalRService } from 'src/app/infra/socket/adapter';
|
||||
import { HttpModule } from 'src/app/infra/http/http.module';
|
||||
@NgModule({
|
||||
imports: [HttpModule],
|
||||
providers: [
|
||||
{
|
||||
provide: ISignalRService,
|
||||
useClass: SignalRService, // or MockDataService
|
||||
},
|
||||
],
|
||||
declarations: [],
|
||||
schemas: [],
|
||||
entryComponents: []
|
||||
})
|
||||
export class GabineteModule {
|
||||
constructor() {}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TaskRepoService } from './task-repo.service';
|
||||
|
||||
describe('TaskRepoService', () => {
|
||||
let service: TaskRepoService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(TaskRepoService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpAdapter } from 'src/app/infra/http/adapter';
|
||||
import { OK } from 'zod';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { Err } from 'neverthrow';
|
||||
import { HttpResult } from 'src/app/infra/http/type';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
|
||||
export function instanceIdGenerator() {
|
||||
const now = new Date();
|
||||
const prefix = 'DC';
|
||||
|
||||
const formattedDate = now.toISOString()
|
||||
.replace('T', ' ')
|
||||
.replace('Z', '')
|
||||
.slice(0, 23); // yyyy-MM-dd HH:mm:ss.SSS
|
||||
|
||||
return `${prefix}_${SessionStore.user.Email}_${formattedDate}`;
|
||||
}
|
||||
|
||||
interface UploadDocInputDto {
|
||||
InstanceId: string;
|
||||
UserId: string;
|
||||
Source: string;
|
||||
FileExtension: string;
|
||||
FileBase64: string;
|
||||
OriginalFileName: string;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TaskRepoService {
|
||||
|
||||
constructor(
|
||||
private http: HttpAdapter
|
||||
) { }
|
||||
|
||||
async uploadDoc(input: UploadDocInputDto[]): Promise<Err<HttpResult<unknown>, HttpErrorResponse> | OK<boolean>> {
|
||||
for(const attachment in input) {
|
||||
var result = await this.http.post('/Tasks/AttachDocImage', attachment);
|
||||
|
||||
if(result.isErr()) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return OK(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user