* avatar overrides added
* cli commands framework added * labinfo service for lab temp monitoring * kanban entry label support
This commit is contained in:
@@ -12,7 +12,7 @@ use Zend\Http\Client;
|
||||
use Zend\Json\Decoder;
|
||||
use Zend\Json\Json;
|
||||
|
||||
class DataCollectorService
|
||||
class JiraCollectorService
|
||||
{
|
||||
/**
|
||||
* @var Config
|
||||
@@ -89,6 +89,7 @@ class DataCollectorService
|
||||
->setAnswerCode($jsonIssue['fields']['customfield_11692'])
|
||||
->setIssuePriority($jsonIssue['fields']['priority']['name'])
|
||||
->setIssuePriorityIcon($jsonIssue['fields']['priority']['iconUrl'])
|
||||
->setLabels($jsonIssue['fields']['labels'])
|
||||
;
|
||||
|
||||
// externalId : customfield_10010
|
||||
@@ -6,7 +6,7 @@ use Interop\Container\ContainerInterface;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Http\Client;
|
||||
|
||||
class DataCollectorServiceFactory
|
||||
class JiraCollectorServiceFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
@@ -14,6 +14,6 @@ class DataCollectorServiceFactory
|
||||
$httpClient = $container->get(Client::class);
|
||||
$config = new Config($configArray['app.config']);
|
||||
$avatarService = $container->get(AvatarService::class);
|
||||
return new DataCollectorService($httpClient, $config, $avatarService);
|
||||
return new JiraCollectorService($httpClient, $config, $avatarService);
|
||||
}
|
||||
}
|
||||
86
src/App/Service/LabInfoCollectorService.php
Normal file
86
src/App/Service/LabInfoCollectorService.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Symfony\Component\CssSelector\CssSelectorConverter;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Http\Client;
|
||||
|
||||
class LabInfoCollectorService
|
||||
{
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
private $httpClient;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $tempSensors = [
|
||||
'Temp 5' => 'back_left',
|
||||
'Temp 4' => 'back_middle',
|
||||
'Temp 3' => 'back_right',
|
||||
];
|
||||
|
||||
/**
|
||||
* JiraClientService constructor.
|
||||
* @param Client $client
|
||||
* @param Config $config
|
||||
*/
|
||||
public function __construct(Client $client, Config $config)
|
||||
{
|
||||
$this->httpClient = $client;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function getLabTemperatureData()
|
||||
{
|
||||
/** @var Config $labTemperatureUrl */
|
||||
$labTemperatureUrl = $this->config->get('url.labTemperatureUrl');
|
||||
|
||||
$response = $this->httpClient
|
||||
->setUri($labTemperatureUrl)
|
||||
->send();
|
||||
|
||||
if(!$response->isSuccess()) {
|
||||
throw new \UnexpectedValueException("Bad LAB result", $response->getStatusCode());
|
||||
}
|
||||
|
||||
return $this->parseHtml($response->getBody());
|
||||
}
|
||||
|
||||
private function parseHtml($html): array
|
||||
{
|
||||
$cssToXpathConverter = new CssSelectorConverter();
|
||||
$xpathLabelQuery = $cssToXpathConverter->toXPath('a.sensormenu.isnotpaused');
|
||||
$xpathValueQuery = $cssToXpathConverter->toXPath('div.graphlabel2');
|
||||
|
||||
$xmlErrorHandling = libxml_use_internal_errors(TRUE);
|
||||
$domDocument = new \DOMDocument();
|
||||
$domDocument->loadHTML($html);
|
||||
libxml_clear_errors();
|
||||
libxml_use_internal_errors($xmlErrorHandling);
|
||||
|
||||
$documentXpath = new \DOMXPath($domDocument);
|
||||
/** @var \DOMNodeList $element */
|
||||
$element = $documentXpath->query($xpathLabelQuery);
|
||||
|
||||
$thing = [];
|
||||
/** @var \DOMElement $item */
|
||||
foreach($element as $item) {
|
||||
$sensorName = trim($item->nodeValue);
|
||||
if( in_array($sensorName, array_keys($this->tempSensors)) ){
|
||||
/** @var \DOMNodeList $element */
|
||||
$valueElement = $documentXpath->query($xpathValueQuery, $item->parentNode->parentNode);
|
||||
$thing[$this->tempSensors[$sensorName]] = $valueElement->item(0)->nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
return $thing;
|
||||
}
|
||||
}
|
||||
18
src/App/Service/LabInfoCollectorServiceFactory.php
Normal file
18
src/App/Service/LabInfoCollectorServiceFactory.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Http\Client;
|
||||
|
||||
class LabInfoCollectorServiceFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
$configArray = $container->get('config');
|
||||
$httpClient = $container->get(Client::class);
|
||||
$config = new Config($configArray['app.config']);
|
||||
return new LabInfoCollectorService($httpClient, $config);
|
||||
}
|
||||
}
|
||||
86
src/App/Service/TrInfoCollectorService.php
Normal file
86
src/App/Service/TrInfoCollectorService.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Symfony\Component\CssSelector\CssSelectorConverter;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Http\Client;
|
||||
|
||||
class TrInfoCollectorService
|
||||
{
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
private $httpClient;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $tempSensors = [
|
||||
'Temp 5' => 'back_left',
|
||||
'Temp 4' => 'back_middle',
|
||||
'Temp 3' => 'back_right',
|
||||
];
|
||||
|
||||
/**
|
||||
* JiraClientService constructor.
|
||||
* @param Client $client
|
||||
* @param Config $config
|
||||
*/
|
||||
public function __construct(Client $client, Config $config)
|
||||
{
|
||||
$this->httpClient = $client;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function getLabTemperatureData()
|
||||
{
|
||||
/** @var Config $labTemperatureUrl */
|
||||
$labTemperatureUrl = $this->config->get('url.labTemperatureUrl');
|
||||
|
||||
$response = $this->httpClient
|
||||
->setUri($labTemperatureUrl)
|
||||
->send();
|
||||
|
||||
if(!$response->isSuccess()) {
|
||||
throw new \UnexpectedValueException("Bad LAB result", $response->getStatusCode());
|
||||
}
|
||||
|
||||
return $this->parseHtml($response->getBody());
|
||||
}
|
||||
|
||||
private function parseHtml($html): array
|
||||
{
|
||||
$cssToXpathConverter = new CssSelectorConverter();
|
||||
$xpathLabelQuery = $cssToXpathConverter->toXPath('a.sensormenu.isnotpaused');
|
||||
$xpathValueQuery = $cssToXpathConverter->toXPath('div.graphlabel2');
|
||||
|
||||
$xmlErrorHandling = libxml_use_internal_errors(TRUE);
|
||||
$domDocument = new \DOMDocument();
|
||||
$domDocument->loadHTML($html);
|
||||
libxml_clear_errors();
|
||||
libxml_use_internal_errors($xmlErrorHandling);
|
||||
|
||||
$documentXpath = new \DOMXPath($domDocument);
|
||||
/** @var \DOMNodeList $element */
|
||||
$element = $documentXpath->query($xpathLabelQuery);
|
||||
|
||||
$thing = [];
|
||||
/** @var \DOMElement $item */
|
||||
foreach($element as $item) {
|
||||
$sensorName = trim($item->nodeValue);
|
||||
if( in_array($sensorName, array_keys($this->tempSensors)) ){
|
||||
/** @var \DOMNodeList $element */
|
||||
$valueElement = $documentXpath->query($xpathValueQuery, $item->parentNode->parentNode);
|
||||
$thing[$this->tempSensors[$sensorName]] = $valueElement->item(0)->nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
return $thing;
|
||||
}
|
||||
}
|
||||
18
src/App/Service/TrInfoCollectorServiceFactory.php
Normal file
18
src/App/Service/TrInfoCollectorServiceFactory.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Http\Client;
|
||||
|
||||
class TrInfoCollectorServiceFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
$configArray = $container->get('config');
|
||||
$httpClient = $container->get(Client::class);
|
||||
$config = new Config($configArray['app.config']);
|
||||
return new TrInfoCollectorService($httpClient, $config);
|
||||
}
|
||||
}
|
||||
86
src/App/Service/VacationInfoCollectorService.php
Normal file
86
src/App/Service/VacationInfoCollectorService.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Symfony\Component\CssSelector\CssSelectorConverter;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Http\Client;
|
||||
|
||||
class VacationInfoCollectorService
|
||||
{
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
private $httpClient;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $tempSensors = [
|
||||
'Temp 5' => 'back_left',
|
||||
'Temp 4' => 'back_middle',
|
||||
'Temp 3' => 'back_right',
|
||||
];
|
||||
|
||||
/**
|
||||
* JiraClientService constructor.
|
||||
* @param Client $client
|
||||
* @param Config $config
|
||||
*/
|
||||
public function __construct(Client $client, Config $config)
|
||||
{
|
||||
$this->httpClient = $client;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function getLabTemperatureData()
|
||||
{
|
||||
/** @var Config $labTemperatureUrl */
|
||||
$labTemperatureUrl = $this->config->get('url.labTemperatureUrl');
|
||||
|
||||
$response = $this->httpClient
|
||||
->setUri($labTemperatureUrl)
|
||||
->send();
|
||||
|
||||
if(!$response->isSuccess()) {
|
||||
throw new \UnexpectedValueException("Bad LAB result", $response->getStatusCode());
|
||||
}
|
||||
|
||||
return $this->parseHtml($response->getBody());
|
||||
}
|
||||
|
||||
private function parseHtml($html): array
|
||||
{
|
||||
$cssToXpathConverter = new CssSelectorConverter();
|
||||
$xpathLabelQuery = $cssToXpathConverter->toXPath('a.sensormenu.isnotpaused');
|
||||
$xpathValueQuery = $cssToXpathConverter->toXPath('div.graphlabel2');
|
||||
|
||||
$xmlErrorHandling = libxml_use_internal_errors(TRUE);
|
||||
$domDocument = new \DOMDocument();
|
||||
$domDocument->loadHTML($html);
|
||||
libxml_clear_errors();
|
||||
libxml_use_internal_errors($xmlErrorHandling);
|
||||
|
||||
$documentXpath = new \DOMXPath($domDocument);
|
||||
/** @var \DOMNodeList $element */
|
||||
$element = $documentXpath->query($xpathLabelQuery);
|
||||
|
||||
$thing = [];
|
||||
/** @var \DOMElement $item */
|
||||
foreach($element as $item) {
|
||||
$sensorName = trim($item->nodeValue);
|
||||
if( in_array($sensorName, array_keys($this->tempSensors)) ){
|
||||
/** @var \DOMNodeList $element */
|
||||
$valueElement = $documentXpath->query($xpathValueQuery, $item->parentNode->parentNode);
|
||||
$thing[$this->tempSensors[$sensorName]] = $valueElement->item(0)->nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
return $thing;
|
||||
}
|
||||
}
|
||||
18
src/App/Service/VacationInfoCollectorServiceFactory.php
Normal file
18
src/App/Service/VacationInfoCollectorServiceFactory.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Http\Client;
|
||||
|
||||
class VacationInfoCollectorServiceFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
$configArray = $container->get('config');
|
||||
$httpClient = $container->get(Client::class);
|
||||
$config = new Config($configArray['app.config']);
|
||||
return new VacationInfoCollectorService($httpClient, $config);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user