Add option to delete webhooks.

This commit is contained in:
James Cole 2022-09-18 05:49:56 +02:00
parent 625ad14d7d
commit d9245f06f7
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
58 changed files with 768 additions and 43 deletions

View File

@ -0,0 +1,76 @@
<?php
/**
* DeleteController.php
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Webhooks;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Webhook;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Redirector;
use Illuminate\View\View;
/**
* Class DeleteController
*/
class DeleteController extends Controller
{
/**
* DeleteController constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
parent::__construct();
// translations:
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-bolt');
app('view')->share('subTitleIcon', 'fa-trash');
app('view')->share('title', (string) trans('firefly.webhooks'));
app('view')->share('subTitle', (string) trans('firefly.delete_webhook'));
return $next($request);
}
);
}
/**
* Delete account screen.
*
* @param Webhook $webhook
*
* @return Factory|RedirectResponse|Redirector|View
*/
public function index(Webhook $webhook)
{
$subTitle = (string) trans('firefly.delete_webhook', ['title' => $webhook->name]);
$this->rememberPreviousUrl('webhooks.delete.url');
return view('webhooks.delete', compact('webhook', 'subTitle'));
}
}

View File

@ -0,0 +1,77 @@
<?php
/**
* EditController.php
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Webhooks;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\Webhook;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\View\View;
/**
* Class EditController
*/
class EditController extends Controller
{
/**
* DeleteController constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
parent::__construct();
// translations:
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-bolt');
app('view')->share('subTitleIcon', 'fa-pencil');
app('view')->share('title', (string) trans('firefly.webhooks'));
return $next($request);
}
);
}
/**
* Delete account screen.
*
* @param Webhook $webhook
*
* @return Factory|RedirectResponse|Redirector|View
*/
public function index(Webhook $webhook)
{
$subTitle = (string) trans('firefly.edit_webhook', ['title' => $webhook->title]);
$this->rememberPreviousUrl('webhooks.delete.url');
return view('webhooks.edit', compact('webhook', 'subTitle'));
}
}

View File

@ -0,0 +1,76 @@
<?php
/**
* ShowController.php
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Webhooks;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\Webhook;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\View\View;
/**
* Class ShowController
*/
class ShowController extends Controller
{
/**
* DeleteController constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
parent::__construct();
// translations:
$this->middleware(
function ($request, $next) {
app('view')->share('mainTitleIcon', 'fa-bolt');
app('view')->share('subTitleIcon', 'fa-bolt');
app('view')->share('title', (string) trans('firefly.webhooks'));
return $next($request);
}
);
}
/**
* Delete account screen.
*
* @param Webhook $webhook
*
* @return Factory|RedirectResponse|Redirector|View
*/
public function index(Webhook $webhook)
{
$subTitle = (string) trans('firefly.show_webhook', ['title' => $webhook->title]);
return view('webhooks.show', compact('webhook', 'subTitle'));
}
}

View File

