Skip to content

Commit

Permalink
Add GNS3 enhanced app (#647)
Browse files Browse the repository at this point in the history
* Added template for enhanced app.
* Enhanced app implementation for GNS3.
* Minified png image.
  • Loading branch information
stanek0j authored Jan 24, 2024
1 parent 43bf6ae commit e8a5e58
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
51 changes: 51 additions & 0 deletions GNS3/GNS3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php namespace App\SupportedApps\GNS3;

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

Check failure on line 3 in GNS3/GNS3.php

View workflow job for this annotation

GitHub Actions / Lint Code Base

Class App\SupportedApps\GNS3\GNS3 extends unknown class App\SupportedApps.

Check failure on line 3 in GNS3/GNS3.php

View workflow job for this annotation

GitHub Actions / Lint Code Base

Class App\SupportedApps\GNS3\GNS3 implements unknown interface App�nhancedApps.

public $config;

//protected $login_first = true; // Uncomment if api requests need to be authed first
//protected $method = 'POST'; // Uncomment if requests to the API should be set by POST

function __construct() {
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
}

public function test()
{
$test = parent::appTest($this->url('/v2/version'), ['auth' => [$this->config->username, $this->config->password]]);

Check failure on line 16 in GNS3/GNS3.php

View workflow job for this annotation

GitHub Actions / Lint Code Base

App\SupportedApps\GNS3\GNS3::test() calls parent::appTest() but App\SupportedApps\GNS3\GNS3 does not extend any class.
$details = json_decode($test->response);
if ($details && isset($details->version)) {
echo $test->status . "\nServer version: " . $details->version;
} else {
echo $test->status;
}
}

public function livestats()
{
$status = 'inactive';
$res = parent::execute($this->url('/v2/projects'), ['auth' => [$this->config->username, $this->config->password]]);

Check failure on line 28 in GNS3/GNS3.php

View workflow job for this annotation

GitHub Actions / Lint Code Base

App\SupportedApps\GNS3\GNS3::livestats() calls parent::execute() but App\SupportedApps\GNS3\GNS3 does not extend any class.
$details = json_decode($res->getBody());

$data = [];
$data["opened"] = 0;
$data["closed"] = 0;

foreach ($details as $project) {
if ($project->status == "opened") {
$data["opened"]++;
} else {
$data["closed"]++;
}
}

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

Check failure on line 43 in GNS3/GNS3.php

View workflow job for this annotation

GitHub Actions / Lint Code Base

App\SupportedApps\GNS3\GNS3::livestats() calls parent::getLiveStats() but App\SupportedApps\GNS3\GNS3 does not extend any class.

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

Check failure on line 48 in GNS3/GNS3.php

View workflow job for this annotation

GitHub Actions / Lint Code Base

App\SupportedApps\GNS3\GNS3::url() calls parent::normaliseurl() but App\SupportedApps\GNS3\GNS3 does not extend any class.
return $api_url;
}
}
10 changes: 10 additions & 0 deletions GNS3/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"appid": "95493920561b1c745f4f6eafb1572a1e17c26cc9",
"name": "GNS3",
"website": "https://www.gns3.com/",
"license": "GNU General Public License v3.0 or later",
"description": "Build, Design and Test your network in a risk-free virtual environment and access the largest networking community to help. Whether you are studying for your first networking exam or building out a state-wide telecommunications network, GNS3 offers an easy way to design and build networks of any size without the need for hardware. And the best part is it's free!",
"enhanced": true,
"tile_background": "dark",
"icon": "gns3.png"
}
19 changes: 19 additions & 0 deletions GNS3/config.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<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]', isset($item) ? $item->getconfig()->override_url : null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.username') }}</label>
{!! Form::text('config[username]', isset($item) ? $item->getconfig()->username : null, array('placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.password') }}</label>
{!! Form::input('password', 'config[password]', '', ['placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item']) !!}
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>

Binary file added GNS3/gns3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions GNS3/livestats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<ul class="livestats">
<li>
<span class="title">Opened</span>
<strong>{!! $opened !!}</strong>
</li>
<li>
<span class="title">Closed</span>
<strong>{!! $closed !!}</strong>
</li>
</ul>

0 comments on commit e8a5e58

Please sign in to comment.