diff --git a/.gitignore b/.gitignore index 18ffc85..c0aa6b0 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ yarn-error.log /public/uploads/ !/public/uploads/.gitkeep /public/media/ +/migrations/ +!/migrations/.gitkeep diff --git a/assets/css/admin.scss b/assets/css/admin.scss index 668eeef..40bfaf3 100644 --- a/assets/css/admin.scss +++ b/assets/css/admin.scss @@ -511,6 +511,8 @@ form { .modal-dialog-large { max-width: 80%; + margin-left: auto; + margin-right: auto; } .output { diff --git a/assets/js/admin/admin.js b/assets/js/admin/admin.js index 0bf8794..4430472 100644 --- a/assets/js/admin/admin.js +++ b/assets/js/admin/admin.js @@ -23,3 +23,4 @@ require('./modules/sortable.js')() require('./modules/batch.js')() require('./modules/file-manager.js')() require('./modules/file-picker.js')() +require('./modules/analytics.js')() diff --git a/assets/js/admin/modules/analytics.js b/assets/js/admin/modules/analytics.js new file mode 100644 index 0000000..dcb6d1a --- /dev/null +++ b/assets/js/admin/modules/analytics.js @@ -0,0 +1,53 @@ +const $ = require('jquery') +const Chart = require('chart.js/auto').default + +const drawChart = () => { + const ctx = document.getElementById('analytic-chart') + const options = { + type: 'bar', + options: { + responsive: true, + maintainAspectRatio: false, + scales: { + y: { + beginAtZero: true + } + } + }, + data: { + labels: JSON.parse(ctx.getAttribute('data-labels')), + datasets: [{ + label: ctx.getAttribute('data-label'), + data: JSON.parse(ctx.getAttribute('data-values')), + backgroundColor: 'rgba(54, 162, 235, 0.2)', + borderColor: 'rgb(54, 162, 235)', + borderWidth: 1 + }] + } + } + + const chart = new Chart(ctx, options) + + const resize = () => { + const width = ctx.parentNode.parentNode.offsetWidth + const height = 250 + + chart.resize(width, height) + } + + resize() + + window.addEventListener('resize', resize) +} + +module.exports = () => { + const body = $('body') + + body.on('shown.bs.modal', '.modal', (e) => { + window.setTimeout(() => { + if (document.getElementById('analytic-chart')) { + drawChart() + } + }, 500) + }) +} diff --git a/assets/js/admin/modules/modal.js b/assets/js/admin/modules/modal.js index 8afb28a..13cecba 100644 --- a/assets/js/admin/modules/modal.js +++ b/assets/js/admin/modules/modal.js @@ -3,8 +3,10 @@ const $ = require('jquery') const openModal = function (url) { let container = $('#modal-container') const body = $('body') + let doTrigger = true if (!container.length) { + let doTrigger = false container = $(' {{ form_row(form.disableUrl) }} + {{ form_row(form.enableAnalytics) }} {{ form_row(form.code) }} {{ form_row(form.contentType) }} {{ form_row(form.controller) }} diff --git a/core/Resources/views/site/tree_admin/navigation.html.twig b/core/Resources/views/site/tree_admin/navigation.html.twig index b077da6..31efad1 100644 --- a/core/Resources/views/site/tree_admin/navigation.html.twig +++ b/core/Resources/views/site/tree_admin/navigation.html.twig @@ -72,6 +72,7 @@ {% set move = path('admin_site_node_move', {entity: node.id}) %} {% set edit = path('admin_site_node_edit', {entity: node.id}) %} {% set new = path('admin_site_node_new', {node: node.id}) %} + {% set analytics = path('admin_analytic_stats', {node: node.id}) %}
@@ -147,6 +148,12 @@ {% endif %} + {% if node.enableAnalytics %} + + {% endif %} + @@ -181,6 +188,12 @@ {% endif %} + {% if node.enableAnalytics %} + + {% endif %} + diff --git a/core/Site/Node.php b/core/Site/Node.php deleted file mode 100644 index ec63344..0000000 --- a/core/Site/Node.php +++ /dev/null @@ -1,24 +0,0 @@ -id; - } -} diff --git a/migrations/.gitignore b/migrations/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/package.json b/package.json index 65c9408..25ed802 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "@fortawesome/fontawesome-free": "^5.11.2", "axios": "^0.21.1", "bootstrap": "^4.3.1", + "chart.js": "^3.7.1", "choices.js": "^9.0.1", "flag-icon-css": "^3.5.0", "jquery": "^3.6.0", diff --git a/symfony.lock b/symfony.lock index 7e97f5e..58d5c8b 100644 --- a/symfony.lock +++ b/symfony.lock @@ -129,6 +129,9 @@ "imagine/imagine": { "version": "1.2.4" }, + "jaybizzle/crawler-detect": { + "version": "v1.2.110" + }, "khanamiryan/qrcode-detector-decoder": { "version": "1.0.4" }, diff --git a/yarn.lock b/yarn.lock index fae2b28..6faa9fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1819,6 +1819,11 @@ chalk@^4.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" +chart.js@^3.7.1: + version "3.7.1" + resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-3.7.1.tgz#0516f690c6a8680c6c707e31a4c1807a6f400ada" + integrity sha512-8knRegQLFnPQAheZV8MjxIXc5gQEfDFD897BJgv/klO/vtIyFFmgMXrNfgrXpbTr/XbTturxRgxIXx/Y+ASJBA== + choices.js@^9.0.1: version "9.0.1" resolved "https://registry.yarnpkg.com/choices.js/-/choices.js-9.0.1.tgz#745fb29af8670428fdc0bf1cc9dfaa404e9d0510" @@ -2048,9 +2053,9 @@ core-js-compat@^3.8.1, core-js-compat@^3.9.0: semver "7.0.0" core-js@^3.0.0: - version "3.9.1" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.9.1.tgz#cec8de593db8eb2a85ffb0dbdeb312cb6e5460ae" - integrity sha512-gSjRvzkxQc1zjM/5paAmL4idJBFzuJoo+jDjF1tStYFMV2ERfD02HhahhCGXUyHxQRG4yFKVSdO6g62eoRMcDg== + version "3.21.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.21.1.tgz#f2e0ddc1fc43da6f904706e8e955bc19d06a0d94" + integrity sha512-FRq5b/VMrWlrmCzwRrpDYNxyHP9BcAZC+xHJaqTgIE5091ZV1NTmyh0sGOg5XqpnHvR0svdy0sv1gWA1zmhxig== core-util-is@~1.0.0: version "1.0.2"