Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions front-end/src/api/func.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const funcApi = {
status: ({ funcName }) => `/function/${funcName}/status`,
trigger: ({ funcName }) => `/function/${funcName}/trigger`,
deleteFunc: ({ funcName }) => `/function/${funcName}/delete`,
addFunc: ({ funcName }) => `/function/${funcName}/add`,
startFunc: ({ funcName }) => `/function/${funcName}/start`,
stopFunc: ({ funcName }) => `/function/${funcName}/stop`,
}

export function getList() {
Expand Down Expand Up @@ -41,9 +42,10 @@ export function deleteFunc(funcName) {
return post(funcApi.deleteFunc({ funcName }));
}

export function addFunc (funcName, data) {
return post(funcApi.addFunc({ funcName }), { data })
export function startFunc(funcName) {
return post(funcApi.startFunc({ funcName }));
}



export function stopFunc(funcName) {
return post(funcApi.stopFunc({ funcName }));
}
7 changes: 6 additions & 1 deletion front-end/src/mock/services/func.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,16 @@ const addFunc = (option) => {

const deleteFunc = { result: 0 };

const startFunc = {result: 0};

const stopFunc = {result: 0};

get(/\/function\/list/, list);
get(/\/function\/create/, createFunc);
get(/\/function\/[^/]*\/info/, info);
get(/\/function\/[^/]*\/stats/, stats);
get(/\/function\/[^/]*\/status/, status);
post(/\/function\/[^/]*\/trigger/, trigger);
post(/\/function\/[^/]*\/delete/, deleteFunc);
post(/\/function\/[^/]*\/add/, addFunc);
post(/\/function\/[^/]*\/start/, startFunc);
post(/\/function\/[^/]*\/stop/, stopFunc);
54 changes: 51 additions & 3 deletions front-end/src/views/function/components/FunctionTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
<a-divider type="vertical" />
<a @click="onShowDetail(text)">Detail</a>
<a-divider type="vertical" />
<a @click="onStart(text)" v-show="!text.status">Start</a>
<a @click="onStop(text)" v-show="text.status">Stop</a>
<a-divider type="vertical" />
<a @click="onDelete(text)">Delete</a>
</span>
</a-table>
</template>

<script>
// import moment from 'moment';
import { deleteFunc } from '@/api/func'
import { deleteFunc, startFunc } from '@/api/func'

const columns = [
{
Expand Down Expand Up @@ -80,7 +83,52 @@ export default {
}
}
})
}
}
},
onStart(text) {
const { name = '' } = text
const _this = this
async function Start() {
try {
const res = await startFunc(name)
text.status = true
_this.$message.success('Function was started successfully.')
} catch (error) {
_this.$message.error('Function startup failed!')
console.error(error)
}
}
Start()
},
onStop(text) {
const { name = '' } = text
const _this = this
async function Stop() {
try {
const res = await startFunc(name)
text.status = false
_this.$message.success('Function was stopped successfully.')
} catch (error) {
_this.$message.error('Function stop failed!')
console.error(error)
}
}
Stop()
},
},
}
</script>

<style>
.ant-table-thead > tr >th,.ant-table-tbody > tr >td{
text-align: center;
}
.ant-table-thead > tr >th:nth-child(1),.ant-table-tbody > tr >td:nth-child(1){
text-align: left;
}
.ant-table-thead > tr >th:nth-child(2),.ant-table-tbody > tr >td:nth-child(2){
width: 15%;
}
.ant-table-thead > tr >th:nth-child(3),.ant-table-tbody > tr >td:nth-child(3){
width: 30%;
}
</style>