Skip to content

Commit 40afe8b

Browse files
diosmosisjustinvelluppillaimattabbx80sgiehl
authored
[Vue] enable full typescript compilation + fix typing errors in existing Vue code (#18545)
* rebuild CoreHome * quick fix * built vue files * fix angularjs issue * add comment * update umd files * 4.6.1-rc1 * 4.6.1 * fix field array title * apply some pr feedback * apply more pr feedback * another fix * tweak * fix ng-change not executed before ng-model * fix another set of issues * fix another issue * rebuild vue * better ng-change/ng-model fix * update some screenshots * rebuild vue * remove some TODOs * initiate initial ng-change ONLY for site selectors where this behavior applies * emit/broadcast on correct scope in wrapper * rebuild vue * fix some issues * couple more fixes * fix another title issue * rebuild vue * do not report on ajax errors in notifications if not logged in * migrate reporting page and model * rebuild vue * create sites selector model adapter * fix siteselector vue bug, initial site is only set if there is just one site available * rebuild vue * migrate plugin settings directive * remove TODO * migrate plugin filter directive * migrate two more plugins directives * migrate save button * fix a bunch of bugs * fix another widget bug * allow change event name between angularjs and vue * rebuild vue * migrate plugin form directive * get to work * migrate select-on-focus directive and start migrating report-export directive * finish migrating report export directive & popover component + create reusable function to create vue app and add globals to it * rebuild vue * remove angularjs files and move less contents to vue dir * migrate sparkline component * migrate progressbar component * migrate content intro & content table directives * rebuild vue * migrate piwik-ajax-form component to vue * migrate popover handler directive to service class * migrate dropdownbutton directive though it does not seem to be in use * migrate show sensitive data directive * build vue * built vue files * fix function signature * fix vue warning * fix ajax request race condition * rebuild vue * add new notification type "help" so the help notification is not cleared when clearing transient notifications * fix some bugs and tests * update screenshot * update screenshot & fix a test * allow using unminified jquery ui + fix bug in last fix * fix error when enrichedheadline is used in modal * add polyfill min.js * remove two todos * fix widget url logic * update some screenshots and fix sanitization/escape issue * update screenshots * rebuild vue * fix url location updating regression in MatomoUrl.updateLocation use * submodule * update screenshots and fix possible error in json parse * built vue files * Merge branch 'vue-period-selector-regression' into vue-reporting-menu * rebuild vue * use correct variable * rebuild vue * fix widget url logic * segment parameter can be undefined now for some reason * fix ngmodel binding in siteselector adapter (for last time hopefully) * the original site selector only set the first site to the first site in the initial sites query if there was only one site in the entire matomo instance * fix sitesmanager ui test failure * fix usersettings test failure * rebuild vue * more siteselector tweaks. * build CoreHome * more siteselector tweaks. * another siteselector issue * update screenshots * update screenshot and try to fix random failure * fix some issues in widget.vue when containerid is specified * fix couple tests * fix several test failures * fix string concat * fix test failure * extra change * fix last change and random failure * styling fix * fix last fix * real fix this time * fix stray request * proper fix * update build files * try to fix random failure * do not submit form * check for api errors in promise chain in ajaxhelper.ts * force a digest after a location change * use proper abortcontroller method instead of promise hack, have to add new polyfill + try to fix random test failure * some UI test fixes * fix some report export issues * several save button fixes + make replace approximation in createAngularJsAdapter better * fix sparkline * apply after manual click triggering in savebutton * css fixes and piwik-content-table was never applied by angularjs in installtion * rebuild vue * add names to divs so they can still be queried as they were in angularjs * rebuild vue * rebuild vue * now that format_metrics checkbox works, need to check it * small delay before processing first popover * fix dropdown class/directive name * fix overlay test * remove unintended changes * remove unintended changes * do not do a passthrough transpile of vue typescript, and fix many typescript errors in existing code * more typescript fixes * even more fixes * workarounds to fix recursive typing issues * get corehome to build w/ full typescript build and output type definitions to local dir * get outputted typings to be used when compiling other plugins and fix typescript issues in CorePluginsAdmin * readd corehome umd * fix typescript errors in ExampleVue plugin * fix feedback typescript errors * update screenshots * Show a summary of new features (#18065) * Added "What is new" notification display, populated by a new event * Removed test example event hook * Added support for applying a link attribute to menu items, fixes layout issue for mobile with html menu items * Updated UI test screenshots * Revert accidental edit * Hide the "What's new" icon if there are no new features to show * Changed to use changes.json, track user last viewed, added ui test * Fix UserManager unit tests broken by new ts_changes_viewed user field * Moved getChanges to separate helper class, added unit test, added user view access check * Updated to add new changes table and populate only on plugin update/install * Added missing fixture class, updated UI screenshots * Updated matomo font to add ringing bell and new releases icons * Fix for integration test * Reworked class structure, removed unnecessary angular directive, merged templates, other tidy ups * built vue files * built vue files * Added null user check, missing table exception handling, show plugin name in change title, better handling of missing change fields * Added sample changes file, moved UserChanges db code to changes model, added return type hints, better db error code handling, various other improvements * Revert accidental UI screenshot commit * Fix for incorrect link name parameter in sample changes, switched back to using $db->query for INSERT IGNORE * Integration test fix, UI screenshot updates * Test fix * Added link styling, show CoreHome changes without plugin prefix in title * Update UI test screenshot * Added styles to the popover, added event for filtering changes * Test fix * UI test screenshot updates Co-authored-by: sgiehl <[email protected]> Co-authored-by: bx80 <[email protected]> * Update test translation (#18531) update a test failed XML * updates all submodules (#18541) Co-authored-by: diosmosis <[email protected]> * Translations update from Hosted Weblate (#18529) * Translated using Weblate (Greek) Currently translated at 100.0% (162 of 162 strings) Translation: Matomo/Plugin CoreAdminHome Translate-URL: https://hosted.weblate.org/projects/matomo/plugin-coreadminhome/el/ [ci skip] Co-authored-by: Hosted Weblate <[email protected]> Co-authored-by: Vasilis Lourdas <[email protected]> * Translated using Weblate (Chinese (Simplified)) Currently translated at 83.9% (136 of 162 strings) Translation: Matomo/Plugin CoreAdminHome Translate-URL: https://hosted.weblate.org/projects/matomo/plugin-coreadminhome/zh_Hans/ [ci skip] Translated using Weblate (Chinese (Simplified)) Currently translated at 99.6% (620 of 622 strings) Translation: Matomo/Matomo Base Translate-URL: https://hosted.weblate.org/projects/matomo/matomo-base/zh_Hans/ [ci skip] Co-authored-by: Hosted Weblate <[email protected]> Co-authored-by: 刘韬 <[email protected]> * Update translation files Updated by "Squash Git commits" hook in Weblate. Translation: Matomo/Plugin CoreAdminHome Translate-URL: https://hosted.weblate.org/projects/matomo/plugin-coreadminhome/ [ci skip] Co-authored-by: Vasilis Lourdas <[email protected]> Co-authored-by: 刘韬 <[email protected]> * [Vue] migrate report export directive and popover (#18440) * update files * sidenav start * make getRef a utility method * tweak * add return type * finish converting side-nav directive * starting on reporting menu conversion * remove unused properties * convert reporting pages service * migrate report metadata store * remove angularjs files * migrating reporting pages store * make store adapters more immutable * get service adapters to work * fix a UI test * another html fix * migrate most of reporting menu directive and model * Use themed font family for input forms to override materialize.css styling * rebuild vue * add a missing div * ui test fixes * update styling * get to build * get to load in the UI w/o error * clone result of functions * fix compile issue * migrate widget loader and get to load in UI * rebuild vue * migrate widgetcontainer * migrate widget bydimension container * migrate widget + add tooltips directive * quick fix * Updating version to 4.6.0 * loading in page * update expected screenshot * add wait just in case travis is slow * fix ordering bug * add another wait * rebuild vue * css tweak * fix some bugs and tests * undo screenshot changes * Menus test passing locally * [Vue] date picker viewDate property is not kept up to date (#18385) * viewDate ref is not kept up to date * rebuild corehome * reporting menu subcategory items are meant to be normal links * update some screenshots * use innerText instead of text() since angularjs maintains newlines in HTML that vue does not add * trigger angularjs digest after ajaxhelper request * rebuild vue * update screenshots, fix bug in link generation in reporting menu and allow syncing multiple screenshot regexes at a time * undo box-shadow change for UI tests * fix more issues & update more tests * update some screenshots * fix some tests * rebuild CoreHome * quick fix * built vue files * fix angularjs issue * add comment * update umd files * 4.6.1-rc1 * 4.6.1 * fix field array title * apply some pr feedback * apply more pr feedback * another fix * tweak * fix ng-change not executed before ng-model * fix another set of issues * fix another issue * rebuild vue * better ng-change/ng-model fix * update some screenshots * rebuild vue * remove some TODOs * initiate initial ng-change ONLY for site selectors where this behavior applies * emit/broadcast on correct scope in wrapper * rebuild vue * fix some issues * couple more fixes * fix another title issue * rebuild vue * do not report on ajax errors in notifications if not logged in * migrate reporting page and model * rebuild vue * create sites selector model adapter * fix siteselector vue bug, initial site is only set if there is just one site available * rebuild vue * migrate plugin settings directive * remove TODO * migrate plugin filter directive * migrate two more plugins directives * migrate save button * fix a bunch of bugs * fix another widget bug * allow change event name between angularjs and vue * rebuild vue * migrate plugin form directive * get to work * migrate select-on-focus directive and start migrating report-export directive * finish migrating report export directive & popover component + create reusable function to create vue app and add globals to it * rebuild vue * remove angularjs files and move less contents to vue dir * built vue files * fix function signature * fix vue warning * fix ajax request race condition * rebuild vue * add new notification type "help" so the help notification is not cleared when clearing transient notifications * fix some bugs and tests * update screenshot * update screenshot & fix a test * allow using unminified jquery ui + fix bug in last fix * fix error when enrichedheadline is used in modal * add polyfill min.js * remove two todos * fix widget url logic * update some screenshots and fix sanitization/escape issue * update screenshots * rebuild vue * fix url location updating regression in MatomoUrl.updateLocation use * submodule * update screenshots and fix possible error in json parse * built vue files * Merge branch 'vue-period-selector-regression' into vue-reporting-menu * rebuild vue * use correct variable * rebuild vue * fix widget url logic * segment parameter can be undefined now for some reason * fix ngmodel binding in siteselector adapter (for last time hopefully) * the original site selector only set the first site to the first site in the initial sites query if there was only one site in the entire matomo instance * fix sitesmanager ui test failure * fix usersettings test failure * rebuild vue * more siteselector tweaks. * build CoreHome * more siteselector tweaks. * another siteselector issue * update screenshots * update screenshot and try to fix random failure * fix some issues in widget.vue when containerid is specified * fix couple tests * fix several test failures * fix string concat * fix test failure * extra change * fix last change and random failure * styling fix * fix last fix * real fix this time * fix stray request * proper fix * update build files * try to fix random failure * do not submit form * check for api errors in promise chain in ajaxhelper.ts * force a digest after a location change * use proper abortcontroller method instead of promise hack, have to add new polyfill + try to fix random test failure * some UI test fixes * fix some report export issues * several save button fixes + make replace approximation in createAngularJsAdapter better * apply after manual click triggering in savebutton * add names to divs so they can still be queried as they were in angularjs * rebuild vue * now that format_metrics checkbox works, need to check it * fix unintended changes * updated expected screenshots * update two more * go back to previous format_metrics behavior in popover Co-authored-by: Justin Velluppillai <[email protected]> Co-authored-by: justinvelluppillai <[email protected]> Co-authored-by: Matthieu Aubry <[email protected]> * [Vue] remove support in vue for FormField.allSettings (#18542) * deprecate support in vue for FormField.allSettings since deep watching the property doesnt quite work * built vue files * update screenshots * update screenshot * Show a summary of new features (#18065) * Added "What is new" notification display, populated by a new event * Removed test example event hook * Added support for applying a link attribute to menu items, fixes layout issue for mobile with html menu items * Updated UI test screenshots * Revert accidental edit * Hide the "What's new" icon if there are no new features to show * Changed to use changes.json, track user last viewed, added ui test * Fix UserManager unit tests broken by new ts_changes_viewed user field * Moved getChanges to separate helper class, added unit test, added user view access check * Updated to add new changes table and populate only on plugin update/install * Added missing fixture class, updated UI screenshots * Updated matomo font to add ringing bell and new releases icons * Fix for integration test * Reworked class structure, removed unnecessary angular directive, merged templates, other tidy ups * built vue files * built vue files * Added null user check, missing table exception handling, show plugin name in change title, better handling of missing change fields * Added sample changes file, moved UserChanges db code to changes model, added return type hints, better db error code handling, various other improvements * Revert accidental UI screenshot commit * Fix for incorrect link name parameter in sample changes, switched back to using $db->query for INSERT IGNORE * Integration test fix, UI screenshot updates * Test fix * Added link styling, show CoreHome changes without plugin prefix in title * Update UI test screenshot * Added styles to the popover, added event for filtering changes * Test fix * UI test screenshot updates Co-authored-by: sgiehl <[email protected]> Co-authored-by: bx80 <[email protected]> * Update test translation (#18531) update a test failed XML * updates all submodules (#18541) Co-authored-by: diosmosis <[email protected]> * Translations update from Hosted Weblate (#18529) * Translated using Weblate (Greek) Currently translated at 100.0% (162 of 162 strings) Translation: Matomo/Plugin CoreAdminHome Translate-URL: https://hosted.weblate.org/projects/matomo/plugin-coreadminhome/el/ [ci skip] Co-authored-by: Hosted Weblate <[email protected]> Co-authored-by: Vasilis Lourdas <[email protected]> * Translated using Weblate (Chinese (Simplified)) Currently translated at 83.9% (136 of 162 strings) Translation: Matomo/Plugin CoreAdminHome Translate-URL: https://hosted.weblate.org/projects/matomo/plugin-coreadminhome/zh_Hans/ [ci skip] Translated using Weblate (Chinese (Simplified)) Currently translated at 99.6% (620 of 622 strings) Translation: Matomo/Matomo Base Translate-URL: https://hosted.weblate.org/projects/matomo/matomo-base/zh_Hans/ [ci skip] Co-authored-by: Hosted Weblate <[email protected]> Co-authored-by: 刘韬 <[email protected]> * Update translation files Updated by "Squash Git commits" hook in Weblate. Translation: Matomo/Plugin CoreAdminHome Translate-URL: https://hosted.weblate.org/projects/matomo/plugin-coreadminhome/ [ci skip] Co-authored-by: Vasilis Lourdas <[email protected]> Co-authored-by: 刘韬 <[email protected]> * [Vue] migrate report export directive and popover (#18440) * update files * sidenav start * make getRef a utility method * tweak * add return type * finish converting side-nav directive * starting on reporting menu conversion * remove unused properties * convert reporting pages service * migrate report metadata store * remove angularjs files * migrating reporting pages store * make store adapters more immutable * get service adapters to work * fix a UI test * another html fix * migrate most of reporting menu directive and model * Use themed font family for input forms to override materialize.css styling * rebuild vue * add a missing div * ui test fixes * update styling * get to build * get to load in the UI w/o error * clone result of functions * fix compile issue * migrate widget loader and get to load in UI * rebuild vue * migrate widgetcontainer * migrate widget bydimension container * migrate widget + add tooltips directive * quick fix * Updating version to 4.6.0 * loading in page * update expected screenshot * add wait just in case travis is slow * fix ordering bug * add another wait * rebuild vue * css tweak * fix some bugs and tests * undo screenshot changes * Menus test passing locally * [Vue] date picker viewDate property is not kept up to date (#18385) * viewDate ref is not kept up to date * rebuild corehome * reporting menu subcategory items are meant to be normal links * update some screenshots * use innerText instead of text() since angularjs maintains newlines in HTML that vue does not add * trigger angularjs digest after ajaxhelper request * rebuild vue * update screenshots, fix bug in link generation in reporting menu and allow syncing multiple screenshot regexes at a time * undo box-shadow change for UI tests * fix more issues & update more tests * update some screenshots * fix some tests * rebuild CoreHome * quick fix * built vue files * fix angularjs issue * add comment * update umd files * 4.6.1-rc1 * 4.6.1 * fix field array title * apply some pr feedback * apply more pr feedback * another fix * tweak * fix ng-change not executed before ng-model * fix another set of issues * fix another issue * rebuild vue * better ng-change/ng-model fix * update some screenshots * rebuild vue * remove some TODOs * initiate initial ng-change ONLY for site selectors where this behavior applies * emit/broadcast on correct scope in wrapper * rebuild vue * fix some issues * couple more fixes * fix another title issue * rebuild vue * do not report on ajax errors in notifications if not logged in * migrate reporting page and model * rebuild vue * create sites selector model adapter * fix siteselector vue bug, initial site is only set if there is just one site available * rebuild vue * migrate plugin settings directive * remove TODO * migrate plugin filter directive * migrate two more plugins directives * migrate save button * fix a bunch of bugs * fix another widget bug * allow change event name between angularjs and vue * rebuild vue * migrate plugin form directive * get to work * migrate select-on-focus directive and start migrating report-export directive * finish migrating report export directive & popover component + create reusable function to create vue app and add globals to it * rebuild vue * remove angularjs files and move less contents to vue dir * built vue files * fix function signature * fix vue warning * fix ajax request race condition * rebuild vue * add new notification type "help" so the help notification is not cleared when clearing transient notifications * fix some bugs and tests * update screenshot * update screenshot & fix a test * allow using unminified jquery ui + fix bug in last fix * fix error when enrichedheadline is used in modal * add polyfill min.js * remove two todos * fix widget url logic * update some screenshots and fix sanitization/escape issue * update screenshots * rebuild vue * fix url location updating regression in MatomoUrl.updateLocation use * submodule * update screenshots and fix possible error in json parse * built vue files * Merge branch 'vue-period-selector-regression' into vue-reporting-menu * rebuild vue * use correct variable * rebuild vue * fix widget url logic * segment parameter can be undefined now for some reason * fix ngmodel binding in siteselector adapter (for last time hopefully) * the original site selector only set the first site to the first site in the initial sites query if there was only one site in the entire matomo instance * fix sitesmanager ui test failure * fix usersettings test failure * rebuild vue * more siteselector tweaks. * build CoreHome * more siteselector tweaks. * another siteselector issue * update screenshots * update screenshot and try to fix random failure * fix some issues in widget.vue when containerid is specified * fix couple tests * fix several test failures * fix string concat * fix test failure * extra change * fix last change and random failure * styling fix * fix last fix * real fix this time * fix stray request * proper fix * update build files * try to fix random failure * do not submit form * check for api errors in promise chain in ajaxhelper.ts * force a digest after a location change * use proper abortcontroller method instead of promise hack, have to add new polyfill + try to fix random test failure * some UI test fixes * fix some report export issues * several save button fixes + make replace approximation in createAngularJsAdapter better * apply after manual click triggering in savebutton * add names to divs so they can still be queried as they were in angularjs * rebuild vue * now that format_metrics checkbox works, need to check it * fix unintended changes * updated expected screenshots * update two more * go back to previous format_metrics behavior in popover Co-authored-by: Justin Velluppillai <[email protected]> Co-authored-by: justinvelluppillai <[email protected]> Co-authored-by: Matthieu Aubry <[email protected]> * [Vue] remove support in vue for FormField.allSettings (#18542) * deprecate support in vue for FormField.allSettings since deep watching the property doesnt quite work * built vue files * update screenshots * update screenshot * fix tests * rebuild * order plugins by dependencies in vue:build and fix warning in corehome build Co-authored-by: Justin Velluppillai <[email protected]> Co-authored-by: justinvelluppillai <[email protected]> Co-authored-by: Matthieu Aubry <[email protected]> Co-authored-by: Ben Burgess <[email protected]> Co-authored-by: sgiehl <[email protected]> Co-authored-by: bx80 <[email protected]> Co-authored-by: Peter Zhang <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Weblate (bot) <[email protected]> Co-authored-by: Vasilis Lourdas <[email protected]> Co-authored-by: 刘韬 <[email protected]>
1 parent d17b842 commit 40afe8b

File tree

126 files changed

+2497
-1789
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+2497
-1789
lines changed

.eslintrc.js

+6
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,11 @@ module.exports = {
2828
'no-param-reassign': ["error", { "props": false }],
2929
'camelcase': 'off',
3030
'@typescript-eslint/no-non-null-assertion': 'off',
31+
32+
// typescript will provide similar error messages, potentially conflicting ones, for
33+
// the following rules, so we disable them
34+
'no-undef': 'off',
35+
'no-undef-init': 'off',
36+
'import/extensions': 'off',
3137
},
3238
};

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ docker-compose.yml
106106
/plugins/*/vue/dist/*.map
107107
/plugins/*/vue/dist/*.development.*
108108
/plugins/CoreVue/polyfills/dist/MatomoPolyfills.min.js.map
109-
109+
/@types

core/AssetManager/UIAssetFetcher/JScriptUIAssetFetcher.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected function getPriorityOrder()
9999

100100
private function addUmdFilesIfDetected($plugins)
101101
{
102-
$plugins = $this->orderPluginsByPluginDependencies($plugins);
102+
$plugins = self::orderPluginsByPluginDependencies($plugins);
103103

104104
foreach ($plugins as $plugin) {
105105
$devUmd = "plugins/$plugin/vue/dist/$plugin.development.umd.js";
@@ -117,18 +117,18 @@ private function addUmdFilesIfDetected($plugins)
117117
}
118118
}
119119

120-
private function orderPluginsByPluginDependencies($plugins)
120+
public static function orderPluginsByPluginDependencies($plugins)
121121
{
122122
$result = [];
123123

124124
while (!empty($plugins)) {
125-
$this->visitPlugin(reset($plugins), $plugins, $result);
125+
self::visitPlugin(reset($plugins), $plugins, $result);
126126
}
127127

128128
return $result;
129129
}
130130

131-
private function visitPlugin($plugin, &$plugins, &$result)
131+
private static function visitPlugin($plugin, &$plugins, &$result)
132132
{
133133
// remove the plugin from the array of plugins to visit
134134
$index = array_search($plugin, $plugins);
@@ -149,7 +149,7 @@ private function visitPlugin($plugin, &$plugins, &$result)
149149
if (!empty($pluginDependencies['dependsOn'])) {
150150
// visit each plugin this one depends on first, so it is loaded first
151151
foreach ($pluginDependencies['dependsOn'] as $pluginDependency) {
152-
$this->visitPlugin($pluginDependency, $plugins, $result);
152+
self::visitPlugin($pluginDependency, $plugins, $result);
153153
}
154154
}
155155

plugins/CoreHome/vue/dist/CoreHome.umd.js

+762-594
Large diffs are not rendered by default.

plugins/CoreHome/vue/dist/CoreHome.umd.min.js

+88-76
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/CoreHome/vue/src/AjaxForm/AjaxForm.adapter.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
*/
77

88
import { DirectiveBinding, ref } from 'vue';
9+
import { IDirective, IDirectiveLinkFn, IParseService } from 'angular';
910
import createVueApp from '../createVueApp';
1011
import AjaxForm from './AjaxForm.vue';
1112

13+
const { $ } = window;
14+
1215
/**
1316
* AngularJS directive that manages an AJAX form.
1417
*
@@ -57,7 +60,7 @@ import AjaxForm from './AjaxForm.vue';
5760
* @deprecated
5861
*/
5962

60-
function piwikAjaxForm($parse) {
63+
function piwikAjaxForm($parse: IParseService): IDirective {
6164
return {
6265
restrict: 'A',
6366
scope: {
@@ -69,10 +72,11 @@ function piwikAjaxForm($parse) {
6972
},
7073
require: '?ngModel',
7174
transclude: true,
72-
compile: function piwikAjaxFormCompile(compileElement, compileAttrs) {
75+
compile: function piwikAjaxFormCompile(compileElement, compileAttrs): IDirectiveLinkFn {
7376
compileAttrs.noErrorNotification = !!compileAttrs.noErrorNotification;
7477

75-
return function piwikAjaxFormLink(scope, element, attrs, ngModel, transclude) {
78+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
79+
return function piwikAjaxFormLink(scope: any, element, attrs, ngModel, transclude) {
7680
if (!scope.submitApiMethod) {
7781
throw new Error('submitApiMethod is required');
7882
}
@@ -139,8 +143,7 @@ function piwikAjaxForm($parse) {
139143
});
140144

141145
function setFormValueFromInput(inputElement: HTMLElement, skipScopeApply?: boolean) {
142-
const $ = angular.element;
143-
const name = $(inputElement).attr('name');
146+
const name = $(inputElement).attr('name')!;
144147
let val;
145148

146149
if ($(inputElement).attr('type') === 'checkbox') {
@@ -161,22 +164,24 @@ function piwikAjaxForm($parse) {
161164
// on change of any input, change appropriate value in model, but only if requested
162165
if (!scope.useCustomDataBinding) {
163166
element.on('change', 'input,select', (event) => {
164-
setFormValueFromInput(event.target);
167+
setFormValueFromInput(event.target as HTMLElement);
165168
});
166169
}
167170

168171
// make sure child elements can access this directive's scope
169-
transclude(scope, (clone, transcludeScope) => {
172+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
173+
transclude!(scope, (clone, transcludeScope: any) => {
170174
if (!transcludeScope.useCustomDataBinding) {
171-
const $inputs = clone.find('input,select').not('[type=submit]');
175+
const $inputs = clone!.find('input,select').not('[type=submit]');
172176

173177
// initialize form data to input values (include <select>s
174178
$inputs.each(function inputEach() {
175179
setFormValueFromInput(this, true);
176180
});
177181
}
178182

179-
$(vm.transcludeTarget).append(clone);
183+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
184+
$((vm as any).transcludeTarget as HTMLElement).append(clone!);
180185
});
181186
};
182187
},
@@ -185,4 +190,4 @@ function piwikAjaxForm($parse) {
185190

186191
piwikAjaxForm.$inject = ['$parse'];
187192

188-
angular.module('piwikApp').directive('piwikAjaxForm', piwikAjaxForm);
193+
window.angular.module('piwikApp').directive('piwikAjaxForm', piwikAjaxForm);

plugins/CoreHome/vue/src/AjaxForm/AjaxForm.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default defineComponent({
6666
emits: ['update:modelValue'],
6767
mounted() {
6868
// on submit call controller submit method
69-
$(this.$refs.root).on('click', 'input[type=submit]', () => {
69+
$(this.$refs.root as HTMLElement).on('click', 'input[type=submit]', () => {
7070
this.submitForm();
7171
});
7272
},

plugins/CoreHome/vue/src/AjaxHelper/AjaxHelper.adapter.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import AjaxHelper from './AjaxHelper';
22

33
declare global {
44
interface Window {
5-
ajaxHelper: AjaxHelper;
5+
ajaxHelper: typeof AjaxHelper;
66
}
77
}
88

99
window.ajaxHelper = AjaxHelper;
1010

1111
function ajaxQueue() {
12-
return globalAjaxQueue;
12+
return window.globalAjaxQueue;
1313
}
1414

15-
angular.module('piwikApp.service').service('globalAjaxQueue', ajaxQueue);
15+
window.angular.module('piwikApp.service').service('globalAjaxQueue', ajaxQueue);

plugins/CoreHome/vue/src/AjaxHelper/AjaxHelper.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ export default class AjaxHelper<T = any> { // eslint-disable-line
174174
defaultParams = ['idSite', 'period', 'date', 'segment'];
175175

176176
// helper method entry point
177-
static fetch<R = any>(params: QueryParameters, options: AjaxOptions = {}): Promise<R> { // eslint-disable-line
177+
static fetch<R = any>( // eslint-disable-line
178+
params: QueryParameters,
179+
options: AjaxOptions = {},
180+
): Promise<R> {
178181
const helper = new AjaxHelper<R>();
179182
if (options.withTokenInUrl) {
180183
helper.withTokenInUrl();
@@ -215,7 +218,8 @@ export default class AjaxHelper<T = any> { // eslint-disable-line
215218
// eslint-disable-next-line @typescript-eslint/no-explicit-any
216219
static post<R = any>(
217220
params: QueryParameters,
218-
postParams: QueryParameters,
221+
// eslint-disable-next-line
222+
postParams: any,
219223
options: AjaxOptions = {},
220224
): Promise<R> {
221225
return this.fetch<R>(params, { ...options, postParams });

plugins/CoreHome/vue/src/Comparisons/Comparisons.adapter.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ function ComparisonFactory() {
1313
return ComparisonsStoreInstance;
1414
}
1515

16-
ComparisonFactory.$inject = [];
17-
18-
angular.module('piwikApp.service').factory('piwikComparisonsService', ComparisonFactory);
16+
window.angular.module('piwikApp.service').factory('piwikComparisonsService', ComparisonFactory);
1917

2018
export default createAngularJsAdapter({
2119
component: Comparisons,

plugins/CoreHome/vue/src/Comparisons/Comparisons.vue

+12-5
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,17 @@ interface ProcessedReportResponse {
9494
reportData: ProcessedReportData;
9595
}
9696

97+
interface ComparisonState {
98+
comparisonTooltips: Record<string, Record<string, string>>|null;
99+
}
100+
97101
export default defineComponent({
98102
props: {
99103
},
100104
directives: {
101105
Tooltips,
102106
},
103-
data() {
107+
data(): ComparisonState {
104108
return {
105109
comparisonTooltips: null,
106110
};
@@ -113,8 +117,11 @@ export default defineComponent({
113117
const periodComparisons = computed(() => ComparisonsStoreInstance.getPeriodComparisons());
114118
const getSeriesColor = ComparisonsStoreInstance.getSeriesColor.bind(ComparisonsStoreInstance);
115119

116-
function transformTooltipContent() {
120+
function transformTooltipContent(this: HTMLElement) {
117121
const title = window.$(this).attr('title');
122+
if (!title) {
123+
return title;
124+
}
118125
return window.vueSanitize(title.replace(/\n/g, '<br />'));
119126
}
120127

@@ -132,7 +139,7 @@ export default defineComponent({
132139
},
133140
removeSegmentComparison(index: number) {
134141
// otherwise the tooltip will be stuck on the screen
135-
window.$(this.$refs.root).tooltip('destroy');
142+
window.$(this.$refs.root as HTMLElement).tooltip('destroy');
136143
ComparisonsStoreInstance.removeSegmentComparison(index);
137144
},
138145
getComparisonPeriodType(comparison: AnyComparison) {
@@ -186,11 +193,11 @@ export default defineComponent({
186193
}).then((report) => {
187194
this.comparisonTooltips = {};
188195
periodComparisons.forEach((periodComp) => {
189-
this.comparisonTooltips[periodComp.index] = {};
196+
this.comparisonTooltips![periodComp.index] = {};
190197

191198
segmentComparisons.forEach((segmentComp) => {
192199
const tooltip = this.generateComparisonTooltip(report, periodComp, segmentComp);
193-
this.comparisonTooltips[periodComp.index][segmentComp.index] = tooltip;
200+
this.comparisonTooltips![periodComp.index][segmentComp.index] = tooltip;
194201
});
195202
});
196203
});

plugins/CoreHome/vue/src/ContentBlock/ContentBlock.vue

+7-6
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ export default defineComponent({
6262
},
6363
},
6464
mounted() {
65-
const { root, content } = this.$refs;
65+
const root = this.$refs.root as HTMLElement;
66+
const content = this.$refs.content as HTMLElement;
6667

67-
if (this.anchor) {
68+
if (this.anchor && root && root.parentElement) {
6869
const anchorElement = document.createElement('a');
6970
anchorElement.id = this.anchor;
7071
root.parentElement.prepend(anchorElement);
@@ -78,7 +79,7 @@ export default defineComponent({
7879
}
7980
}, 0);
8081

81-
if (this.actualFeature && (this.actualFeature === true || this.actualFeature === 'true')) {
82+
if (this.actualFeature && this.actualFeature === 'true') {
8283
this.actualFeature = this.contentTitle;
8384
}
8485

@@ -87,13 +88,13 @@ export default defineComponent({
8788
adminContent = document.querySelector('#content.admin');
8889
}
8990

90-
let contentTopPosition: number;
91+
let contentTopPosition: number|null = null;
9192
if (adminContent) {
9293
contentTopPosition = adminContent.offsetTop;
9394
}
9495

9596
if (contentTopPosition || contentTopPosition === 0) {
96-
const parents = root.closest('[piwik-widget-loader]');
97+
const parents = root.closest('[piwik-widget-loader]') as HTMLElement;
9798

9899
// when shown within the widget loader, we need to get the offset of that element
99100
// as the widget loader might be still shown. Would otherwise not position correctly
@@ -103,7 +104,7 @@ export default defineComponent({
103104
if (topThis - contentTopPosition < 17) {
104105
// we make sure to display the first card with no margin-top to have it on same as line as
105106
// navigation
106-
root.style.marginTop = 0;
107+
root.style.marginTop = '0';
107108
}
108109
}
109110
},

plugins/CoreHome/vue/src/ContentIntro/ContentIntro.adapter.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@ export default function piwikContentIntro(): IDirective {
1717
};
1818
}
1919

20-
piwikContentIntro.$inject = [];
21-
22-
angular.module('piwikApp').directive('piwikContentIntro', piwikContentIntro);
20+
window.angular.module('piwikApp').directive('piwikContentIntro', piwikContentIntro);

plugins/CoreHome/vue/src/ContentTable/ContentTable.adapter.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@ export default function piwikContentTable(): IDirective {
1717
};
1818
}
1919

20-
piwikContentTable.$inject = [];
21-
22-
angular.module('piwikApp').directive('piwikContentTable', piwikContentTable);
20+
window.angular.module('piwikApp').directive('piwikContentTable', piwikContentTable);

plugins/CoreHome/vue/src/DatePicker/DatePicker.adapter.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ITimeoutService } from 'angular';
99
import createAngularJsAdapter from '../createAngularJsAdapter';
1010
import DatePicker from './DatePicker.vue';
1111

12-
export default createAngularJsAdapter({
12+
export default createAngularJsAdapter<[ITimeoutService]>({
1313
component: DatePicker,
1414
scope: {
1515
selectedDateStart: {
@@ -48,13 +48,13 @@ export default createAngularJsAdapter({
4848
},
4949
directiveName: 'piwikDatePicker',
5050
events: {
51-
'cell-hover': (event, scope, element, attrs, $timeout: ITimeoutService) => {
51+
'cell-hover': (event, vm, scope, element, attrs, controller, $timeout) => {
5252
$timeout(); // trigger new digest
5353
},
54-
'cell-hover-leave': (event, scope, element, attrs, $timeout: ITimeoutService) => {
54+
'cell-hover-leave': (event, vm, scope, element, attrs, controller, $timeout) => {
5555
$timeout(); // trigger new digest
5656
},
57-
'date-select': (event, scope, element, attrs, $timeout: ITimeoutService) => {
57+
'date-select': (event, vm, scope, element, attrs, controller, $timeout) => {
5858
$timeout(); // trigger new digest
5959
},
6060
},

0 commit comments

Comments
 (0)