@olenbetong/appframe-core 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/af.common.js +18 -1
- package/dist/esm/af.common.legacy.js +18 -1
- package/dist/esm/af.common.legacy.min.js +1 -1
- package/dist/esm/af.common.legacy.min.js.map +4 -4
- package/dist/esm/af.common.min.js +1 -1
- package/dist/esm/af.common.min.js.map +4 -4
- package/dist/iife/af.common.js +18 -1
- package/dist/iife/af.common.legacy.js +18 -1
- package/dist/iife/af.common.legacy.min.js +1 -1
- package/dist/iife/af.common.legacy.min.js.map +4 -4
- package/dist/iife/af.common.min.js +1 -1
- package/dist/iife/af.common.min.js.map +4 -4
- package/es/getUserImage.d.ts +31 -0
- package/es/getUserImage.js +20 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/package.json +2 -2
- package/src/getUserImage.ts +50 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type ImageSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
2
|
+
|
|
3
|
+
export interface getUserImageOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Prim key of the record in atbl_Personnel_Employees
|
|
6
|
+
*/
|
|
7
|
+
primKey: string | null;
|
|
8
|
+
/**
|
|
9
|
+
* Person ID of the employee
|
|
10
|
+
*/
|
|
11
|
+
login: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* The value of the ImageHash column in atbl_Personnel_Employees
|
|
14
|
+
*/
|
|
15
|
+
hash: string | number | null;
|
|
16
|
+
/**
|
|
17
|
+
* The image will be resized according to this value. Default is 'xs':
|
|
18
|
+
* - xs: 64px
|
|
19
|
+
* - sm: 128px
|
|
20
|
+
* - md: 256px
|
|
21
|
+
* - lg: 512px
|
|
22
|
+
* - xl: image is not resized
|
|
23
|
+
*/
|
|
24
|
+
size?: ImageSize;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const sizeMap: Record<ImageSize, number | undefined> = {
|
|
28
|
+
xs: 64,
|
|
29
|
+
sm: 128,
|
|
30
|
+
md: 256,
|
|
31
|
+
lg: 512,
|
|
32
|
+
xl: undefined,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns the absolute path of a users profile picture. Uses the EmployeesLookup
|
|
37
|
+
* data resource to enable caching across applications.
|
|
38
|
+
*
|
|
39
|
+
* If one of primKey or hash are not provided, or are null, an empty string will be returned.
|
|
40
|
+
*/
|
|
41
|
+
export function getUserImage({ primKey, login, hash, size = "xs" }: getUserImageOptions) {
|
|
42
|
+
if (!primKey || !hash) {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let sizePx = sizeMap[size];
|
|
47
|
+
return `/api/data/blob/EmployeesLookup/${primKey}/Image/${login}${login ? "." : ""}${hash}.jpg${
|
|
48
|
+
sizePx ? `?width=${sizePx}` : ""
|
|
49
|
+
}`;
|
|
50
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./date.js";
|
|
|
7
7
|
export { downloadBlob } from "./downloadBlob.js";
|
|
8
8
|
export * from "./downloadRequest.js";
|
|
9
9
|
export { expose } from "./expose.js";
|
|
10
|
+
export * from "./getUserImage.js";
|
|
10
11
|
export { getLocalizedString } from "./getLocalizedString.js";
|
|
11
12
|
export { localize } from "./localize.js";
|
|
12
13
|
export * from "./has.js";
|