UNPKG

n8n-editor-ui

Version:

Workflow Editor UI for n8n

202 lines (201 loc) 9.69 kB
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/InsightsPaywall-Cgjhc58I.js","assets/_plugin-vue_export-helper-BwBpWJRZ.js","assets/src-DgvumQTi.js","assets/preload-helper-CR0ecmWK.js","assets/truncate-B1HVeveJ.js","assets/_MapCache-ficiegRb.js","assets/vue.runtime.esm-bundler-tP5dCd7J.js","assets/chunk-6z4oVpB-.js","assets/CalendarDate-zWqgZMlk.js","assets/sanitize-html-Cc45ZKm8.js","assets/empty-BuGRxzl4.js","assets/path-browserify-BtCDmZ3_.js","assets/en-CF30SCh2.js","assets/src-CMoPZtHv.css","assets/constants-BbpucWL4.js","assets/merge-k8vSyyXH.js","assets/builder.store-sBTWwxRU.js","assets/_baseOrderBy-B_6CV8x6.js","assets/dateformat-CM9k0--B.js","assets/useDebounce-Bnb8W2LR.js","assets/versions.store-BwdT833-.js","assets/usePageRedirectionHelper-fGNB6ZKK.js","assets/InsightsPaywall-CE5W3W4m.css"])))=>i.map(i=>d[i]); import { C as computed, Cn as toDisplayString, D as createElementBlock, Gt as unref, I as guardReactiveProps, It as ref, M as createVNode, N as defineAsyncComponent, P as defineComponent, T as createBlock, U as mergeModels, _ as Fragment, _t as watch, bt as withCtx, ct as resolveDynamicComponent, et as openBlock, ft as useModel, j as createTextVNode, k as createSlots, vn as normalizeClass, w as createBaseVNode, yn as normalizeProps } from "./vue.runtime.esm-bundler-tP5dCd7J.js"; import { _t as useI18n } from "./_MapCache-ficiegRb.js"; import { ht as N8nTooltip_default, u as N8nDataTableServer_default, yn as N8nHeading_default } from "./src-DgvumQTi.js"; import "./en-CF30SCh2.js"; import { t as __vitePreload } from "./preload-helper-CR0ecmWK.js"; import { t as __plugin_vue_export_helper_default } from "./_plugin-vue_export-helper-BwBpWJRZ.js"; import { f as RouterLink } from "./truncate-B1HVeveJ.js"; import { O as useTelemetry } from "./builder.store-sBTWwxRU.js"; import "./empty-BuGRxzl4.js"; import "./sanitize-html-Cc45ZKm8.js"; import "./CalendarDate-zWqgZMlk.js"; import "./path-browserify-BtCDmZ3_.js"; import { Ro as VIEWS } from "./constants-BbpucWL4.js"; import "./merge-k8vSyyXH.js"; import "./_baseOrderBy-B_6CV8x6.js"; import "./dateformat-CM9k0--B.js"; import "./useDebounce-Bnb8W2LR.js"; import { a as INSIGHTS_UNIT_MAPPING } from "./insights.constants-C8GITe6H.js"; import { a as transformInsightsAverageRunTime, c as transformInsightsTimeSaved, o as transformInsightsFailureRate } from "./insights.utils-B7OXsqrQ.js"; import { t as smartDecimal } from "./smartDecimal-DK6-_VSq.js"; var InsightsTableWorkflows_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({ __name: "InsightsTableWorkflows", props: /* @__PURE__ */ mergeModels({ data: {}, loading: { type: Boolean }, isDashboardEnabled: { type: Boolean } }, { "sortBy": {}, "sortByModifiers": {} }), emits: /* @__PURE__ */ mergeModels(["update:options"], ["update:sortBy"]), setup(__props, { emit: __emit }) { const InsightsPaywall = defineAsyncComponent(async () => await __vitePreload(() => import("./InsightsPaywall-Cgjhc58I.js"), __vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))); const props = __props; const i18n = useI18n(); const telemetry = useTelemetry(); const sampleWorkflows = Array.from({ length: 10 }, (_, i) => ({ workflowId: `sample-workflow-${i + 1}`, workflowName: `Sample Workflow ${i + 1}`, total: Math.floor(Math.random() * 2e3) + 500, failed: Math.floor(Math.random() * 100) + 20, failureRate: Math.random() * 100, timeSaved: Math.floor(Math.random() * 3e5) + 6e4, averageRunTime: Math.floor(Math.random() * 6e4) + 15e3, projectName: `Sample Project ${i + 1}`, projectId: `sample-project-${i + 1}`, succeeded: Math.floor(Math.random() * 2e3) + 500, runTime: Math.floor(Math.random() * 6e4) + 15e3 })); const sampleData = { data: sampleWorkflows, count: sampleWorkflows.length }; const tableData = computed(() => props.isDashboardEnabled ? props.data : sampleData); const rows = computed(() => tableData.value.data); const headers = ref([ { title: "Name", key: "workflowName", width: 400, disableSort: !props.isDashboardEnabled }, { title: i18n.baseText("insights.banner.title.total"), key: "total", value(row) { return row.total.toLocaleString("en-US"); }, disableSort: !props.isDashboardEnabled }, { title: i18n.baseText("insights.banner.title.failed"), key: "failed", value(row) { return row.failed.toLocaleString("en-US"); }, disableSort: !props.isDashboardEnabled }, { title: i18n.baseText("insights.banner.title.failureRate"), key: "failureRate", value(row) { return smartDecimal(transformInsightsFailureRate(row.failureRate)) + INSIGHTS_UNIT_MAPPING.failureRate(row.failureRate); }, disableSort: !props.isDashboardEnabled }, { title: i18n.baseText("insights.banner.title.timeSaved"), key: "timeSaved", value(row) { return smartDecimal(transformInsightsTimeSaved(row.timeSaved)) + INSIGHTS_UNIT_MAPPING.timeSaved(row.timeSaved); }, disableSort: !props.isDashboardEnabled }, { title: i18n.baseText("insights.banner.title.averageRunTime"), key: "averageRunTime", value(row) { return smartDecimal(transformInsightsAverageRunTime(row.averageRunTime)) + INSIGHTS_UNIT_MAPPING.averageRunTime(row.averageRunTime); }, disableSort: !props.isDashboardEnabled }, { title: i18n.baseText("insights.dashboard.table.projectName"), key: "projectName", disableSort: true } ]); const sortBy = useModel(__props, "sortBy"); const currentPage = ref(0); const itemsPerPage = ref(25); const emit = __emit; const getWorkflowLink = (item, query) => ({ name: VIEWS.WORKFLOW, params: { name: item.workflowId }, query }); const trackWorkflowClick = (item) => { telemetry.track("User clicked on workflow from insights table", { workflow_id: item.workflowId }); }; watch(sortBy, (newValue) => { telemetry.track("User sorted insights table", { sorted_by: (newValue ?? []).map((item) => ({ ...item, label: headers.value.find((header) => header.key === item.id)?.title })) }); }); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", null, [createVNode(unref(N8nHeading_default), { bold: "", tag: "h3", size: "medium", class: "mb-s" }, { default: withCtx(() => [createTextVNode(toDisplayString(unref(i18n).baseText("insights.dashboard.table.title")), 1)]), _: 1 }), createVNode(unref(N8nDataTableServer_default), { "sort-by": sortBy.value, "onUpdate:sortBy": _cache[0] || (_cache[0] = ($event) => sortBy.value = $event), page: currentPage.value, "onUpdate:page": _cache[1] || (_cache[1] = ($event) => currentPage.value = $event), "items-per-page": itemsPerPage.value, "onUpdate:itemsPerPage": _cache[2] || (_cache[2] = ($event) => itemsPerPage.value = $event), items: rows.value, headers: headers.value, "items-length": tableData.value.count, "onUpdate:options": _cache[3] || (_cache[3] = ($event) => emit("update:options", $event)) }, createSlots({ [`item.workflowName`]: withCtx(({ item }) => [(openBlock(), createBlock(resolveDynamicComponent(item.workflowId ? unref(RouterLink) : "div"), normalizeProps(guardReactiveProps(item.workflowId ? { to: getWorkflowLink(item), class: _ctx.$style.link, onClick: () => trackWorkflowClick(item) } : {})), { default: withCtx(() => [createVNode(unref(N8nTooltip_default), { content: item.workflowName, placement: "top" }, { default: withCtx(() => [createBaseVNode("div", { class: normalizeClass(_ctx.$style.ellipsis) }, toDisplayString(item.workflowName), 3)]), _: 2 }, 1032, ["content"])]), _: 2 }, 1040))]), [`item.timeSaved`]: withCtx(({ item, value }) => [!item.timeSaved && item.workflowId ? (openBlock(), createBlock(unref(RouterLink), { key: 0, to: getWorkflowLink(item, { settings: "true" }), class: normalizeClass(_ctx.$style.link) }, { default: withCtx(() => [createTextVNode(toDisplayString(unref(i18n).baseText("insights.dashboard.table.estimate")), 1)]), _: 2 }, 1032, ["to", "class"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(value), 1)], 64))]), [`item.projectName`]: withCtx(({ item }) => [item.projectName ? (openBlock(), createBlock(unref(N8nTooltip_default), { key: 0, content: item.projectName, placement: "top" }, { default: withCtx(() => [createBaseVNode("div", { class: normalizeClass(_ctx.$style.ellipsis) }, toDisplayString(item.projectName), 3)]), _: 2 }, 1032, ["content"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(" - ")], 64))]), _: 2 }, [!_ctx.isDashboardEnabled ? { name: "cover", fn: withCtx(() => [createBaseVNode("div", { class: normalizeClass(_ctx.$style.blurryCover) }, [createVNode(unref(InsightsPaywall))], 2)]), key: "0" } : void 0]), 1032, [ "sort-by", "page", "items-per-page", "items", "headers", "items-length" ])]); }; } }); var InsightsTableWorkflows_vue_vue_type_style_index_0_lang_module_default = { ellipsis: "_ellipsis_z0cff_123", link: "_link_z0cff_132", blurryCover: "_blurryCover_z0cff_144" }; var InsightsTableWorkflows_default = /* @__PURE__ */ __plugin_vue_export_helper_default(InsightsTableWorkflows_vue_vue_type_script_setup_true_lang_default, [["__cssModules", { "$style": InsightsTableWorkflows_vue_vue_type_style_index_0_lang_module_default }]]); export { InsightsTableWorkflows_default as default };