From 0e14c3594137e2e24be9d5786a20ab40fa1de755 Mon Sep 17 00:00:00 2001 From: Alessio Biancalana Date: Tue, 12 Apr 2022 18:01:32 +0200 Subject: [PATCH 1/2] Expose EULA data through the API --- .../controllers/settings_controller.ex | 19 +++++++++++++++++++ lib/trento_web/router.ex | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 lib/trento_web/controllers/settings_controller.ex diff --git a/lib/trento_web/controllers/settings_controller.ex b/lib/trento_web/controllers/settings_controller.ex new file mode 100644 index 0000000000..0834b5f55d --- /dev/null +++ b/lib/trento_web/controllers/settings_controller.ex @@ -0,0 +1,19 @@ +defmodule TrentoWeb.SettingsController do + use TrentoWeb, :controller + + alias Trento.Installation + + def settings(conn, _) do + conn + |> json(%{ + eula_accepted: Installation.eula_accepted?(), + premium_subscription: Installation.premium_active?() + }) + end + + def accept_eula(conn, _) do + :ok = Installation.accept_eula() + + conn |> json(%{}) + end +end diff --git a/lib/trento_web/router.ex b/lib/trento_web/router.ex index 9319484f49..b1f23efd77 100644 --- a/lib/trento_web/router.ex +++ b/lib/trento_web/router.ex @@ -100,6 +100,9 @@ defmodule TrentoWeb.Router do post "/runner/callback", ClusterController, :runner_callback get "/prometheus/targets", PrometheusController, :targets + + get "/settings", SettingsController, :settings + post "/accept_eula", SettingsController, :accept_eula end # Other scopes may use custom stacks. From c650b272e22b95437dc65c59ad772286edcfd10c Mon Sep 17 00:00:00 2001 From: Alessio Biancalana Date: Tue, 12 Apr 2022 18:01:54 +0200 Subject: [PATCH 2/2] Add EULA to the webapp --- assets/js/components/Eula/Eula.jsx | 92 ++++++++++++++++++++++++++++ assets/js/components/Eula/index.js | 3 + assets/js/components/Modal/Modal.jsx | 2 +- assets/js/state/index.js | 2 + assets/js/state/sagas/eula.js | 18 ++++++ assets/js/state/sagas/index.js | 13 ++++ assets/js/state/settings.js | 22 +++++++ assets/js/trento.jsx | 2 + 8 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 assets/js/components/Eula/Eula.jsx create mode 100644 assets/js/components/Eula/index.js create mode 100644 assets/js/state/sagas/eula.js create mode 100644 assets/js/state/settings.js diff --git a/assets/js/components/Eula/Eula.jsx b/assets/js/components/Eula/Eula.jsx new file mode 100644 index 0000000000..1996601e9f --- /dev/null +++ b/assets/js/components/Eula/Eula.jsx @@ -0,0 +1,92 @@ +import React, { Fragment } from 'react'; +import { useSelector, useDispatch } from 'react-redux'; + +import Button from '@components/Button'; +import Modal from '@components/Modal'; + +const Eula = () => { + const eulaVisible = useSelector((state) => state.settings.eulaVisible); + const dispatch = useDispatch(); + + return ( + + {}}> +
+
+
+

+ Trento, an open cloud-native web console improving the life of + SAP Applications administrators +

+
+

+ Trento is an open source (Apache License 2.0) component that is + supported as part of SUSE Linux Enterprise Server for SAP + applications and therefore falls under the standard SUSE Terms + and Conditions that can be reviewed at{' '} + + https://www.suse.com/products/terms_and_conditions.pdf + + , SUSE EULA is available at{' '} + + https://www.suse.com/licensing/eula/#server + + . +

+ +

+ By using Trento via a registered SUSE Linux Enterprise Server + for SAP you agree to the Terms and Conditions also for Trento. +

+ +

+ Trento collects the following KPIs on your environment and + transmits it to SUSE: +

+
    +
  • SUSE Customer Center ID
  • +
  • Number of registered hosts in Trento
  • +
  • + For each of those hosts: +
      +
    • SLES version
    • +
    • Number of sockets and total count of cores per host
    • +
    • Available memory per host
    • +
    • + Hosting platform (Cloud service provider, Hypervisor or + bare metal) +
    • +
    • List of running SAP instances
    • +
    • Statistics about Trento checks configuration
    • +
    +
  • +
+ +

+ Trento neither collects, processes or sends any personal data to + SUSE. +

+ +

+ By using Trento Premium and its updates available through SUSE + channels you agree to these terms. In case you disagree, please + switch to the Community version of Trento. +

