Skip to content

Commit 496d29e

Browse files
committed
✨ error/warn/log to console from commands
Signed-off-by: Bruno Meilick <[email protected]>
1 parent fb5dbe5 commit 496d29e

File tree

8 files changed

+169
-152
lines changed

8 files changed

+169
-152
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ The button you create with the `field: janitor` in your blueprint can be configu
168168
- `confirm`, sets text for confirmation after clicking the button and before executing the command, can prevent the execution of the command if the user clicks `cancel` in the OS dialog
169169
- `command`, command like you would enter it in terminal, with [query language support](https://getkirby.com/docs/guide/blueprints/query-language) and page/file/user/site/data arguments
170170
- `cooldown`, time in milliseconds the message is flashed on the button (default: 2000)
171-
- `error`, set message to show on all **non-200**-status returns with query language support
171+
- `error`, set message on button to show onpa all **non-200**-status returns with query language support, also will print to `console.error()`
172+
- `warn`, print to `console.warn()`
173+
- `log`, print to `console.log()`
172174
- `help`, set help of the button
173175
- `icon`, set the [icon](https://getkirby.com/docs/reference/panel/icons) of the button
174176
- `intab`, if `true` then use in combination with the `open`-option to open an URL in a new tab

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bnomei/kirby3-janitor",
33
"type": "kirby-plugin",
4-
"version": "5.0.1",
4+
"version": "5.1.0",
55
"license": "MIT",
66
"homepage": "https://github.com/bnomei/kirby3-janitor",
77
"description": "Kirby Plugin for running commands like cleaning the cache from within the Panel, PHP code or a cronjob",

composer.lock

Lines changed: 142 additions & 142 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/fields/Janitor.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,15 @@ export default {
185185
download,
186186
clipboard,
187187
success,
188-
error,
189188
icon,
190189
help,
191190
color,
192191
backgroundColor,
193192
resetStyle,
194-
notification
193+
notification,
194+
error,
195+
warn,
196+
log
195197
} = await this.$api.post(path, data);
196198
197199
if (status === 200) {
@@ -249,6 +251,18 @@ export default {
249251
this.$panel.notification[f](m);
250252
}
251253
254+
if (error) {
255+
console.error(error);
256+
}
257+
258+
if (warn) {
259+
console.warn(warn);
260+
}
261+
262+
if (log) {
263+
console.log(log);
264+
}
265+
252266
if (reload) {
253267
location.reload();
254268
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ window.panel.plugin("bnomei/janitor", {
55
janitor: Janitor
66
},
77
viewButtons: {
8-
janitor: Janitor,
8+
janitor: Janitor
99
},
1010
icons: {
1111
janitorLoader:

tests/site/commands/ping.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
janitor()->data($cli->arg('command'), [
1717
'status' => $success ? 200 : 404,
18+
($success ? 'log' : 'warn') => $success ? 'Pong' : $cli->kirby()->page($cli->arg('page'))->content()->toArray(),
1819
// messages for success and error are defined in blueprint
1920
// but could also be provided here
2021
// 'success' => 'Pang',

vendor/composer/installed.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php return array(
22
'root' => array(
33
'name' => 'bnomei/kirby3-janitor',
4-
'pretty_version' => '5.0.0',
5-
'version' => '5.0.0.0',
4+
'pretty_version' => '5.1.0',
5+
'version' => '5.1.0.0',
66
'reference' => null,
77
'type' => 'kirby-plugin',
88
'install_path' => __DIR__ . '/../../',
@@ -11,8 +11,8 @@
1111
),
1212
'versions' => array(
1313
'bnomei/kirby3-janitor' => array(
14-
'pretty_version' => '5.0.0',
15-
'version' => '5.0.0.0',
14+
'pretty_version' => '5.1.0',
15+
'version' => '5.1.0.0',
1616
'reference' => null,
1717
'type' => 'kirby-plugin',
1818
'install_path' => __DIR__ . '/../../',

0 commit comments

Comments
 (0)