From 0f28aa9c8e2a133d9a6a944125f4efd9ad6871df Mon Sep 17 00:00:00 2001 From: frikky Date: Mon, 5 Dec 2022 14:48:48 +0100 Subject: [PATCH] Fixed small issues with Workflow view and added new standard view --- frontend/src/components/CreatorGrid.jsx | 2 +- frontend/src/views/AngularWorkflow.jsx | 2 +- frontend/src/views/DashboardViews.jsx | 101 ++++-------------------- frontend/src/views/Workflows.jsx | 94 +++++++++++----------- 4 files changed, 62 insertions(+), 137 deletions(-) diff --git a/frontend/src/components/CreatorGrid.jsx b/frontend/src/components/CreatorGrid.jsx index 6eaa6222..6c83b134 100644 --- a/frontend/src/components/CreatorGrid.jsx +++ b/frontend/src/components/CreatorGrid.jsx @@ -233,7 +233,7 @@ const CreatorGrid = props => {
- + {showSuggestion === true ?
diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 9048afcd..6d482c01 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -11871,7 +11871,7 @@ const AngularWorkflow = (defaultprops) => { diff --git a/frontend/src/views/DashboardViews.jsx b/frontend/src/views/DashboardViews.jsx index 1c8e1ac9..d2b0c043 100644 --- a/frontend/src/views/DashboardViews.jsx +++ b/frontend/src/views/DashboardViews.jsx @@ -349,7 +349,7 @@ const Dashboard = (props) => { const [workflows, setWorkflows] = useState([]); const [frameworkData, setFrameworkData] = useState(undefined); - const [widgetData, setWidgetData] = useState(undefined); + const [widgetData, setWidgetData] = useState([]); let navigate = useNavigate(); const isCloud = @@ -440,9 +440,16 @@ const Dashboard = (props) => { } } - console.log("VAl: ", tmpdata) + const foundWidget = widgetData.findIndex(data => data.title === widget) + console.log("Found: ", foundWidget) + if (foundWidget !== undefined && foundWidget !== null && foundWidget >= 0) { + widgetData[foundWidget] = tmpdata + } else { + widgetData.push(tmpdata) + } - setWidgetData(tmpdata) + console.log("Data: ", widgetData) + setWidgetData(widgetData) } }) .catch((error) => { @@ -470,89 +477,9 @@ const Dashboard = (props) => { setTreeKeys(treeCategories) } - const fetchUsecases = (workflows) => { - fetch(globalUrl + "/api/v1/workflows/usecases", { - method: "GET", - headers: { - "Content-Type": "application/json", - Accept: "application/json", - }, - credentials: "include", - }) - .then((response) => { - if (response.status !== 200) { - console.log("Status not 200 for usecases"); - } - - return response.json(); - }) - .then((responseJson) => { - // Matching workflows with usecases - if (responseJson.success !== false) { - if (workflows !== undefined && workflows !== null && workflows.length > 0) { - var categorydata = responseJson - - var newcategories = [] - for (var key in categorydata) { - var category = categorydata[key] - category.matches = [] - - for (var subcategorykey in category.list) { - var subcategory = category.list[subcategorykey] - subcategory.matches = [] - - for (var workflowkey in workflows) { - const workflow = workflows[workflowkey] - - if (workflow.usecase_ids !== undefined && workflow.usecase_ids !== null) { - for (var usecasekey in workflow.usecase_ids) { - if (workflow.usecase_ids[usecasekey].toLowerCase() === subcategory.name.toLowerCase()) { - - category.matches.push({ - "workflow": workflow.id, - "category": subcategory.name, - }) - - subcategory.matches.push(workflow) - break - } - } - } - - if (subcategory.matches.length > 0) { - break - } - } - } - - newcategories.push(category) - } - - if (newcategories !== undefined && newcategories !== null && newcategories.length > 0) { - handleKeysetting(newcategories) - setUsecases(newcategories) - setSelectedUsecases(newcategories) - } else { - handleKeysetting(responseJson) - setUsecases(responseJson) - setSelectedUsecases(responseJson) - } - } else { - handleKeysetting(responseJson) - setUsecases(responseJson) - setSelectedUsecases(responseJson) - } - } - }) - .catch((error) => { - //alert.error("ERROR: " + error.toString()); - console.log("ERROR: " + error.toString()); - }); - }; - useEffect(() => { - getWidget("main", "tmp") - //fetchUsecases() + getWidget("main", "Overall") + getWidget("main", "Overall2") }, []); const fetchdata = (stats_id) => { @@ -812,10 +739,10 @@ const Dashboard = (props) => { : null}
- {widgetData === undefined ? null : + {widgetData === undefined || widgetData === null || widgetData === [] || widgetData.length === 0 ? null : - + } diff --git a/frontend/src/views/Workflows.jsx b/frontend/src/views/Workflows.jsx index 47b025fe..19a14c0a 100644 --- a/frontend/src/views/Workflows.jsx +++ b/frontend/src/views/Workflows.jsx @@ -3136,54 +3136,52 @@ const Workflows = (props) => { //if ((userdata.tutorials !== undefined && userdata.tutorials !== null && !userdata.tutorials.includes("getting-started")) || userdata.tutorials === null) { // return ; //} - - return ( -
- -
-

Welcome to Shuffle

-
-
-

- Shuffle is a flexible, easy to use, automation platform - allowing users to integrate their services and devices freely. - It's made to significantly reduce the amount of manual labor, - and is focused on security applications.{" "} - - Click here to learn more. - -

-
-
- If you want to jump straight into it, click here to create your - first workflow: -
-
- - - - ..OR - - {workflowButtons} - -
-
-
- ) - + //return ( + //
+ // + //
+ //

Welcome to Shuffle

+ //
+ //
+ //

+ // Shuffle is a flexible, easy to use, automation platform + // allowing users to integrate their services and devices freely. + // It's made to significantly reduce the amount of manual labor, + // and is focused on security applications.{" "} + // + // Click here to learn more. + // + //

+ //
+ //
+ // If you want to jump straight into it, click here to create your + // first workflow: + //
+ //
+ // + // + // + // ..OR + // + // {workflowButtons} + // + //
+ //
+ //
+ //) } var workflowDelay = -150