Contract Signing and contract printing
This commit is contained in:
@@ -15,7 +15,7 @@ import { ArrayTypeComponent } from "./types/array.type";
|
||||
import { ObjectTypeComponent } from "./types/object.type";
|
||||
import { DatetimeTypeComponent } from "./types/datetime.type";
|
||||
import { DateTypeComponent } from "./types/date.type";
|
||||
import { ApiService, CrudService } from "./crud.service";
|
||||
import { ApiService, CrudService, ImageUploaderCrudService } from "./crud.service";
|
||||
import { CrudFormlyJsonschemaService } from "./crud-formly-jsonschema.service";
|
||||
import { NgbModule} from "@ng-bootstrap/ng-bootstrap";
|
||||
import { allIcons, NgxBootstrapIconsModule } from "ngx-bootstrap-icons";
|
||||
@@ -49,6 +49,7 @@ import { ClipboardModule } from '@angular/cdk/clipboard';
|
||||
JsonschemasService,
|
||||
ApiService,
|
||||
CrudService,
|
||||
ImageUploaderCrudService,
|
||||
CrudFormlyJsonschemaService,
|
||||
DictionaryService
|
||||
],
|
||||
|
||||
@@ -116,3 +116,28 @@ export class CrudService extends ApiService {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class ImageUploaderCrudService extends CrudService {
|
||||
public upload(resource: string, signature_id: string, image: string) {
|
||||
const formData: FormData = new FormData();
|
||||
formData.append("signature_file", dataURIToBlob(image), signature_id + ".png");
|
||||
|
||||
return this.http.post<{ menu: [{}] }>(
|
||||
`${this.api_root}/${resource.toLowerCase()}/${signature_id}`,
|
||||
formData
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function dataURIToBlob(dataURI: string) {
|
||||
const splitDataURI = dataURI.split(',')
|
||||
const byteString = splitDataURI[0].indexOf('base64') >= 0 ? atob(splitDataURI[1]) : decodeURI(splitDataURI[1])
|
||||
const mimeString = splitDataURI[0].split(':')[1].split(';')[0]
|
||||
|
||||
const ia = new Uint8Array(byteString.length)
|
||||
for (let i = 0; i < byteString.length; i++)
|
||||
ia[i] = byteString.charCodeAt(i)
|
||||
|
||||
return new Blob([ia], { type: mimeString })
|
||||
}
|
||||
Reference in New Issue
Block a user