Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion Memos/Memos.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,57 @@

namespace App\SupportedApps\Memos;

class Memos extends \App\SupportedApps
class Memos extends \App\SupportedApps implements \App\EnhancedApps
{

public $config;

public function __construct() {}

public function test()
{
$test = parent::appTest(
$this->url('api/v1/auth/sessions/current'),
$this->attrs()
);
echo $test->status;
}

public function livestats()
{
$status = 'inactive';
$res = parent::execute(
$this->url('api/v1/memos'),
$this->attrs()
);
$details = json_decode($res->getBody());

$data = [];

if ($details) {
$status = 'active';
$data['memo_count'] = count($details->memos);
}

return parent::getLiveStats($status, $data);
}

public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url) . $endpoint;
return $api_url;
}


public function attrs()
{
$access_token = $this->config->access_token;
$attrs = [
"headers" => [
"content-type" => "application/json",
"Authorization" => "Bearer " . $access_token,
],
];
return $attrs;
}
}
2 changes: 1 addition & 1 deletion Memos/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"website": "https://github.com/usememos/memos",
"license": "MIT License",
"description": "A privacy-first, lightweight note-taking service. Easily capture and share your great thoughts.",
"enhanced": false,
"enhanced": true,
"tile_background": "light",
"icon": "memos.png"
}
15 changes: 15 additions & 0 deletions Memos/config.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
<div class="items">
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.apikey') }} (Access Token)</label>
{!! Form::text('config[access_token]', null, array('placeholder' => __('app.apps.apikey'), 'data-config' => 'access_token', 'class' => 'form-control config-item')) !!}
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>

6 changes: 6 additions & 0 deletions Memos/livestats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ul class="livestats">
<li>
<span class="title">Memos</span>
<strong>{!! $memo_count !!}</strong>
</li>
</ul>
Loading