@cundi/refine-xaf 1.0.5 → 1.0.6

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/index.mjs CHANGED
@@ -7,13 +7,13 @@ var TOKEN_KEY = "refine-auth";
7
7
  var MAX_RETRIES = 3;
8
8
  var BASE_RETRY_DELAY = 1e3;
9
9
  var HttpError = class _HttpError extends Error {
10
- constructor(statusCode, message2, body) {
11
- super(message2);
10
+ constructor(statusCode, message3, body) {
11
+ super(message3);
12
12
  __publicField(this, "statusCode");
13
13
  __publicField(this, "message");
14
14
  __publicField(this, "body");
15
15
  this.statusCode = statusCode;
16
- this.message = message2;
16
+ this.message = message3;
17
17
  this.body = body;
18
18
  Object.setPrototypeOf(this, _HttpError.prototype);
19
19
  }
@@ -552,7 +552,7 @@ var parseFilter = (filter) => {
552
552
  // src/dataProvider.ts
553
553
  var dataProvider = (apiUrl) => ({
554
554
  getList: async ({ resource, pagination, sorters, filters }) => {
555
- const url = new URL(`${apiUrl}/${resource}`);
555
+ const url = new URL(`${apiUrl}/${resource}`, window.location.origin);
556
556
  if (pagination) {
557
557
  const { current, pageSize } = pagination;
558
558
  if (current && pageSize) {
@@ -580,7 +580,7 @@ var dataProvider = (apiUrl) => ({
580
580
  };
581
581
  },
582
582
  getOne: async ({ resource, id, meta }) => {
583
- const url = new URL(`${apiUrl}/${resource}(${id})`);
583
+ const url = new URL(`${apiUrl}/${resource}(${id})`, window.location.origin);
584
584
  if (meta?.expand) {
585
585
  const expand = meta.expand.map((item) => item.field ?? item).join(",");
586
586
  if (expand) {
@@ -593,7 +593,8 @@ var dataProvider = (apiUrl) => ({
593
593
  return { data: { ...data, id: data.Oid } };
594
594
  },
595
595
  create: async ({ resource, variables }) => {
596
- const response = await httpClient(`${apiUrl}/${resource}`, {
596
+ const url = new URL(`${apiUrl}/${resource}`, window.location.origin);
597
+ const response = await httpClient(url.toString(), {
597
598
  method: "POST",
598
599
  body: JSON.stringify(variables)
599
600
  });
@@ -602,7 +603,8 @@ var dataProvider = (apiUrl) => ({
602
603
  return { data };
603
604
  },
604
605
  update: async ({ resource, id, variables }) => {
605
- const response = await httpClient(`${apiUrl}/${resource}(${id})`, {
606
+ const url = new URL(`${apiUrl}/${resource}(${id})`, window.location.origin);
607
+ const response = await httpClient(url.toString(), {
606
608
  method: "PATCH",
607
609
  body: JSON.stringify(variables)
608
610
  });
@@ -613,14 +615,15 @@ var dataProvider = (apiUrl) => ({
613
615
  return { data };
614
616
  },
615
617
  deleteOne: async ({ resource, id }) => {
616
- await httpClient(`${apiUrl}/${resource}(${id})`, {
618
+ const url = new URL(`${apiUrl}/${resource}(${id})`, window.location.origin);
619
+ await httpClient(url.toString(), {
617
620
  method: "DELETE"
618
621
  });
619
622
  return { data: { id } };
620
623
  },
621
624
  getApiUrl: () => apiUrl,
622
625
  getMany: async ({ resource, ids }) => {
623
- const url = new URL(`${apiUrl}/${resource}`);
626
+ const url = new URL(`${apiUrl}/${resource}`, window.location.origin);
624
627
  const filter = ids.map((id) => {
625
628
  const isGuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(id.toString());
626
629
  return `Oid eq ${isGuid ? id : `'${id}'`}`;
@@ -645,7 +648,10 @@ var dataProvider = (apiUrl) => ({
645
648
  throw new Error("Not implemented");
646
649
  },
647
650
  custom: async ({ url, method, filters, sorters, payload, query, headers }) => {
648
- let requestUrl = new URL(`${url.startsWith("http") ? url : `${apiUrl}${url}`}`);
651
+ let requestUrl = new URL(
652
+ url.startsWith("http") ? url : `${apiUrl}${url}`,
653
+ window.location.origin
654
+ );
649
655
  if (filters) {
650
656
  const filterString = generateFilterString(filters);
651
657
  if (filterString) {
@@ -816,7 +822,58 @@ var en = {
816
822
  drawioExamples: "Drawio Examples",
817
823
  users: "Users",
818
824
  roles: "Roles",
819
- settings: "Settings"
825
+ settings: "Settings",
826
+ backgroundJobs: "Background Jobs"
827
+ },
828
+ backgroundJobs: {
829
+ title: "Background Jobs",
830
+ tabs: {
831
+ recurring: "Recurring",
832
+ succeeded: "Succeeded",
833
+ failed: "Failed",
834
+ processing: "Processing"
835
+ },
836
+ columns: {
837
+ id: "ID",
838
+ jobId: "Job ID",
839
+ jobName: "Job Name",
840
+ cron: "Cron",
841
+ queue: "Queue",
842
+ nextExecution: "Next Execution",
843
+ lastState: "Last State",
844
+ succeededAt: "Succeeded At",
845
+ failedAt: "Failed At",
846
+ startedAt: "Started At",
847
+ duration: "Duration (ms)",
848
+ exception: "Exception",
849
+ serverId: "Server ID",
850
+ actions: "Actions"
851
+ },
852
+ status: {
853
+ succeeded: "Succeeded",
854
+ failed: "Failed",
855
+ processing: "Processing",
856
+ scheduled: "Scheduled",
857
+ unknown: "Unknown"
858
+ },
859
+ actions: {
860
+ trigger: "Trigger Now",
861
+ delete: "Delete",
862
+ triggerSuccess: "Job triggered successfully",
863
+ deleteSuccess: "Job deleted successfully",
864
+ triggerError: "Failed to trigger job",
865
+ deleteError: "Failed to delete job"
866
+ },
867
+ drawer: {
868
+ title: "Job Details",
869
+ jobName: "Job Name",
870
+ createdAt: "Created At",
871
+ history: "History",
872
+ state: "State",
873
+ reason: "Reason",
874
+ data: "Data",
875
+ noData: "No Data"
876
+ }
820
877
  }
821
878
  };
822
879
  var zhTW = {
@@ -915,7 +972,58 @@ var zhTW = {
915
972
  drawioExamples: "Drawio \u7BC4\u4F8B",
916
973
  users: "\u4F7F\u7528\u8005",
917
974
  roles: "\u89D2\u8272",
918
- settings: "\u8A2D\u5B9A"
975
+ settings: "\u8A2D\u5B9A",
976
+ backgroundJobs: "\u80CC\u666F\u6392\u7A0B"
977
+ },
978
+ backgroundJobs: {
979
+ title: "\u80CC\u666F\u6392\u7A0B",
980
+ tabs: {
981
+ recurring: "\u9031\u671F\u6027\u4EFB\u52D9",
982
+ succeeded: "\u6210\u529F",
983
+ failed: "\u5931\u6557",
984
+ processing: "\u57F7\u884C\u4E2D"
985
+ },
986
+ columns: {
987
+ id: "ID",
988
+ jobId: "\u4EFB\u52D9 ID",
989
+ jobName: "\u4EFB\u52D9\u540D\u7A31",
990
+ cron: "\u6392\u7A0B\u8868\u9054\u5F0F",
991
+ queue: "\u4F47\u5217",
992
+ nextExecution: "\u4E0B\u6B21\u57F7\u884C",
993
+ lastState: "\u6700\u5F8C\u72C0\u614B",
994
+ succeededAt: "\u6210\u529F\u6642\u9593",
995
+ failedAt: "\u5931\u6557\u6642\u9593",
996
+ startedAt: "\u958B\u59CB\u6642\u9593",
997
+ duration: "\u8017\u6642 (\u6BEB\u79D2)",
998
+ exception: "\u4F8B\u5916",
999
+ serverId: "\u4F3A\u670D\u5668 ID",
1000
+ actions: "\u64CD\u4F5C"
1001
+ },
1002
+ status: {
1003
+ succeeded: "\u6210\u529F",
1004
+ failed: "\u5931\u6557",
1005
+ processing: "\u57F7\u884C\u4E2D",
1006
+ scheduled: "\u5DF2\u6392\u7A0B",
1007
+ unknown: "\u672A\u77E5"
1008
+ },
1009
+ actions: {
1010
+ trigger: "\u7ACB\u5373\u57F7\u884C",
1011
+ delete: "\u522A\u9664",
1012
+ triggerSuccess: "\u4EFB\u52D9\u5DF2\u6210\u529F\u89F8\u767C",
1013
+ deleteSuccess: "\u4EFB\u52D9\u5DF2\u6210\u529F\u522A\u9664",
1014
+ triggerError: "\u89F8\u767C\u4EFB\u52D9\u5931\u6557",
1015
+ deleteError: "\u522A\u9664\u4EFB\u52D9\u5931\u6557"
1016
+ },
1017
+ drawer: {
1018
+ title: "\u4EFB\u52D9\u8A73\u60C5",
1019
+ jobName: "\u4EFB\u52D9\u540D\u7A31",
1020
+ createdAt: "\u5EFA\u7ACB\u6642\u9593",
1021
+ history: "\u6B77\u53F2\u7D00\u9304",
1022
+ state: "\u72C0\u614B",
1023
+ reason: "\u539F\u56E0",
1024
+ data: "\u8CC7\u6599",
1025
+ noData: "\u7121\u8CC7\u6599"
1026
+ }
919
1027
  }
920
1028
  };
921
1029
  var refineXafTranslations = {
@@ -5181,8 +5289,8 @@ var StepResult = class _StepResult {
5181
5289
  /**
5182
5290
  Create a failed step result.
5183
5291
  */
5184
- static fail(message2) {
5185
- return new _StepResult(null, message2);
5292
+ static fail(message3) {
5293
+ return new _StepResult(null, message3);
5186
5294
  }
5187
5295
  /**
5188
5296
  Call [`Node.replace`](https://prosemirror.net/docs/ref/#model.Node.replace) with the given
@@ -6394,8 +6502,8 @@ var DocAttrStep = class _DocAttrStep extends Step {
6394
6502
  Step.jsonID("docAttr", DocAttrStep);
6395
6503
  var TransformError = class extends Error {
6396
6504
  };
6397
- TransformError = function TransformError2(message2) {
6398
- let err = Error.call(this, message2);
6505
+ TransformError = function TransformError2(message3) {
6506
+ let err = Error.call(this, message3);
6399
6507
  err.__proto__ = TransformError2.prototype;
6400
6508
  return err;
6401
6509
  };
@@ -19711,7 +19819,7 @@ import React13 from "react";
19711
19819
  import { Edit, useForm as useForm2, useSelect } from "@refinedev/antd";
19712
19820
  import { Form as Form7, Input as Input7, Checkbox as Checkbox5, Select, App } from "antd/lib";
19713
19821
  var ApplicationUserEdit = () => {
19714
- const { message: message2 } = App.useApp();
19822
+ const { message: message3 } = App.useApp();
19715
19823
  const { formProps, saveButtonProps, id, form } = useForm2({
19716
19824
  meta: {
19717
19825
  expand: ["Roles"]
@@ -19732,12 +19840,12 @@ var ApplicationUserEdit = () => {
19732
19840
  })
19733
19841
  });
19734
19842
  if (response.ok) {
19735
- message2.success("Roles updated successfully");
19843
+ message3.success("Roles updated successfully");
19736
19844
  } else {
19737
- message2.error("Failed to update roles");
19845
+ message3.error("Failed to update roles");
19738
19846
  }
19739
19847
  } catch (e) {
19740
- message2.error("Error updating roles");
19848
+ message3.error("Error updating roles");
19741
19849
  }
19742
19850
  }
19743
19851
  });
@@ -20083,11 +20191,361 @@ var RoleEdit = () => {
20083
20191
  )
20084
20192
  ));
20085
20193
  };
20194
+
20195
+ // src/pages/background-jobs/list.tsx
20196
+ import React18, { useState as useState7, useEffect as useEffect6, useCallback } from "react";
20197
+ import { useApiUrl, useTranslate as useTranslate3 } from "@refinedev/core";
20198
+ import { List as List3 } from "@refinedev/antd";
20199
+ import { Table as Table7, Button as Button8, Space as Space8, Tag, Card as Card3, Statistic, Row, Col, message as message2, Tooltip as Tooltip2, Tabs, Drawer, Descriptions, Timeline, Skeleton } from "antd";
20200
+ import {
20201
+ ReloadOutlined as ReloadOutlined2,
20202
+ PlayCircleOutlined,
20203
+ DeleteOutlined as DeleteOutlined2,
20204
+ CheckCircleOutlined,
20205
+ CloseCircleOutlined,
20206
+ SyncOutlined,
20207
+ ClockCircleOutlined
20208
+ } from "@ant-design/icons";
20209
+ var BackgroundJobList = ({
20210
+ title,
20211
+ apiUrl: customApiUrl
20212
+ }) => {
20213
+ const t = useTranslate3();
20214
+ const defaultApiUrl = useApiUrl();
20215
+ const apiUrl = customApiUrl || defaultApiUrl?.replace("/odata", "");
20216
+ const [refreshKey, setRefreshKey] = useState7(0);
20217
+ const [activeTab, setActiveTab] = useState7("recurring");
20218
+ const [loading, setLoading] = useState7(false);
20219
+ const [recurringJobs, setRecurringJobs] = useState7([]);
20220
+ const [succeededResult, setSucceededResult] = useState7(null);
20221
+ const [failedResult, setFailedResult] = useState7(null);
20222
+ const [processingResult, setProcessingResult] = useState7(null);
20223
+ const [drawerVisible, setDrawerVisible] = useState7(false);
20224
+ const [jobDetails, setJobDetails] = useState7(null);
20225
+ const [detailLoading, setDetailLoading] = useState7(false);
20226
+ const fetchData = useCallback(async () => {
20227
+ setLoading(true);
20228
+ const token = localStorage.getItem("refine-auth") || localStorage.getItem("access_token");
20229
+ const headers = token ? { "Authorization": `Bearer ${token}` } : {};
20230
+ try {
20231
+ const [recurringRes, succeededRes, failedRes, processingRes] = await Promise.all([
20232
+ fetch(`${apiUrl}/hangfire/recurring`, { headers }),
20233
+ fetch(`${apiUrl}/hangfire/jobs/succeeded`, { headers }),
20234
+ fetch(`${apiUrl}/hangfire/jobs/failed`, { headers }),
20235
+ fetch(`${apiUrl}/hangfire/jobs/processing`, { headers })
20236
+ ]);
20237
+ if (recurringRes.ok) {
20238
+ const data = await recurringRes.json();
20239
+ setRecurringJobs(data.value || data || []);
20240
+ }
20241
+ if (succeededRes.ok) {
20242
+ setSucceededResult(await succeededRes.json());
20243
+ }
20244
+ if (failedRes.ok) {
20245
+ setFailedResult(await failedRes.json());
20246
+ }
20247
+ if (processingRes.ok) {
20248
+ setProcessingResult(await processingRes.json());
20249
+ }
20250
+ } catch (error) {
20251
+ console.error("Failed to fetch Hangfire data:", error);
20252
+ } finally {
20253
+ setLoading(false);
20254
+ }
20255
+ }, [apiUrl]);
20256
+ useEffect6(() => {
20257
+ fetchData();
20258
+ }, [fetchData, refreshKey]);
20259
+ const handleRefresh = () => {
20260
+ setRefreshKey((prev) => prev + 1);
20261
+ };
20262
+ const handleTrigger = async (jobId) => {
20263
+ try {
20264
+ const token = localStorage.getItem("refine-auth") || localStorage.getItem("access_token");
20265
+ const headers = token ? { "Authorization": `Bearer ${token}` } : {};
20266
+ const response = await fetch(`${apiUrl}/hangfire/trigger/${jobId}`, {
20267
+ method: "POST",
20268
+ headers
20269
+ });
20270
+ if (response.ok) {
20271
+ message2.success(t("backgroundJobs.actions.triggerSuccess"));
20272
+ handleRefresh();
20273
+ } else {
20274
+ message2.error(t("backgroundJobs.actions.triggerError"));
20275
+ }
20276
+ } catch {
20277
+ message2.error(t("backgroundJobs.actions.triggerError"));
20278
+ }
20279
+ };
20280
+ const handleDelete = async (jobId) => {
20281
+ try {
20282
+ const token = localStorage.getItem("refine-auth") || localStorage.getItem("access_token");
20283
+ const headers = token ? { "Authorization": `Bearer ${token}` } : {};
20284
+ const response = await fetch(`${apiUrl}/hangfire/recurring/${jobId}`, {
20285
+ method: "DELETE",
20286
+ headers
20287
+ });
20288
+ if (response.ok) {
20289
+ message2.success(t("backgroundJobs.actions.deleteSuccess"));
20290
+ handleRefresh();
20291
+ } else {
20292
+ message2.error(t("backgroundJobs.actions.deleteError"));
20293
+ }
20294
+ } catch {
20295
+ message2.error(t("backgroundJobs.actions.deleteError"));
20296
+ }
20297
+ };
20298
+ const showDetails = async (jobId) => {
20299
+ setDrawerVisible(true);
20300
+ setDetailLoading(true);
20301
+ setJobDetails(null);
20302
+ try {
20303
+ const token = localStorage.getItem("refine-auth") || localStorage.getItem("access_token");
20304
+ const headers = token ? { "Authorization": `Bearer ${token}` } : {};
20305
+ const res = await fetch(`${apiUrl}/hangfire/jobs/${jobId}`, { headers });
20306
+ if (res.ok) {
20307
+ const data = await res.json();
20308
+ setJobDetails(data);
20309
+ } else {
20310
+ message2.error("Failed to load details");
20311
+ }
20312
+ } catch {
20313
+ message2.error("Failed to load details");
20314
+ } finally {
20315
+ setDetailLoading(false);
20316
+ }
20317
+ };
20318
+ const closeDrawer = () => {
20319
+ setDrawerVisible(false);
20320
+ setJobDetails(null);
20321
+ };
20322
+ const getStateTag = (state) => {
20323
+ if (!state) return /* @__PURE__ */ React18.createElement(Tag, null, t("backgroundJobs.status.unknown"));
20324
+ switch (state.toLowerCase()) {
20325
+ case "succeeded":
20326
+ return /* @__PURE__ */ React18.createElement(Tag, { icon: /* @__PURE__ */ React18.createElement(CheckCircleOutlined, null), color: "success" }, t("backgroundJobs.status.succeeded"));
20327
+ case "failed":
20328
+ return /* @__PURE__ */ React18.createElement(Tag, { icon: /* @__PURE__ */ React18.createElement(CloseCircleOutlined, null), color: "error" }, t("backgroundJobs.status.failed"));
20329
+ case "processing":
20330
+ return /* @__PURE__ */ React18.createElement(Tag, { icon: /* @__PURE__ */ React18.createElement(SyncOutlined, { spin: true }), color: "processing" }, t("backgroundJobs.status.processing"));
20331
+ case "scheduled":
20332
+ return /* @__PURE__ */ React18.createElement(Tag, { icon: /* @__PURE__ */ React18.createElement(ClockCircleOutlined, null), color: "warning" }, t("backgroundJobs.status.scheduled"));
20333
+ default:
20334
+ return /* @__PURE__ */ React18.createElement(Tag, null, state);
20335
+ }
20336
+ };
20337
+ const recurringColumns = [
20338
+ { title: t("backgroundJobs.columns.id"), dataIndex: "Id", key: "Id" },
20339
+ {
20340
+ title: t("backgroundJobs.columns.cron"),
20341
+ dataIndex: "Cron",
20342
+ key: "Cron",
20343
+ render: (cron) => /* @__PURE__ */ React18.createElement(Tag, { color: "blue" }, cron)
20344
+ },
20345
+ { title: t("backgroundJobs.columns.queue"), dataIndex: "Queue", key: "Queue" },
20346
+ {
20347
+ title: t("backgroundJobs.columns.nextExecution"),
20348
+ dataIndex: "NextExecution",
20349
+ key: "NextExecution",
20350
+ render: (date) => date ? new Date(date).toLocaleString() : "-"
20351
+ },
20352
+ {
20353
+ title: t("backgroundJobs.columns.lastState"),
20354
+ dataIndex: "LastJobState",
20355
+ key: "LastJobState",
20356
+ render: (state) => getStateTag(state)
20357
+ },
20358
+ {
20359
+ title: t("backgroundJobs.columns.actions"),
20360
+ key: "actions",
20361
+ render: (_, record) => /* @__PURE__ */ React18.createElement(Space8, null, /* @__PURE__ */ React18.createElement(Tooltip2, { title: t("backgroundJobs.actions.trigger") }, /* @__PURE__ */ React18.createElement(
20362
+ Button8,
20363
+ {
20364
+ type: "primary",
20365
+ icon: /* @__PURE__ */ React18.createElement(PlayCircleOutlined, null),
20366
+ size: "small",
20367
+ onClick: () => handleTrigger(record.Id)
20368
+ }
20369
+ )), /* @__PURE__ */ React18.createElement(Tooltip2, { title: t("backgroundJobs.actions.delete") }, /* @__PURE__ */ React18.createElement(
20370
+ Button8,
20371
+ {
20372
+ danger: true,
20373
+ icon: /* @__PURE__ */ React18.createElement(DeleteOutlined2, null),
20374
+ size: "small",
20375
+ onClick: () => handleDelete(record.Id)
20376
+ }
20377
+ )))
20378
+ }
20379
+ ];
20380
+ const succeededColumns = [
20381
+ {
20382
+ title: t("backgroundJobs.columns.jobId"),
20383
+ dataIndex: "JobId",
20384
+ key: "JobId",
20385
+ render: (text) => /* @__PURE__ */ React18.createElement("a", { onClick: () => showDetails(text) }, text)
20386
+ },
20387
+ { title: t("backgroundJobs.columns.jobName"), dataIndex: "JobName", key: "JobName" },
20388
+ {
20389
+ title: t("backgroundJobs.columns.succeededAt"),
20390
+ dataIndex: "SucceededAt",
20391
+ key: "SucceededAt",
20392
+ render: (date) => date ? new Date(date).toLocaleString() : "-"
20393
+ },
20394
+ { title: t("backgroundJobs.columns.duration"), dataIndex: "TotalDuration", key: "TotalDuration" }
20395
+ ];
20396
+ const failedColumns = [
20397
+ {
20398
+ title: t("backgroundJobs.columns.jobId"),
20399
+ dataIndex: "JobId",
20400
+ key: "JobId",
20401
+ render: (text) => /* @__PURE__ */ React18.createElement("a", { onClick: () => showDetails(text) }, text)
20402
+ },
20403
+ { title: t("backgroundJobs.columns.jobName"), dataIndex: "JobName", key: "JobName" },
20404
+ {
20405
+ title: t("backgroundJobs.columns.failedAt"),
20406
+ dataIndex: "FailedAt",
20407
+ key: "FailedAt",
20408
+ render: (date) => date ? new Date(date).toLocaleString() : "-"
20409
+ },
20410
+ {
20411
+ title: t("backgroundJobs.columns.exception"),
20412
+ dataIndex: "ExceptionMessage",
20413
+ key: "ExceptionMessage",
20414
+ render: (msg) => /* @__PURE__ */ React18.createElement(Tooltip2, { title: msg }, /* @__PURE__ */ React18.createElement("span", null, msg?.substring(0, 50), msg && msg.length > 50 ? "..." : ""))
20415
+ }
20416
+ ];
20417
+ const processingColumns = [
20418
+ {
20419
+ title: t("backgroundJobs.columns.jobId"),
20420
+ dataIndex: "JobId",
20421
+ key: "JobId",
20422
+ render: (text) => /* @__PURE__ */ React18.createElement("a", { onClick: () => showDetails(text) }, text)
20423
+ },
20424
+ { title: t("backgroundJobs.columns.jobName"), dataIndex: "JobName", key: "JobName" },
20425
+ {
20426
+ title: t("backgroundJobs.columns.startedAt"),
20427
+ dataIndex: "StartedAt",
20428
+ key: "StartedAt",
20429
+ render: (date) => date ? new Date(date).toLocaleString() : "-"
20430
+ },
20431
+ { title: t("backgroundJobs.columns.serverId"), dataIndex: "ServerId", key: "ServerId" }
20432
+ ];
20433
+ const items = [
20434
+ {
20435
+ key: "recurring",
20436
+ label: `${t("backgroundJobs.tabs.recurring")} (${recurringJobs.length})`,
20437
+ children: /* @__PURE__ */ React18.createElement(
20438
+ Table7,
20439
+ {
20440
+ dataSource: recurringJobs,
20441
+ columns: recurringColumns,
20442
+ rowKey: "Id",
20443
+ loading,
20444
+ pagination: false
20445
+ }
20446
+ )
20447
+ },
20448
+ {
20449
+ key: "succeeded",
20450
+ label: /* @__PURE__ */ React18.createElement("span", null, /* @__PURE__ */ React18.createElement(CheckCircleOutlined, { style: { color: "#52c41a" } }), " ", t("backgroundJobs.tabs.succeeded"), " (", succeededResult?.Total || 0, ")"),
20451
+ children: /* @__PURE__ */ React18.createElement(
20452
+ Table7,
20453
+ {
20454
+ dataSource: succeededResult?.Jobs || [],
20455
+ columns: succeededColumns,
20456
+ rowKey: "JobId",
20457
+ loading,
20458
+ pagination: { pageSize: 10 }
20459
+ }
20460
+ )
20461
+ },
20462
+ {
20463
+ key: "failed",
20464
+ label: /* @__PURE__ */ React18.createElement("span", null, /* @__PURE__ */ React18.createElement(CloseCircleOutlined, { style: { color: "#ff4d4f" } }), " ", t("backgroundJobs.tabs.failed"), " (", failedResult?.Total || 0, ")"),
20465
+ children: /* @__PURE__ */ React18.createElement(
20466
+ Table7,
20467
+ {
20468
+ dataSource: failedResult?.Jobs || [],
20469
+ columns: failedColumns,
20470
+ rowKey: "JobId",
20471
+ loading,
20472
+ pagination: { pageSize: 10 }
20473
+ }
20474
+ )
20475
+ },
20476
+ {
20477
+ key: "processing",
20478
+ label: /* @__PURE__ */ React18.createElement("span", null, /* @__PURE__ */ React18.createElement(SyncOutlined, { spin: true, style: { color: "#1890ff" } }), " ", t("backgroundJobs.tabs.processing"), " (", processingResult?.Total || 0, ")"),
20479
+ children: /* @__PURE__ */ React18.createElement(
20480
+ Table7,
20481
+ {
20482
+ dataSource: processingResult?.Jobs || [],
20483
+ columns: processingColumns,
20484
+ rowKey: "JobId",
20485
+ loading,
20486
+ pagination: false
20487
+ }
20488
+ )
20489
+ }
20490
+ ];
20491
+ return /* @__PURE__ */ React18.createElement(
20492
+ List3,
20493
+ {
20494
+ title: title || t("backgroundJobs.title"),
20495
+ headerButtons: /* @__PURE__ */ React18.createElement(Button8, { icon: /* @__PURE__ */ React18.createElement(ReloadOutlined2, null), onClick: handleRefresh, loading }, t("buttons.refresh"))
20496
+ },
20497
+ /* @__PURE__ */ React18.createElement(Row, { gutter: 16, style: { marginBottom: 16 } }, /* @__PURE__ */ React18.createElement(Col, { span: 6 }, /* @__PURE__ */ React18.createElement(Card3, null, /* @__PURE__ */ React18.createElement(
20498
+ Statistic,
20499
+ {
20500
+ title: t("backgroundJobs.tabs.recurring"),
20501
+ value: recurringJobs.length,
20502
+ prefix: /* @__PURE__ */ React18.createElement(ClockCircleOutlined, null)
20503
+ }
20504
+ ))), /* @__PURE__ */ React18.createElement(Col, { span: 6 }, /* @__PURE__ */ React18.createElement(Card3, null, /* @__PURE__ */ React18.createElement(
20505
+ Statistic,
20506
+ {
20507
+ title: t("backgroundJobs.tabs.succeeded"),
20508
+ value: succeededResult?.Total || 0,
20509
+ valueStyle: { color: "#3f8600" },
20510
+ prefix: /* @__PURE__ */ React18.createElement(CheckCircleOutlined, null)
20511
+ }
20512
+ ))), /* @__PURE__ */ React18.createElement(Col, { span: 6 }, /* @__PURE__ */ React18.createElement(Card3, null, /* @__PURE__ */ React18.createElement(
20513
+ Statistic,
20514
+ {
20515
+ title: t("backgroundJobs.tabs.failed"),
20516
+ value: failedResult?.Total || 0,
20517
+ valueStyle: { color: "#cf1322" },
20518
+ prefix: /* @__PURE__ */ React18.createElement(CloseCircleOutlined, null)
20519
+ }
20520
+ ))), /* @__PURE__ */ React18.createElement(Col, { span: 6 }, /* @__PURE__ */ React18.createElement(Card3, null, /* @__PURE__ */ React18.createElement(
20521
+ Statistic,
20522
+ {
20523
+ title: t("backgroundJobs.tabs.processing"),
20524
+ value: processingResult?.Total || 0,
20525
+ valueStyle: { color: "#1890ff" },
20526
+ prefix: /* @__PURE__ */ React18.createElement(SyncOutlined, null)
20527
+ }
20528
+ )))),
20529
+ /* @__PURE__ */ React18.createElement(Tabs, { activeKey: activeTab, onChange: setActiveTab, items }),
20530
+ /* @__PURE__ */ React18.createElement(
20531
+ Drawer,
20532
+ {
20533
+ title: t("backgroundJobs.drawer.title"),
20534
+ placement: "right",
20535
+ onClose: closeDrawer,
20536
+ open: drawerVisible,
20537
+ width: 600
20538
+ },
20539
+ detailLoading ? /* @__PURE__ */ React18.createElement(Skeleton, { active: true }) : jobDetails ? /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(Descriptions, { column: 1, bordered: true, size: "small" }, /* @__PURE__ */ React18.createElement(Descriptions.Item, { label: t("backgroundJobs.drawer.jobName") }, jobDetails.JobName), /* @__PURE__ */ React18.createElement(Descriptions.Item, { label: t("backgroundJobs.drawer.createdAt") }, jobDetails.CreatedAt ? new Date(jobDetails.CreatedAt).toLocaleString() : "-")), /* @__PURE__ */ React18.createElement("div", { style: { marginTop: 24 } }, /* @__PURE__ */ React18.createElement("h3", null, t("backgroundJobs.drawer.history")), /* @__PURE__ */ React18.createElement(Timeline, { mode: "left" }, jobDetails.History.map((h, i) => /* @__PURE__ */ React18.createElement(Timeline.Item, { key: i, color: h.StateName === "Succeeded" ? "green" : h.StateName === "Failed" ? "red" : "blue" }, /* @__PURE__ */ React18.createElement("p", null, /* @__PURE__ */ React18.createElement("strong", null, h.StateName), " - ", new Date(h.CreatedAt).toLocaleString()), h.Reason && /* @__PURE__ */ React18.createElement("p", null, t("backgroundJobs.drawer.reason"), ": ", h.Reason), h.Data && Object.keys(h.Data).length > 0 && /* @__PURE__ */ React18.createElement("div", { style: { background: "#f5f5f5", padding: 8, borderRadius: 4, overflowX: "auto", marginTop: 8 } }, /* @__PURE__ */ React18.createElement("pre", { style: { margin: 0, fontSize: 12 } }, JSON.stringify(h.Data, null, 2)))))))) : /* @__PURE__ */ React18.createElement("div", null, t("backgroundJobs.drawer.noData"))
20540
+ )
20541
+ );
20542
+ };
20086
20543
  export {
20087
20544
  ApplicationUserCreate,
20088
20545
  ApplicationUserEdit,
20089
20546
  ApplicationUserList,
20090
20547
  AuthCallback,
20548
+ BackgroundJobList,
20091
20549
  Base64Upload,
20092
20550
  ColorModeContext,
20093
20551
  ColorModeContextProvider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cundi/refine-xaf",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Integration SDK for XAF backend and Refine frontend",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -8,6 +8,7 @@
8
8
  "scripts": {
9
9
  "build": "tsup",
10
10
  "dev": "tsup --watch",
11
+ "pack": "npm run build && npm pack --pack-destination ../../output/npm",
11
12
  "test": "jest",
12
13
  "test:watch": "jest --watch",
13
14
  "test:coverage": "jest --coverage",