release/0.1.0
HerrHase 3 years ago
parent c483af9cc8
commit a64c850e8d

@ -1,5 +1,5 @@
{ {
"/public/js/spritemap.js": "/public/js/spritemap.js?id=2dda73ecee3bb668b395026efda6524c", "/public/js/spritemap.js": "/public/js/spritemap.js?id=2dda73ecee3bb668b395026efda6524c",
"/public/js/app.js": "/public/js/app.js?id=0d34aa6088ee57ed4e67ebcbb9497b4e", "/public/js/app.js": "/public/js/app.js?id=33b6f39f449c765b8c7674ad6a35b92e",
"/public/css/styles.css": "/public/css/styles.css?id=72a43d98017bdbcb83928c41f6289210" "/public/css/styles.css": "/public/css/styles.css?id=72a43d98017bdbcb83928c41f6289210"
} }

@ -4,10 +4,10 @@
<!-- slot:title --> <!-- slot:title -->
<span slot="title"> <span slot="title">
<virtual if={ state.current.id }> <virtual if={ state.current._id }>
Edit Task { state.current.name } Edit Task { state.current.name }
</virtual> </virtual>
<virtual if={ !state.current.id }> <virtual if={ !state.current._id }>
New Task New Task
</virtual> </virtual>
</span> </span>
@ -33,7 +33,7 @@
requestHandlers requestHandlers
<select class="field-choice" name="requestHandler"> <select class="field-choice" name="requestHandler">
<option></option> <option></option>
<option value="{ requestHandler.file }" each={ requestHandler in state.requestHandlers } selected={ action === state.current.requestHandler }> <option value="{ requestHandler.file }" each={ requestHandler in state.requestHandlers } selected={ state.current.requestHandler && requestHandler.file === state.current.requestHandler.file }>
{ requestHandler.name } { requestHandler.name }
</option> </option>
</select> </select>
@ -45,7 +45,7 @@
actionHandlers actionHandlers
<select class="field-choice" name="action"> <select class="field-choice" name="action">
<option></option> <option></option>
<option value="{ actionHandler.file }" each={ actionHandler in state.actionHandlers } selected={ action === state.current.actionHandler }> <option value="{ actionHandler.file }" each={ actionHandler in state.actionHandlers } selected={ state.current.actionHandler && actionHandler.file === state.current.actionHandler.file }>
{ actionHandler.name } { actionHandler.name }
</option> </option>
</select> </select>
@ -98,17 +98,12 @@
state: { state: {
requestHandlers: [], requestHandlers: [],
validator: undefined, validator: undefined
current: {
name: '',
url: '',
requestHandlers: '',
actionHandlers: '',
options: {
}, },
timer: ''
} onBeforeMount()
{
this.resetCurrent()
}, },
/** /**
@ -153,7 +148,14 @@
// //
taskFormStore.on('open', (data) => { taskFormStore.on('open', (data) => {
this.resetCurrent()
this.state.isOpen = true this.state.isOpen = true
if (data) {
this.state.current = data
}
this.update() this.update()
}) })
@ -161,6 +163,29 @@
this.getActionHandlers() this.getActionHandlers()
}, },
/**
*
*
*
*/
resetCurrent()
{
this.state.current = {
name: '',
url: '',
requestHandlers: '',
actionHandlers: '',
options: {
},
timer: ''
}
},
/**
* getting available RequestHandlers
*
*/
getRequestHandlers() getRequestHandlers()
{ {
fetch('/api/v1/handler/request', { fetch('/api/v1/handler/request', {
@ -173,6 +198,11 @@
}) })
}, },
/**
* getting available ActionHandlers
*
*
*/
getActionHandlers() getActionHandlers()
{ {
fetch('/api/v1/handler/action', { fetch('/api/v1/handler/action', {
@ -186,8 +216,10 @@
}, },
/** /**
* send data to server
* *
* * @param {object} event
* @param {object} data
* *
*/ */
handleSuccess(event, data) handleSuccess(event, data)
@ -196,7 +228,10 @@
fetch('/api/v1/task', { fetch('/api/v1/task', {
'method': 'POST', 'method': 'POST',
'body': JSON.stringify(data) 'body': JSON.stringify(data),
'headers': {
'Content-Type': 'application/json'
}
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((response) => { .then((response) => {
@ -207,6 +242,14 @@
// add id to current // add id to current
this.state.current.id = response.data.id this.state.current.id = response.data.id
this.update() this.update()
}).catch((error) => {
// stop loading
this.state.isLoading = false
// show error message
notificationStore.danger('Error! Server has a Error, Request can not proceed!')
this.update()
}) })
} }
} }

@ -3,6 +3,9 @@
<table class="table table--stripped"> <table class="table table--stripped">
<thead> <thead>
<tr> <tr>
<td class="table__th">
state
</td>
<th class="table__th"> <th class="table__th">
name name
</th> </th>
@ -23,6 +26,9 @@
</thead> </thead>
<tbody> <tbody>
<tr if={ state.tasks.length > 0 } each={ task in state.tasks }> <tr if={ state.tasks.length > 0 } each={ task in state.tasks }>
<td class="table__td">
</td>
<td class="table__td"> <td class="table__td">
{ task.name } { task.name }
</td> </td>
@ -46,6 +52,9 @@
{ task.cron } { task.cron }
</td> </td>
<td class="table__td"> <td class="table__td">
<button class="button">
Pause
</button>
<button class="button" onclick={ (event) => { handleEdit(event, task) } }> <button class="button" onclick={ (event) => { handleEdit(event, task) } }>
Edit Edit
</button> </button>
@ -65,7 +74,12 @@
<script> <script>
// stores
import taskFormStore from './../stores/taskForm.js'
import notificationStore from './../stores/notification'
/** /**
* show all tasks
* *
* *
* *
@ -92,27 +106,46 @@
*/ */
getTasks() getTasks()
{ {
fetch('/api/task', (response) => { fetch('/api/v1/task')
.then((response) => response.json())
.then((response) => {
this.state.tasks = response.data this.state.tasks = response.data
this.update()
}) })
}, },
/** /**
* delete
* *
* @param {object} event
* @param {object} task
* *
*/ */
handleDelete(event, action) handleDelete(event, task)
{ {
fetch('/api/v1/task/' + task._id, {
'method': 'DELETE'
})
.then((response) => response.json())
.then((response) => {
notificationStore.success('Deleted ' + response.data.name + '!')
this.getTasks()
})
.catch((errors) => {
notificationStore.success('Error! ' + response.data.name + ' could not deleted!')
})
}, },
/** /**
* edit task, trigger form taskForm
* *
* @param {object} event
* @param {object} task
* *
*/ */
handleEdit(event, action) handleEdit(event, task)
{ {
taskFormStore.open(task)
} }
} }

@ -1,4 +1,5 @@
{ {
"private": true,
"name": "frontend", "name": "frontend",
"version": "0.1.0", "version": "0.1.0",
"scripts": { "scripts": {

@ -1,4 +1,5 @@
{ {
"private": true,
"name": "runner", "name": "runner",
"version": "0.1.0", "version": "0.1.0",
"scripts": { "scripts": {

@ -40,7 +40,7 @@ server
'prefix': '/api/v1' 'prefix': '/api/v1'
}) })
.register(handlerHttp, { .register(handlerHttp, {
'prefix': '/api/v1/' 'prefix': '/api/v1'
}) })
.register(indexHttp) .register(indexHttp)
.register(staticHttp) .register(staticHttp)

@ -31,9 +31,18 @@ export default async function(fastify, opts)
// adding each from directory // adding each from directory
fs.readdirSync(directoryPath).forEach(file => { fs.readdirSync(directoryPath).forEach(file => {
let name = file.replace('.js', '')
// if custom add to name
if (request.params.namespace === 'custom') {
name += ' (custom)'
}
handlers.push({ handlers.push({
'name': file.replace('.js', ''), 'name': file.replace('.js', ''),
'file': path.resolve(file) 'className': file,
'file': directoryPath + file
}) })
}) })
}) })

@ -21,7 +21,7 @@ export default async function(fastify, opts)
* @param {object} response * @param {object} response
* *
*/ */
fastify.get('/task/:id', async function (request, reply) fastify.get('/task', async function (request, reply)
{ {
// getting actions // getting actions
const actions = await actionRepository.find({ 'selector': { const actions = await actionRepository.find({ 'selector': {
@ -46,7 +46,7 @@ export default async function(fastify, opts)
fastify.post('/task', async function (request, reply) fastify.post('/task', async function (request, reply)
{ {
// getting actions // getting actions
const action = await actionRepository.create() const action = await actionRepository.create(request.body)
// send 200 and send set-token // send 200 and send set-token
reply reply
@ -89,9 +89,7 @@ export default async function(fastify, opts)
fastify.delete('/task/:id', async function (request, reply) fastify.delete('/task/:id', async function (request, reply)
{ {
// getting actions // getting actions
const action = await actionRepository.findOne({ const action = await actionRepository.remove(request.params.id)
'id': request.query.id
})
if (!action) { if (!action) {
return reply return reply

@ -1,4 +1,5 @@
{ {
"private": true,
"name": "server", "name": "server",
"version": "0.1.0", "version": "0.1.0",
"scripts": { "scripts": {

@ -14,9 +14,8 @@ class ActionRepository extends Repository
constructor() constructor()
{ {
super() super()
this.type = 'action'
this.index.push('id') this.type = 'action'
this.index.push('name') this.index.push('name')
} }
} }

@ -112,20 +112,28 @@ class Repository
* @param {function} success * @param {function} success
* *
*/ */
remove(id, success) async remove(id)
{ {
this.db.get(id).then((documents) => { this.findOne({
'selector': {
'_id': id
}
}).then((document) => {
if (document) {
// if beforeUpdate exists // if beforeUpdate exists
if (typeof this['beforeRemove'] === 'function') { if (typeof this['beforeRemove'] === 'function') {
this.beforeRemove(documents) this.beforeRemove(document)
} }
this.db.remove(documents, {}, success) return this.db.remove(document._id, document._rev, () => {
return document
})
// if beforeUpdate exists // if beforeUpdate exists
if (typeof this['afterRemove'] === 'function') { if (typeof this['afterRemove'] === 'function') {
this.afterRemove(documents) this.afterRemove(document)
}
} }
}) })
} }

@ -419,16 +419,16 @@ __webpack_require__.r(__webpack_exports__);
bindingTypes, bindingTypes,
getComponent getComponent
) => template( ) => template(
'<div expr19="expr19" class="toast-wrapper toast-wrapper--right"></div>', '<div expr35="expr35" class="toast-wrapper toast-wrapper--right"></div>',
[ [
{ {
type: bindingTypes.IF, type: bindingTypes.IF,
evaluate: _scope => _scope.state.items.length > 0, evaluate: _scope => _scope.state.items.length > 0,
redundantAttribute: 'expr19', redundantAttribute: 'expr35',
selector: '[expr19]', selector: '[expr35]',
template: template( template: template(
'<div expr20="expr20"></div>', '<div expr36="expr36"></div>',
[ [
{ {
type: bindingTypes.EACH, type: bindingTypes.EACH,
@ -436,7 +436,7 @@ __webpack_require__.r(__webpack_exports__);
condition: null, condition: null,
template: template( template: template(
'<div expr21="expr21" class="toast__body"> </div>', '<div expr37="expr37" class="toast__body"> </div>',
[ [
{ {
expressions: [ expressions: [
@ -458,8 +458,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
}, },
{ {
redundantAttribute: 'expr21', redundantAttribute: 'expr37',
selector: '[expr21]', selector: '[expr37]',
expressions: [ expressions: [
{ {
@ -477,8 +477,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
), ),
redundantAttribute: 'expr20', redundantAttribute: 'expr36',
selector: '[expr20]', selector: '[expr36]',
itemName: 'item', itemName: 'item',
indexName: null, indexName: null,
evaluate: _scope => _scope.state.items evaluate: _scope => _scope.state.items
@ -689,17 +689,12 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
state: { state: {
requestHandlers: [], requestHandlers: [],
validator: undefined, validator: undefined
current: {
name: '',
url: '',
requestHandlers: '',
actionHandlers: '',
options: {
}, },
timer: ''
} onBeforeMount()
{
this.resetCurrent()
}, },
/** /**
@ -744,7 +739,14 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
// //
_stores_taskForm_js__WEBPACK_IMPORTED_MODULE_1__["default"].on('open', (data) => { _stores_taskForm_js__WEBPACK_IMPORTED_MODULE_1__["default"].on('open', (data) => {
this.resetCurrent()
this.state.isOpen = true this.state.isOpen = true
if (data) {
this.state.current = data
}
this.update() this.update()
}) })
@ -752,6 +754,29 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
this.getActionHandlers() this.getActionHandlers()
}, },
/**
*
*
*
*/
resetCurrent()
{
this.state.current = {
name: '',
url: '',
requestHandlers: '',
actionHandlers: '',
options: {
},
timer: ''
}
},
/**
* getting available RequestHandlers
*
*/
getRequestHandlers() getRequestHandlers()
{ {
fetch('/api/v1/handler/request', { fetch('/api/v1/handler/request', {
@ -764,6 +789,11 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
}) })
}, },
/**
* getting available ActionHandlers
*
*
*/
getActionHandlers() getActionHandlers()
{ {
fetch('/api/v1/handler/action', { fetch('/api/v1/handler/action', {
@ -777,8 +807,10 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
}, },
/** /**
* send data to server
* *
* * @param {object} event
* @param {object} data
* *
*/ */
handleSuccess(event, data) handleSuccess(event, data)
@ -787,7 +819,10 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
fetch('/api/v1/task', { fetch('/api/v1/task', {
'method': 'POST', 'method': 'POST',
'body': JSON.stringify(data) 'body': JSON.stringify(data),
'headers': {
'Content-Type': 'application/json'
}
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((response) => { .then((response) => {
@ -798,6 +833,14 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
// add id to current // add id to current
this.state.current.id = response.data.id this.state.current.id = response.data.id
this.update() this.update()
}).catch((error) => {
// stop loading
this.state.isLoading = false
// show error message
_stores_notification__WEBPACK_IMPORTED_MODULE_2__["default"].danger('Error! Server has a Error, Request can not proceed!')
this.update()
}) })
} }
} }
@ -809,7 +852,7 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
bindingTypes, bindingTypes,
getComponent getComponent
) => template( ) => template(
'<app-sidebar expr22="expr22" form-id="app-task-form"></app-sidebar>', '<app-sidebar expr19="expr19" form-id="app-task-form"></app-sidebar>',
[ [
{ {
type: bindingTypes.TAG, type: bindingTypes.TAG,
@ -819,14 +862,14 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
slots: [ slots: [
{ {
id: 'title', id: 'title',
html: '<span slot="title"><virtual expr23="expr23"></virtual><virtual expr24="expr24"></virtual></span>', html: '<span slot="title"><virtual expr20="expr20"></virtual><virtual expr21="expr21"></virtual></span>',
bindings: [ bindings: [
{ {
type: bindingTypes.IF, type: bindingTypes.IF,
evaluate: _scope => _scope.state.current.id, evaluate: _scope => _scope.state.current._id,
redundantAttribute: 'expr23', redundantAttribute: 'expr20',
selector: '[expr23]', selector: '[expr20]',
template: template( template: template(
null, null,
@ -868,9 +911,9 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
}, },
{ {
type: bindingTypes.IF, type: bindingTypes.IF,
evaluate: _scope => !_scope.state.current.id, evaluate: _scope => !_scope.state.current._id,
redundantAttribute: 'expr24', redundantAttribute: 'expr21',
selector: '[expr24]', selector: '[expr21]',
template: template( template: template(
null, null,
@ -897,12 +940,12 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
}, },
{ {
id: 'form', id: 'form',
html: '<form expr25="expr25" id="app-task-form" class="form" slot="form"><div class="field-group"><label class="field-label">\n name\n <input expr26="expr26" class="field-text" name="name" type="text"/><field-error expr27="expr27" name="name"></field-error></label></div><div class="field-group"><label class="field-label">\n url\n <input expr28="expr28" class="field-text" name="url" type="text"/><field-error expr29="expr29" name="url"></field-error></label></div><div class="field-group"><label class="field-label">\n requestHandlers\n <select class="field-choice" name="requestHandler"><option></option><option expr30="expr30"></option></select><field-error expr31="expr31" name="requestHandlers"></field-error></label></div><div class="field-group"><label class="field-label">\n actionHandlers\n <select class="field-choice" name="action"><option></option><option expr32="expr32"></option></select><field-error expr33="expr33" name="actionHandlers"></field-error></label></div><div class="field-group"><label class="field-label">\n options\n <input expr34="expr34" type="text" name="options" class="field-text"/><field-error expr35="expr35" name="options"></field-error></label></div><div class="field-group"><label class="field-label">\n timer\n <input expr36="expr36" type="text" name="timer" class="field-text"/><field-error expr37="expr37" name="timer"></field-error></label></div></form>', html: '<form expr22="expr22" id="app-task-form" class="form" slot="form"><div class="field-group"><label class="field-label">\n name\n <input expr23="expr23" class="field-text" name="name" type="text"/><field-error expr24="expr24" name="name"></field-error></label></div><div class="field-group"><label class="field-label">\n url\n <input expr25="expr25" class="field-text" name="url" type="text"/><field-error expr26="expr26" name="url"></field-error></label></div><div class="field-group"><label class="field-label">\n requestHandlers\n <select class="field-choice" name="requestHandler"><option></option><option expr27="expr27"></option></select><field-error expr28="expr28" name="requestHandlers"></field-error></label></div><div class="field-group"><label class="field-label">\n actionHandlers\n <select class="field-choice" name="action"><option></option><option expr29="expr29"></option></select><field-error expr30="expr30" name="actionHandlers"></field-error></label></div><div class="field-group"><label class="field-label">\n options\n <input expr31="expr31" type="text" name="options" class="field-text"/><field-error expr32="expr32" name="options"></field-error></label></div><div class="field-group"><label class="field-label">\n timer\n <input expr33="expr33" type="text" name="timer" class="field-text"/><field-error expr34="expr34" name="timer"></field-error></label></div></form>',
bindings: [ bindings: [
{ {
redundantAttribute: 'expr25', redundantAttribute: 'expr22',
selector: '[expr25]', selector: '[expr22]',
expressions: [ expressions: [
{ {
@ -913,8 +956,8 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
] ]
}, },
{ {
redundantAttribute: 'expr26', redundantAttribute: 'expr23',
selector: '[expr26]', selector: '[expr23]',
expressions: [ expressions: [
{ {
@ -929,12 +972,12 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
evaluate: _scope => 'field-error', evaluate: _scope => 'field-error',
slots: [], slots: [],
attributes: [], attributes: [],
redundantAttribute: 'expr27', redundantAttribute: 'expr24',
selector: '[expr27]' selector: '[expr24]'
}, },
{ {
redundantAttribute: 'expr28', redundantAttribute: 'expr25',
selector: '[expr28]', selector: '[expr25]',
expressions: [ expressions: [
{ {
@ -949,8 +992,8 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
evaluate: _scope => 'field-error', evaluate: _scope => 'field-error',
slots: [], slots: [],
attributes: [], attributes: [],
redundantAttribute: 'expr29', redundantAttribute: 'expr26',
selector: '[expr29]' selector: '[expr26]'
}, },
{ {
type: bindingTypes.EACH, type: bindingTypes.EACH,
@ -980,15 +1023,15 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
{ {
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'selected', name: 'selected',
evaluate: _scope => _scope.action === _scope.state.current.requestHandler evaluate: _scope => _scope.state.current.requestHandler && _scope.requestHandler.file === _scope.state.current.requestHandler.file
} }
] ]
} }
] ]
), ),
redundantAttribute: 'expr30', redundantAttribute: 'expr27',
selector: '[expr30]', selector: '[expr27]',
itemName: 'requestHandler', itemName: 'requestHandler',
indexName: null, indexName: null,
evaluate: _scope => _scope.state.requestHandlers evaluate: _scope => _scope.state.requestHandlers
@ -999,8 +1042,8 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
evaluate: _scope => 'field-error', evaluate: _scope => 'field-error',
slots: [], slots: [],
attributes: [], attributes: [],
redundantAttribute: 'expr31', redundantAttribute: 'expr28',
selector: '[expr31]' selector: '[expr28]'
}, },
{ {
type: bindingTypes.EACH, type: bindingTypes.EACH,
@ -1030,15 +1073,15 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
{ {
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'selected', name: 'selected',
evaluate: _scope => _scope.action === _scope.state.current.actionHandler evaluate: _scope => _scope.state.current.actionHandler && _scope.actionHandler.file === _scope.state.current.actionHandler.file
} }
] ]
} }
] ]
), ),
redundantAttribute: 'expr32', redundantAttribute: 'expr29',
selector: '[expr32]', selector: '[expr29]',
itemName: 'actionHandler', itemName: 'actionHandler',
indexName: null, indexName: null,
evaluate: _scope => _scope.state.actionHandlers evaluate: _scope => _scope.state.actionHandlers
@ -1049,12 +1092,12 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
evaluate: _scope => 'field-error', evaluate: _scope => 'field-error',
slots: [], slots: [],
attributes: [], attributes: [],
redundantAttribute: 'expr33', redundantAttribute: 'expr30',
selector: '[expr33]' selector: '[expr30]'
}, },
{ {
redundantAttribute: 'expr34', redundantAttribute: 'expr31',
selector: '[expr34]', selector: '[expr31]',
expressions: [ expressions: [
{ {
@ -1069,12 +1112,12 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
evaluate: _scope => 'field-error', evaluate: _scope => 'field-error',
slots: [], slots: [],
attributes: [], attributes: [],
redundantAttribute: 'expr35', redundantAttribute: 'expr32',
selector: '[expr35]' selector: '[expr32]'
}, },
{ {
redundantAttribute: 'expr36', redundantAttribute: 'expr33',
selector: '[expr36]', selector: '[expr33]',
expressions: [ expressions: [
{ {
@ -1089,8 +1132,8 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
evaluate: _scope => 'field-error', evaluate: _scope => 'field-error',
slots: [], slots: [],
attributes: [], attributes: [],
redundantAttribute: 'expr37', redundantAttribute: 'expr34',
selector: '[expr37]' selector: '[expr34]'
} }
] ]
} }
@ -1114,8 +1157,8 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
} }
], ],
redundantAttribute: 'expr22', redundantAttribute: 'expr19',
selector: '[expr22]' selector: '[expr19]'
} }
] ]
), ),
@ -1178,11 +1221,11 @@ __webpack_require__.r(__webpack_exports__);
bindingTypes, bindingTypes,
getComponent getComponent
) => template( ) => template(
'<button expr7="expr7" class="button m-bottom-0 m-top-5"><svg class="icon fill-text fill-text-contrast-hover m-top-1 p-right-2" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-close"/></svg> </button>', '<button expr18="expr18" class="button m-bottom-0 m-top-5"><svg class="icon fill-text fill-text-contrast-hover m-top-1 p-right-2" aria-hidden="true"><use xlink:href="/symbol-defs.svg#icon-close"/></svg> </button>',
[ [
{ {
redundantAttribute: 'expr7', redundantAttribute: 'expr18',
selector: '[expr7]', selector: '[expr18]',
expressions: [ expressions: [
{ {
@ -1221,6 +1264,12 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ }); /* harmony export */ });
/* harmony import */ var _stores_taskForm_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../stores/taskForm.js */ "./js/stores/taskForm.js");
/* harmony import */ var _stores_notification__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../stores/notification */ "./js/stores/notification.js");
// stores
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
css: null, css: null,
@ -1244,27 +1293,46 @@ __webpack_require__.r(__webpack_exports__);
*/ */
getTasks() getTasks()
{ {
fetch('/api/task', (response) => { fetch('/api/v1/task')
.then((response) => response.json())
.then((response) => {
this.state.tasks = response.data this.state.tasks = response.data
this.update()
}) })
}, },
/** /**
* delete
* *
* @param {object} event
* @param {object} task
* *
*/ */
handleDelete(event, action) handleDelete(event, task)
{ {
fetch('/api/v1/task/' + task._id, {
'method': 'DELETE'
})
.then((response) => response.json())
.then((response) => {
_stores_notification__WEBPACK_IMPORTED_MODULE_1__["default"].success('Deleted ' + response.data.name + '!')
this.getTasks()
})
.catch((errors) => {
_stores_notification__WEBPACK_IMPORTED_MODULE_1__["default"].success('Error! ' + response.data.name + ' could not deleted!')
})
}, },
/** /**
* edit task, trigger form taskForm
* *
* @param {object} event
* @param {object} task
* *
*/ */
handleEdit(event, action) handleEdit(event, task)
{ {
_stores_taskForm_js__WEBPACK_IMPORTED_MODULE_0__["default"].open(task)
} }
}, },
@ -1274,7 +1342,7 @@ __webpack_require__.r(__webpack_exports__);
bindingTypes, bindingTypes,
getComponent getComponent
) => template( ) => template(
'<div class="tasks"><table class="table table--stripped"><thead><tr><th class="table__th">\n name\n </th><th class="table__th">\n url\n </th><th class="table__th">\n requestHandler\n </th><th class="table__th">\n actions\n </th><th class="table__th">\n cron\n </th><th class="table__th"></th><tr></tr><tbody><tr expr8="expr8"></tr><tr expr18="expr18"></tr></tbody></tr></thead></table></div>', '<div class="tasks"><table class="table table--stripped"><thead><tr><td class="table__th">\n state\n </td><th class="table__th">\n name\n </th><th class="table__th">\n url\n </th><th class="table__th">\n requestHandler\n </th><th class="table__th">\n actions\n </th><th class="table__th">\n cron\n </th><th class="table__th"></th><tr></tr><tbody><tr expr7="expr7"></tr><tr expr17="expr17"></tr></tbody></tr></thead></table></div>',
[ [
{ {
type: bindingTypes.EACH, type: bindingTypes.EACH,
@ -1282,11 +1350,11 @@ __webpack_require__.r(__webpack_exports__);
condition: _scope => _scope.state.tasks.length > 0, condition: _scope => _scope.state.tasks.length > 0,
template: template( template: template(
'<td expr9="expr9" class="table__td"> </td><td expr10="expr10" class="table__td"> </td><td expr11="expr11" class="table__td"> </td><td class="table__td"><virtual expr12="expr12"></virtual></td><td expr15="expr15" class="table__td"> </td><td class="table__td"><button expr16="expr16" class="button">\n Edit\n </button><button expr17="expr17" class="button">\n Delete\n </button></td>', '<td class="table__td"></td><td expr8="expr8" class="table__td"> </td><td expr9="expr9" class="table__td"> </td><td expr10="expr10" class="table__td"> </td><td class="table__td"><virtual expr11="expr11"></virtual></td><td expr14="expr14" class="table__td"> </td><td class="table__td"><button class="button">\n Pause\n </button><button expr15="expr15" class="button">\n Edit\n </button><button expr16="expr16" class="button">\n Delete\n </button></td>',
[ [
{ {
redundantAttribute: 'expr9', redundantAttribute: 'expr8',
selector: '[expr9]', selector: '[expr8]',
expressions: [ expressions: [
{ {
@ -1302,8 +1370,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
}, },
{ {
redundantAttribute: 'expr10', redundantAttribute: 'expr9',
selector: '[expr10]', selector: '[expr9]',
expressions: [ expressions: [
{ {
@ -1319,8 +1387,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
}, },
{ {
redundantAttribute: 'expr11', redundantAttribute: 'expr10',
selector: '[expr11]', selector: '[expr10]',
expressions: [ expressions: [
{ {
@ -1351,12 +1419,12 @@ __webpack_require__.r(__webpack_exports__);
slots: [ slots: [
{ {
id: 'default', id: 'default',
html: '<span expr13="expr13"> </span><span expr14="expr14"></span>', html: '<span expr12="expr12"> </span><span expr13="expr13"></span>',
bindings: [ bindings: [
{ {
redundantAttribute: 'expr13', redundantAttribute: 'expr12',
selector: '[expr13]', selector: '[expr12]',
expressions: [ expressions: [
{ {
@ -1374,8 +1442,8 @@ __webpack_require__.r(__webpack_exports__);
{ {
type: bindingTypes.IF, type: bindingTypes.IF,
evaluate: _scope => _scope.actions.options, evaluate: _scope => _scope.actions.options,
redundantAttribute: 'expr14', redundantAttribute: 'expr13',
selector: '[expr14]', selector: '[expr13]',
template: template( template: template(
' ', ' ',
@ -1406,15 +1474,15 @@ __webpack_require__.r(__webpack_exports__);
] ]
), ),
redundantAttribute: 'expr12', redundantAttribute: 'expr11',
selector: '[expr12]', selector: '[expr11]',
itemName: 'action', itemName: 'action',
indexName: null, indexName: null,
evaluate: _scope => _scope.task.actions evaluate: _scope => _scope.task.actions
}, },
{ {
redundantAttribute: 'expr15', redundantAttribute: 'expr14',
selector: '[expr15]', selector: '[expr14]',
expressions: [ expressions: [
{ {
@ -1430,8 +1498,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
}, },
{ {
redundantAttribute: 'expr16', redundantAttribute: 'expr15',
selector: '[expr16]', selector: '[expr15]',
expressions: [ expressions: [
{ {
@ -1442,8 +1510,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
}, },
{ {
redundantAttribute: 'expr17', redundantAttribute: 'expr16',
selector: '[expr17]', selector: '[expr16]',
expressions: [ expressions: [
{ {
@ -1456,8 +1524,8 @@ __webpack_require__.r(__webpack_exports__);
] ]
), ),
redundantAttribute: 'expr8', redundantAttribute: 'expr7',
selector: '[expr8]', selector: '[expr7]',
itemName: 'task', itemName: 'task',
indexName: null, indexName: null,
evaluate: _scope => _scope.state.tasks evaluate: _scope => _scope.state.tasks
@ -1465,8 +1533,8 @@ __webpack_require__.r(__webpack_exports__);
{ {
type: bindingTypes.IF, type: bindingTypes.IF,
evaluate: _scope => _scope.state.tasks.length === 0, evaluate: _scope => _scope.state.tasks.length === 0,
redundantAttribute: 'expr18', redundantAttribute: 'expr17',
selector: '[expr18]', selector: '[expr17]',
template: template( template: template(
'<td class="table__td center" colspan="6">\n Nothing found\n </td>', '<td class="table__td center" colspan="6">\n Nothing found\n </td>',

Loading…
Cancel
Save