moh-common-lib
Version:
A library of Angular components, services, and styles for B.C. Government Ministry of Health (MoH).
73 lines (72 loc) • 2.25 kB
TypeScript
export declare enum CommonImageError {
WrongType = 0,
TooSmall = 1,
TooBig = 2,
AlreadyExists = 3,
Unknown = 4,
CannotOpen = 5,
PDFnotSupported = 6,
CannotOpenPDF = 7
}
export declare class CommonImageProcessingError {
errorCode: CommonImageError;
errorDescription?: string;
commonImage?: CommonImage;
rawImageFile?: File;
maxSizeAllowed?: number;
constructor(errorCode: CommonImageError, errorDescription?: string);
}
/**
* Image as uploaded by user
*/
export declare class CommonImage<T = any> {
uuid: string;
/**
* @param fileContent (optional) The base64 of an image. See `fileContent` property.
*/
constructor(fileContent?: string);
/**
* The base64 content of an image. Must already be base64 or some other stringable data-type.
*
* You should be able to do <img src='myCommonImage.fileContent'> to render the image.
*/
fileContent: string;
documentType: T;
/**
* ContentType should generally match the MIME type, but can be set as needed by application.
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
*/
contentType: string;
size: number;
sizeUnit: string;
sizeTxt: string;
naturalHeight: number;
naturalWidth: number;
name: string;
id: string;
error?: CommonImageError;
attachmentOrder: number;
/**
* Returns the JSON of an image ready to be submitted to the API. You may
* have to set attachmentOrder before calling this.
*/
toJSON(): CommonAttachmentJson<T>;
clone(): CommonImage;
calculateSize(): void;
}
export interface CommonAttachmentJson<T> {
attachmentOrder: number;
attachmentUuid: string;
attachmentDocumentType: T;
}
export interface CommonImageScaleFactors {
widthFactor: number;
heightFactor: number;
scaleDown(scale: number): CommonImageScaleFactors;
}
export declare class CommonImageScaleFactorsImpl implements CommonImageScaleFactors {
widthFactor: number;
heightFactor: number;
constructor(wFactor: number, hFactor: number);
scaleDown(scale: number): CommonImageScaleFactors;
}