Browse Source

UPD: small changes to admin manage interface

Giancarlo Voci 7 years ago
parent
commit
0041cf6684

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
 	"name": "omlink",
 	"name": "omlink",
-	"version": "1.9.32",
+	"version": "1.9.33",
 	"codename": "Barricade",
 	"codename": "Barricade",
 	"private": true,
 	"private": true,
 	"description": "OM-Link Engine",
 	"description": "OM-Link Engine",

+ 15 - 8
src/OpenMind/Admin/Pages.php

@@ -7,6 +7,7 @@
 
 
 namespace OpenMind\Admin;
 namespace OpenMind\Admin;
 
 
+use Base;
 use Exception;
 use Exception;
 use OpenMind\FindBox\FindBoxCoreSystem;
 use OpenMind\FindBox\FindBoxCoreSystem;
 use OpenMind\FindBox\SmartESL;
 use OpenMind\FindBox\SmartESL;
@@ -20,7 +21,7 @@ class Pages extends Controller
 
 
 	/**
 	/**
 	 * Pages constructor.
 	 * Pages constructor.
-	 * @param \Base $f3
+	 * @param Base $f3
 	 */
 	 */
 	public function __construct($f3)
 	public function __construct($f3)
 	{
 	{
@@ -28,7 +29,7 @@ class Pages extends Controller
 
 
 		try {
 		try {
 			$this->findBoxCore = new FindBoxCoreSystem(...array_values($f3->get('CORE.fb')));
 			$this->findBoxCore = new FindBoxCoreSystem(...array_values($f3->get('CORE.fb')));
-		} catch (\Exception $e) {
+		} catch (Exception $e) {
 			$ns = new Notifications();
 			$ns = new Notifications();
 			$ns->notify(Notifications::FB_ADMIN, $f3->clean($e->getMessage()));
 			$ns->notify(Notifications::FB_ADMIN, $f3->clean($e->getMessage()));
 			// IF can't connect to FINDBOX, reroute to OMLINK Page Settings to fast change settings
 			// IF can't connect to FINDBOX, reroute to OMLINK Page Settings to fast change settings
@@ -45,7 +46,7 @@ class Pages extends Controller
 		echo Template::instance()->render('masterpage.tpl');
 		echo Template::instance()->render('masterpage.tpl');
 	}
 	}
 
 
-	public function ESLStatus($f3)
+	public function ESLStatus(Base $f3)
 	{
 	{
 		$eslStatus = $this->findBoxCore->GetAllESLStatus();
 		$eslStatus = $this->findBoxCore->GetAllESLStatus();
 
 
@@ -68,7 +69,7 @@ class Pages extends Controller
 		echo Template::instance()->render('masterpage.tpl');
 		echo Template::instance()->render('masterpage.tpl');
 	}
 	}
 
 
-	public function OML_Settings($f3)
+	public function OML_Settings(Base $f3)
 	{
 	{
 		global $frameworkUtils;
 		global $frameworkUtils;
 
 
@@ -85,7 +86,7 @@ class Pages extends Controller
 		echo Template::instance()->render('masterpage.tpl');
 		echo Template::instance()->render('masterpage.tpl');
 	}
 	}
 
 
-	public function Config($f3)
+	public function Config(Base $f3)
 	{
 	{
 		global $frameworkUtils;
 		global $frameworkUtils;
 		$config = $f3->get('BODY');
 		$config = $f3->get('BODY');
@@ -192,9 +193,9 @@ class Pages extends Controller
 		return;
 		return;
 	}
 	}
 
 
-	private function TemplateSelector($f3, $Command)
+	private function TemplateSelector(Base $f3, $Command)
 	{
 	{
-		global $f3, $frameworkUtils;
+		global $frameworkUtils;
 
 
 		$fb_template = $this->findBoxCore->CallAPI('/1.0.0/index.php/smartesl.gettemplates/1.0.0/', '[]');
 		$fb_template = $this->findBoxCore->CallAPI('/1.0.0/index.php/smartesl.gettemplates/1.0.0/', '[]');
 		$templates = $this->findBoxCore->getLabelsFromResponse($fb_template);
 		$templates = $this->findBoxCore->getLabelsFromResponse($fb_template);
@@ -232,8 +233,14 @@ class Pages extends Controller
 
 
 	}
 	}
 
 
-	public function Users($f3)
+	public function Users(Base $f3)
 	{
 	{
+		$f3->set('USERLIST',
+			[
+				['username' => 'giancarlo'],
+				['username' => 'luigi']
+			]
+		);
 		$f3->set('PAGENAME', 'User Management');
 		$f3->set('PAGENAME', 'User Management');
 		$f3->set('CONTENT', 'users.tpl');
 		$f3->set('CONTENT', 'users.tpl');
 		echo Template::instance()->render('masterpage.tpl');
 		echo Template::instance()->render('masterpage.tpl');

+ 1 - 0
src/OpenMind/FindBox/FindBoxCoreSystem.php

@@ -393,6 +393,7 @@ class FindBoxCoreSystem
 
 
 		$svgNode = $svgTemplate->getElementsByTagName('svg');
 		$svgNode = $svgTemplate->getElementsByTagName('svg');
 		if ($svgNode->length > 0) {
 		if ($svgNode->length > 0) {
+			$svgNode[0]->setAttribute('class', 'w-100'); // Just fit everywhere
 			$svgNode[0]->removeAttribute('transform');
 			$svgNode[0]->removeAttribute('transform');
 		}
 		}
 
 

+ 2 - 1
src/OpenMind/System/QueueSystem.php

@@ -44,7 +44,6 @@ class QueueSystem
 		if ($connectOK = @socket_connect($socket, 'localhost', $this->serverPort))
 		if ($connectOK = @socket_connect($socket, 'localhost', $this->serverPort))
 			socket_write($socket, $command, strlen($command));
 			socket_write($socket, $command, strlen($command));
 
 
-		// TODO da testare
 		if ($waitResponse) {
 		if ($waitResponse) {
 			$cmdResponse = "";
 			$cmdResponse = "";
 			while ($resp = @socket_read($socket, 60 * 1024, PHP_BINARY_READ)) {
 			while ($resp = @socket_read($socket, 60 * 1024, PHP_BINARY_READ)) {
@@ -56,6 +55,7 @@ class QueueSystem
 
 
 		socket_close($socket);
 		socket_close($socket);
 
 
+		/** @noinspection PhpUndefinedVariableInspection */
 		return ($waitResponse ? $cmdResponse : $connectOK);
 		return ($waitResponse ? $cmdResponse : $connectOK);
 	}
 	}
 
 
@@ -107,6 +107,7 @@ class QueueSystem
 	/**
 	/**
 	 * Retrieve and unserialize current object
 	 * Retrieve and unserialize current object
 	 *
 	 *
+	 * @param $clientData
 	 * @return mixed
 	 * @return mixed
 	 */
 	 */
 	private function decodeClientData($clientData)
 	private function decodeClientData($clientData)

+ 0 - 49
src/OpenMind/System/Soap.php

@@ -1,49 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: Giancarlo
- * Date: 23/07/2018
- * Time: 12:53
- */
-
-namespace OpenMind\System;
-
-use SoapClient;
-use SoapFault;
-
-class Soap extends SoapClient
-{
-	private $ws_url;
-
-	/**
-	 * Soap easy constructor.
-	 * @param mixed $wsdl Ex.: http://<ip_or_hostname_server>/<service_name>.asmx
-	 */
-	public function __construct(string $ws_url)
-	{
-		$this->ws_url = $ws_url;
-		$options = array(
-			'trace' => true,
-			'exceptions' => true,
-			'cache_wsdl' => false,
-		);
-		parent::__construct("{$ws_url}?wsdl", $options);
-	}
-
-	/**
-	 * Send list to Soap Service
-	 *
-	 * @param string $xml The xml in string format
-	 * @param string $soapaction the SOAPACTION: "http://servizi_xchange.org/ImportLists"
-	 * @return string The XML SOAP response or exception error
-	 */
-	public function ImportLists(string $xml, string $soapaction): ?string
-	{
-		try {
-			$ret = $this->__doRequest($xml, $this->ws_url, $soapaction, SOAP_1_1);
-		} catch (SoapFault $e) {
-			return $e->getMessage();
-		}
-		return $ret;
-	}
-}

+ 6 - 7
src/OpenMind/System/System.php

@@ -13,6 +13,7 @@ use DB\SQL;
 use PDO;
 use PDO;
 use PDOException;
 use PDOException;
 use ReflectionClass;
 use ReflectionClass;
+use ReflectionException;
 
 
 /**
 /**
  * Class Enum
  * Class Enum
@@ -51,18 +52,16 @@ abstract class Enum
 	 *
 	 *
 	 * @param $value
 	 * @param $value
 	 * @return string|null the variable name
 	 * @return string|null the variable name
+	 * @throws ReflectionException
 	 */
 	 */
 	public function getNameByValue($value): ?string
 	public function getNameByValue($value): ?string
 	{
 	{
-		try {
-			foreach((new ReflectionClass($this))->getProperties() as $property) {
-				if ($property->getValue($this) === $value) {
-					return $property->name;
-				}
+		foreach((new ReflectionClass($this))->getProperties() as $property) {
+			if ($property->getValue($this) === $value) {
+				return $property->name;
 			}
 			}
-		} catch (\ReflectionException $e) {
-			return $e->getMessage();
 		}
 		}
+
 		return null;
 		return null;
 	}
 	}
 }
 }

+ 2 - 2
src/OpenMind/System/User.php

@@ -99,13 +99,13 @@ class User extends Mapper
 	public function save()
 	public function save()
 	{
 	{
 		$this->roles = serialize($this->userRoles);
 		$this->roles = serialize($this->userRoles);
-		return parent::save(); // TODO: Change the autogenerated stub
+		return parent::save();
 	}
 	}
 
 
 	public function reset()
 	public function reset()
 	{
 	{
 		$this->userRoles = [];
 		$this->userRoles = [];
-		parent::reset(); // TODO: Change the autogenerated stub
+		parent::reset();
 	}
 	}
 
 
 	/**
 	/**

+ 2 - 2
ui/admin/assets/css/bootstrap-tagsinput.css

@@ -4,8 +4,8 @@
  */
  */
 
 
 .bootstrap-tagsinput {
 .bootstrap-tagsinput {
-  background-color: #fff;
-  border: 1px solid #ccc;
+  background-color: #354650;
+  border: 1px solid #49616f;
   box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
   box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
   display: inline-block;
   display: inline-block;
   padding: 4px 6px;
   padding: 4px 6px;

+ 1 - 1
ui/admin/package.json

@@ -1,7 +1,7 @@
 {
 {
 	"name": "admin",
 	"name": "admin",
 	"projectname": "omlink",
 	"projectname": "omlink",
-	"version": "1.3.5",
+	"version": "1.3.7",
 	"private": true,
 	"private": true,
 	"description": "OM-Link Admin Module",
 	"description": "OM-Link Admin Module",
 	"author": "Open Mind",
 	"author": "Open Mind",

+ 33 - 18
ui/admin/users.tpl

@@ -1,23 +1,38 @@
 <div class="accordion" id="userlist">
 <div class="accordion" id="userlist">
-	<div class="card">
-		<div class="card-header">
-			<h5 class="m-0">
-				<a class="text-dark" data-toggle="collapse" data-target="#user1" aria-controls="collapseOne">
-					Utente 1
-				</a>
-			</h5>
-		</div>
+	<repeat group="{{@USERLIST}}" value="{{@USER}}">
+		<div class="card">
+			<div class="card-header">
+				<h5 class="m-0">
+					<a class="text-dark" data-toggle="collapse" data-target="#{{@USER.username}}" aria-controls="collapseOne">
+						{{@USER.username}}
+					</a>
+				</h5>
+			</div>
+
+			<div id="{{@USER.username}}" class="collapse" data-target="#userlist">
+				<div class="card-body">
+					<form class="form">
+						<div class="form-group">
+							<input type="text" class="mb-1 form-control" placeholder="username"/>
+
+							<div class="input-group mb-1">
+								<input type="text" class="form-control" placeholder="password" aria-label="password">
+								<div class="input-group-append">
+									<button class="btn btn-primary" type="button"><i class="fa fa-eye"></i></button>
+								</div>
+							</div>
+
+
+							<input type="text" class="form-control" placeholder="roles" data-role="tagsinput"/>
+						</div>
 
 
-		<div id="user1" class="collapse" data-target="#userlist">
-			<div class="card-body">
-				<form class="form">
-					<div class="form-group">
-						<input type="text" class="form-control" placeholder="username"/>
-						<input type="text" class="form-control" placeholder="password"/>
-						<input type="text" class="form-control" placeholder="roles"/>
-					</div>
-				</form>
+						<div class="form-group">
+							<button class="btn btn-primary" type="button">Save</button>
+							<button class="btn btn-primary" type="reset">Reset</button>
+						</div>
+					</form>
+				</div>
 			</div>
 			</div>
 		</div>
 		</div>
-	</div>
+	</repeat>
 </div>
 </div>