+
+ +
+
+
+
+
+
+ ); +}; + +export default Eula; diff --git a/assets/js/components/Eula/index.js b/assets/js/components/Eula/index.js new file mode 100644 index 0000000000..0634c5b442 --- /dev/null +++ b/assets/js/components/Eula/index.js @@ -0,0 +1,3 @@ +import Eula from './Eula'; + +export default Eula; diff --git a/assets/js/components/Modal/Modal.jsx b/assets/js/components/Modal/Modal.jsx index a26bdea995..4d8cb7f927 100644 --- a/assets/js/components/Modal/Modal.jsx +++ b/assets/js/components/Modal/Modal.jsx @@ -41,7 +41,7 @@ const Modal = ({ children, open, onClose, title }) => {
{title} diff --git a/assets/js/state/index.js b/assets/js/state/index.js index 9942146e06..cf17c214c8 100644 --- a/assets/js/state/index.js +++ b/assets/js/state/index.js @@ -11,6 +11,7 @@ import sapSystemListReducer from './sapSystems'; import databasesListReducer from './databases'; import catalogReducer from './catalog'; import liveFeedReducer from './liveFeed'; +import settingsReducer from './settings'; import rootSaga from './sagas'; @@ -25,6 +26,7 @@ export const store = configureStore({ databasesList: databasesListReducer, catalog: catalogReducer, liveFeed: liveFeedReducer, + settings: settingsReducer, }, middleware: [sagaMiddleware], }); diff --git a/assets/js/state/sagas/eula.js b/assets/js/state/sagas/eula.js new file mode 100644 index 0000000000..509a9d2a34 --- /dev/null +++ b/assets/js/state/sagas/eula.js @@ -0,0 +1,18 @@ +import { put, call, takeEvery } from 'redux-saga/effects'; +import { post } from 'axios'; + +import { acceptEula } from '@state/settings'; +import { logError } from '@lib/log'; + +export function* acceptEulaSaga() { + try { + yield call(post, '/api/accept_eula'); + yield put(acceptEula()); + } catch (error) { + logError(error); + } +} + +export function* watchAcceptEula() { + yield takeEvery('ACCEPT_EULA', acceptEulaSaga); +} diff --git a/assets/js/state/sagas/index.js b/assets/js/state/sagas/index.js index a4d9b58af0..9047606d54 100644 --- a/assets/js/state/sagas/index.js +++ b/assets/js/state/sagas/index.js @@ -55,7 +55,11 @@ import { import { setCatalog } from '@state/catalog'; import { appendEntryToLiveFeed } from '@state/liveFeed'; +import { setEulaVisible } from '@state/settings'; + import { watchNotifications } from '@state/sagas/notifications'; +import { watchAcceptEula } from '@state/sagas/eula'; + import { getDatabase, getSapSystem } from '@state/selectors'; const notify = ({ text, icon }) => ({ @@ -83,6 +87,14 @@ function* loadSapSystemsHealthSummary() { function* initialDataFetch() { yield loadSapSystemsHealthSummary(); + const { + data: { eula_accepted, premium_subscription }, + } = yield call(get, '/api/settings'); + + if (!eula_accepted && premium_subscription) { + yield put(setEulaVisible()); + } + yield put(startHostsLoading()); const { data: hosts } = yield call(get, '/api/hosts'); yield put(setHosts(hosts)); @@ -496,6 +508,7 @@ export default function* rootSaga() { watchSapSystem(), watchDatabase(), watchCatalogUpdate(), + watchAcceptEula(), refreshHealthSummaryOnComnponentsHealthChange(), ]); } diff --git a/assets/js/state/settings.js b/assets/js/state/settings.js new file mode 100644 index 0000000000..b457966521 --- /dev/null +++ b/assets/js/state/settings.js @@ -0,0 +1,22 @@ +import { createSlice } from '@reduxjs/toolkit'; + +const initialState = { + eulaVisible: false, +}; + +export const settingsSlice = createSlice({ + name: 'settings', + initialState, + reducers: { + setEulaVisible: (state) => { + state.eulaVisible = true; + }, + acceptEula: (state) => { + state.eulaVisible = false; + }, + }, +}); + +export const { setEulaVisible, acceptEula } = settingsSlice.actions; + +export default settingsSlice.reducer; diff --git a/assets/js/trento.jsx b/assets/js/trento.jsx index 1aa5033683..5c7923b4a0 100644 --- a/assets/js/trento.jsx +++ b/assets/js/trento.jsx @@ -27,11 +27,13 @@ import ChecksCatalog from '@components/ChecksCatalog'; import NotFound from '@components/NotFound'; import SomethingWentWrong from '@components/SomethingWentWrong'; import Settings from '@components/Settings'; +import Eula from '@components/Eula'; const App = () => { return ( +