Skip to content

Commit

Permalink
feat: add first workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Kholid060 committed Oct 25, 2021
1 parent 34ea00e commit 4ddc723
Show file tree
Hide file tree
Showing 16 changed files with 101 additions and 78 deletions.
Binary file added src/assets/images/icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/assets/images/logo.png
Binary file not shown.
Binary file removed src/assets/img/icon-128.png
Binary file not shown.
Binary file removed src/assets/img/icon-34.png
Binary file not shown.
7 changes: 0 additions & 7 deletions src/assets/img/logo.svg

This file was deleted.

19 changes: 13 additions & 6 deletions src/background/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,19 @@ browser.alarms.onAlarm.addListener(({ name }) => {

browser.runtime.onInstalled.addListener((details) => {
if (details.reason === 'install') {
browser.storage.local.set({
logs: [],
workflows: [],
workflowState: [],
visitWebTriggers: [],
});
browser.storage.local
.set({
logs: [],
workflows: [],
workflowState: [],
visitWebTriggers: [],
})
.then(() => {
browser.tabs.create({
active: true,
url: browser.runtime.getURL('newtab.html#/workflows'),
});
});
}
});

Expand Down
6 changes: 1 addition & 5 deletions src/components/block/BlockExportData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
class="w-full bg-input rounded-lg transition mb-2 py-2 px-4 block"
placeholder="File name"
/>
<ui-select
v-model="block.data.type"
class="px-4 py-2 rounded-lg w-40 bg-input"
placeholder="Export as"
>
<ui-select v-model="block.data.type" class="w-40" placeholder="Export as">
<option v-for="type in dataExportTypes" :key="type.id" :value="type.id">
{{ type.name }}
</option>
Expand Down
14 changes: 12 additions & 2 deletions src/components/newtab/workflow/WorkflowDetailsCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="px-4 mb-2">
<div class="px-4 flex items-center mb-2">
<ui-popover>
<template #trigger>
<span
Expand Down Expand Up @@ -30,7 +30,17 @@
</span>
</div>
</ui-popover>
<p class="font-semibold inline-block text-lg flex-1 mr-4 align-middle">
<p
class="
font-semibold
text-overflow
inline-block
text-lg
flex-1
mr-4
align-middle
"
>
{{ workflow.name }}
</p>
</div>
Expand Down
1 change: 0 additions & 1 deletion src/components/newtab/workflow/edit/EditGetText.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<edit-interaction-base v-bind="{ data }" @change="updateData">
{{ data }}
<div class="flex rounded-lg bg-input px-4 items-center transition mt-2">
<span>/</span>
<input
Expand Down
5 changes: 2 additions & 3 deletions src/components/popup/home/HomeWorkflowCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
class="w-full flex items-center space-x-2 hover:ring-2 hover:ring-gray-900"
>
<div
to="/workflow/anu/edit"
class="flex-1 cursor-pointer"
class="flex-1 text-overflow cursor-pointer"
@click="$emit('details', workflow)"
>
<p class="leading-tight">{{ workflow.name }}</p>
<p class="leading-tight text-overflow">{{ workflow.name }}</p>
<p class="leading-none text-gray-500">
{{ dayjs(workflow.createdAt).fromNow() }}
</p>
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"manifest_version": 2,
"name": "Chrome Extension with React & Webpack",
"name": "Automa",
"background": {
"scripts": [
"background.bundle.js"
Expand Down
2 changes: 1 addition & 1 deletion src/models/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Workflow extends Model {
createdAt: this.number(),
settings: this.attr({
timeout: 120000,
onError: 'keep-running',
onError: 'stop-workflow',
}),
logs: this.hasMany(Log, 'workflowId'),
};
Expand Down
94 changes: 48 additions & 46 deletions src/newtab/pages/workflows/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,52 +48,54 @@
</ui-tab>
</ui-tabs>
</div>
<workflow-builder
v-if="activeTab === 'editor'"
class="h-full w-full"
:data="workflow.drawflow"
@load="editor = $event"
@deleteBlock="deleteBlock"
/>
<div v-else class="container pb-4 mt-24 px-4">
<template v-if="activeTab === 'logs'">
<div v-if="logs.length === 0" class="text-center">
<img
src="@/assets/svg/files-and-folder.svg"
class="mx-auto max-w-sm"
/>
<p class="text-xl font-semibold">No data to show</p>
</div>
<shared-logs-table :logs="logs" class="w-full">
<template #item-append="{ log: itemLog }">
<td class="text-right">
<v-remixicon
name="riDeleteBin7Line"
class="inline-block text-red-500 cursor-pointer"
@click="deleteLog(itemLog.id)"
/>
</td>
</template>
</shared-logs-table>
</template>
<template v-else-if="activeTab === 'running'">
<div v-if="workflowState.length === 0" class="text-center">
<img
src="@/assets/svg/files-and-folder.svg"
class="mx-auto max-w-sm"
/>
<p class="text-xl font-semibold">No data to show</p>
</div>
<div class="grid grid-cols-2 gap-4">
<shared-workflow-state
v-for="item in workflowState"
:id="item.id"
:key="item.id"
:state="item.state"
/>
</div>
</template>
</div>
<keep-alive>
<workflow-builder
v-if="activeTab === 'editor'"
class="h-full w-full"
:data="workflow.drawflow"
@load="editor = $event"
@deleteBlock="deleteBlock"
/>
<div v-else class="container pb-4 mt-24 px-4">
<template v-if="activeTab === 'logs'">
<div v-if="logs.length === 0" class="text-center">
<img
src="@/assets/svg/files-and-folder.svg"
class="mx-auto max-w-sm"
/>
<p class="text-xl font-semibold">No data to show</p>
</div>
<shared-logs-table :logs="logs" class="w-full">
<template #item-append="{ log: itemLog }">
<td class="text-right">
<v-remixicon
name="riDeleteBin7Line"
class="inline-block text-red-500 cursor-pointer"
@click="deleteLog(itemLog.id)"
/>
</td>
</template>
</shared-logs-table>
</template>
<template v-else-if="activeTab === 'running'">
<div v-if="workflowState.length === 0" class="text-center">
<img
src="@/assets/svg/files-and-folder.svg"
class="mx-auto max-w-sm"
/>
<p class="text-xl font-semibold">No data to show</p>
</div>
<div class="grid grid-cols-2 gap-4">
<shared-workflow-state
v-for="item in workflowState"
:id="item.id"
:key="item.id"
:state="item.state"
/>
</div>
</template>
</div>
</keep-alive>
</div>
</div>
<ui-modal v-model="state.showDataColumnsModal" content-class="max-w-xl">
Expand Down
10 changes: 10 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createStore } from 'vuex';
import browser from 'webextension-polyfill';
import vuexORM from '@/lib/vuex-orm';
import * as models from '@/models';
import { firstWorkflows } from '@/utils/shared';

const store = createStore({
plugins: [vuexORM(models)],
Expand Down Expand Up @@ -31,6 +32,15 @@ const store = createStore({
data: data[entity],
});
});
const isFirstTime =
(await browser.storage.local.get('isFirstTime')?.isFirstTime) ?? true;

if (isFirstTime) {
await dispatch('entities/insert', {
entity: 'workflows',
data: firstWorkflows,
});
}

return await Promise.allSettled(promises);
} catch (error) {
Expand Down
12 changes: 12 additions & 0 deletions src/utils/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,15 @@ export const dataExportTypes = [
{ name: 'CSV', id: 'csv' },
{ name: 'Plain text', id: 'plain-text' },
];

export const firstWorkflows = [
{
name: 'Google search',
drawflow: `{"drawflow":{"Home":{"data":{"d634ff22-5dfe-44dc-83d2-842412bd9fbf":{"id":"d634ff22-5dfe-44dc-83d2-842412bd9fbf","name":"trigger","data":{"type":"interval","interval":10},"class":"trigger","html":"BlockBasic","typenode":"vue","inputs":{},"outputs":{"output_1":{"connections":[{"node":"b9e7e0d4-e86a-4635-a352-31c63723fef4","output":"input_1"}]}},"pos_x":50,"pos_y":300},"b9e7e0d4-e86a-4635-a352-31c63723fef4":{"id":"b9e7e0d4-e86a-4635-a352-31c63723fef4","name":"new-tab","data":{"url":"https://google.com","active":true},"class":"new-tab","html":"BlockNewTab","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"d634ff22-5dfe-44dc-83d2-842412bd9fbf","input":"output_1"}]}},"outputs":{"output_1":{"connections":[{"node":"09f3a14c-0514-4287-93b0-aa92b0064fba","output":"input_1"}]}},"pos_x":278,"pos_y":268},"09f3a14c-0514-4287-93b0-aa92b0064fba":{"id":"09f3a14c-0514-4287-93b0-aa92b0064fba","name":"forms","data":{"description":"Type query","selector":"[name='q']","markEl":false,"multiple":false,"selected":true,"type":"text-field","value":"Stackoverflow","delay":"120","events":[]},"class":"forms","html":"BlockBasic","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"b9e7e0d4-e86a-4635-a352-31c63723fef4","input":"output_1"}]}},"outputs":{"output_1":{"connections":[{"node":"5f76370d-aa3d-4258-8319-230fcfc49a3a","output":"input_1"}]}},"pos_x":551,"pos_y":290},"5f76370d-aa3d-4258-8319-230fcfc49a3a":{"id":"5f76370d-aa3d-4258-8319-230fcfc49a3a","name":"event-click","data":{"description":"Click search","selector":"center:nth-child(1) > .gNO89b","markEl":false,"multiple":false},"class":"event-click","html":"BlockBasic","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"09f3a14c-0514-4287-93b0-aa92b0064fba","input":"output_1"}]}},"outputs":{"output_1":{"connections":[]}},"pos_x":794,"pos_y":308}}}}}`,
},
{
name: 'Generate lorem ipsum',
drawflow:
'{"drawflow":{"Home":{"data":{"c5774692-0be4-457f-82be-d5e4b3344ad7":{"id":"c5774692-0be4-457f-82be-d5e4b3344ad7","name":"trigger","data":{"type":"manual"},"class":"trigger","html":"BlockBasic","typenode":"vue","inputs":{},"outputs":{"output_1":{"connections":[{"node":"10a0429e-b8c4-4c04-9ea3-df169cea78e4","output":"input_1"}]}},"pos_x":50,"pos_y":300},"10a0429e-b8c4-4c04-9ea3-df169cea78e4":{"id":"10a0429e-b8c4-4c04-9ea3-df169cea78e4","name":"new-tab","data":{"url":"http://lipsum.com","active":true},"class":"new-tab","html":"BlockNewTab","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"c5774692-0be4-457f-82be-d5e4b3344ad7","input":"output_1"}]}},"outputs":{"output_1":{"connections":[{"node":"24bdec44-1e80-4cee-9139-00545b8d33d9","output":"input_1"}]}},"pos_x":285,"pos_y":282},"df24edcc-4c29-49f5-8a29-0e572a4bc6ae":{"id":"df24edcc-4c29-49f5-8a29-0e572a4bc6ae","name":"delay","data":{"time":4000},"class":"delay","html":"BlockDelay","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"24bdec44-1e80-4cee-9139-00545b8d33d9","input":"output_1"}]}},"outputs":{"output_1":{"connections":[{"node":"2d93c1de-42ca-4f39-8e61-e3e55529fbba","output":"input_1"}]}},"pos_x":833,"pos_y":297},"24bdec44-1e80-4cee-9139-00545b8d33d9":{"id":"24bdec44-1e80-4cee-9139-00545b8d33d9","name":"element-scroll","data":{"description":"","selector":"#amount","markEl":false,"multiple":false,"scrollY":0,"scrollX":0,"incX":false,"incY":false,"smooth":true,"scrollIntoView":true},"class":"element-scroll","html":"BlockBasic","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"10a0429e-b8c4-4c04-9ea3-df169cea78e4","input":"output_1"},{"node":"2f5fec61-a318-4e2b-b7d3-bc7328bd282c","input":"output_1"}]}},"outputs":{"output_1":{"connections":[{"node":"df24edcc-4c29-49f5-8a29-0e572a4bc6ae","output":"input_1"}]}},"pos_x":566,"pos_y":317},"2d93c1de-42ca-4f39-8e61-e3e55529fbba":{"id":"2d93c1de-42ca-4f39-8e61-e3e55529fbba","name":"forms","data":{"description":"Lipsum length","selector":"#amount","markEl":false,"multiple":false,"selected":true,"type":"text-field","value":"3","delay":0,"events":[]},"class":"forms","html":"BlockBasic","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"df24edcc-4c29-49f5-8a29-0e572a4bc6ae","input":"output_1"}]}},"outputs":{"output_1":{"connections":[{"node":"0f3e2baa-8d6d-4323-8ac7-362f1be39ecb","output":"input_1"}]}},"pos_x":1058,"pos_y":327},"0f3e2baa-8d6d-4323-8ac7-362f1be39ecb":{"id":"0f3e2baa-8d6d-4323-8ac7-362f1be39ecb","name":"event-click","data":{"description":"Generate button","selector":"#generate","markEl":false,"multiple":false},"class":"event-click","html":"BlockBasic","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"2d93c1de-42ca-4f39-8e61-e3e55529fbba","input":"output_1"}]}},"outputs":{"output_1":{"connections":[{"node":"fb9be12f-8995-4876-8bfe-79323769474b","output":"input_1"}]}},"pos_x":1309,"pos_y":329},"fb9be12f-8995-4876-8bfe-79323769474b":{"id":"fb9be12f-8995-4876-8bfe-79323769474b","name":"delay","data":{"time":2000},"class":"delay","html":"BlockDelay","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"0f3e2baa-8d6d-4323-8ac7-362f1be39ecb","input":"output_1"}]}},"outputs":{"output_1":{"connections":[{"node":"7205fcf2-deda-445e-9690-4e36adb52585","output":"input_1"}]}},"pos_x":1566,"pos_y":310},"7205fcf2-deda-445e-9690-4e36adb52585":{"id":"7205fcf2-deda-445e-9690-4e36adb52585","name":"get-text","data":{"description":"Get text result","selector":"#lipsum","markEl":false,"multiple":false,"regex":"","regexExp":["g"],"dataColumn":"","saveData":true},"class":"get-text","html":"BlockBasic","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"fb9be12f-8995-4876-8bfe-79323769474b","input":"output_1"}]}},"outputs":{"output_1":{"connections":[{"node":"3d3e8fac-97fa-4c3d-84bc-a3db18740184","output":"input_1"}]}},"pos_x":1823,"pos_y":337},"3d3e8fac-97fa-4c3d-84bc-a3db18740184":{"id":"3d3e8fac-97fa-4c3d-84bc-a3db18740184","name":"repeat-task","data":{"repeatFor":2},"class":"repeat-task","html":"BlockRepeatTask","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"7205fcf2-deda-445e-9690-4e36adb52585","input":"output_1"}]}},"outputs":{"output_1":{"connections":[{"node":"4d39ecd5-f33f-4e57-b11d-2f26b1076334","output":"input_1"}]},"output_2":{"connections":[{"node":"2f5fec61-a318-4e2b-b7d3-bc7328bd282c","output":"input_1","points":[{"pos_x":2290.2500152587886,"pos_y":542.0000076293943},{"pos_x":1125.2500152587886,"pos_y":552.0000076293943}]}]}},"pos_x":2073,"pos_y":293.5},"2f5fec61-a318-4e2b-b7d3-bc7328bd282c":{"id":"2f5fec61-a318-4e2b-b7d3-bc7328bd282c","name":"go-back","data":{},"class":"go-back","html":"BlockBasic","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"3d3e8fac-97fa-4c3d-84bc-a3db18740184","input":"output_2"}]}},"outputs":{"output_1":{"connections":[{"node":"24bdec44-1e80-4cee-9139-00545b8d33d9","output":"input_1","points":[{"pos_x":1305.2500152587886,"pos_y":829.5000076293943},{"pos_x":545.250015258789,"pos_y":834.499988555908}]}]}},"pos_x":1135.5,"pos_y":628},"4d39ecd5-f33f-4e57-b11d-2f26b1076334":{"id":"4d39ecd5-f33f-4e57-b11d-2f26b1076334","name":"export-data","data":{"name":"Lipsum","type":"plain-text"},"class":"export-data","html":"BlockExportData","typenode":"vue","inputs":{"input_1":{"connections":[{"node":"3d3e8fac-97fa-4c3d-84bc-a3db18740184","input":"output_1"}]}},"outputs":{"output_1":{"connections":[]}},"pos_x":2409.75,"pos_y":289}}}}}',
},
];
7 changes: 1 addition & 6 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,7 @@ const options = {
},
},
{
from: 'src/assets/img/icon-128.png',
to: path.join(__dirname, 'build'),
force: true,
},
{
from: 'src/assets/img/icon-34.png',
from: 'src/assets/images/icon-128.png',
to: path.join(__dirname, 'build'),
force: true,
},
Expand Down

0 comments on commit 4ddc723

Please sign in to comment.