From 93dd389437b0a23d9b43fccf42f7f3444dbdb35c Mon Sep 17 00:00:00 2001 From: Sapoleone <154547272+Sapoleone@users.noreply.github.com> Date: Thu, 25 Sep 2025 00:26:42 +0200 Subject: [PATCH] Add remote access feature and UI improvements - Implement `remoteAccess` functionality in `ApiCLI` for Veyon integration. - Create `selectIP.php` view and associated form for remote access inputs. - Add JSON configuration for lab setups (`labList.json`). - Introduce reusable `home-button` web component. - Update project router and controller to support new `/remoteAccess` and `/conn` routes. - Add custom styles and icons to enhance UI. --- .idea/dictionaries/project.xml | 1 + .idea/icon.svg | 5 + .idea/inspectionProfiles/Project_Default.xml | 4 +- .idea/project16.iml | 1 + .idea/webResources.xml | 14 +++ app/controllers/Controller.php | 10 +- app/models/ApiCLI.php | 29 ++++- app/views/home.php | 54 +++++++++ app/views/selectIP.php | 66 ++++++++++ public/assets/icons/hamburger.svg | 9 ++ public/assets/icons/placeholder.svg | 20 ++++ public/commons/components/button.js | 119 +++++++++++++++++++ public/commons/css/style.css | 42 +++++++ public/commons/php/head.php | 12 ++ public/configs/labList.json | 40 +++++++ public/index.php | 10 +- public/routes.php | 4 +- 17 files changed, 432 insertions(+), 8 deletions(-) create mode 100644 .idea/icon.svg create mode 100644 .idea/webResources.xml create mode 100644 app/views/selectIP.php create mode 100644 public/assets/icons/hamburger.svg create mode 100644 public/assets/icons/placeholder.svg create mode 100644 public/commons/components/button.js create mode 100644 public/commons/css/style.css create mode 100644 public/commons/php/head.php create mode 100644 public/configs/labList.json diff --git a/.idea/dictionaries/project.xml b/.idea/dictionaries/project.xml index 79e95d0..f689139 100644 --- a/.idea/dictionaries/project.xml +++ b/.idea/dictionaries/project.xml @@ -2,6 +2,7 @@ Veyon + veyon \ No newline at end of file diff --git a/.idea/icon.svg b/.idea/icon.svg new file mode 100644 index 0000000..cd93eef --- /dev/null +++ b/.idea/icon.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 0a34b07..c1b4c72 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -5,7 +5,7 @@ diff --git a/.idea/project16.iml b/.idea/project16.iml index c5fb91b..7171c2d 100644 --- a/.idea/project16.iml +++ b/.idea/project16.iml @@ -2,6 +2,7 @@ + diff --git a/.idea/webResources.xml b/.idea/webResources.xml new file mode 100644 index 0000000..3432ba4 --- /dev/null +++ b/.idea/webResources.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/controllers/Controller.php b/app/controllers/Controller.php index bf21286..b770d6b 100644 --- a/app/controllers/Controller.php +++ b/app/controllers/Controller.php @@ -3,7 +3,15 @@ class Controller { public function index(): void { - require_once '../views/home.php'; + require_once BASE_PATH.'/app/views/home.php'; + } + + public function remoteAccess() { + require_once BASE_PATH.'/app/views/selectIP.php'; + } + + public function cli() { + ApiCLI::testConnection(); } } diff --git a/app/models/ApiCLI.php b/app/models/ApiCLI.php index 681e460..8e64b48 100644 --- a/app/models/ApiCLI.php +++ b/app/models/ApiCLI.php @@ -6,5 +6,32 @@ */ class ApiCLI { - + static $SET_WD = "cd 'C:\\Program Files\\Veyon' 2>&1 &&"; + + public static function testConnection() { + $cmd = "curl -I 127.0.0.1 && cd"; + $response = shell_exec($cmd." 2>&1"); + echo "
"; echo $response; echo "
"; + } + // Veyon Modules + // [N] 1. authkeys - Commands for managing authentication keys + // [N] 2. config - Commands for managing the configuration of Veyon + // [?] 3. ldap - Commands for configuring and testing LDAP/AD integration + // [?] 4. networkobjects - Commands for managing the builtin network object directory + // [Y] 5. power - Commands for controlling power status of computers + // [Y] 6. remoteaccess - Remote view or control a computer + // [N] 7. service - Commands for configuring and controlling Veyon Service + // [N] 8. shell - Commands for shell functionalities + // [Y] 9. functions - Commands for managing functions + public static function remoteAccess($ip, $connectionType='view') { + global $SET_WD; + + echo "Executing: ".EXE_NAME." remoteaccess ".$connectionType." ".$ip; + echo "
"; + + $response = shell_exec($SET_WD . " ". EXE_NAME ." remoteaccess ".$connectionType." ".$ip." 2>&1"); + if ($response != "[OK]") { + echo "
"; echo $response; echo "
"; + } + } } \ No newline at end of file diff --git a/app/views/home.php b/app/views/home.php index e69de29..b78ec38 100644 --- a/app/views/home.php +++ b/app/views/home.php @@ -0,0 +1,54 @@ + + + + + + + Project 16 - Dashboard + + + + + +
+
+
+ + + +
+
+
+ + + +
+ + \ No newline at end of file diff --git a/app/views/selectIP.php b/app/views/selectIP.php new file mode 100644 index 0000000..dcee039 --- /dev/null +++ b/app/views/selectIP.php @@ -0,0 +1,66 @@ + + + + + + Project 16 + + + +
+ + + +
+ name?> +
+ + + + + + +
+
+ +
+

Inserisci le informazioni per la connessione

+
+ + +
+
+ + +
+
+ + +
+ + +
+ +
+
+
+ + diff --git a/public/assets/icons/hamburger.svg b/public/assets/icons/hamburger.svg new file mode 100644 index 0000000..80aeaf0 --- /dev/null +++ b/public/assets/icons/hamburger.svg @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/public/assets/icons/placeholder.svg b/public/assets/icons/placeholder.svg new file mode 100644 index 0000000..15da889 --- /dev/null +++ b/public/assets/icons/placeholder.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/commons/components/button.js b/public/commons/components/button.js new file mode 100644 index 0000000..55fe99b --- /dev/null +++ b/public/commons/components/button.js @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2025. Brusegan Samuele, Davanzo Andrea + * Questo file fa parte di VeyonCtrl ed è rilasciato + * sotto la licenza MIT. Vedere il file LICENSE per i dettagli. + */ + +class HomeButton extends HTMLElement { + + static watchedList = [ + { + attribute: "icon-src", + htmlElement: "img", + tagName: "src", + }, + { + attribute: "text", + htmlElement: "span", + tagName: "", + }, + { + attribute: "main-href", + htmlElement: "div", + tagName: "data-href", + } + ]; + + constructor() { + super(); + + /* + // 0. Richiedo le variabili globali da sessionStorage + let URL_PATH = sessionStorage.getItem("url"); + let THEME = sessionStorage.getItem("theme"); + */ + + // 1. Crea lo Shadow DOM + const shadow = this.attachShadow({mode: 'open'}); + + // 2. Definisci la struttura interna (HTML) e lo stile (CSS) + const template = document.createElement('template'); + template.innerHTML = ` + + +
+ + +

+
+ `; + + // 3. Clona il contenuto del template e aggiungilo allo Shadow DOM + shadow.appendChild(template.content.cloneNode(true)); + } + + // Passaggio 2: Gestisci gli attributi e i callback + static get observedAttributes() { + let array = []; + + HomeButton.watchedList.forEach(element => { + array.push(element.attribute); + }) + + return array; + } + + attributeChangedCallback(name, oldValue, newValue) { + + HomeButton.watchedList.forEach(element => { + if (element.attribute === name) { + let domElement = this.shadowRoot.querySelector(element.htmlElement); + /*console.log(name, element, oldValue, newValue) + console.log()*/ + if (domElement) { + if (element.tagName !== "") { + // console.log(domElement) + domElement[element.tagName] = newValue; + // console.log(domElement) + // console.log("------------") + } else { + domElement.textContent = newValue; + } + } + } + }) + } + + connectedCallback() { + let btn = this.shadowRoot.querySelector(".btn-home"); + // console.log(btn) + if (btn) { + btn.addEventListener("click", () => { + console.log(btn[ "data-href"]) + window.location.href = btn.dataset.href; + }) + } + } +} + +// Passaggio 3: Registra il tuo elemento personalizzato +customElements.define('home-button', HomeButton); \ No newline at end of file diff --git a/public/commons/css/style.css b/public/commons/css/style.css new file mode 100644 index 0000000..5da2c0e --- /dev/null +++ b/public/commons/css/style.css @@ -0,0 +1,42 @@ +:root { + /* STD */ + + /* Palette */ + --error: #E12D39; + --accent: #FF5252; + --bg: #F0ECD4; + --divider: #BDBDBD; + + --primary: #FFE3BD; + --primary-light: #F1DC7E; + --primary-dark: #00796B; + + --secondary-light: #00967D; + --secondary: #006E59; + --secondary-dark: #004D3E; + + --teal-blue: #16425B; + --kashmir: #2F6690; + --allports: #3A7CA5; + + --text-primary: #000000; + --text-secondary: #757575; + --text-tertiary: #BDBDBD; + + + --background: #FFFFFF; + --gray: #F7F7F7; + --quill: #D9DCD6; + --disabled: #D0D0D0; + --default: #BDBDBD; + --hover: #999999; + --storm-dust: #656565; + --focus: #000000; +} + +body { + /*background-color: var(--bg);*/ + /*color: var(--text-primary);*/ + background: #111; + color: #fff; +} diff --git a/public/commons/php/head.php b/public/commons/php/head.php new file mode 100644 index 0000000..ba7ab5c --- /dev/null +++ b/public/commons/php/head.php @@ -0,0 +1,12 @@ + + + + + + diff --git a/public/configs/labList.json b/public/configs/labList.json new file mode 100644 index 0000000..3f557bc --- /dev/null +++ b/public/configs/labList.json @@ -0,0 +1,40 @@ +[ + { + "name": "LASA", + "netIP": "192.168.2.0", + "subnetMask": 24 + }, + { + "name": "LMM", + "netIP": "192.168.9.0", + "subnetMask": 24 + }, + { + "name": "LAM", + "netIP": "192.168.10.0", + "subnetMask": 24 + }, + { + "name": "LAPs", + "netIP": "192.168.4.0", + "subnetMask": 24 + }, + { + "name": "Classi", + "netIP": "192.168.12.0", + "subnetMask": 24 + } +] + + + + + + + + + + + + + diff --git a/public/index.php b/public/index.php index 312b70e..3c0c485 100644 --- a/public/index.php +++ b/public/index.php @@ -9,9 +9,12 @@ define( 'BASE_PATH', dirname( __DIR__ ) ); session_start(); -const URL_PATH = "https://project16.test"; -const COMMON_HTML_HEAD = BASE_PATH . '/public/commons/head.php'; -const COMMON_HTML_FOOT = BASE_PATH . '/public/commons/bottom_navigation.php'; +const URL_PATH = "http://project16.test"; +const COMMON_HTML_HEAD = BASE_PATH . '/public/commons/php/head.php'; +const COMMON_HTML_FOOT = BASE_PATH . '/public/commons/php/bottom_navigation.php'; +const PROJECT_NAME = "Project 16"; + +const EXE_NAME = "veyon-cli"; const THEME = ( 0 ) ? 'light' : 'dark'; @@ -20,6 +23,7 @@ require_once BASE_PATH . '/Router.php'; require_once BASE_PATH . '/public/functions.php'; // require_once BASE_PATH . '/public/commons/php/session_wall.php'; require_once BASE_PATH . '/app/controllers/Controller.php'; +require_once BASE_PATH . '/app/models/ApiCLI.php'; // checkSessionExpiration(); diff --git a/public/routes.php b/public/routes.php index 58f4504..e764fd6 100644 --- a/public/routes.php +++ b/public/routes.php @@ -12,8 +12,8 @@ $router->add('/login' , 'ApiController', 'login'); // === Pagine === $router->add('/' , 'Controller', 'index'); -$router->add('/grades' , 'Controller', 'grades'); -$router->add('/settings' , 'Controller', 'settings'); +$router->add('/remoteAccess', 'Controller', 'remoteAccess'); +$router->add('/conn' , 'Controller', 'cli'); $router->add('/account' , 'Controller', 'account'); $router->add('/subjects' , 'Controller', 'subjects'); $router->add('/agenda' , 'Controller', 'agenda'); \ No newline at end of file