@ -82,9 +82,6 @@ use FireflyIII\TransactionRules\Actions\SetNotes;
use FireflyIII\TransactionRules\Actions\SetSourceAccount;
use FireflyIII\TransactionRules\Actions\UpdatePiggybank;
use FireflyIII\User;
use FireflyIII\Enums\WebhookResponse as WebhookResponseEnum;
use FireflyIII\Enums\WebhookDelivery as WebhookDeliveryEnum;
use FireflyIII\Enums\WebhookTrigger as WebhookTriggerEnum;
/*
@ -510,7 +507,7 @@ return [
'expected_source_types' => [
'source' => [
TransactionTypeModel::WITHDRAWAL => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
TransactionTypeEnum::DEPOSIT->value => [AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
TransactionTypeEnum::DEPOSIT->value => [AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
TransactionTypeModel::TRANSFER => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
TransactionTypeModel::OPENING_BALANCE => [AccountType::INITIAL_BALANCE, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT,
AccountType::MORTGAGE,],
@ -529,7 +526,7 @@ return [
'destination' => [
TransactionTypeModel::WITHDRAWAL => [AccountType::EXPENSE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT,
AccountType::MORTGAGE,],
TransactionTypeEnum::DEPOSIT->value => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
TransactionTypeEnum::DEPOSIT->value => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
TransactionTypeModel::TRANSFER => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
TransactionTypeModel::OPENING_BALANCE => [AccountType::INITIAL_BALANCE, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT,
AccountType::MORTGAGE,],
@ -680,7 +677,7 @@ return [
AccountType::DEBT => [AccountType::EXPENSE, AccountType::CASH],
AccountType::MORTGAGE => [AccountType::EXPENSE, AccountType::CASH],
],
TransactionTypeEnum::DEPOSIT->value => [
TransactionTypeEnum::DEPOSIT->value => [
AccountType::REVENUE => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
AccountType::CASH => [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE],
AccountType::LOAN => [AccountType::ASSET],
@ -730,7 +727,7 @@ return [
'recurrence_total', 'recurrence_count',
],
'webhooks' => [
'max_attempts' => env('WEBHOOK_MAX_ATTEMPTS', 3)
'max_attempts' => env('WEBHOOK_MAX_ATTEMPTS', 3),
],
'can_have_virtual_amounts' => [AccountType::ASSET],
'can_have_opening_balance' => [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],

View File

@ -5,5 +5,7 @@
"/v1/js/edit_transaction.js": "/v1/js/edit_transaction.js",
"/v1/js/profile.js": "/v1/js/profile.js",
"/v1/js/webhooks/index.js": "/v1/js/webhooks/index.js",
"/v1/js/webhooks/create.js": "/v1/js/webhooks/create.js"
"/v1/js/webhooks/create.js": "/v1/js/webhooks/create.js",
"/v1/js/webhooks/edit.js": "/v1/js/webhooks/edit.js",
"/v1/js/webhooks/show.js": "/v1/js/webhooks/show.js"
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
public/v1/js/webhooks/edit.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */

File diff suppressed because one or more lines are too long

2
public/v1/js/webhooks/show.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */

View File

