add reports details + handle uppercase

This commit is contained in:
Jordan Blasenhauer 2024-06-26 11:07:42 +02:00
parent d152ed903e
commit 6d14ad67c6
10 changed files with 1280 additions and 48 deletions

View file

@ -1119,7 +1119,7 @@ body {
/* LIST COMPONENT */
.list-pairs-container {
@apply grid grid-cols-12 gap-2 my-4;
@apply col-span-12 grid grid-cols-12 gap-2 my-4;
}
.list-pairs-item {

File diff suppressed because one or more lines are too long

View file

@ -5,6 +5,7 @@ import GridLayout from "@components/Widget/GridLayout.vue";
import Title from "@components/Widget/Title.vue";
import Subtitle from "@components/Widget/Subtitle.vue";
import Table from "@components/Widget/Table.vue";
import ListPairs from "@components/List/Pairs.vue";
import MessageUnmatch from "@components/Message/Unmatch.vue";
/**
@ -52,6 +53,7 @@ const props = defineProps({
<Title v-if="widget.type === 'Title'" v-bind="widget.data" />
<Subtitle v-if="widget.type === 'Subtitle'" v-bind="widget.data" />
<Table v-if="widget.type === 'Table'" v-bind="widget.data" />
<ListPairs v-if="widget.type === 'ListPairs'" v-bind="widget.data" />
</template>
</Grid>
</GridLayout>

View file

@ -16,6 +16,7 @@ import { computed, onMounted, reactive, ref } from "vue";
@param {string} [tag=""] - The tag of the subtitle. Can be h1, h2, h3, h4, h5, h6 or p. If empty, will be determine by the type of subtitle.
@param {string} [color=""] - The color of the subtitle between error, success, warning, info or tailwind color
@param {boolean} [bold=false] - If the subtitle should be bold or not.
@param {boolean} [uppercase=false] - If the subtitle should be uppercase or not.
@param {string} [subtitleClass=""] - Additional class, useful when component is used directly on a grid system
*/
@ -44,6 +45,11 @@ const props = defineProps({
required: false,
default: false,
},
uppercase: {
type: Boolean,
required: false,
default: false,
},
subtitleClass: {
type: String,
required: false,
@ -78,7 +84,13 @@ onMounted(() => {
data-subtitle
:is="tag"
v-if="props.subtitle"
:class="[subtitle.class, props.color, 'text-el', props.bold ? 'bold' : '']"
:class="[
subtitle.class,
props.color,
'text-el',
props.bold ? 'bold' : '',
props.uppercase ? 'uppercase' : '',
]"
>
{{ $t(props.subtitle, $t("dashboard_placeholder", props.subtitle)) }}
</component>

View file

@ -15,6 +15,7 @@ import { onMounted, reactive, ref } from "vue";
@param {string} [textClass=""] - Style of text. Can be replace by any class starting by 'text-' like 'text-stat'.
@param {string} [color=""] - The color of the text between error, success, warning, info or tailwind color
@param {boolean} [bold=false] - If the text should be bold or not.
@param {boolean} [uppercase=false] - If the text should be uppercase or not.
@param {string} [tag="p"] - The tag of the text. Can be p, span, div, h1, h2, h3, h4, h5, h6
@param {boolean|object} [icon=false] - The icon to add before the text. If true, will add a default icon. If object, will add the icon with the name and the color.
@param {object} [attrs={}] - List of attributs to add to the text.
@ -40,6 +41,11 @@ const props = defineProps({
required: false,
default: false,
},
uppercase: {
type: Boolean,
required: false,
default: false,
},
tag: {
type: String,
required: false,
@ -84,7 +90,13 @@ onMounted(() => {
:is="props.tag"
v-bind="props.attrs"
ref="textEl"
:class="[text.class, props.color, 'text-el', props.bold ? 'bold' : '']"
:class="[
text.class,
props.color,
'text-el',
props.bold ? 'bold' : '',
props.uppercase ? 'uppercase' : '',
]"
>
{{ $t(props.text, $t("dashboard_placeholder", props.text)) }}
</component>

View file

@ -15,6 +15,7 @@ import { computed, onMounted, reactive, ref } from "vue";
@param {string} [type="card"] - The type of title between "container", "card", "content", "min" or "stat"
@param {string} [tag=""] - The tag of the title. Can be h1, h2, h3, h4, h5, h6 or p. If empty, will be determine by the type of title.
@param {string} [color=""] - The color of the title between error, success, warning, info or tailwind color
@param {boolean} [uppercase=false] - If the title should be uppercase or not.
@param {string} [titleClass=""] - Additional class, useful when component is used directly on a grid system
*/
@ -38,6 +39,11 @@ const props = defineProps({
required: false,
default: "",
},
uppercase: {
type: Boolean,
required: false,
default: false,
},
titleClass: {
type: String,
required: false,
@ -83,7 +89,13 @@ onMounted(() => {
data-title
:is="tag"
v-if="props.title"
:class="[props.color, isSubtitleClass, title.class, 'text-el']"
:class="[
props.color,
isSubtitleClass,
title.class,
'text-el',
props.uppercase ? 'uppercase' : '',
]"
>
{{ $t(props.title, $t("dashboard_placeholder", props.title)) }}
</component>

View file

@ -1,4 +1,5 @@
{
"dashboard_details": "details",
"dashboard_placehoder" : "{placeholder}",
"dashboard_logo_alt": "BunkerWeb logo image",
"dashboard_logo_link_label": "Redirect to home page",
@ -238,5 +239,8 @@
"reports_table_status_code" : "Status code",
"reports_table_cache_user_agent" : "User agent",
"reports_table_reason" : "Reason",
"reports_table_data": "Data"
"reports_table_data": "Data",
"reports_total": "Total reports",
"reports_top_status": "Top status code",
"reports_top_reason": "Top reason"
}

View file

@ -33,12 +33,577 @@ onMounted(() => {
const builder = [
{
type: "void",
type: "card",
containerColumns: {
pc: 4,
tablet: 6,
mobile: 12,
},
widgets: [
{
type: "MessageUnmatch",
type: "Title",
data: {
text: "reports_not_found",
title: "dashboard_details",
},
},
{
type: "ListPairs",
data: {
pairs: [
{
key: "reports_total",
value: "200",
},
{
key: "reports_top_status",
value: "400",
},
{
key: "reports_top_reason",
value: "antibot",
},
],
},
},
],
},
{
type: "card",
containerColumns: {
pc: 12,
tablet: 12,
mobile: 12,
},
widgets: [
{
type: "Title",
data: {
title: "reports_title",
},
},
{
type: "Table",
data: {
title: "reports_table_title",
minWidth: "xl",
header: [
"reports_table_date",
"reports_table_ip",
"reports_table_country",
"reports_table_method",
"reports_table_url",
"reports_table_status_code",
"reports_table_cache_user_agent",
"reports_table_reason",
"reports_table_data",
],
positions: [1, 1, 1, 1, 2, 1, 2, 1, 2],
items: [
[
{
date: "25/06/2024 07:40:23",
type: "Text",
data: {
text: "25/06/2024 07:40:23",
},
},
{
ip: "172.21.0.1",
type: "Text",
data: {
text: "172.21.0.1",
},
},
{
country: "local",
type: "Text",
data: {
text: "local",
},
},
{
method: "GET",
type: "Text",
data: {
text: "GET",
},
},
{
url: "/admin/login?id=etc/passwd",
type: "Text",
data: {
text: "/admin/login?id=etc/passwd",
},
},
{
code: "403",
type: "Text",
data: {
text: "403",
},
},
{
user_agent:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
type: "Text",
data: {
text: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
},
},
{
reason: "modsecurity",
type: "Text",
data: {
text: "modsecurity",
},
},
{
raw_data:
'{"fesfesfsefesfesfesfesfesfesfesfesfesfsefes": "fesfs"}',
type: "Text",
data: {
text: '{"fesfesfsefesfesfesfesfesfesfesfesfesfsefes": "fesfs"}',
},
},
],
[
{
date: "25/06/2024 07:40:23",
type: "Text",
data: {
text: "25/06/2024 07:40:23",
},
},
{
ip: "111111",
type: "Text",
data: {
text: "111111",
},
},
{
country: "fr",
type: "Text",
data: {
text: "fr",
},
},
{
method: "POST",
type: "Text",
data: {
text: "POST",
},
},
{
url: "/admin/login?id=e",
type: "Text",
data: {
text: "/admin/login?id=e",
},
},
{
code: "403",
type: "Text",
data: {
text: "403",
},
},
{
user_agent:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
type: "Text",
data: {
text: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
},
},
{
reason: " antibot",
type: "Text",
data: {
text: " antibot",
},
},
{
raw_data: "{}",
type: "Text",
data: {
text: "{}",
},
},
],
[
{
date: "25/06/2024 07:40:23",
type: "Text",
data: {
text: "25/06/2024 07:40:23",
},
},
{
ip: "111111",
type: "Text",
data: {
text: "111111",
},
},
{
country: "fr",
type: "Text",
data: {
text: "fr",
},
},
{
method: "POST",
type: "Text",
data: {
text: "POST",
},
},
{
url: "/admin/login?id=e",
type: "Text",
data: {
text: "/admin/login?id=e",
},
},
{
code: "403",
type: "Text",
data: {
text: "403",
},
},
{
user_agent:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
type: "Text",
data: {
text: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
},
},
{
reason: " antibot",
type: "Text",
data: {
text: " antibot",
},
},
{
raw_data: "{}",
type: "Text",
data: {
text: "{}",
},
},
],
[
{
date: "25/06/2024 07:40:23",
type: "Text",
data: {
text: "25/06/2024 07:40:23",
},
},
{
ip: "111111",
type: "Text",
data: {
text: "111111",
},
},
{
country: "fr",
type: "Text",
data: {
text: "fr",
},
},
{
method: "POST",
type: "Text",
data: {
text: "POST",
},
},
{
url: "/admin/login?id=e",
type: "Text",
data: {
text: "/admin/login?id=e",
},
},
{
code: "403",
type: "Text",
data: {
text: "403",
},
},
{
user_agent:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
type: "Text",
data: {
text: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
},
},
{
reason: " antibot",
type: "Text",
data: {
text: " antibot",
},
},
{
raw_data: "{}",
type: "Text",
data: {
text: "{}",
},
},
],
[
{
date: "25/06/2024 07:40:23",
type: "Text",
data: {
text: "25/06/2024 07:40:23",
},
},
{
ip: "111111",
type: "Text",
data: {
text: "111111",
},
},
{
country: "fr",
type: "Text",
data: {
text: "fr",
},
},
{
method: "POST",
type: "Text",
data: {
text: "POST",
},
},
{
url: "/admin/login?id=e",
type: "Text",
data: {
text: "/admin/login?id=e",
},
},
{
code: "403",
type: "Text",
data: {
text: "403",
},
},
{
user_agent:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
type: "Text",
data: {
text: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
},
},
{
reason: " antibot",
type: "Text",
data: {
text: " antibot",
},
},
{
raw_data: "{}",
type: "Text",
data: {
text: "{}",
},
},
],
[
{
date: "25/06/2024 07:40:23",
type: "Text",
data: {
text: "25/06/2024 07:40:23",
},
},
{
ip: "111111",
type: "Text",
data: {
text: "111111",
},
},
{
country: "fr",
type: "Text",
data: {
text: "fr",
},
},
{
method: "POST",
type: "Text",
data: {
text: "POST",
},
},
{
url: "/admin/login?id=e",
type: "Text",
data: {
text: "/admin/login?id=e",
},
},
{
code: "403",
type: "Text",
data: {
text: "403",
},
},
{
user_agent:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
type: "Text",
data: {
text: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
},
},
{
reason: " antibot",
type: "Text",
data: {
text: " antibot",
},
},
{
raw_data: "{}",
type: "Text",
data: {
text: "{}",
},
},
],
],
filters: [
{
filter: "table",
filterName: "keyword",
type: "keyword",
value: "",
keys: ["url", "ip", "date", "user_agent", "raw_data"],
field: {
id: "reports-keyword",
value: "",
type: "text",
name: "reports-keyword",
label: "reports_search",
placeholder: "inp_keyword",
isClipboard: false,
popovers: [
{
text: "reports_search_desc",
iconName: "info",
},
],
columns: {
pc: 3,
tablet: 4,
mobile: 12,
},
},
},
{
filter: "table",
filterName: "country",
type: "select",
value: "all",
keys: ["country"],
field: {
id: "reports-country",
value: "all",
values: ["all", "local", "fr"],
name: "reports-country",
onlyDown: true,
label: "reports_country",
popovers: [
{
text: "reports_country_desc",
iconName: "info",
},
],
columns: {
pc: 3,
tablet: 4,
mobile: 12,
},
},
},
{
filter: "table",
filterName: "method",
type: "select",
value: "all",
keys: ["method"],
field: {
id: "reports-method",
value: "all",
values: ["all", "GET", "POST"],
name: "reports-method",
onlyDown: true,
label: "reports_method",
popovers: [
{
text: "reports_method_desc",
iconName: "info",
},
],
columns: {
pc: 3,
tablet: 4,
mobile: 12,
},
},
},
{
filter: "table",
filterName: "reason",
type: "select",
value: "all",
keys: ["reason"],
field: {
id: "reports-reason",
value: "all",
values: ["all", "modsecurity", " antibot"],
name: "reports-reason",
onlyDown: true,
label: "reports_reason",
popovers: [
{
text: "reports_reason_desc",
iconName: "info",
},
],
columns: {
pc: 3,
tablet: 4,
mobile: 12,
},
},
},
],
},
},
],

View file

@ -1,11 +1,603 @@
[
{
"type": "void",
"type": "card",
"containerColumns": {
"pc": 4,
"tablet": 6,
"mobile": 12
},
"widgets": [
{
"type": "MessageUnmatch",
"type": "Title",
"data": {
"text": "reports_not_found"
"title": "dashboard_details"
}
},
{
"type": "ListPairs",
"data": {
"details": [
{
"key": "reports_total",
"value": "200"
},
{
"key": "reports_top_status",
"value": "400"
},
{
"key": "reports_top_reason",
"value": "antibot"
}
]
}
}
]
},
{
"type": "card",
"containerColumns": {
"pc": 12,
"tablet": 12,
"mobile": 12
},
"widgets": [
{
"type": "Title",
"data": {
"title": "reports_title"
}
},
{
"type": "Table",
"data": {
"title": "reports_table_title",
"minWidth": "xl",
"header": [
"reports_table_date",
"reports_table_ip",
"reports_table_country",
"reports_table_method",
"reports_table_url",
"reports_table_status_code",
"reports_table_cache_user_agent",
"reports_table_reason",
"reports_table_data"
],
"positions": [
1,
1,
1,
1,
2,
1,
2,
1,
2
],
"items": [
[
{
"date": "25/06/2024 07:40:23",
"type": "Text",
"data": {
"text": "25/06/2024 07:40:23"
}
},
{
"ip": "172.21.0.1",
"type": "Text",
"data": {
"text": "172.21.0.1"
}
},
{
"country": "local",
"type": "Text",
"data": {
"text": "local"
}
},
{
"method": "GET",
"type": "Text",
"data": {
"text": "GET"
}
},
{
"url": "/admin/login?id=etc/passwd",
"type": "Text",
"data": {
"text": "/admin/login?id=etc/passwd"
}
},
{
"code": "403",
"type": "Text",
"data": {
"text": "403"
}
},
{
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"type": "Text",
"data": {
"text": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
}
},
{
"reason": "modsecurity",
"type": "Text",
"data": {
"text": "modsecurity"
}
},
{
"raw_data": "{\"fesfesfsefesfesfesfesfesfesfesfesfesfsefes\": \"fesfs\"}",
"type": "Text",
"data": {
"text": "{\"fesfesfsefesfesfesfesfesfesfesfesfesfsefes\": \"fesfs\"}"
}
}
],
[
{
"date": "25/06/2024 07:40:23",
"type": "Text",
"data": {
"text": "25/06/2024 07:40:23"
}
},
{
"ip": "111111",
"type": "Text",
"data": {
"text": "111111"
}
},
{
"country": "fr",
"type": "Text",
"data": {
"text": "fr"
}
},
{
"method": "POST",
"type": "Text",
"data": {
"text": "POST"
}
},
{
"url": "/admin/login?id=e",
"type": "Text",
"data": {
"text": "/admin/login?id=e"
}
},
{
"code": "403",
"type": "Text",
"data": {
"text": "403"
}
},
{
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"type": "Text",
"data": {
"text": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
}
},
{
"reason": " antibot",
"type": "Text",
"data": {
"text": " antibot"
}
},
{
"raw_data": "{}",
"type": "Text",
"data": {
"text": "{}"
}
}
],
[
{
"date": "25/06/2024 07:40:23",
"type": "Text",
"data": {
"text": "25/06/2024 07:40:23"
}
},
{
"ip": "111111",
"type": "Text",
"data": {
"text": "111111"
}
},
{
"country": "fr",
"type": "Text",
"data": {
"text": "fr"
}
},
{
"method": "POST",
"type": "Text",
"data": {
"text": "POST"
}
},
{
"url": "/admin/login?id=e",
"type": "Text",
"data": {
"text": "/admin/login?id=e"
}
},
{
"code": "403",
"type": "Text",
"data": {
"text": "403"
}
},
{
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"type": "Text",
"data": {
"text": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
}
},
{
"reason": " antibot",
"type": "Text",
"data": {
"text": " antibot"
}
},
{
"raw_data": "{}",
"type": "Text",
"data": {
"text": "{}"
}
}
],
[
{
"date": "25/06/2024 07:40:23",
"type": "Text",
"data": {
"text": "25/06/2024 07:40:23"
}
},
{
"ip": "111111",
"type": "Text",
"data": {
"text": "111111"
}
},
{
"country": "fr",
"type": "Text",
"data": {
"text": "fr"
}
},
{
"method": "POST",
"type": "Text",
"data": {
"text": "POST"
}
},
{
"url": "/admin/login?id=e",
"type": "Text",
"data": {
"text": "/admin/login?id=e"
}
},
{
"code": "403",
"type": "Text",
"data": {
"text": "403"
}
},
{
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"type": "Text",
"data": {
"text": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
}
},
{
"reason": " antibot",
"type": "Text",
"data": {
"text": " antibot"
}
},
{
"raw_data": "{}",
"type": "Text",
"data": {
"text": "{}"
}
}
],
[
{
"date": "25/06/2024 07:40:23",
"type": "Text",
"data": {
"text": "25/06/2024 07:40:23"
}
},
{
"ip": "111111",
"type": "Text",
"data": {
"text": "111111"
}
},
{
"country": "fr",
"type": "Text",
"data": {
"text": "fr"
}
},
{
"method": "POST",
"type": "Text",
"data": {
"text": "POST"
}
},
{
"url": "/admin/login?id=e",
"type": "Text",
"data": {
"text": "/admin/login?id=e"
}
},
{
"code": "403",
"type": "Text",
"data": {
"text": "403"
}
},
{
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"type": "Text",
"data": {
"text": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
}
},
{
"reason": " antibot",
"type": "Text",
"data": {
"text": " antibot"
}
},
{
"raw_data": "{}",
"type": "Text",
"data": {
"text": "{}"
}
}
],
[
{
"date": "25/06/2024 07:40:23",
"type": "Text",
"data": {
"text": "25/06/2024 07:40:23"
}
},
{
"ip": "111111",
"type": "Text",
"data": {
"text": "111111"
}
},
{
"country": "fr",
"type": "Text",
"data": {
"text": "fr"
}
},
{
"method": "POST",
"type": "Text",
"data": {
"text": "POST"
}
},
{
"url": "/admin/login?id=e",
"type": "Text",
"data": {
"text": "/admin/login?id=e"
}
},
{
"code": "403",
"type": "Text",
"data": {
"text": "403"
}
},
{
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
"type": "Text",
"data": {
"text": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
}
},
{
"reason": " antibot",
"type": "Text",
"data": {
"text": " antibot"
}
},
{
"raw_data": "{}",
"type": "Text",
"data": {
"text": "{}"
}
}
]
],
"filters": [
{
"filter": "table",
"filterName": "keyword",
"type": "keyword",
"value": "",
"keys": [
"url",
"ip",
"date",
"user_agent",
"raw_data"
],
"field": {
"id": "reports-keyword",
"value": "",
"type": "text",
"name": "reports-keyword",
"label": "reports_search",
"placeholder": "inp_keyword",
"isClipboard": false,
"popovers": [
{
"text": "reports_search_desc",
"iconName": "info"
}
],
"columns": {
"pc": 3,
"tablet": 4,
"mobile": 12
}
}
},
{
"filter": "table",
"filterName": "country",
"type": "select",
"value": "all",
"keys": [
"country"
],
"field": {
"id": "reports-country",
"value": "all",
"values": [
"all",
"local",
"fr"
],
"name": "reports-country",
"onlyDown": true,
"label": "reports_country",
"popovers": [
{
"text": "reports_country_desc",
"iconName": "info"
}
],
"columns": {
"pc": 3,
"tablet": 4,
"mobile": 12
}
}
},
{
"filter": "table",
"filterName": "method",
"type": "select",
"value": "all",
"keys": [
"method"
],
"field": {
"id": "reports-method",
"value": "all",
"values": [
"all",
"GET",
"POST"
],
"name": "reports-method",
"onlyDown": true,
"label": "reports_method",
"popovers": [
{
"text": "reports_method_desc",
"iconName": "info"
}
],
"columns": {
"pc": 3,
"tablet": 4,
"mobile": 12
}
}
},
{
"filter": "table",
"filterName": "reason",
"type": "select",
"value": "all",
"keys": [
"reason"
],
"field": {
"id": "reports-reason",
"value": "all",
"values": [
"all",
"modsecurity",
" antibot"
],
"name": "reports-reason",
"onlyDown": true,
"label": "reports_reason",
"popovers": [
{
"text": "reports_reason_desc",
"iconName": "info"
}
],
"columns": {
"pc": 3,
"tablet": 4,
"mobile": 12
}
}
}
]
}
}
]

View file

@ -2,6 +2,12 @@ import json
no_reports = []
details = {
"top_reason": "antibot",
"top_code": "400",
"total_reports": "200",
}
reports = [
{
"url": "/admin/login?id=etc/passwd",
@ -262,7 +268,33 @@ def get_reports_list(reports):
return data
def reports_builder(reports, data=None):
def get_reports_details(details):
return {
"type": "card",
"containerColumns": {"pc": 4, "tablet": 6, "mobile": 12},
"widgets": [
{
"type": "Title",
"data": {"title": "dashboard_details"},
},
{
"type": "ListPairs",
"data": {
"pairs": [
{"key": "reports_total", "value": details.get("total_reports")},
{"key": "reports_top_status", "value": details.get("top_code")},
{
"key": "reports_top_reason",
"value": details.get("top_reason"),
},
],
},
},
],
}
def reports_builder(reports, details=None):
if not reports:
return [
@ -274,49 +306,50 @@ def reports_builder(reports, data=None):
},
]
filters = get_reports_filter(reports)
details = get_reports_details(details)
filters = get_reports_filter(reports)
reports_list = get_reports_list(reports)
builder = [
{
"type": "card",
"containerColumns": {"pc": 12, "tablet": 12, "mobile": 12},
"widgets": [
{
"type": "Title",
"data": {"title": "reports_title"},
reports_table = {
"type": "card",
"containerColumns": {"pc": 12, "tablet": 12, "mobile": 12},
"widgets": [
{
"type": "Title",
"data": {"title": "reports_title"},
},
{
"type": "Table",
"data": {
"title": "reports_table_title",
"minWidth": "xl",
"header": [
"reports_table_date",
"reports_table_ip",
"reports_table_country",
"reports_table_method",
"reports_table_url",
"reports_table_status_code",
"reports_table_cache_user_agent",
"reports_table_reason",
"reports_table_data",
],
"positions": [1, 1, 1, 1, 2, 1, 2, 1, 2],
"items": reports_list,
"filters": filters,
},
{
"type": "Table",
"data": {
"title": "reports_table_title",
"minWidth": "xl",
"header": [
"reports_table_date",
"reports_table_ip",
"reports_table_country",
"reports_table_method",
"reports_table_url",
"reports_table_status_code",
"reports_table_cache_user_agent",
"reports_table_reason",
"reports_table_data",
],
"positions": [1, 1, 1, 1, 2, 1, 2, 1, 2],
"items": reports_list,
"filters": filters,
},
},
],
}
]
},
],
}
builder = [details, reports_table]
return builder
#output = reports_builder(reports)
output = reports_builder(no_reports)
# output = reports_builder(reports)
output = reports_builder(reports, details)
# store on a file
with open("reports.json", "w") as f: