diff --git a/public/assets/pages/adminpage/ctrl_workflow.css b/public/assets/pages/adminpage/ctrl_workflow.css
index 4c089923..2601d235 100644
--- a/public/assets/pages/adminpage/ctrl_workflow.css
+++ b/public/assets/pages/adminpage/ctrl_workflow.css
@@ -1,6 +1,11 @@
.component_page_workflow .pull-right {
float: right;
}
+.component_page_workflow button {
+ font-size: 0.9rem;
+ padding: 3px 5px;
+ margin: 0 2px;
+}
.component_page_workflow .box {
display: block;
background: white;
@@ -11,7 +16,7 @@
padding: 15px;
overflow: visible;
}
-.component_page_workflow .box.status-unpublished {
+.component_page_workflow .box.disabled {
background: var(--border);
}
.component_page_workflow .box h3 {
@@ -24,26 +29,14 @@
font-style: italic;
color: var(--light);
}
-.component_page_workflow button {
- font-size: 0.9rem;
- padding: 3px 5px;
- margin: 0 2px;
-}
.component_page_workflow .box svg {
float: left;
width: 25px;
- margin-right: 10px;
fill: var(--light);
}
-.component_page_workflow button.box {
- padding: 5px 10px;
- background: var(--light);
- color: var(--bg-color);
-}
.component_page_workflow .box .workflow-summary button {
color: var(--light);
}
-
.component_page_workflow hr {
border: none;
height: 30px;
@@ -53,13 +46,162 @@
.component_page_workflow hr:after {
content: " ";
position: absolute;
- left: 20px;
+ left: 26px;
top: 0;
bottom: 0;
- border-right: 4px dashed rgba(0, 0, 0, 0.15);
+ border-right: 4px dashed rgba(0, 0, 0, 0.2);
border-right-style: dotted;
}
-
-.component_page_admin .page_container a:hover {
- opacity: 1;
+.component_page_workflow .box [data-bind="form"] {
+ overflow: hidden;
+}
+.component_page_workflow .box [data-bind="form"] .formbuilder {
+ padding: 10px;
+ border-radius: 5px;
+ margin-top: 10px;
+ border: 2px solid #ebebec;
+ background: transparent;
+}
+.component_page_workflow .box.disabled [data-bind="form"] .formbuilder {
+ border-color: var(--border);
+}
+.component_page_workflow .box [data-bind="form"] .formbuilder:empty {
+ display: none;
+}
+
+.component_page_workflow .box h3 button.pull-right {
+ padding: 0;
+ margin: 0;
+}
+
+/* details page buttons */
+.component_page_workflow .box button[alt="delete"] {
+ position: absolute;
+ top: -13px;
+ right: -13px;
+}
+.component_page_workflow .box button[alt="delete"] svg {
+ width: 10px;
+ height: 10px;
+ border: 2px solid var(--border);
+ background: #ebebec;
+ fill: var(--light);
+ padding: 5px;
+ border-radius: 15px;
+}
+
+/* Workflow creation modal */
+.component_workflow_create {
+ font-size: 1rem;
+}
+.component_workflow_create h2 {
+ margin: 0 0 5px 0;
+ font-size: 1.1rem;
+ color: var(--light);
+}
+.component_workflow_create form {
+ margin-bottom: 15px;
+}
+.component_workflow_create form input {
+ font-size: 1rem;
+ border: 2px solid var(--border);
+ border-radius: 5px;
+ padding: 5px 10px;
+ color: rgba(0,0,0,0.75);
+ width: 100%;
+ display: block;
+ box-sizing: border-box;
+ margin-bottom: 5px;
+}
+.component_workflow_create form input::placeholder {
+ color: rgba(0,0,0,0.4);
+}
+.component_workflow_create [data-bind="list"] {
+ overflow: hidden;
+}
+.component_workflow_create [data-bind="list"] .item {
+ color: var(--color);
+ background: #f2f2f2;
+ transition: all 0.1s ease;
+ padding: 5px 5px 5px 12px;
+ border-radius: 5px;
+ cursor: pointer;
+ letter-spacing: -0.5px;
+ margin-top: 2px;
+ align-items: center;
+}
+.component_workflow_create [data-bind="list"] .item svg {
+ height: 20px;
+ margin-right: 5px;
+ fill: var(--light);
+}
+
+/* save button */
+.workflow-fab {
+ position: fixed;
+ bottom: 20px;
+ right: 20px;
+ background: var(--emphasis);
+ border-radius: 10px;
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
+ cursor: pointer;
+}
+.workflow-fab select {
+ background: var(--emphasis);
+ color: var(--bg-color);
+ font-family: monospace;
+ border: none;
+ padding-left: 10px;
+ padding-right: 5px;
+ text-align: right;
+ border-top-left-radius: 2px;
+ border-bottom-left-radius: 10px;
+ font-weight: 600;
+}
+.workflow-fab svg {
+ height: 30px;
+ fill: var(--bg-color);
+ padding: 7px;
+}
+
+/* ADD BUTTON */
+.component_page_workflow [data-bind="add"] {
+ display: inline-block;
+}
+.component_page_workflow [data-bind="add"] .box {
+ align-items: center;
+ background: var(--emphasis);
+ display: flex;
+ padding: 4px 0px 2px 0px;
+ position: relative;
+ left: 5px;
+ overflow-x: scroll;
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
+ border-width: 0;
+}
+.component_page_workflow [data-bind="add"] .box button {
+ color: var(--bg-color);
+ font-family: monospace;
+ text-transform: uppercase;
+ padding-left: 0;
+ padding-right: 0;
+}
+.component_page_workflow [data-bind="add"] .box svg {
+ margin-right: 0;
+ fill: var(--bg-color);
+ transition: transform 0.2s ease;
+}
+.component_page_workflow [data-bind="add"] .box > .item {
+ position: sticky;
+ left: 0;
+ z-index: 1;
+ background: transparent;
+ backdrop-filter: blur(2px);
+ padding: 3px 8px;
+}
+.component_page_workflow [data-bind="add"] .box .sub {
+ padding: 0 5px;
+}
+.component_page_workflow [data-bind="add"] .box > .flex {
+ padding: 0 5px 0 0;
}
diff --git a/public/assets/pages/adminpage/ctrl_workflow.js b/public/assets/pages/adminpage/ctrl_workflow.js
index f7640b4a..865d36f0 100644
--- a/public/assets/pages/adminpage/ctrl_workflow.js
+++ b/public/assets/pages/adminpage/ctrl_workflow.js
@@ -5,34 +5,251 @@ import AdminHOC from "./decorator.js";
import ctrlList from "./ctrl_workflow_list.js";
import ctrlDetails from "./ctrl_workflow_details.js";
-const mockWorkflows = [
+const workflows = [
{
- id: "uuid",
- name: "Notify team when file uploaded",
- description: "Send notification to #general when any file is uploaded to /shared",
- status: "published",
- lastEdited: "2 days ago",
- trigger: "File uploaded",
- action: "Send notification"
+ id: "dummy",
+ name: "My First Workflow",
+ published: false,
+ trigger: { name: "user" },
+ actions: [
+ {
+ name: "tools/debug",
+ },
+ {
+ name: "notify/email",
+ }
+ ],
},
{
- id: "uuid",
- name: "Notify team when file uploaded",
- description: "Send notification to #general when any file is uploaded to /shared",
- status: "unpublished",
+ id: "uuid0",
+ name: "Detection de fichier d'inbox",
+ published: true,
lastEdited: "2 days ago",
- trigger: "File uploaded",
- action: "Send notification"
+ trigger: { name: "watch" },
+ actions: [
+ {
+ name: "run/program",
+ },
+ {
+ name: "notify/email",
+ },
+ ],
+ },
+ {
+ id: "uuid1",
+ name: "Notify team when file is moved",
+ published: true,
+ lastEdited: "2 days ago",
+ history: [],
+ trigger: { name: "operation" },
+ actions: [
+ {
+ name: "notify/email",
+ },
+ ]
+ },
+ {
+ id: "uuid2",
+ name: "Any change to the contract folder",
+ published: true,
+ history: [],
+ trigger: { name: "operation", values: {} },
+ actions: [
+ {
+ name: "notify/email",
+ // values: {} // TODO
+ },
+ ]
},
];
-export default AdminHOC(async function(render) {
- const id = new URLSearchParams(location.search).get("id");
+const triggers = [
+ {
+ name: "schedule",
+ title: "On a Schedule",
+ icon: ``,
+ specs: {
+ "start": {
+ name: "test",
+ type: "datetime",
+ },
+ "frequency": {
+ type: "select",
+ options: ["hourly", "weekly", "monthly", "yearly"],
+ },
+ },
+ },
+ {
+ name: "user",
+ title: "When a User Creates a Request",
+ icon: ``,
+ specs: {
+ name: { type: "text" },
+ form: { type: "text", placeholder: "Optional form user should submit" },
+ visibility: { type: "text" },
+ },
+ },
+ {
+ name: "operation",
+ title: "When a File Action Happens",
+ icon: ``,
+ specs: {
+ event: {
+ type: "text",
+ datalist: ["ls", "cat", "mkdir", "mv", "rm", "touch"],
+ multi: true,
+ },
+ path: {
+ type: "text",
+ },
+ },
+ },
+ {
+ name: "watch",
+ title: "When the Filesystem Changes",
+ icon: ``,
+ specs: {
+ token: {
+ type: "text",
+ },
+ path: {
+ type: "text",
+ },
+ },
+ },
+ {
+ name: "webhook",
+ title: "From a webhook",
+ icon: ``,
+ specs: {
+ url: {
+ type: "text",
+ readonly: true,
+ value: "http://example.com/workflow/webhook?id=generatedID",
+ }
+ },
+ },
+];
+const actions = [
+ {
+ name: "run/program",
+ title: "Execute Program",
+ subtitle: "name",
+ icon: ``,
+ specs: {
+ name: {
+ type: "select",
+ options: ["ocr", "duplicate", "expiry", "sign"],
+ }
+ },
+ },
+ {
+ name: "run/api",
+ title: "Make API Call",
+ icon: ``,
+ specs: {
+ url: {
+ type: "text",
+ },
+ method: {
+ options: ["POST", "PUT", "GET"],
+ },
+ headers: {
+ type: "long_text",
+ },
+ body: {
+ type: "long_text",
+ },
+ },
+ },
+ {
+ name: "notify/email",
+ title: "Notify",
+ subtitle: "email",
+ icon: ``,
+ specs: {
+ email: {
+ type: "text",
+ },
+ message: {
+ type: "long_text",
+ }
+ },
+ },
+ {
+ name: "approval/email",
+ title: "Approval",
+ subtitle: "email",
+ icon: ``,
+ specs: {
+ email: {
+ type: "text",
+ },
+ message: {
+ type: "long_text",
+ },
+ },
+ },
+ {
+ name: "tools/debug",
+ title: "Debug",
+ icon: ``,
+ specs: {},
+ },
+ {
+ name: "tools/map",
+ title: "Map",
+ icon: ``,
+ specs: {
+ transform: {
+ type: "long_text",
+ }
+ },
+ }
+ // TODO: expand macros
+];
+
+const macros = [
+ {
+ name: "files/mv",
+ specs: [
+ { name: "from", type: "text" },
+ { name: "to", type: "text" },
+ ],
+ run: [
+ {
+ name: "run/api",
+ values: [
+ { name: "url", value: "{{ .endpoint }}/api/files/mv?from={{ .from }}&to={{ .to }}" },
+ { name: "method", value: "POST" },
+ { name: "headers", value: "Authorization: Bearer {{ .authorization }}" },
+ ]
+ },
+ ],
+ },
+ // {
+ // name: "metadata/add",
+ // }
+]
+
+export default AdminHOC(async function(render) {
await loadCSS(import.meta.url, "./ctrl_workflow.css");
render(createElement("