From 693cf58767e22f33e33cd79367c89a518b75d99f Mon Sep 17 00:00:00 2001 From: Finevman Date: Fri, 6 Oct 2023 14:41:17 +0200 Subject: [PATCH] Final fixes --- .github/workflows/github.yml | 56 ++++++------- frontend/generated/vaadin-featureflags.ts | 6 +- frontend/generated/vaadin.ts | 2 + package-lock.json | 80 +++++++++++-------- package.json | 12 +-- .../application/views/MainLayout.java | 2 +- .../application/views/apps/AppsView.java | 8 ++ .../views/apps/AvailableAppsView.java | 10 ++- webpack.generated.js | 39 ++++++--- 9 files changed, 133 insertions(+), 82 deletions(-) diff --git a/.github/workflows/github.yml b/.github/workflows/github.yml index d03fef2..b2e4069 100644 --- a/.github/workflows/github.yml +++ b/.github/workflows/github.yml @@ -37,34 +37,34 @@ jobs: - name: Package privacydashboard run: mvn clean package -Pproduction -DskipTests -# - name: Coverage Report -# run: mvn jacoco:report -# -# - name: Generate Jacoco Badge -# id: jacoco -# if: ${{ matrix.java-version == '18.0.x' }} -# uses: cicirello/jacoco-badge-generator@v2 -# with: -# jacoco-csv-file: target/site/jacoco/jacoco.csv -# -# - name: Log coverage percentage -# if: ${{ matrix.java-version == '18.0.x' }} -# run: | -# echo "coverage = ${{ steps.jacoco.outputs.coverage }}" -# -# - name: Move the badge to jacoco-aggregate folder -# if: ${{ matrix.java-version == '18.0.x' }} -# run: | -# mv .github/badges/*.svg target/site/jacoco/ -# -# - name: Deploy Jacoco code coverage reports to gh-pages -# uses: JamesIves/github-pages-deploy-action@v4 -# if: ${{ matrix.java-version == '18.0.x' }} -# with: -# clean: true -# folder: target/site/jacoco -# target-folder: reports -# branch: gh-pages + - name: Coverage Report + run: mvn jacoco:report + + - name: Generate Jacoco Badge + id: jacoco + if: ${{ matrix.java-version == '18.0.x' }} + uses: cicirello/jacoco-badge-generator@v2 + with: + jacoco-csv-file: target/site/jacoco/jacoco.csv + + - name: Log coverage percentage + if: ${{ matrix.java-version == '18.0.x' }} + run: | + echo "coverage = ${{ steps.jacoco.outputs.coverage }}" + + - name: Move the badge to jacoco-aggregate folder + if: ${{ matrix.java-version == '18.0.x' }} + run: | + mv .github/badges/*.svg target/site/jacoco/ + + - name: Deploy Jacoco code coverage reports to gh-pages + uses: JamesIves/github-pages-deploy-action@v4 + if: ${{ matrix.java-version == '18.0.x' }} + with: + clean: true + folder: target/site/jacoco + target-folder: reports + branch: gh-pages # Build files necessary for building Docker Images (Dockerfiles and Contexts) build-for-docker: diff --git a/frontend/generated/vaadin-featureflags.ts b/frontend/generated/vaadin-featureflags.ts index d0581a6..0f81f16 100644 --- a/frontend/generated/vaadin-featureflags.ts +++ b/frontend/generated/vaadin-featureflags.ts @@ -3,4 +3,8 @@ window.Vaadin = window.Vaadin || {}; window.Vaadin.featureFlags = window.Vaadin.featureFlags || {}; window.Vaadin.featureFlags.exampleFeatureFlag = false; window.Vaadin.featureFlags.viteForFrontendBuild = false; -window.Vaadin.featureFlags.mapComponent = false; \ No newline at end of file +window.Vaadin.featureFlags.mapComponent = false; +window.Vaadin.featureFlags.spreadsheetComponent = false; +window.Vaadin.featureFlags.hillaPush = false; +window.Vaadin.featureFlags.newLicenseChecker = false; +window.Vaadin.featureFlags.collaborationEngineBackend = false; \ No newline at end of file diff --git a/frontend/generated/vaadin.ts b/frontend/generated/vaadin.ts index 27ba504..f79bf42 100644 --- a/frontend/generated/vaadin.ts +++ b/frontend/generated/vaadin.ts @@ -2,5 +2,7 @@ import './vaadin-featureflags.ts'; import './index'; +import '@vaadin/flow-frontend/vaadin-dev-tools.js'; + import { applyTheme } from './theme'; applyTheme(document); diff --git a/package-lock.json b/package-lock.json index d344c08..74e2f42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -121,12 +121,13 @@ "@vaadin/vaadin-virtual-list": "23.1.0", "@vaadin/vertical-layout": "23.1.0", "@vaadin/virtual-list": "23.1.0", - "construct-style-sheets-polyfill": "3.0.4", + "construct-style-sheets-polyfill": "3.1.0", "date-fns": "2.28.0", "line-awesome": "1.3.0", - "lit": "2.1.4" + "lit": "2.2.3" }, "devDependencies": { + "async": "3.2.2", "chokidar": "^3.5.0", "compression-webpack-plugin": "4.0.1", "css-loader": "5.2.7", @@ -4552,6 +4553,12 @@ "node": ">=0.10.0" } }, + "node_modules/async": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.2.tgz", + "integrity": "sha512-H0E+qZaDEfx/FY4t7iLRv1W2fFI6+pyCeTw1uN20AQPiwqwM6ojPxHxdLv4z8hi2DtnW9BOckSspLucW7pIE5g==", + "dev": true + }, "node_modules/at-least-node": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", @@ -6111,12 +6118,9 @@ "dev": true }, "node_modules/construct-style-sheets-polyfill": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/construct-style-sheets-polyfill/-/construct-style-sheets-polyfill-3.0.4.tgz", - "integrity": "sha512-thhh/YOa3lVpA0dRbl/QVSD9WOdI0LSAQIhxQ6kzTlz/HOrPjUEj5hNM6L4AOCOO/HqvHi5XUvbpVmq3YdbO/w==", - "engines": { - "npm": ">=7" - } + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/construct-style-sheets-polyfill/-/construct-style-sheets-polyfill-3.1.0.tgz", + "integrity": "sha512-HBLKP0chz8BAY6rBdzda11c3wAZeCZ+kIG4weVC2NM3AXzxx09nhe8t0SQNdloAvg5GLuHwq/0SPOOSPvtCcKw==" }, "node_modules/content-disposition": { "version": "0.5.4", @@ -9361,13 +9365,13 @@ "dev": true }, "node_modules/lit": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/lit/-/lit-2.1.4.tgz", - "integrity": "sha512-m1tHAZdXQhiBe0ReAjyVIUeKnHZpBfx+A5R5dkia8dtvIBwOR6KhD+RxaDnCwrEavRqkZAy5ntLv7chiOZCdNg==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/lit/-/lit-2.2.3.tgz", + "integrity": "sha512-5/v+r9dH3Pw/o0rhp/qYk3ERvOUclNF31bWb0FiW6MPgwdQIr+/KCt/p3zcd8aPl8lIGnxdGrVcZA+gWS6oFOQ==", "dependencies": { - "@lit/reactive-element": "^1.1.0", - "lit-element": "^3.1.0", - "lit-html": "^2.1.0" + "@lit/reactive-element": "^1.3.0", + "lit-element": "^3.2.0", + "lit-html": "^2.2.0" } }, "node_modules/lit-css-loader": { @@ -15629,7 +15633,7 @@ "resolved": "https://registry.npmjs.org/@polymer/iron-a11y-keys-behavior/-/iron-a11y-keys-behavior-3.0.1.tgz", "integrity": "sha512-lnrjKq3ysbBPT/74l0Fj0U9H9C35Tpw2C/tpJ8a+5g8Y3YJs1WSZYnEl1yOkw6sEyaxOq/1DkzH0+60gGu5/PQ==", "requires": { - "@polymer/polymer": "3.4.1" + "@polymer/polymer": "^3.0.0" } }, "@polymer/iron-flex-layout": { @@ -15637,7 +15641,7 @@ "resolved": "https://registry.npmjs.org/@polymer/iron-flex-layout/-/iron-flex-layout-3.0.1.tgz", "integrity": "sha512-7gB869czArF+HZcPTVSgvA7tXYFze9EKckvM95NB7SqYF+NnsQyhoXgKnpFwGyo95lUjUW9TFDLUwDXnCYFtkw==", "requires": { - "@polymer/polymer": "3.4.1" + "@polymer/polymer": "^3.0.0" } }, "@polymer/iron-icon": { @@ -16175,7 +16179,7 @@ "@polymer/polymer": "3.4.1", "@vaadin/vaadin-development-mode-detector": "2.0.5", "@vaadin/vaadin-usage-statistics": "2.1.2", - "lit": "2.1.4" + "lit": "2.2.3" } }, "@vaadin/confirm-dialog": { @@ -16339,7 +16343,7 @@ "@open-wc/dedupe-mixin": "^1.3.0", "@polymer/polymer": "3.4.1", "@vaadin/component-base": "23.1.0", - "lit": "2.1.4" + "lit": "2.2.3" } }, "@vaadin/field-highlighter": { @@ -16353,7 +16357,7 @@ "@vaadin/vaadin-material-styles": "23.1.0", "@vaadin/vaadin-overlay": "23.1.0", "@vaadin/vaadin-themable-mixin": "23.1.0", - "lit": "2.1.4" + "lit": "2.2.3" } }, "@vaadin/flow-frontend": { @@ -16429,7 +16433,7 @@ "@vaadin/component-base": "23.1.0", "@vaadin/vaadin-lumo-styles": "23.1.0", "@vaadin/vaadin-themable-mixin": "23.1.0", - "lit": "2.1.4" + "lit": "2.2.3" } }, "@vaadin/icons": { @@ -16498,7 +16502,7 @@ "resolved": "https://registry.npmjs.org/@vaadin/lit-renderer/-/lit-renderer-23.1.0.tgz", "integrity": "sha512-3Ob/T23hAMpWl3EUHwuaK0dFwOkZfyVvgsB4MgoqxRJBnyy9ApZpJFhQuQke41O3rK9ppQKQFMokwm4b3MZ6Hw==", "requires": { - "lit": "2.1.4" + "lit": "2.2.3" } }, "@vaadin/login": { @@ -16583,7 +16587,7 @@ "@vaadin/vaadin-lumo-styles": "23.1.0", "@vaadin/vaadin-material-styles": "23.1.0", "@vaadin/vaadin-themable-mixin": "23.1.0", - "lit": "2.1.4" + "lit": "2.2.3" } }, "@vaadin/number-field": { @@ -16619,7 +16623,7 @@ "requires": { "@polymer/polymer": "3.4.1", "@vaadin/vaadin-themable-mixin": "23.1.0", - "lit": "2.1.4" + "lit": "2.2.3" } }, "@vaadin/progress-bar": { @@ -17167,7 +17171,7 @@ "integrity": "sha512-T+xvFnbhim/L9bP8ugMWqWFlcDeSmxKCVi/19GDCpVk7Li1CxVhBbTB4bU8en4e0jFIyMtsWjosfe/F2yjx3BA==", "requires": { "@open-wc/dedupe-mixin": "^1.3.0", - "lit": "2.1.4" + "lit": "2.2.3" } }, "@vaadin/vaadin-time-picker": { @@ -17640,6 +17644,12 @@ "integrity": "sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw==", "dev": true }, + "async": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.2.tgz", + "integrity": "sha512-H0E+qZaDEfx/FY4t7iLRv1W2fFI6+pyCeTw1uN20AQPiwqwM6ojPxHxdLv4z8hi2DtnW9BOckSspLucW7pIE5g==", + "dev": true + }, "at-least-node": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", @@ -19010,9 +19020,9 @@ "dev": true }, "construct-style-sheets-polyfill": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/construct-style-sheets-polyfill/-/construct-style-sheets-polyfill-3.0.4.tgz", - "integrity": "sha512-thhh/YOa3lVpA0dRbl/QVSD9WOdI0LSAQIhxQ6kzTlz/HOrPjUEj5hNM6L4AOCOO/HqvHi5XUvbpVmq3YdbO/w==" + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/construct-style-sheets-polyfill/-/construct-style-sheets-polyfill-3.1.0.tgz", + "integrity": "sha512-HBLKP0chz8BAY6rBdzda11c3wAZeCZ+kIG4weVC2NM3AXzxx09nhe8t0SQNdloAvg5GLuHwq/0SPOOSPvtCcKw==" }, "content-disposition": { "version": "0.5.4", @@ -21463,13 +21473,13 @@ "dev": true }, "lit": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/lit/-/lit-2.1.4.tgz", - "integrity": "sha512-m1tHAZdXQhiBe0ReAjyVIUeKnHZpBfx+A5R5dkia8dtvIBwOR6KhD+RxaDnCwrEavRqkZAy5ntLv7chiOZCdNg==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/lit/-/lit-2.2.3.tgz", + "integrity": "sha512-5/v+r9dH3Pw/o0rhp/qYk3ERvOUclNF31bWb0FiW6MPgwdQIr+/KCt/p3zcd8aPl8lIGnxdGrVcZA+gWS6oFOQ==", "requires": { - "@lit/reactive-element": "^1.1.0", - "lit-element": "^3.1.0", - "lit-html": "^2.1.0" + "@lit/reactive-element": "^1.3.0", + "lit-element": "^3.2.0", + "lit-html": "^2.2.0" } }, "lit-css-loader": { @@ -24676,7 +24686,7 @@ "integrity": "sha512-9P3MWk6SrKjHsGkLT2KHXdQ/9SNkyoJbabxnKOoJepsvJjJG8uYTR3yTPxPQvNDI3w4Nz1xnE0TLHK4RIVe/MQ==", "dev": true, "requires": { - "chokidar": "^3.5.0", + "chokidar": "^3.4.1", "graceful-fs": "^4.1.2", "neo-async": "^2.5.0", "watchpack-chokidar2": "^2.0.1" @@ -24689,7 +24699,7 @@ "dev": true, "optional": true, "requires": { - "chokidar": "^3.5.0" + "chokidar": "^2.1.8" } }, "wbuf": { diff --git a/package.json b/package.json index 8496202..5defa90 100644 --- a/package.json +++ b/package.json @@ -116,12 +116,13 @@ "@vaadin/vaadin-virtual-list": "23.1.0", "@vaadin/vertical-layout": "23.1.0", "@vaadin/virtual-list": "23.1.0", - "construct-style-sheets-polyfill": "3.0.4", + "construct-style-sheets-polyfill": "3.1.0", "date-fns": "2.28.0", "line-awesome": "1.3.0", - "lit": "2.1.4" + "lit": "2.2.3" }, "devDependencies": { + "async": "3.2.2", "chokidar": "^3.5.0", "compression-webpack-plugin": "4.0.1", "css-loader": "5.2.7", @@ -378,12 +379,13 @@ "@vaadin/vaadin-virtual-list": "23.1.0", "@vaadin/vertical-layout": "23.1.0", "@vaadin/virtual-list": "23.1.0", - "construct-style-sheets-polyfill": "3.0.4", + "construct-style-sheets-polyfill": "3.1.0", "date-fns": "2.28.0", "line-awesome": "1.3.0", - "lit": "2.1.4" + "lit": "2.2.3" }, "devDependencies": { + "async": "3.2.2", "chokidar": "^3.5.0", "compression-webpack-plugin": "4.0.1", "css-loader": "5.2.7", @@ -405,6 +407,6 @@ "workbox-precaching": "6.5.0", "workbox-webpack-plugin": "6.5.0" }, - "hash": "3b16695e3f7bb085e675a9b14b37f92ee4989515e9410b15414cea9d123b8bf4" + "hash": "48c21928de86ae4372de126c2e0cac0c63f0f4b73cb82c1c05e740d20b194724" } } diff --git a/src/main/java/com/privacydashboard/application/views/MainLayout.java b/src/main/java/com/privacydashboard/application/views/MainLayout.java index 674e7a4..fc9aa36 100644 --- a/src/main/java/com/privacydashboard/application/views/MainLayout.java +++ b/src/main/java/com/privacydashboard/application/views/MainLayout.java @@ -153,7 +153,7 @@ private MenuItemInfo[] createMenuItems() { new MenuItemInfo("Rights", "las la-school", ControllerDPORightsView.class), //ONLY FOR CONTROLLERS AND DPOS - new MenuItemInfo("AvailableApps", "la la-list", AvailableAppsView.class), // + new MenuItemInfo("Available Apps", "la la-list", AvailableAppsView.class), // new MenuItemInfo("Apps", "la la-list", AppsView.class), // diff --git a/src/main/java/com/privacydashboard/application/views/apps/AppsView.java b/src/main/java/com/privacydashboard/application/views/apps/AppsView.java index 57d3721..f3d02f4 100644 --- a/src/main/java/com/privacydashboard/application/views/apps/AppsView.java +++ b/src/main/java/com/privacydashboard/application/views/apps/AppsView.java @@ -141,6 +141,11 @@ public void checkServerTrusted(X509Certificate[] certs, String authType) { JsonNode json = new ObjectMapper().readTree(new StringReader(responseString)); json = json.get("value"); int size = json.get("containers").size(); + + if(size == 0){ + throw new NullPointerException("Size was 0"); + } + IoTApp[] appArray = new IoTApp[size]; Iterator iterator = json.get("containers").elements(); @@ -201,6 +206,9 @@ public AppsView(DataBaseService dataBaseService, AuthenticatedUser authenticated } catch(Exception e){ System.out.println("Exception: "+e); + Span exNotice = e.getMessage().equals("Size was 0") ? new Span("You do not have any apps.") : new Span("We could not retrieve your apps."); + exNotice.addClassName("bold"); + appLayout.add(exNotice); } add(summaryEvaluation, searchText, appLayout, grid); diff --git a/src/main/java/com/privacydashboard/application/views/apps/AvailableAppsView.java b/src/main/java/com/privacydashboard/application/views/apps/AvailableAppsView.java index c2356b3..916155b 100644 --- a/src/main/java/com/privacydashboard/application/views/apps/AvailableAppsView.java +++ b/src/main/java/com/privacydashboard/application/views/apps/AvailableAppsView.java @@ -47,7 +47,7 @@ import com.privacydashboard.application.views.usefulComponents.MyDialog; @PageTitle("AvailableApps") -@Route(value = "available_apps-view", layout = MainLayout.class) +@Route(value = "available-apps-view", layout = MainLayout.class) @PermitAll @NpmPackage(value = "line-awesome", version = "1.3.0") public class AvailableAppsView extends Div { @@ -93,6 +93,11 @@ private List getJsonAppsFromUrl() throws NullPointerException { JsonNode json = new ObjectMapper().readTree(new StringReader(responseString)); int size = json.get("packages").size(); + + if(size == 0){ + throw new NullPointerException("Size was 0"); + } + IoTApp[] appArray = new IoTApp[size]; Iterator iterator = json.get("packages").elements(); @@ -364,6 +369,9 @@ public AvailableAppsView(DataBaseService dataBaseService, AuthenticatedUser auth } catch(Exception e){ System.out.println("Exception: "+e); + Span exNotice = e.getMessage().equals("Size was 0") ? new Span("You do not have any apps.") : new Span("We could not retrieve your apps."); + exNotice.addClassName("bold"); + appLayout.add(exNotice); } add(appLayout); diff --git a/webpack.generated.js b/webpack.generated.js index 5d816ea..5df88af 100644 --- a/webpack.generated.js +++ b/webpack.generated.js @@ -29,6 +29,7 @@ const useClientSideIndexFileForBootstrapping = true; const clientSideIndexHTML = './index.html'; const clientSideIndexEntryPoint = path.resolve(__dirname, 'frontend', 'generated/', 'vaadin.ts');; const pwaEnabled = true; +const offlineEnabled = true; const offlinePath = '.'; const clientServiceWorkerEntryPoint = path.resolve(__dirname, 'target/sw'); // public path for resources, must match Flow VAADIN_BUILD @@ -51,12 +52,8 @@ const buildDirectory = path.resolve(__dirname, 'target'); // Flow plugins const BuildStatusPlugin = require(buildDirectory + '/plugins/build-status-plugin'); const ThemeLiveReloadPlugin = require(buildDirectory + '/plugins/theme-live-reload-plugin'); -const { - ApplicationThemePlugin, - processThemeResources, - extractThemeName, - findParentThemes -} = require(buildDirectory + '/plugins/application-theme-plugin'); +const { ApplicationThemePlugin, processThemeResources, extractThemeName, findParentThemes } = require(buildDirectory + + '/plugins/application-theme-plugin'); const themeLoader = buildDirectory + '/plugins/theme-loader'; // Folders in the project which can contain static assets. @@ -167,6 +164,7 @@ const createServiceWorkerPlugin = function () { ], webpackCompilationPlugins: [ new DefinePlugin({ + VITE_ENABLED: 'false', OFFLINE_PATH: JSON.stringify(offlinePath) }) ] @@ -337,13 +335,32 @@ module.exports = { function (compiler) { // V14 bootstrapping needs the bundle names - compiler.hooks.afterEmit.tapAsync("FlowStatsHelper", (compilation, done) => { + compiler.hooks.afterEmit.tapAsync('FlowStatsHelper', (compilation, done) => { + const st = compilation.getStats().toJson(); + const modules = st.modules; + const nodeModulesFolders = modules + .map((module) => module.identifier) + .filter((id) => id.includes('node_modules')); + const npmModules = nodeModulesFolders + .map((id) => id.replace(/.*node_modules./, '')) + .map((id) => { + const parts = id.split('/'); + if (id.startsWith('@')) { + return parts[0] + '/' + parts[1]; + } else { + return parts[0]; + } + }) + .sort() + .filter((value, index, self) => self.indexOf(value) === index); + let miniStats = { - assetsByChunkName: compilation.getStats().toJson().assetsByChunkName + assetsByChunkName: st.assetsByChunkName, + npmModules: npmModules }; + if (!devMode) { - fs.writeFile(statsFile, JSON.stringify(miniStats, null, 1), - () => done()); + fs.writeFile(statsFile, JSON.stringify(miniStats, null, 1), () => done()); } else { stats = miniStats; done(); @@ -362,7 +379,7 @@ module.exports = { }), // Service worker for offline - pwaEnabled && createServiceWorkerPlugin(), + offlineEnabled && createServiceWorkerPlugin(), // Generate compressed bundles when not devMode !devMode && new CompressionPlugin(),