@ -70,6 +70,11 @@ export default {
mounted() {
this.title = this.value;
},
watch: {
value() {
this.title = this.value;
}
},
components: {},
data() {
return {

View File

@ -68,6 +68,11 @@ export default {
}
},
name: "URL",
watch: {
value() {
this.url = this.value;
}
},
mounted() {
this.url = this.value;
},

View File

@ -75,6 +75,11 @@ export default {
{id: 300, name: this.$t('firefly.webhook_delivery_JSON')},
];
},
watch: {
value() {
this.delivery = this.value;
}
},
methods: {
hasError() {
return this.error?.length > 0;

View File

@ -67,6 +67,11 @@ export default {
required: true,
}
},
watch: {
value() {
this.response = this.value;
}
},
mounted() {
this.response = this.value;
this.responses = [

View File

@ -75,6 +75,11 @@ export default {
{id: 120, name: this.$t('firefly.webhook_trigger_DESTROY_TRANSACTION')},
];
},
watch: {
value() {
this.trigger = this.value;
}
},
methods: {
hasError() {
return this.error?.length > 0;

View File

@ -162,7 +162,3 @@ export default {
},
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,209 @@
<!--
- Edit.vue
- Copyright (c) 2022 james@firefly-iii.org
-
- This file is part of Firefly III (https://github.com/firefly-iii).
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<template>
<form accept-charset="UTF-8" class="form-horizontal" enctype="multipart/form-data">
<input name="_token" type="hidden" value="xxx">
<div v-if="error_message !== ''" class="row">
<div class="col-lg-12">
<div class="alert alert-danger alert-dismissible" role="alert">
<button class="close" data-dismiss="alert" type="button" v-bind:aria-label="$t('firefly.close')"><span
aria-hidden="true">&times;</span></button>
<strong>{{ $t("firefly.flash_error") }}</strong> {{ error_message }}
</div>
</div>
</div>
<div v-if="success_message !== ''" class="row">
<div class="col-lg-12">
<div class="alert alert-success alert-dismissible" role="alert">
<button class="close" data-dismiss="alert" type="button" v-bind:aria-label="$t('firefly.close')"><span
aria-hidden="true">&times;</span></button>
<strong>{{ $t("firefly.flash_success") }}</strong> <span v-html="success_message"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-12 col-sm-12">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">
{{ $t('firefly.edit_webhook_js', {title: this.title}) }}
</h3>
</div>
<div class="box-body">
<div class="row">
<div class="col-lg-12">
<Title :value=this.title :error="errors.title" v-on:input="title = $event"></Title>
<WebhookTrigger :value=this.trigger :error="errors.trigger"
v-on:input="trigger = $event"></WebhookTrigger>
<WebhookResponse :value=this.response :error="errors.response"
v-on:input="response = $event"></WebhookResponse>
<WebhookDelivery :value=this.delivery :error="errors.delivery"
v-on:input="delivery = $event"></WebhookDelivery>
<URL :value=this.url :error="errors.url" v-on:input="url = $event"></URL>
<Checkbox :value=this.active :error="errors.active" help="ACTIVE HELP TODO" :title="$t('form.active')"
v-on:input="active = $event"></Checkbox>
</div>
</div>
</div>
<div class="box-footer">
<div class="btn-group">
<button id="submitButton" ref="submitButton" class="btn btn-success" @click="submit">
{{ $t('firefly.submit') }}
</button>
</div>
<p class="text-success" v-html="success_message"></p>
<p class="text-danger" v-html="error_message"></p>
</div>
</div>
</div>
</div>
</form>
</template>
<script>
import Title from "../form/Title";
import WebhookTrigger from "../form/WebhookTrigger";
import WebhookResponse from "../form/WebhookResponse";
import WebhookDelivery from "../form/WebhookDelivery";
import URL from "../form/URL";
import Checkbox from "../form/Checkbox";
export default {
name: "Edit",
components: {URL, Title, WebhookTrigger, WebhookResponse, WebhookDelivery, Checkbox},
data() {
return {
error_message: '',
success_message: '',
title: '',
trigger: 100,
response: 200,
delivery: 300,
active: true,
url: '',
errors: {
title: [],
trigger: [],
response: [],
delivery: [],
url: [],
active: []
}
};
},
mounted() {
this.getWebhook();
},
methods: {
getWebhook: function () {
const page = window.location.href.split('/');
const webhookId = page[page.length - 1];
this.downloadWebhook(webhookId);
},
downloadWebhook: function (id) {
axios.get('./api/v1/webhooks/' + id).then(response => {
console.log(response.data.data.attributes);
this.title = response.data.data.attributes.title;
// trigger value on content
if('STORE_TRANSACTION' === response.data.data.attributes.trigger) {
this.trigger = 100;
}
if('UPDATE_TRANSACTION' === response.data.data.attributes.trigger) {
this.trigger = 110;
}
if('DESTROY_TRANSACTION' === response.data.data.attributes.trigger) {
this.trigger = 120;
}
// response value
if('TRANSACTIONS' === response.data.data.attributes.response) {
this.response = 200;
}
if('ACCOUNTS' === response.data.data.attributes.response) {
this.response = 210;
}
if('NONE' === response.data.data.attributes.response) {
this.response = 220;
}
if('JSON' === response.data.data.attributes.delivery) {
this.delivery = 300;
}
this.active = response.data.data.attributes.active;
this.url = response.data.data.attributes.url;
}).catch(error => {
this.error_message = error.response.data.message;
});
},
submit: function (e) {
// reset messages
this.error_message = '';
this.success_message = '';
this.errors = {
title: [],
trigger: [],
response: [],
delivery: [],
url: [],
active: [],
};
// disable button
$('#submitButton').prop("disabled", true);
// collect data
let data = {
title: this.title,
trigger: this.trigger,
response: this.response,
delivery: this.delivery,
url: this.url,
};
// post!
axios.post('./api/v1/webhooks', data).then((response) => {
this.success_message = response.data.message;
// console.log('Will now go to redirectUser()');
let webhookId = response.data.data.id;
window.location.href = window.previousUrl + '?webhook_id=' + webhookId + '&message=created';
}).catch((error) => {
this.error_message = error.response.data.message;
this.errors.title = error.response.data.errors.title;
this.errors.trigger = error.response.data.errors.trigger;
this.errors.response = error.response.data.errors.response;
this.errors.delivery = error.response.data.errors.delivery;
this.errors.url = error.response.data.errors.url;
// enable button again
$('#submitButton').prop("disabled", false);
});
if (e) {
e.preventDefault();
}
}
},
}
</script>

View File

@ -0,0 +1,35 @@
<!--
- Show.vue
- Copyright (c) 2022 james@firefly-iii.org
-
- This file is part of Firefly III (https://github.com/firefly-iii).
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<template>
<p>
ShowX
</p>
</template>
<script>
export default {
name: "Show"
}
</script>
<style scoped>
</style>

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "\u0394\u03b9\u03b5\u03cd\u03b8\u03c5\u03bd\u03c3\u03b7 URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL-osoite",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "Liens",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "link",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "\u0421\u0441\u044b\u043b\u043a\u0430",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "L\u00e4nk",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "\u7f51\u5740",

View File

@ -100,7 +100,8 @@
"webhook_trigger_form_help": "Indicate on what event the webhook wil trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called."
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\""
},
"form": {
"url": "URL",

39
resources/assets/js/webhooks/edit.js vendored Normal file
View File

@ -0,0 +1,39 @@
/*
* edit.js
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import Edit from "../components/webhooks/Edit";
/**
* First we will load Axios via bootstrap.js
* jquery and bootstrap-sass preloaded in app.js
* vue, uiv and vuei18n are in app_vue.js
*/
require('../bootstrap');
const i18n = require('../i18n');
let props = {};
const app = new Vue({
i18n,
el: "#webhooks_edit",
render: (createElement) => {
return createElement(Edit, {props: props})
},
});

39
resources/assets/js/webhooks/show.js vendored Normal file
View File

@ -0,0 +1,39 @@
/*
* edit.js
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import Show from "../components/webhooks/Show";
/**
* First we will load Axios via bootstrap.js
* jquery and bootstrap-sass preloaded in app.js
* vue, uiv and vuei18n are in app_vue.js
*/
require('../bootstrap');
const i18n = require('../i18n');
let props = {};
const app = new Vue({
i18n,
el: "#webhooks_show",
render: (createElement) => {
return createElement(Show, {props: props})
},
});

View File

@ -244,6 +244,11 @@ return [
'webhook_delivery_form_help' => 'Which format the webhook must deliver data in.',
'webhook_active_form_help' => 'The webhook must be active or it won\'t be called.',
'stored_new_webhook' => 'Stored new webhook ":title"',
'delete_webhook' => 'Delete webhook',
'deleted_webhook' => 'Deleted webhook ":title"',
'edit_webhook' => 'Edit webhook ":title"',
'edit_webhook_js' => 'Edit webhook "{title}"',
'show_webhook' => 'Webhook ":title"',
// API access
'authorization_request' => 'Firefly III v:version Authorization Request',

View File

@ -125,6 +125,7 @@ return [
'start' => 'Start of range',
'end' => 'End of range',
'delete_account' => 'Delete account ":name"',
'delete_webhook' => 'Delete webhook ":title"',
'delete_bill' => 'Delete bill ":name"',
'delete_budget' => 'Delete budget ":name"',
'delete_category' => 'Delete category ":name"',
@ -145,6 +146,7 @@ return [
'object_group_areYouSure' => 'Are you sure you want to delete the group titled ":title"?',
'ruleGroup_areYouSure' => 'Are you sure you want to delete the rule group titled ":title"?',
'budget_areYouSure' => 'Are you sure you want to delete the budget named ":name"?',
'webhook_areYouSure' => 'Are you sure you want to delete the webhook named ":title"?',
'category_areYouSure' => 'Are you sure you want to delete the category named ":name"?',
'recurring_areYouSure' => 'Are you sure you want to delete the recurring transaction titled ":title"?',
'currency_areYouSure' => 'Are you sure you want to delete the currency named ":name"?',

View File

@ -1,7 +1,7 @@
{% set VUE_SCRIPT_NAME = 'webhooks/create' %}
{% extends './layout/default' %}
{% block breadcrumbs %}
{{ Breadcrumbs.render(Route.getCurrentRoute.getName, objectType) }}
{{ Breadcrumbs.render(Route.getCurrentRoute.getName) }}
{% endblock %}
{% block content %}

View File

@ -0,0 +1,44 @@
{% extends './layout/default' %}
{% block breadcrumbs %}
{{ Breadcrumbs.render(Route.getCurrentRoute.getName, webhook) }}
{% endblock %}
{% block content %}
<div class="row">
<div class="col-lg-6 col-lg-offset-3 col-md-12 col-sm-12">
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title">{{ trans('form.delete_webhook', {'title': webhook.title}) }}</h3>
</div>
<div class="box-body">
<p class="text-danger">
{{ trans('form.permDeleteWarning') }}
</p>
<p>
{{ trans('form.webhook_areYouSure', {'title': webhook.title}) }}
</p>
</div>
<div class="box-footer">
<input type="submit" id="button" name="submit" value="{{ trans('form.deletePermanently') }}"
class="btn pull-right btn-danger"/>
<a href="{{ URL.previous() }}" class="btn-default btn">{{ trans('form.cancel') }}</a>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script nonce="{{ JS_NONCE }}">
$(function () {
"use strict";
$('#button').click(function() {
var url = "{{ route('index') }}/api/v1/webhooks/{{ webhook.id }}";
$.ajax({url: url, type: 'DELETE'}).done(function() {
window.location = "{{ URL.previous() }}?webhook_id={{ webhook.id }}&message=deleted";
});
});
});
</script>
{% endblock %}

View File

@ -0,0 +1,14 @@
{% set VUE_SCRIPT_NAME = 'webhooks/edit' %}
{% extends './layout/default' %}
{% block breadcrumbs %}
{{ Breadcrumbs.render(Route.getCurrentRoute.getName, webhook) }}
{% endblock %}
{% block content %}
<div id="webhooks_edit"></div>
{% endblock %}
{% block scripts %}
<script type="text/javascript" nonce="{{ JS_NONCE }}">
var previousUrl = '{{ previousUrl }}';
</script>
{% endblock %}

View File

@ -0,0 +1,14 @@
{% set VUE_SCRIPT_NAME = 'webhooks/show' %}
{% extends './layout/default' %}
{% block breadcrumbs %}
{{ Breadcrumbs.render(Route.getCurrentRoute.getName, webhook) }}
{% endblock %}
{% block content %}
<div id="webhooks_show"></div>
{% endblock %}
{% block scripts %}
<script type="text/javascript" nonce="{{ JS_NONCE }}">
var previousUrl = '{{ previousUrl }}';
</script>
{% endblock %}

View File

@ -40,6 +40,7 @@ use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalLink;
use FireflyIII\Models\Webhook;
use FireflyIII\User;
use Illuminate\Support\Arr;
@ -1244,6 +1245,30 @@ try {
}
);
Breadcrumbs::for(
'webhooks.show',
static function (Generator $breadcrumbs, Webhook $webhook) {
$breadcrumbs->parent('webhooks.index');
$breadcrumbs->push(limitStringLength($webhook->title), route('webhooks.show', [$webhook->id]));
}
);
Breadcrumbs::for(
'webhooks.delete',
static function (Generator $breadcrumbs, Webhook $webhook) {
$breadcrumbs->parent('webhooks.show', $webhook);
$breadcrumbs->push(trans('firefly.delete_webhook', ['title' => limitStringLength($webhook->title)]), route('webhooks.delete', [$webhook->id]));
}
);
Breadcrumbs::for(
'webhooks.edit',
static function (Generator $breadcrumbs, Webhook $webhook) {
$breadcrumbs->parent('webhooks.show', $webhook);
$breadcrumbs->push(trans('firefly.edit_webhook', ['title' => limitStringLength($webhook->title)]), route('webhooks.edit', [$webhook->id]));
}
);
} catch (DuplicateBreadcrumbException $e) {
// @ignoreException
}

View File

@ -1092,6 +1092,9 @@ Route::group(
static function () {
Route::get('index', ['uses' => 'IndexController@index', 'as' => 'index']);
Route::get('create', ['uses' => 'CreateController@index', 'as' => 'create']);
Route::get('edit/{webhook}', ['uses' => 'EditController@index', 'as' => 'edit']);
Route::get('delete/{webhook}', ['uses' => 'DeleteController@index', 'as' => 'delete']);
Route::get('show/{webhook}', ['uses' => 'ShowController@index', 'as' => 'show']);
}
);

2
webpack.mix.js vendored
View File

@ -37,3 +37,5 @@ mix.js('resources/assets/js/profile.js', 'public/v1/js').vue({version: 2});
// webhooks
mix.js('resources/assets/js/webhooks/index.js', 'public/v1/js/webhooks').vue({version: 2});
mix.js('resources/assets/js/webhooks/create.js', 'public/v1/js/webhooks').vue({version: 2});
mix.js('resources/assets/js/webhooks/edit.js', 'public/v1/js/webhooks').vue({version: 2});
mix.js('resources/assets/js/webhooks/show.js', 'public/v1/js/webhooks').vue({version: 2});