Skip to content

Commit

Permalink
Merge pull request #1 from Daniel-WWU-IT/main
Browse files Browse the repository at this point in the history
API updates
  • Loading branch information
labkode authored Mar 30, 2021
2 parents e050041 + 763b0c3 commit 4d9570b
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 176 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
launch.sh

10 changes: 5 additions & 5 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<description>This apps connects the site to the Science Mesh</description>
<licence>MIT</licence>
<author>Hugo Gonzalez Labrador</author>
<version>1.0.0</version>
<version>1.1.0</version>
<namespace>ScienceMesh</namespace>
<category>productivity</category>
<dependencies>
<owncloud min-version="9.0" />
<owncloud max-version="11.0" />
<owncloud min-version="9.0"/>
<owncloud max-version="11.0"/>
</dependencies>
<settings>
<admin>OCA\Sciencemesh\AdminSettings</admin>
<admin>OCA\Sciencemesh\AdminSettings</admin>
</settings>
</info>
</info>
36 changes: 22 additions & 14 deletions controller/pagecontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,26 @@
use OCP\Http\Client\IClientService;
use OCP\AppFramework\Http;

class PageController extends Controller {
private $logger;
class PageController extends Controller
{
private $logger;
private $userId;
protected $connection;

/** @var IClientService */
private $httpClientService;

public function __construct($AppName,
IRequest $request,
$UserId,
IDBConnection $connection,
IClientService $httpClientService,
ILogger $logger) {
public function __construct($AppName,
IRequest $request,
$UserId,
IDBConnection $connection,
IClientService $httpClientService,
ILogger $logger)
{

parent::__construct($AppName, $request);
$this->userId = $UserId;
$this->connection = $connection;
$this->connection = $connection;
$this->httpClientService = $httpClientService;
$this->logger = $logger;
}
Expand All @@ -53,7 +55,8 @@ public function __construct($AppName,
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index() {
public function index()
{
$params = ['user' => $this->userId];
return new TemplateResponse('sciencemesh', 'main', $params); // templates/main.php
}
Expand All @@ -62,7 +65,8 @@ public function index() {
* Simply method that posts back the payload of the request
* @NoAdminRequired
*/
public function doEcho($echo) {
public function doEcho($echo)
{
return new DataResponse(['echo' => $echo]);
}

Expand All @@ -71,7 +75,8 @@ public function doEcho($echo) {
* @NoAdminRequired
* @NoCSRFRequired
*/
public function getMetrics() {
public function getMetrics()
{
// for localhost requests is needed to add
// 'allow_local_remote_servers' => true,
// to config.php
Expand Down Expand Up @@ -108,7 +113,8 @@ public function getMetrics() {
* @NoAdminRequired
* @NoCSRFRequired
*/
public function getInternalMetrics() {
public function getInternalMetrics()
{
//$metrics = $this->getInternal();
$settings = $this->loadSettings();
if (!$settings) {
Expand All @@ -125,7 +131,8 @@ public function getInternalMetrics() {
return new JSONResponse($payload);
}

private function loadSettings(){
private function loadSettings()
{
$query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$query->select('*')->from('sciencemesh');
$result = $query->execute();
Expand All @@ -134,6 +141,7 @@ private function loadSettings(){
$row['numusers'] = intval($row['numusers']);
$row['numfiles'] = intval($row['numfiles']);
$row['numstorage'] = intval($row['numstorage']);
unset($row['apikey']); // Remove the private API key from the exposed settings
return $row;
}

Expand Down
Loading

0 comments on commit 4d9570b

Please sign in to comment.