From 29d657906eb34471eee38a9f5ca5c1a6239b3882 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Wed, 24 Aug 2022 08:35:20 +0200 Subject: [PATCH] [TASK] Update vulnerable build dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update (most) vulnerable dependencies/packages found by `npm audit fix --force --dry-run`. Notes redarding package changes: * The outdated grunt-postcss plugin is replaced by a (maintained) fork for compatibility with newer grunt versions. * karma is updated to v6 and pulls in @types/node which conflicts with TypeScript type definitions by @types/requirejs. Therefore 3rd party type declarations from packages (@types/*) are now explicitly enabled in tsconfig.json – note that there is no other way to exclude from typeRoots: https://github.com/microsoft/TypeScript/issues/18588 * grunt-lintspaces and grunt-contrib-imagemin are replaced as these packages have been not been updated to not depend on vulnerabe dependencies, while grunt-lintspaces and grunt-contrib-imagemin would cause downgrades to older version when running `npm audit fix --force` (because only the older versions do not depend on vulnerable software). * (grunt-contrib-)imagemin is replaced by squoosh (by google) as a) imagemin dependencies ("bin-build" > "download") rely on vulnerable versions of "got". Neither of these packages is currently updated,see https://github.com/kevva/download/issues/224 b) imagemin is unmaintained: https://github.com/imagemin/imagemin/issues/385 and suggests squoosh as replacement * stylefmt is replaced by a maintained fork. There is one remaining packages that pulls in a vulnerability alerts: * jquery-ui is marked as vulnerable (severity: high), but worked on in a separate patch #96497. (We don't actually use the vulnerable library parts though). Vulnerability report before this patch: 74 vulnerabilities (1 low, 30 moderate, 38 high, 5 critical) Vulnerability report after this patch: 1 high severity vulnerability (this is jquery-ui) Commands executed: # Supposed to be non breaking, but broke grunt-css npm audit fix npm remove grunt-postcss npm install @lodder/grunt-postcss # Preparation for `npm audit fix --force` (breaking changes) npm install grunt@^1.5 npm install grunt-lintspaces@^0.10.0 npm remove grunt-lintspaces npm install --save-dev lintspaces-cli npm remove grunt-contrib-imagemin npm install --save-dev npm remove stylefmt npm install --save-dev @ronilaukkarinen/stylefmt npm audit fix --force Releases: main Resolves: #98198 Change-Id: I09df87fe131a499790e6c5f95f1c51e9216b71c2 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75539 Tested-by: core-ci Tested-by: Georg Ringer Tested-by: Stefan Bürk Tested-by: Benjamin Franzke Reviewed-by: Georg Ringer Reviewed-by: Stefan Bürk Reviewed-by: Benjamin Franzke --- Resources/Public/Css/dashboard.css | 2 +- Resources/Public/JavaScript/dashboard-delete.js | 2 +- Resources/Public/JavaScript/dashboard-modal.js | 2 +- Resources/Public/JavaScript/grid.js | 2 +- Resources/Public/JavaScript/widget-content-collector.js | 2 +- Resources/Public/JavaScript/widget-refresh.js | 2 +- Resources/Public/JavaScript/widget-remover.js | 2 +- Resources/Public/JavaScript/widget-selector.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Resources/Public/Css/dashboard.css b/Resources/Public/Css/dashboard.css index ceed772..03b3a45 100644 --- a/Resources/Public/Css/dashboard.css +++ b/Resources/Public/Css/dashboard.css @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -.module.module{background-color:#eaeaea}.module.module h1{line-height:1.5;margin-bottom:20px;font-weight:900;font-size:32px}.dashboard-header{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;margin:-24px -24px 24px;padding:24px 24px 0;background:#dadada;border-bottom:1px solid #cdcdcd}.dashboard-tabs{display:flex;flex-wrap:wrap;align-items:center}.dashboard-tab{border-radius:5px 5px 0 0;display:inline-block;padding:12px;margin-right:2px;background:#bababa;color:#000}.dashboard-tab:focus,.dashboard-tab:hover{text-decoration:none;background:#adadad;color:#000}.dashboard-tab--active{background:#ff8700;color:#fff}.dashboard-tab--active:focus,.dashboard-tab--active:hover{text-decoration:none;background:#e67a00;color:#f2f2f2}.dashboard-button-tab-add{margin:5px}.dashboard-empty{position:relative}.dashboard-empty-content{background-color:rgba(0,0,0,.05);border:2px dashed rgba(0,0,0,.15);padding:2.5em;text-align:center}.dashboard-empty-content h3{font-size:1.5em;margin-bottom:.5em}.dashboard-empty-content p{font-size:1.25em;margin-bottom:1em}.dashboard-empty-content>:first-child{margin-top:0}.dashboard-empty-content>:last-child{margin-bottom:0}.dashboard-grid{position:relative;margin-right:-10px;margin-left:-10px}.dashboard-item{position:absolute;z-index:1;padding:10px;width:100%;height:auto}@media screen and (min-width:750px){.dashboard-item{width:50%;height:200px}}@media screen and (min-width:1285px){.dashboard-item{width:25%}}.dashboard-item.muuri-item-positioning{z-index:2}.dashboard-item.muuri-item-positioning .widget-remove{display:none}.dashboard-item.muuri-item-placeholder{z-index:2;margin:0;opacity:.5}.dashboard-item.muuri-item-placeholder .widget{border:1px dashed #737373}.dashboard-item.muuri-item-placeholder .widget-remove{display:none}.dashboard-item.muuri-item-dragging,.dashboard-item.muuri-item-releasing{z-index:9999}.dashboard-item.muuri-item-releasing .widget-remove{display:none}.dashboard-item.muuri-item-dragging{cursor:move}.dashboard-item.muuri-item-hidden{z-index:0}.dashboard-item.widget-waiting{line-height:200px}.dashboard-item--enableSelect{-webkit-user-select:auto!important;-moz-user-select:auto!important;-ms-user-select:auto!important;user-select:auto!important}@media screen and (min-width:750px){.dashboard-item--h-medium{height:400px}}@media screen and (min-width:750px){.dashboard-item--h-large{height:600px}}.dashboard-item--w-medium{width:100%}@media screen and (min-width:1285px){.dashboard-item--w-medium{width:50%}}.dashboard-item--w-large{width:100%}.dashboard-item-content{position:relative;width:100%;height:100%}.dashboard-button{display:inline-flex;align-items:center;border-radius:3px;background:#313131;color:#fff;padding:8px;text-decoration:none}.dashboard-button:focus,.dashboard-button:hover{text-decoration:none;background:#ff8700;color:#fff}.dashboard-button .dashboard-button-icon .icon{display:block}.dashboard-button .dashboard-button-icon+.dashboard-button-text{margin-left:.25em;margin-right:.25em}.dashboard-button-add{position:fixed;padding:16px;right:24px;bottom:24px;z-index:2}.widget{height:100%;border-radius:2px;overflow:hidden;background-color:#fff;box-shadow:0 2px 2px 0 rgba(0,0,0,.15);color:#000}.widget:hover .widget-actions{opacity:1}.widget-content{display:flex;flex-direction:column;height:100%}.widget-content-title{padding:10px 20px;padding-right:76px;border-bottom:1px solid #d7d7d7;font-family:"Source Sans Pro",sans-serif;font-size:16px;font-weight:700;line-height:1.25}.widget-content-title span{overflow:hidden;display:block;white-space:nowrap;text-overflow:ellipsis}.widget-content-main{flex-grow:1;overflow-y:auto;padding:20px}.widget-content-footer{padding:20px;padding-top:0}.widget-actions{position:absolute;display:flex;top:calc((16px * 1.25)/ 2 + (20px / 2));right:10px;transform:translate(0,-50%);opacity:0;transition:opacity .2s ease-in-out}.widget-action{width:28px;height:28px;position:relative;color:#737373;text-align:center}.widget-action:focus,.widget-action:hover{color:#ff8700}.widget-action .icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.widget-action-move{cursor:-webkit-grab;cursor:grab}.widget-waiting{position:absolute;top:50%;left:50%;line-height:300px;margin-right:-50%;transform:translate(-50%,-50%)}.widget-error{padding:20px;position:absolute;top:50%;text-align:center;transform:translateY(-50%);color:#c83c3c}.widget-chart{width:100%;height:100%}.widget-edit{width:45px;text-align:center}.widget-editIcon{color:#000}.widget-editIcon:focus,.widget-editIcon:hover{color:#ff8700}.widget-table{width:100%;color:#000}.widget-table thead tr{background-color:transparent}.widget-table tr:nth-child(odd){background-color:transparent}.widget-table tr:nth-child(even){background-color:#f2f2f2}.widget-table tbody td,.widget-table tbody th{border-top:1px solid #e0e0e0}.widget-table tbody:first-child tr:first-child td,.widget-table tbody:first-child tr:first-child th{border-top:none}.widget-table td,.widget-table th{padding:10px}.widget-table td>:first-child,.widget-table th>:first-child{margin-top:0}.widget-table td>:last-child,.widget-table th>:last-child{margin-bottom:0}.widget-table th{font-weight:700}.widget-content-main .widget-table-wrapper{margin-top:-10px;margin-left:-20px;margin-right:-20px}.widget-content-main .widget-table-wrapper td:first-child,.widget-content-main .widget-table-wrapper th:first-child{padding-left:20px}.widget-content-main .widget-table-wrapper td:last-child,.widget-content-main .widget-table-wrapper th:last-child{padding-right:20px}.widget-cta{display:flex;justify-content:center;align-items:center;background-color:#313131;color:#fff;border-radius:3px;padding:8px}.widget-cta:focus,.widget-cta:hover{text-decoration:none;background:#ff8700;color:#fff}.widget-cta-icon{display:flex;justify-content:center;align-items:center;width:18px;height:18px;margin-right:12px;color:#fff}.widget-doughnut--value{line-height:1.3;font-weight:900;font-size:36px;text-align:center}.widget-doughnut--meta{margin-top:10px;font-style:italic;color:#737373;text-align:center}.widget-number{height:100%;display:flex;align-items:center}.widget-number-icon{display:flex;align-items:center;width:42px;margin-right:20px;color:#000}.widget-number-content{display:flex;flex-direction:column;justify-content:center}.widget-number-title{line-height:1.3;margin-bottom:5px;font-size:16px;color:#000}.widget-number-number{line-height:1.3;font-weight:900;font-size:24px} \ No newline at end of file +.module.module{background-color:#eaeaea}.module.module h1{line-height:1.5;margin-bottom:20px;font-weight:900;font-size:32px}.dashboard-header{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;margin:-24px -24px 24px;padding:24px 24px 0;background:#dadada;border-bottom:1px solid #cdcdcd}.dashboard-tabs{display:flex;flex-wrap:wrap;align-items:center}.dashboard-tab{border-radius:5px 5px 0 0;display:inline-block;padding:12px;margin-right:2px;background:#bababa;color:#000}.dashboard-tab:focus,.dashboard-tab:hover{text-decoration:none;background:#adadad;color:#000}.dashboard-tab--active{background:#ff8700;color:#fff}.dashboard-tab--active:focus,.dashboard-tab--active:hover{text-decoration:none;background:#e67a00;color:#f2f2f2}.dashboard-button-tab-add{margin:5px}.dashboard-empty{position:relative}.dashboard-empty-content{background-color:rgba(0,0,0,.05);border:2px dashed rgba(0,0,0,.15);padding:2.5em;text-align:center}.dashboard-empty-content h3{font-size:1.5em;margin-bottom:.5em}.dashboard-empty-content p{font-size:1.25em;margin-bottom:1em}.dashboard-empty-content>:first-child{margin-top:0}.dashboard-empty-content>:last-child{margin-bottom:0}.dashboard-grid{position:relative;margin-right:-10px;margin-left:-10px}.dashboard-item{position:absolute;z-index:1;padding:10px;width:100%;height:auto}@media screen and (min-width:750px){.dashboard-item{width:50%;height:200px}}@media screen and (min-width:1285px){.dashboard-item{width:25%}}.dashboard-item.muuri-item-positioning{z-index:2}.dashboard-item.muuri-item-positioning .widget-remove{display:none}.dashboard-item.muuri-item-placeholder{z-index:2;margin:0;opacity:.5}.dashboard-item.muuri-item-placeholder .widget{border:1px dashed #737373}.dashboard-item.muuri-item-placeholder .widget-remove{display:none}.dashboard-item.muuri-item-dragging,.dashboard-item.muuri-item-releasing{z-index:9999}.dashboard-item.muuri-item-releasing .widget-remove{display:none}.dashboard-item.muuri-item-dragging{cursor:move}.dashboard-item.muuri-item-hidden{z-index:0}.dashboard-item.widget-waiting{line-height:200px}.dashboard-item--enableSelect{-webkit-user-select:auto!important;-moz-user-select:auto!important;user-select:auto!important}@media screen and (min-width:750px){.dashboard-item--h-medium{height:400px}}@media screen and (min-width:750px){.dashboard-item--h-large{height:600px}}.dashboard-item--w-medium{width:100%}@media screen and (min-width:1285px){.dashboard-item--w-medium{width:50%}}.dashboard-item--w-large{width:100%}.dashboard-item-content{position:relative;width:100%;height:100%}.dashboard-button{display:inline-flex;align-items:center;border-radius:3px;background:#313131;color:#fff;padding:8px;text-decoration:none}.dashboard-button:focus,.dashboard-button:hover{text-decoration:none;background:#ff8700;color:#fff}.dashboard-button .dashboard-button-icon .icon{display:block}.dashboard-button .dashboard-button-icon+.dashboard-button-text{margin-left:.25em;margin-right:.25em}.dashboard-button-add{position:fixed;padding:16px;right:24px;bottom:24px;z-index:2}.widget{height:100%;border-radius:2px;overflow:hidden;background-color:#fff;box-shadow:0 2px 2px 0 rgba(0,0,0,.15);color:#000}.widget:hover .widget-actions{opacity:1}.widget-content{display:flex;flex-direction:column;height:100%}.widget-content-title{padding:10px 20px;padding-right:76px;border-bottom:1px solid #d7d7d7;font-family:"Source Sans Pro",sans-serif;font-size:16px;font-weight:700;line-height:1.25}.widget-content-title span{overflow:hidden;display:block;white-space:nowrap;text-overflow:ellipsis}.widget-content-main{flex-grow:1;overflow-y:auto;padding:20px}.widget-content-footer{padding:20px;padding-top:0}.widget-actions{position:absolute;display:flex;top:calc((16px * 1.25)/ 2 + (20px / 2));right:10px;transform:translate(0,-50%);opacity:0;transition:opacity .2s ease-in-out}.widget-action{width:28px;height:28px;position:relative;color:#737373;text-align:center}.widget-action:focus,.widget-action:hover{color:#ff8700}.widget-action .icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.widget-action-move{cursor:-webkit-grab;cursor:grab}.widget-waiting{position:absolute;top:50%;left:50%;line-height:300px;margin-right:-50%;transform:translate(-50%,-50%)}.widget-error{padding:20px;position:absolute;top:50%;text-align:center;transform:translateY(-50%);color:#c83c3c}.widget-chart{width:100%;height:100%}.widget-edit{width:45px;text-align:center}.widget-editIcon{color:#000}.widget-editIcon:focus,.widget-editIcon:hover{color:#ff8700}.widget-table{width:100%;color:#000}.widget-table thead tr{background-color:transparent}.widget-table tr:nth-child(odd){background-color:transparent}.widget-table tr:nth-child(even){background-color:#f2f2f2}.widget-table tbody td,.widget-table tbody th{border-top:1px solid #e0e0e0}.widget-table tbody:first-child tr:first-child td,.widget-table tbody:first-child tr:first-child th{border-top:none}.widget-table td,.widget-table th{padding:10px}.widget-table td>:first-child,.widget-table th>:first-child{margin-top:0}.widget-table td>:last-child,.widget-table th>:last-child{margin-bottom:0}.widget-table th{font-weight:700}.widget-content-main .widget-table-wrapper{margin-top:-10px;margin-left:-20px;margin-right:-20px}.widget-content-main .widget-table-wrapper td:first-child,.widget-content-main .widget-table-wrapper th:first-child{padding-left:20px}.widget-content-main .widget-table-wrapper td:last-child,.widget-content-main .widget-table-wrapper th:last-child{padding-right:20px}.widget-cta{display:flex;justify-content:center;align-items:center;background-color:#313131;color:#fff;border-radius:3px;padding:8px}.widget-cta:focus,.widget-cta:hover{text-decoration:none;background:#ff8700;color:#fff}.widget-cta-icon{display:flex;justify-content:center;align-items:center;width:18px;height:18px;margin-right:12px;color:#fff}.widget-doughnut--value{line-height:1.3;font-weight:900;font-size:36px;text-align:center}.widget-doughnut--meta{margin-top:10px;font-style:italic;color:#737373;text-align:center}.widget-number{height:100%;display:flex;align-items:center}.widget-number-icon{display:flex;align-items:center;width:42px;margin-right:20px;color:#000}.widget-number-content{display:flex;flex-direction:column;justify-content:center}.widget-number-title{line-height:1.3;margin-bottom:5px;font-size:16px;color:#000}.widget-number-number{line-height:1.3;font-weight:900;font-size:24px} \ No newline at end of file diff --git a/Resources/Public/JavaScript/dashboard-delete.js b/Resources/Public/JavaScript/dashboard-delete.js index 7523a7f..3f1e8d6 100644 --- a/Resources/Public/JavaScript/dashboard-delete.js +++ b/Resources/Public/JavaScript/dashboard-delete.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -import Modal from"@typo3/backend/modal.js";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import RegularEvent from"@typo3/core/event/regular-event.js";class DashboardDelete{constructor(){this.selector=".js-dashboard-delete",this.initialize()}initialize(){new RegularEvent("click",(function(e){e.preventDefault();Modal.confirm(this.dataset.modalTitle,this.dataset.modalQuestion,SeverityEnum.warning,[{text:this.dataset.modalCancel,active:!0,btnClass:"btn-default",name:"cancel"},{text:this.dataset.modalOk,btnClass:"btn-warning",name:"delete"}]).on("button.clicked",e=>{"delete"===e.target.getAttribute("name")&&(window.location.href=this.getAttribute("href")),Modal.dismiss()})})).delegateTo(document,this.selector)}}export default new DashboardDelete; \ No newline at end of file +import Modal from"@typo3/backend/modal.js";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import RegularEvent from"@typo3/core/event/regular-event.js";class DashboardDelete{constructor(){this.selector=".js-dashboard-delete",this.initialize()}initialize(){new RegularEvent("click",(function(e){e.preventDefault();Modal.confirm(this.dataset.modalTitle,this.dataset.modalQuestion,SeverityEnum.warning,[{text:this.dataset.modalCancel,active:!0,btnClass:"btn-default",name:"cancel"},{text:this.dataset.modalOk,btnClass:"btn-warning",name:"delete"}]).on("button.clicked",(e=>{"delete"===e.target.getAttribute("name")&&(window.location.href=this.getAttribute("href")),Modal.dismiss()}))})).delegateTo(document,this.selector)}}export default new DashboardDelete; \ No newline at end of file diff --git a/Resources/Public/JavaScript/dashboard-modal.js b/Resources/Public/JavaScript/dashboard-modal.js index 31081f5..60ad006 100644 --- a/Resources/Public/JavaScript/dashboard-modal.js +++ b/Resources/Public/JavaScript/dashboard-modal.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -import Modal from"@typo3/backend/modal.js";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import RegularEvent from"@typo3/core/event/regular-event.js";class DashboardModal{constructor(){this.selector=".js-dashboard-modal",this.initialize()}initialize(){new RegularEvent("click",(function(t){t.preventDefault();const e=new DocumentFragment;e.append(document.getElementById("dashboardModal-"+this.dataset.modalIdentifier).content.cloneNode(!0));const a={type:Modal.types.default,title:this.dataset.modalTitle,size:Modal.sizes.medium,severity:SeverityEnum.notice,content:e,additionalCssClasses:["dashboard-modal"],callback:t=>{t.on("submit",".dashboardModal-form",e=>{t.trigger("modal-dismiss")}),t.on("button.clicked",e=>{if("save"===e.target.getAttribute("name")){t.find("form").trigger("submit")}else t.trigger("modal-dismiss")})},buttons:[{text:this.dataset.buttonCloseText,btnClass:"btn-default",name:"cancel"},{text:this.dataset.buttonOkText,active:!0,btnClass:"btn-info",name:"save"}]};Modal.advanced(a)})).delegateTo(document,this.selector)}}export default new DashboardModal; \ No newline at end of file +import Modal from"@typo3/backend/modal.js";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import RegularEvent from"@typo3/core/event/regular-event.js";class DashboardModal{constructor(){this.selector=".js-dashboard-modal",this.initialize()}initialize(){new RegularEvent("click",(function(t){t.preventDefault();const e=new DocumentFragment;e.append(document.getElementById(`dashboardModal-${this.dataset.modalIdentifier}`).content.cloneNode(!0));const a={type:Modal.types.default,title:this.dataset.modalTitle,size:Modal.sizes.medium,severity:SeverityEnum.notice,content:e,additionalCssClasses:["dashboard-modal"],callback:t=>{t.on("submit",".dashboardModal-form",(e=>{t.trigger("modal-dismiss")})),t.on("button.clicked",(e=>{if("save"===e.target.getAttribute("name")){t.find("form").trigger("submit")}else t.trigger("modal-dismiss")}))},buttons:[{text:this.dataset.buttonCloseText,btnClass:"btn-default",name:"cancel"},{text:this.dataset.buttonOkText,active:!0,btnClass:"btn-info",name:"save"}]};Modal.advanced(a)})).delegateTo(document,this.selector)}}export default new DashboardModal; \ No newline at end of file diff --git a/Resources/Public/JavaScript/grid.js b/Resources/Public/JavaScript/grid.js index 2776c16..82dc27d 100644 --- a/Resources/Public/JavaScript/grid.js +++ b/Resources/Public/JavaScript/grid.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -import Muuri from"muuri";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import RegularEvent from"@typo3/core/event/regular-event.js";class Grid{constructor(){this.selector=".dashboard-grid",this.initialize()}initialize(){const e={dragEnabled:!0,dragSortHeuristics:{sortInterval:50,minDragDistance:10,minBounceBackAngle:1},layoutDuration:400,layoutEasing:"ease",dragPlaceholder:{enabled:!0,duration:400,createElement:e=>e.getElement().cloneNode(!0)},dragSortPredicate:{action:"move",threshold:30},dragHandle:".js-dashboard-move-widget",dragReleaseDuration:400,dragReleaseEasing:"ease",layout:{fillGaps:!1,rounding:!1}};if(null!==document.querySelector(this.selector)){const t=new Muuri(this.selector,e);t.on("dragStart",()=>{document.querySelectorAll(".dashboard-item").forEach(e=>{e.classList.remove("dashboard-item--enableSelect")})}),t.on("dragReleaseEnd",()=>{document.querySelectorAll(".dashboard-item").forEach(e=>{e.classList.add("dashboard-item--enableSelect")}),this.saveItems(t)}),new RegularEvent("widgetContentRendered",()=>{t.refreshItems().layout()}).delegateTo(document,".dashboard-item")}}saveItems(e){let t=e.getItems().map((function(e){return[e.getElement().getAttribute("data-widget-key"),e.getElement().getAttribute("data-widget-hash")]}));new AjaxRequest(TYPO3.settings.ajaxUrls.dashboard_save_widget_positions).post({widgets:t}).then(async e=>{await e.resolve()})}}export default new Grid; \ No newline at end of file +import Muuri from"muuri";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import RegularEvent from"@typo3/core/event/regular-event.js";class Grid{constructor(){this.selector=".dashboard-grid",this.initialize()}initialize(){const e={dragEnabled:!0,dragSortHeuristics:{sortInterval:50,minDragDistance:10,minBounceBackAngle:1},layoutDuration:400,layoutEasing:"ease",dragPlaceholder:{enabled:!0,duration:400,createElement:e=>e.getElement().cloneNode(!0)},dragSortPredicate:{action:"move",threshold:30},dragHandle:".js-dashboard-move-widget",dragReleaseDuration:400,dragReleaseEasing:"ease",layout:{fillGaps:!1,rounding:!1}};if(null!==document.querySelector(this.selector)){const t=new Muuri(this.selector,e);t.on("dragStart",(()=>{document.querySelectorAll(".dashboard-item").forEach((e=>{e.classList.remove("dashboard-item--enableSelect")}))})),t.on("dragReleaseEnd",(()=>{document.querySelectorAll(".dashboard-item").forEach((e=>{e.classList.add("dashboard-item--enableSelect")})),this.saveItems(t)})),new RegularEvent("widgetContentRendered",(()=>{t.refreshItems().layout()})).delegateTo(document,".dashboard-item")}}saveItems(e){let t=e.getItems().map((function(e){return[e.getElement().getAttribute("data-widget-key"),e.getElement().getAttribute("data-widget-hash")]}));new AjaxRequest(TYPO3.settings.ajaxUrls.dashboard_save_widget_positions).post({widgets:t}).then((async e=>{await e.resolve()}))}}export default new Grid; \ No newline at end of file diff --git a/Resources/Public/JavaScript/widget-content-collector.js b/Resources/Public/JavaScript/widget-content-collector.js index 2573b1c..4948b1b 100644 --- a/Resources/Public/JavaScript/widget-content-collector.js +++ b/Resources/Public/JavaScript/widget-content-collector.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import RegularEvent from"@typo3/core/event/regular-event.js";class WidgetContentCollector{constructor(){this.selector=".dashboard-item",this.initialize()}initialize(){this.registerEvents();document.querySelectorAll(this.selector).forEach(e=>{let t;t=new Event("widgetRefresh",{bubbles:!0}),e.dispatchEvent(t)})}registerEvents(){new RegularEvent("widgetRefresh",(e,t)=>{e.preventDefault(),this.getContentForWidget(t)}).delegateTo(document,this.selector)}getContentForWidget(e){const t=e.querySelector(".widget-waiting"),n=e.querySelector(".widget-content"),s=e.querySelector(".widget-error");t.classList.remove("hide"),n.classList.add("hide"),s.classList.add("hide");new AjaxRequest(TYPO3.settings.ajaxUrls.dashboard_get_widget_content).withQueryArguments({widget:e.dataset.widgetKey}).get().then(async s=>{const i=await s.resolve();let r;null!==n&&(n.innerHTML=i.content,n.classList.remove("hide")),null!==t&&t.classList.add("hide");const o={bubbles:!0};r=Object.keys(i.eventdata).length>0?new CustomEvent("widgetContentRendered",{...o,detail:i.eventdata}):new Event("widgetContentRendered",o),e.dispatchEvent(r)}).catch(n=>{null!==s&&s.classList.remove("hide"),null!==t&&t.classList.add("hide"),console.warn(`Error while retrieving widget [${e.dataset.widgetKey}] content: ${n.message}`)})}}export default new WidgetContentCollector; \ No newline at end of file +import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import RegularEvent from"@typo3/core/event/regular-event.js";class WidgetContentCollector{constructor(){this.selector=".dashboard-item",this.initialize()}initialize(){this.registerEvents();document.querySelectorAll(this.selector).forEach((e=>{let t;t=new Event("widgetRefresh",{bubbles:!0}),e.dispatchEvent(t)}))}registerEvents(){new RegularEvent("widgetRefresh",((e,t)=>{e.preventDefault(),this.getContentForWidget(t)})).delegateTo(document,this.selector)}getContentForWidget(e){const t=e.querySelector(".widget-waiting"),n=e.querySelector(".widget-content"),s=e.querySelector(".widget-error");t.classList.remove("hide"),n.classList.add("hide"),s.classList.add("hide");new AjaxRequest(TYPO3.settings.ajaxUrls.dashboard_get_widget_content).withQueryArguments({widget:e.dataset.widgetKey}).get().then((async s=>{const i=await s.resolve();let r;null!==n&&(n.innerHTML=i.content,n.classList.remove("hide")),null!==t&&t.classList.add("hide");const o={bubbles:!0};r=Object.keys(i.eventdata).length>0?new CustomEvent("widgetContentRendered",{...o,detail:i.eventdata}):new Event("widgetContentRendered",o),e.dispatchEvent(r)})).catch((n=>{null!==s&&s.classList.remove("hide"),null!==t&&t.classList.add("hide"),console.warn(`Error while retrieving widget [${e.dataset.widgetKey}] content: ${n.message}`)}))}}export default new WidgetContentCollector; \ No newline at end of file diff --git a/Resources/Public/JavaScript/widget-refresh.js b/Resources/Public/JavaScript/widget-refresh.js index 21559c7..b111c82 100644 --- a/Resources/Public/JavaScript/widget-refresh.js +++ b/Resources/Public/JavaScript/widget-refresh.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -var Selectors,__decorate=function(e,t,r,o){var s,c=arguments.length,l=c<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,r,o);else for(var n=e.length-1;n>=0;n--)(s=e[n])&&(l=(c<3?s(l):c>3?s(t,r,l):s(t,r))||l);return c>3&&l&&Object.defineProperty(t,r,l),l};import{html,LitElement}from"lit";import{customElement}from"lit/decorators.js";!function(e){e.dashboardItem=".dashboard-item"}(Selectors||(Selectors={}));let WidgetRefresh=class extends LitElement{constructor(){super(),this.addEventListener("click",e=>{e.preventDefault(),this.closest(Selectors.dashboardItem).dispatchEvent(new Event("widgetRefresh",{bubbles:!0})),this.querySelector("button").blur()})}render(){return html``}};WidgetRefresh=__decorate([customElement("typo3-dashboard-widget-refresh")],WidgetRefresh); \ No newline at end of file +var Selectors,__decorate=function(e,t,r,o){var s,c=arguments.length,l=c<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,r,o);else for(var n=e.length-1;n>=0;n--)(s=e[n])&&(l=(c<3?s(l):c>3?s(t,r,l):s(t,r))||l);return c>3&&l&&Object.defineProperty(t,r,l),l};import{html,LitElement}from"lit";import{customElement}from"lit/decorators.js";!function(e){e.dashboardItem=".dashboard-item"}(Selectors||(Selectors={}));let WidgetRefresh=class extends LitElement{constructor(){super(),this.addEventListener("click",(e=>{e.preventDefault(),this.closest(Selectors.dashboardItem).dispatchEvent(new Event("widgetRefresh",{bubbles:!0})),this.querySelector("button").blur()}))}render(){return html``}};WidgetRefresh=__decorate([customElement("typo3-dashboard-widget-refresh")],WidgetRefresh); \ No newline at end of file diff --git a/Resources/Public/JavaScript/widget-remover.js b/Resources/Public/JavaScript/widget-remover.js index 55db5b1..2fe41be 100644 --- a/Resources/Public/JavaScript/widget-remover.js +++ b/Resources/Public/JavaScript/widget-remover.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -import Modal from"@typo3/backend/modal.js";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import RegularEvent from"@typo3/core/event/regular-event.js";class WidgetRemover{constructor(){this.selector=".js-dashboard-remove-widget",this.initialize()}initialize(){new RegularEvent("click",(function(e){e.preventDefault();Modal.confirm(this.dataset.modalTitle,this.dataset.modalQuestion,SeverityEnum.warning,[{text:this.dataset.modalCancel,active:!0,btnClass:"btn-default",name:"cancel"},{text:this.dataset.modalOk,btnClass:"btn-warning",name:"delete"}]).on("button.clicked",e=>{"delete"===e.target.getAttribute("name")&&(window.location.href=this.getAttribute("href")),Modal.dismiss()})})).delegateTo(document,this.selector)}}export default new WidgetRemover; \ No newline at end of file +import Modal from"@typo3/backend/modal.js";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import RegularEvent from"@typo3/core/event/regular-event.js";class WidgetRemover{constructor(){this.selector=".js-dashboard-remove-widget",this.initialize()}initialize(){new RegularEvent("click",(function(e){e.preventDefault();Modal.confirm(this.dataset.modalTitle,this.dataset.modalQuestion,SeverityEnum.warning,[{text:this.dataset.modalCancel,active:!0,btnClass:"btn-default",name:"cancel"},{text:this.dataset.modalOk,btnClass:"btn-warning",name:"delete"}]).on("button.clicked",(e=>{"delete"===e.target.getAttribute("name")&&(window.location.href=this.getAttribute("href")),Modal.dismiss()}))})).delegateTo(document,this.selector)}}export default new WidgetRemover; \ No newline at end of file diff --git a/Resources/Public/JavaScript/widget-selector.js b/Resources/Public/JavaScript/widget-selector.js index 2f71b88..8eeda2f 100644 --- a/Resources/Public/JavaScript/widget-selector.js +++ b/Resources/Public/JavaScript/widget-selector.js @@ -10,4 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -import Modal from"@typo3/backend/modal.js";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import RegularEvent from"@typo3/core/event/regular-event.js";class WidgetSelector{constructor(){this.selector=".js-dashboard-addWidget",this.initialize()}initialize(){new RegularEvent("click",(function(e){e.preventDefault();const t=new DocumentFragment;t.append(document.getElementById("widgetSelector").content.cloneNode(!0));const o={type:Modal.types.default,title:this.dataset.modalTitle,size:Modal.sizes.medium,severity:SeverityEnum.notice,content:t,additionalCssClasses:["dashboard-modal"],callback:e=>{e.on("click","a.dashboard-modal-item-block",t=>{e.trigger("modal-dismiss")})}};Modal.advanced(o)})).delegateTo(document,this.selector),document.querySelectorAll(this.selector).forEach(e=>{e.classList.remove("hide")})}}export default new WidgetSelector; \ No newline at end of file +import Modal from"@typo3/backend/modal.js";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import RegularEvent from"@typo3/core/event/regular-event.js";class WidgetSelector{constructor(){this.selector=".js-dashboard-addWidget",this.initialize()}initialize(){new RegularEvent("click",(function(e){e.preventDefault();const t=new DocumentFragment;t.append(document.getElementById("widgetSelector").content.cloneNode(!0));const o={type:Modal.types.default,title:this.dataset.modalTitle,size:Modal.sizes.medium,severity:SeverityEnum.notice,content:t,additionalCssClasses:["dashboard-modal"],callback:e=>{e.on("click","a.dashboard-modal-item-block",(t=>{e.trigger("modal-dismiss")}))}};Modal.advanced(o)})).delegateTo(document,this.selector),document.querySelectorAll(this.selector).forEach((e=>{e.classList.remove("hide")}))}}export default new WidgetSelector; \ No newline at end of file