diff --git a/mix-manifest.json b/mix-manifest.json
index 79b4870..13805a0 100644
--- a/mix-manifest.json
+++ b/mix-manifest.json
@@ -1,5 +1,5 @@
{
"/public/js/spritemap.js": "/public/js/spritemap.js?id=2dda73ecee3bb668b395026efda6524c",
- "/public/js/app.js": "/public/js/app.js?id=1c9307a192e1817119e543e388f2a43b",
+ "/public/js/app.js": "/public/js/app.js?id=0d34aa6088ee57ed4e67ebcbb9497b4e",
"/public/css/styles.css": "/public/css/styles.css?id=72a43d98017bdbcb83928c41f6289210"
}
diff --git a/packages/frontend/js/components/task-form.riot b/packages/frontend/js/components/task-form.riot
index 33c3946..773b15d 100644
--- a/packages/frontend/js/components/task-form.riot
+++ b/packages/frontend/js/components/task-form.riot
@@ -4,10 +4,10 @@
-
+
Edit Task { state.current.name }
-
+
New Task
@@ -30,22 +30,26 @@
@@ -87,68 +91,98 @@
*
*/
- export default () => {
- return {
-
- ...sidebar, // adding basic funtion for sidebar
-
- state: {
- requestHandlers: [],
- validator: undefined,
- current: {
- name: '',
- url: '',
- requestHandler: '',
- action: '',
- options: {
+ export default () => {
+ return {
+
+ ...sidebar, // adding basic funtion for sidebar
+
+ state: {
+ requestHandlers: [],
+ validator: undefined,
+ current: {
+ name: '',
+ url: '',
+ requestHandlers: '',
+ actionHandlers: '',
+ options: {
+
+ },
+ timer: ''
+ }
+ },
+
+ /**
+ *
+ *
+ */
+ onMounted()
+ {
+ // creating formValidator
+ this.state.validator = new FormValidator(this.$('.form'), {
+ 'name': {
+ 'presence': true
+ },
+ 'url': {
+ 'presence': true
+ },
+ 'requestHandler': {
+ 'presence': true
+ },
+ 'action': {
+ 'presence': true
+ },
+ 'timer': {
+
+ }
+ })
+
+ // adding on success
+ this.state.validator.onSuccess((event, data) => {
+ this.handleSuccess(event, data)
+ })
+
+ // adding on success
+ this.state.validator.onError((event, data) => {
+ this.state.isLoading = false
+
+ // add notification
+ notificationStore.danger('Error! Check your input!')
+
+ this.update()
+ })
+
+ //
+ taskFormStore.on('open', (data) => {
+ this.state.isOpen = true
+ this.update()
+ })
+
+ this.getRequestHandlers()
+ this.getActionHandlers()
+ },
- },
- timer: ''
- }
+ getRequestHandlers()
+ {
+ fetch('/api/v1/handler/request', {
+ 'method': 'GET'
+ })
+ .then((response) => response.json())
+ .then((response) => {
+ this.state.requestHandlers = response.data
+ this.update()
+ })
},
- /**
- *
- *
- */
- onMounted()
+ getActionHandlers()
{
- // creating formValidator
- this.state.validator = new FormValidator(this.$('.form'), {
- 'name': {
- 'presence': true
- },
- 'url': {
- 'presence': true
- },
- 'requestHandler': {
- 'presence': true
- },
- 'action': {
- 'presence': true
- },
- 'timer': {
- 'presence': true
- }
- })
-
- // adding on success
- this.state.validator.onSuccess((event, data) => {
- this.handleSuccess(event, data)
- })
-
- // adding on success
- this.state.validator.onError((event, data) => {
- this.state.isLoading = false
- notificationStore.danger('Error! Check your input!')
-
- this.update()
- })
-
- taskFormStore.on('open', (data) => {
- this.state.isOpen = true
- this.update()
- })
+ fetch('/api/v1/handler/action', {
+ 'method': 'GET'
+ })
+ .then((response) => response.json())
+ .then((response) => {
+ this.state.actionHandlers = response.data
+ this.update()
+ })
},
/**
@@ -158,11 +192,25 @@
*/
handleSuccess(event, data)
{
-
+ event.preventDefault()
+
+ fetch('/api/v1/task', {
+ 'method': 'POST',
+ 'body': JSON.stringify(data)
+ })
+ .then((response) => response.json())
+ .then((response) => {
+
+ // stop loading
+ this.state.isLoading = false
+
+ // add id to current
+ this.state.current.id = response.data.id
+ this.update()
+ })
}
- }
+ }
}
-
\ No newline at end of file
diff --git a/packages/frontend/views/index.liquid b/packages/frontend/views/index.liquid
index 95c3297..4063274 100644
--- a/packages/frontend/views/index.liquid
+++ b/packages/frontend/views/index.liquid
@@ -19,7 +19,4 @@
{% block script %}
-
{% endblock %}
\ No newline at end of file
diff --git a/packages/runner/custom/actions/moveFile.js b/packages/runner/custom/action/moveFile.js
similarity index 100%
rename from packages/runner/custom/actions/moveFile.js
rename to packages/runner/custom/action/moveFile.js
diff --git a/packages/runner/actions/action.js b/packages/runner/handlers/action/action.js
similarity index 100%
rename from packages/runner/actions/action.js
rename to packages/runner/handlers/action/action.js
diff --git a/packages/runner/actions/actionInterface.js b/packages/runner/handlers/action/actionInterface.js
similarity index 100%
rename from packages/runner/actions/actionInterface.js
rename to packages/runner/handlers/action/actionInterface.js
diff --git a/packages/runner/actions/downloadPodcast.js b/packages/runner/handlers/action/downloadPodcast.js
similarity index 100%
rename from packages/runner/actions/downloadPodcast.js
rename to packages/runner/handlers/action/downloadPodcast.js
diff --git a/packages/runner/requestHandlers/jsonHandler.js b/packages/runner/handlers/request/jsonHandler.js
similarity index 100%
rename from packages/runner/requestHandlers/jsonHandler.js
rename to packages/runner/handlers/request/jsonHandler.js
diff --git a/packages/runner/requestHandlers/requestHandler.js b/packages/runner/handlers/request/requestHandler.js
similarity index 100%
rename from packages/runner/requestHandlers/requestHandler.js
rename to packages/runner/handlers/request/requestHandler.js
diff --git a/packages/runner/requestHandlers/requestHandlerInterface.js b/packages/runner/handlers/request/requestHandlerInterface.js
similarity index 100%
rename from packages/runner/requestHandlers/requestHandlerInterface.js
rename to packages/runner/handlers/request/requestHandlerInterface.js
diff --git a/packages/runner/requestHandlers/rssHandler.js b/packages/runner/handlers/request/rssHandler.js
similarity index 100%
rename from packages/runner/requestHandlers/rssHandler.js
rename to packages/runner/handlers/request/rssHandler.js
diff --git a/packages/server/bootstrap.js b/packages/server/bootstrap.js
index aa96758..7211163 100644
--- a/packages/server/bootstrap.js
+++ b/packages/server/bootstrap.js
@@ -30,13 +30,17 @@ server.register(pov, {
* add routes
*
*/
-import actionHttp from './http/api/action.js'
+import taskHttp from './http/api/task.js'
+import handlerHttp from './http/api/handler.js'
import indexHttp from './http/index.js'
import staticHttp from './http/static.js'
server
- .register(actionHttp, {
- 'prefix': '/api'
+ .register(taskHttp, {
+ 'prefix': '/api/v1'
+ })
+ .register(handlerHttp, {
+ 'prefix': '/api/v1/'
})
.register(indexHttp)
.register(staticHttp)
diff --git a/packages/server/http/api/handler.js b/packages/server/http/api/handler.js
new file mode 100644
index 0000000..ca23648
--- /dev/null
+++ b/packages/server/http/api/handler.js
@@ -0,0 +1,47 @@
+import * as fs from 'fs'
+import * as path from 'path'
+
+/**
+ * getting handlers
+ *
+ * @author Björn Hase, me@herr-hase.wtf
+ * @license http://opensource.org/licenses/MIT The MIT License
+ * @link https://gitea.node001.net/HerrHase/super-hog
+ *
+ */
+
+export default async function(fastify, opts)
+{
+ fastify.get('/handler/:namespace(request|action)', async function (request, reply)
+ {
+ // handlers that found
+ const handlers = []
+
+ // directories to find
+ const directories = [
+ 'custom',
+ 'handlers'
+ ]
+
+ // getting
+ directories.forEach((directory) => {
+
+ // create path
+ const directoryPath = './../runner/' + directory + '/' + request.params.namespace
+
+ // adding each from directory
+ fs.readdirSync(directoryPath).forEach(file => {
+ handlers.push({
+ 'name': file.replace('.js', ''),
+ 'file': path.resolve(file)
+ })
+ })
+ })
+
+ reply
+ .code(200)
+ .send({
+ 'data': handlers
+ })
+ })
+}
\ No newline at end of file
diff --git a/packages/server/http/api/action.js b/packages/server/http/api/task.js
similarity index 89%
rename from packages/server/http/api/action.js
rename to packages/server/http/api/task.js
index 61fdfc9..8811fea 100644
--- a/packages/server/http/api/action.js
+++ b/packages/server/http/api/task.js
@@ -21,7 +21,7 @@ export default async function(fastify, opts)
* @param {object} response
*
*/
- fastify.get('/action', async function (request, reply)
+ fastify.get('/task/:id', async function (request, reply)
{
// getting actions
const actions = await actionRepository.find({ 'selector': {
@@ -43,7 +43,7 @@ export default async function(fastify, opts)
* @param {object} response
*
*/
- fastify.post('/action', async function (request, reply)
+ fastify.post('/task', async function (request, reply)
{
// getting actions
const action = await actionRepository.create()
@@ -63,7 +63,7 @@ export default async function(fastify, opts)
* @param {object} response
*
*/
- fastify.put('/action/:id', async function (request, reply)
+ fastify.put('/task/:id', async function (request, reply)
{
// getting actions
const action = await actionRepository.update({
@@ -86,7 +86,7 @@ export default async function(fastify, opts)
* @param {object} response
*
*/
- fastify.delete('/action/:id', async function (request, reply)
+ fastify.delete('/task/:id', async function (request, reply)
{
// getting actions
const action = await actionRepository.findOne({
diff --git a/packages/server/http/index.js b/packages/server/http/index.js
index 0d42953..76679a7 100644
--- a/packages/server/http/index.js
+++ b/packages/server/http/index.js
@@ -1,5 +1,6 @@
import token from '@fastify/csrf'
+
/**
* index
*
@@ -24,12 +25,7 @@ export default async function(fastify, opts)
*/
fastify.get('/', (request, response) =>
{
- response.view('../frontend/views/index', {
- 'responseHandlers': [{
- test: 1
- }],
- 'actions': []
- })
+ response.view('../frontend/views/index')
})
/**
diff --git a/public/js/app.js b/public/js/app.js
index 79288b9..3c589cf 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -549,11 +549,11 @@ riot__WEBPACK_IMPORTED_MODULE_1__.register('app-loading', _loading_riot__WEBPACK
bindingTypes,
getComponent
) => template(
- '
',
+ '
',
[
{
- redundantAttribute: 'expr12',
- selector: '[expr12]',
+ redundantAttribute: 'expr0',
+ selector: '[expr0]',
expressions: [
{
@@ -567,12 +567,12 @@ riot__WEBPACK_IMPORTED_MODULE_1__.register('app-loading', _loading_riot__WEBPACK
type: bindingTypes.SLOT,
attributes: [],
name: 'title',
- redundantAttribute: 'expr13',
- selector: '[expr13]'
+ redundantAttribute: 'expr1',
+ selector: '[expr1]'
},
{
- redundantAttribute: 'expr14',
- selector: '[expr14]',
+ redundantAttribute: 'expr2',
+ selector: '[expr2]',
expressions: [
{
@@ -586,8 +586,8 @@ riot__WEBPACK_IMPORTED_MODULE_1__.register('app-loading', _loading_riot__WEBPACK
type: bindingTypes.SLOT,
attributes: [],
name: 'form',
- redundantAttribute: 'expr15',
- selector: '[expr15]'
+ redundantAttribute: 'expr3',
+ selector: '[expr3]'
},
{
type: bindingTypes.TAG,
@@ -603,12 +603,12 @@ riot__WEBPACK_IMPORTED_MODULE_1__.register('app-loading', _loading_riot__WEBPACK
}
],
- redundantAttribute: 'expr16',
- selector: '[expr16]'
+ redundantAttribute: 'expr4',
+ selector: '[expr4]'
},
{
- redundantAttribute: 'expr17',
- selector: '[expr17]',
+ redundantAttribute: 'expr5',
+ selector: '[expr5]',
expressions: [
{
@@ -624,8 +624,8 @@ riot__WEBPACK_IMPORTED_MODULE_1__.register('app-loading', _loading_riot__WEBPACK
]
},
{
- redundantAttribute: 'expr18',
- selector: '[expr18]',
+ redundantAttribute: 'expr6',
+ selector: '[expr6]',
expressions: [
{
@@ -693,8 +693,8 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
current: {
name: '',
url: '',
- requestHandler: '',
- action: '',
+ requestHandlers: '',
+ actionHandlers: '',
options: {
},
@@ -723,7 +723,7 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
'presence': true
},
'timer': {
- 'presence': true
+
}
})
@@ -735,28 +735,73 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
// adding on success
this.state.validator.onError((event, data) => {
this.state.isLoading = false
+
+ // add notification
_stores_notification__WEBPACK_IMPORTED_MODULE_2__["default"].danger('Error! Check your input!')
this.update()
})
+ //
_stores_taskForm_js__WEBPACK_IMPORTED_MODULE_1__["default"].on('open', (data) => {
this.state.isOpen = true
this.update()
})
- },
- /**
- *
- *
- *
- */
- handleSuccess(event, data)
- {
-
- }
+ this.getRequestHandlers()
+ this.getActionHandlers()
+ },
+
+ getRequestHandlers()
+ {
+ fetch('/api/v1/handler/request', {
+ 'method': 'GET'
+ })
+ .then((response) => response.json())
+ .then((response) => {
+ this.state.requestHandlers = response.data
+ this.update()
+ })
+ },
+
+ getActionHandlers()
+ {
+ fetch('/api/v1/handler/action', {
+ 'method': 'GET'
+ })
+ .then((response) => response.json())
+ .then((response) => {
+ this.state.actionHandlers = response.data
+ this.update()
+ })
+ },
+
+ /**
+ *
+ *
+ *
+ */
+ handleSuccess(event, data)
+ {
+ event.preventDefault()
+
+ fetch('/api/v1/task', {
+ 'method': 'POST',
+ 'body': JSON.stringify(data)
+ })
+ .then((response) => response.json())
+ .then((response) => {
+
+ // stop loading
+ this.state.isLoading = false
+
+ // add id to current
+ this.state.current.id = response.data.id
+ this.update()
+ })
+ }
}
- },
+ },
template: (
template,
@@ -779,7 +824,7 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
bindings: [
{
type: bindingTypes.IF,
- evaluate: _scope => _scope.state.current.name,
+ evaluate: _scope => _scope.state.current.id,
redundantAttribute: 'expr23',
selector: '[expr23]',
@@ -823,7 +868,7 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
},
{
type: bindingTypes.IF,
- evaluate: _scope => !_scope.state.current.name,
+ evaluate: _scope => !_scope.state.current.id,
redundantAttribute: 'expr24',
selector: '[expr24]',
@@ -852,7 +897,7 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
},
{
id: 'form',
- html: '
',
+ html: '
',
bindings: [
{
@@ -913,14 +958,24 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
condition: null,
template: template(
- null,
+ ' ',
[
{
expressions: [
+ {
+ type: expressionTypes.TEXT,
+ childNodeIndex: 0,
+
+ evaluate: _scope => [
+ _scope.requestHandler.name
+ ].join(
+ ''
+ )
+ },
{
type: expressionTypes.ATTRIBUTE,
name: 'value',
- evaluate: _scope => _scope.handler
+ evaluate: _scope => _scope.requestHandler.file
},
{
type: expressionTypes.ATTRIBUTE,
@@ -934,7 +989,7 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
redundantAttribute: 'expr30',
selector: '[expr30]',
- itemName: 'handler',
+ itemName: 'requestHandler',
indexName: null,
evaluate: _scope => _scope.state.requestHandlers
},
@@ -953,19 +1008,29 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
condition: null,
template: template(
- null,
+ ' ',
[
{
expressions: [
+ {
+ type: expressionTypes.TEXT,
+ childNodeIndex: 0,
+
+ evaluate: _scope => [
+ _scope.actionHandler.name
+ ].join(
+ ''
+ )
+ },
{
type: expressionTypes.ATTRIBUTE,
name: 'value',
- evaluate: _scope => _scope.action
+ evaluate: _scope => _scope.actionHandler.file
},
{
type: expressionTypes.ATTRIBUTE,
name: 'selected',
- evaluate: _scope => _scope.action === _scope.state.current.action
+ evaluate: _scope => _scope.action === _scope.state.current.actionHandler
}
]
}
@@ -974,9 +1039,9 @@ riot__WEBPACK_IMPORTED_MODULE_5__.register('field-error', _tiny_components_valid
redundantAttribute: 'expr32',
selector: '[expr32]',
- itemName: 'action',
+ itemName: 'actionHandler',
indexName: null,
- evaluate: _scope => _scope.state.actions
+ evaluate: _scope => _scope.state.actionHandlers
},
{
type: bindingTypes.TAG,
@@ -1113,11 +1178,11 @@ __webpack_require__.r(__webpack_exports__);
bindingTypes,
getComponent
) => template(
- '
',
+ '
',
[
{
- redundantAttribute: 'expr11',
- selector: '[expr11]',
+ redundantAttribute: 'expr7',
+ selector: '[expr7]',
expressions: [
{
@@ -1209,7 +1274,7 @@ __webpack_require__.r(__webpack_exports__);
bindingTypes,
getComponent
) => template(
- '
\n name\n | \n url\n | \n requestHandler\n | \n actions\n | \n cron\n | |
---|
|
|
|
',
+ '
\n name\n | \n url\n | \n requestHandler\n | \n actions\n | \n cron\n | |
---|
|
|
|
',
[
{
type: bindingTypes.EACH,
@@ -1217,11 +1282,11 @@ __webpack_require__.r(__webpack_exports__);
condition: _scope => _scope.state.tasks.length > 0,
template: template(
- '
| | | | | | ',
+ '
| | | | | | ',
[
{
- redundantAttribute: 'expr1',
- selector: '[expr1]',
+ redundantAttribute: 'expr9',
+ selector: '[expr9]',
expressions: [
{
@@ -1237,8 +1302,8 @@ __webpack_require__.r(__webpack_exports__);
]
},
{
- redundantAttribute: 'expr2',
- selector: '[expr2]',
+ redundantAttribute: 'expr10',
+ selector: '[expr10]',
expressions: [
{
@@ -1254,8 +1319,8 @@ __webpack_require__.r(__webpack_exports__);
]
},
{
- redundantAttribute: 'expr3',
- selector: '[expr3]',
+ redundantAttribute: 'expr11',
+ selector: '[expr11]',
expressions: [
{
@@ -1286,12 +1351,12 @@ __webpack_require__.r(__webpack_exports__);
slots: [
{
id: 'default',
- html: '
',
+ html: '
',
bindings: [
{
- redundantAttribute: 'expr5',
- selector: '[expr5]',
+ redundantAttribute: 'expr13',
+ selector: '[expr13]',
expressions: [
{
@@ -1309,8 +1374,8 @@ __webpack_require__.r(__webpack_exports__);
{
type: bindingTypes.IF,
evaluate: _scope => _scope.actions.options,
- redundantAttribute: 'expr6',
- selector: '[expr6]',
+ redundantAttribute: 'expr14',
+ selector: '[expr14]',
template: template(
' ',
@@ -1341,15 +1406,15 @@ __webpack_require__.r(__webpack_exports__);
]
),
- redundantAttribute: 'expr4',
- selector: '[expr4]',
+ redundantAttribute: 'expr12',
+ selector: '[expr12]',
itemName: 'action',
indexName: null,
evaluate: _scope => _scope.task.actions
},
{
- redundantAttribute: 'expr7',
- selector: '[expr7]',
+ redundantAttribute: 'expr15',
+ selector: '[expr15]',
expressions: [
{
@@ -1365,8 +1430,8 @@ __webpack_require__.r(__webpack_exports__);
]
},
{
- redundantAttribute: 'expr8',
- selector: '[expr8]',
+ redundantAttribute: 'expr16',
+ selector: '[expr16]',
expressions: [
{
@@ -1377,8 +1442,8 @@ __webpack_require__.r(__webpack_exports__);
]
},
{
- redundantAttribute: 'expr9',
- selector: '[expr9]',
+ redundantAttribute: 'expr17',
+ selector: '[expr17]',
expressions: [
{
@@ -1391,8 +1456,8 @@ __webpack_require__.r(__webpack_exports__);
]
),
- redundantAttribute: 'expr0',
- selector: '[expr0]',
+ redundantAttribute: 'expr8',
+ selector: '[expr8]',
itemName: 'task',
indexName: null,
evaluate: _scope => _scope.state.tasks
@@ -1400,8 +1465,8 @@ __webpack_require__.r(__webpack_exports__);
{
type: bindingTypes.IF,
evaluate: _scope => _scope.state.tasks.length === 0,
- redundantAttribute: 'expr10',
- selector: '[expr10]',
+ redundantAttribute: 'expr18',
+ selector: '[expr18]',
template: template(
'
\n Nothing found\n | ',