Skip to content

Commit fbb4a1b

Browse files
vancexudmetzgar
authored andcommitted
Support list workflows with SQL like query (#55)
* Fix missing dependencies * Add support to list workflow using SQL like query * Address comments
1 parent 56197a6 commit fbb4a1b

File tree

4 files changed

+72
-31
lines changed

4 files changed

+72
-31
lines changed

client/routes/Workflows.vue

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,48 @@
11
<template>
22
<section :class="{ workflows: true, loading }">
33
<header class="filters">
4-
<div class="field workflow-id">
5-
<input type="search" class="workflow-id"
6-
placeholder=" "
7-
name="workflowId"
8-
v-bind:value="$route.query.workflowId"
9-
@input="setWorkflowFilter" />
10-
<label for="workflowId">Workflow ID</label>
11-
</div>
12-
<div class="field workflow-name">
13-
<input type="search" class="workflow-name"
14-
placeholder=" "
15-
name="workflowName"
16-
v-bind:value="$route.query.workflowName"
17-
@input="setWorkflowFilter" />
18-
<label for="workflowName">Workflow Name</label>
19-
</div>
20-
<date-range-picker
21-
:date-range="range"
22-
:max-days="maxRetentionDays"
23-
@change="setRange"
24-
/>
25-
<v-select
26-
class="status"
27-
:value="status"
28-
:options="statuses"
29-
:on-change="setStatus"
30-
:searchable="false"
31-
/>
4+
<template v-if="filterMode === 'advanced'">
5+
<div class="field query-string">
6+
<input type="search" class="query-string"
7+
placeholder=" "
8+
key="sql-query"
9+
name="queryString"
10+
v-bind:value="$route.query.queryString"
11+
@input="setWorkflowFilter" />
12+
<label for="queryString">Query</label>
13+
</div>
14+
</template>
15+
<template v-else>
16+
<div class="field workflow-id">
17+
<input type="search" class="workflow-id"
18+
placeholder=" "
19+
name="workflowId"
20+
v-bind:value="$route.query.workflowId"
21+
@input="setWorkflowFilter" />
22+
<label for="workflowId">Workflow ID</label>
23+
</div>
24+
<div class="field workflow-name">
25+
<input type="search" class="workflow-name"
26+
placeholder=" "
27+
name="workflowName"
28+
v-bind:value="$route.query.workflowName"
29+
@input="setWorkflowFilter" />
30+
<label for="workflowName">Workflow Name</label>
31+
</div>
32+
<date-range-picker
33+
:date-range="range"
34+
:max-days="maxRetentionDays"
35+
@change="setRange"
36+
/>
37+
<v-select
38+
class="status"
39+
:value="status"
40+
:options="statuses"
41+
:on-change="setStatus"
42+
:searchable="false"
43+
/>
44+
</template>
45+
<a class="toggle-filter" @click="toggleFilter">{{ filterMode === 'advanced' ? 'basic' : 'advanced' }}</a>
3246
</header>
3347
<section class="results"
3448
v-infinite-scroll="nextPage"
@@ -84,7 +98,8 @@ export default pagedGrid({
8498
{ value: 'CONTINUED_AS_NEW', label: 'Continued As New' },
8599
{ value: 'TIMED_OUT', label: 'Timed Out'}
86100
],
87-
maxRetentionDays: undefined
101+
maxRetentionDays: undefined,
102+
filterMode: 'basic'
88103
}
89104
},
90105
created() {
@@ -137,7 +152,8 @@ export default pagedGrid({
137152
endTime,
138153
status: q.status,
139154
workflowId: q.workflowId,
140-
workflowName: q.workflowName
155+
workflowName: q.workflowName,
156+
queryString: q.queryString,
141157
}
142158
},
143159
queryOnChange() {
@@ -153,6 +169,10 @@ export default pagedGrid({
153169
delete q.domain
154170
q.nextPageToken = this.nextPageToken
155171
172+
if (q.queryString) {
173+
return this.fetch(`/api/domain/${domain}/workflows/list`, q)
174+
}
175+
156176
return this.fetch(`/api/domain/${domain}/workflows/${state}`, q)
157177
}
158178
},
@@ -211,6 +231,14 @@ export default pagedGrid({
211231
}
212232
this.$router.replace({ query })
213233
}
234+
},
235+
toggleFilter() {
236+
if (this.filterMode === 'advanced') {
237+
this.filterMode = 'basic'
238+
this.$route.query.queryString = ''
239+
} else {
240+
this.filterMode = 'advanced'
241+
}
214242
}
215243
}
216244
})
@@ -228,6 +256,8 @@ section.workflows
228256
flex 1 1 auto
229257
.v-select
230258
flex 1 1 240px
259+
a.toggle-filter
260+
action-button()
231261
232262
paged-grid()
233263

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"vue-router": "^3.0.1",
6262
"vue-select": "nathanboktae/vue-select#after2.4",
6363
"vue-split-panel": "^1.0.4",
64+
"vue-style-loader": "^3.1.2",
6465
"vue-template-compiler": "^2.5.2",
6566
"webpack": "^3.10.0"
6667
},
@@ -72,6 +73,7 @@
7273
"mocha": "^4.0.1",
7374
"mocha-chrome": "^1.1.0",
7475
"nathanboktae-browser-test-utils": "^0.1.0",
75-
"supertest": "^3.0.0"
76+
"supertest": "^3.0.0",
77+
"webpack-hot-client": "^1.3.0"
7678
}
7779
}

server/middleware/tchannel-client.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ module.exports = async function(ctx, next) {
160160
ctx.cadence = {
161161
openWorkflows: req('ListOpenWorkflowExecutions', 'list', withDomainPaging),
162162
closedWorkflows: req('ListClosedWorkflowExecutions', 'list', withDomainPaging),
163+
listWorkflows: req('ListWorkflowExecutions', 'list', withDomainPaging),
163164
getHistory: req('GetWorkflowExecutionHistory', 'get', withDomainAndWorkflowExecution),
164165
exportHistory: req('GetWorkflowExecutionHistory', 'get', withDomainAndWorkflowExecution, cliTransform),
165166
describeWorkflow: req('DescribeWorkflowExecution', 'describe', withWorkflowExecution),

server/routes.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ async function listWorkflows(state, ctx) {
3939
router.get('/api/domain/:domain/workflows/open', listWorkflows.bind(null, 'open'))
4040
router.get('/api/domain/:domain/workflows/closed', listWorkflows.bind(null, 'closed'))
4141

42+
router.get('/api/domain/:domain/workflows/list', async function (ctx) {
43+
var q = ctx.query || {}
44+
ctx.body = await ctx.cadence['listWorkflows']({
45+
query: q.queryString || undefined,
46+
nextPageToken: q.nextPageToken ? Buffer.from(q.nextPageToken, 'base64') : undefined
47+
})
48+
})
49+
4250
router.get('/api/domain/:domain/workflows/:workflowId/:runId/history', async function (ctx) {
4351
var q = ctx.query || {}
4452

0 commit comments

Comments
 (0)