From b4ec5ab21996be7c1e9001fb2691ef8dd0bcf8b9 Mon Sep 17 00:00:00 2001 From: Eugen Ciur <eugen@papermerge.com> Date: Sat, 2 Oct 2021 08:33:47 +0200 Subject: [PATCH] adding automates routes/components --- app/models/automate.js | 1 + app/router.js | 8 +++---- app/routes/automates/index.js | 11 +++++++++ app/routes/tags/edit.js | 12 ---------- app/routes/tags/index.js | 1 + app/templates/automates/index.hbs | 40 ++++++++++++++++++++++++++++--- public/api/automates.json | 23 ++++++++++++++++++ 7 files changed, 76 insertions(+), 20 deletions(-) create mode 100644 app/routes/automates/index.js delete mode 100644 app/routes/tags/edit.js create mode 100644 public/api/automates.json diff --git a/app/models/automate.js b/app/models/automate.js index e852ec1..e908b67 100644 --- a/app/models/automate.js +++ b/app/models/automate.js @@ -5,6 +5,7 @@ export default class AutomateModel extends Model { @attr name; @attr match; @attr matching_algorithm; + @attr dst_folder; @attr('boolean') is_case_sensitive; @hasMany('tags') tags; } diff --git a/app/router.js b/app/router.js index f110606..f2c57b5 100644 --- a/app/router.js +++ b/app/router.js @@ -1,28 +1,26 @@ import EmberRouter from '@ember/routing/router'; import config from 'papermerge/config/environment'; + export default class Router extends EmberRouter { location = config.locationType; rootURL = config.rootURL; } + Router.map(function () { this.route('documents'); - this.route('about'); - this.route('contact', { path: '/getting-in-touch' }); this.route('document', { path: '/document/:document_id' }); this.route('node', { path: '/node/:node_id' }); this.route('tags', function () { - this.route('add'); - this.route('edit', { path: ':tag_id/edit' }); this.route('index', { path: '/' }); }); this.route('automates', function () { this.route('add'); - this.route('automate', { path: '/:automate_id' }); + this.route('edit', { path: '/:automate_id/edit' }); this.route('index', { path: '/' }); }); diff --git a/app/routes/automates/index.js b/app/routes/automates/index.js new file mode 100644 index 0000000..bb83b1c --- /dev/null +++ b/app/routes/automates/index.js @@ -0,0 +1,11 @@ +import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; + + +export default class AutomatesRoute extends Route { + @service store; + + async model() { + return this.store.findAll('automate'); + } +} diff --git a/app/routes/tags/edit.js b/app/routes/tags/edit.js deleted file mode 100644 index c6173ca..0000000 --- a/app/routes/tags/edit.js +++ /dev/null @@ -1,12 +0,0 @@ -import Route from '@ember/routing/route'; -import { inject as service } from '@ember/service'; - -export default class TagsRoute extends Route { - @service store; - - async model(params) { - let ret = this.store.findRecord('tag', params.tag_id); - console.log(ret); - return ret; - } -} diff --git a/app/routes/tags/index.js b/app/routes/tags/index.js index 615910e..f4518b6 100644 --- a/app/routes/tags/index.js +++ b/app/routes/tags/index.js @@ -1,6 +1,7 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; + export default class TagsRoute extends Route { @service store; diff --git a/app/templates/automates/index.hbs b/app/templates/automates/index.hbs index d0abf2a..e2b8ed7 100644 --- a/app/templates/automates/index.hbs +++ b/app/templates/automates/index.hbs @@ -1,4 +1,38 @@ -<h1>Automates Index</h1> +<LinkTo @route="automates.add" class="btn btn-success">New</LinkTo> - -<LinkTo @route="automates.add" class="btn btn-success">New</LinkTo> \ No newline at end of file +<div class="tags"> + <table class="table table-striped align-middle"> + <thead> + <tr class="text-uppercase"> + <th class="border-top-0">Name</th> + <th class="border-top-0">Match</th> + <th class="border-top-0">Destination</th> + <th class="border-top-0">Tags</th> + <th class="border-top-0">Action</th> + </tr> + </thead> + <tbody> + {{#each @model as |automate|}} + <tr> + <td> + {{automate.name}} + </td> + <td> + {{automate.match}} + </td> + <td> + {{automate.dst_folder}} + </td> + <td> + ... + </td> + <td> + <button class="btn btn-link"> Edit + </button> + <button class="btn btn-link">Remove</button> + </td> + </tr> + {{/each}} + </tbody> + </table> +</div> \ No newline at end of file diff --git a/public/api/automates.json b/public/api/automates.json new file mode 100644 index 0000000..49773e1 --- /dev/null +++ b/public/api/automates.json @@ -0,0 +1,23 @@ +{ + "data": [ + { + "id": 1, + "type": "automate", + "attributes": { + "name": "zdf", + "match": "ZDF", + "matching_algorithm": "any", + "is_case_sensitive": false + } + }, { + "id": 2, + "type": "automate", + "attributes": { + "name": "groceries", + "match": "LIDL|LDL", + "matching_algorithm": "any", + "is_case_sensitive": false + } + } + ] +} \ No newline at end of file -- GitLab