-
Notifications
You must be signed in to change notification settings - Fork 832
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
11 changes: 10 additions & 1 deletion
11
plugins/dns_api/resources/js/controllers/index.controller.es
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
angular.module('ajenti.dns_api').controller('DnsAPIIndexController', function($scope, $http, pageTitle, gettext, notify) { | ||
pageTitle.set(gettext('DNS API')); | ||
|
||
$http.get('/api/dns_api'); | ||
$http.get('/api/dns_api/domains').then((resp) => { | ||
$scope.domains = resp.data; | ||
$scope.active_domain = resp.data[0]; // Could not exist | ||
$scope.get_records(); | ||
}); | ||
|
||
$scope.get_records = () => { | ||
$http.get(`/api/dns_api/domain/${$scope.active_domain}/records`).then((rsp) => { | ||
$scope.records = rsp.data; | ||
}); | ||
}; | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
<br/> | ||
|
||
<h1>DNS</h1> | ||
<div> | ||
<div root-access> | ||
<h1>DNS</h1> | ||
|
||
<div> | ||
<span translate>Select domain: </span> | ||
<select ng:options="domain for domain in domains" ng:model="active_domain" ng:change="get_records()"></select> | ||
</div> | ||
|
||
<table class="table"> | ||
<tr> | ||
<th translate>Name</th> | ||
<th translate>TTL</th> | ||
<th translate>Type</th> | ||
<th translate>Values</th> | ||
<th translate></th> | ||
</tr> | ||
<tr ng:repeat="record in records"> | ||
<td>{{record.name}}</td> | ||
<td>{{record.ttl}}</td> | ||
<td>{{record.type}}</td> | ||
<td> | ||
<span ng:repeat="value in record.values">{{value}}</span> | ||
</td> | ||
<td></td> | ||
</tr> | ||
|
||
</table> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
from jadi import component | ||
from dataclasses import asdict | ||
|
||
from aj.api.http import get, HttpPlugin | ||
from aj.auth import authorize | ||
from aj.api.endpoint import endpoint, EndpointError | ||
from aj.plugins.dns_api.manager import DomainManager | ||
|
||
|
||
@component(HttpPlugin) | ||
class Handler(HttpPlugin): | ||
def __init__(self, context): | ||
self.context = context | ||
self.mgr = DomainManager(self.context) | ||
|
||
|
||
@get(r'/api/dns_api') | ||
@get(r'/api/dns_api/domains') | ||
@endpoint(api=True) | ||
def handle_api_example_dns_api(self, http_context): | ||
def handle_api_dns_list_domains(self, http_context): | ||
self.mgr.load() | ||
print(self.mgr.domains) | ||
return list(self.mgr.domains.keys()) | ||
|
||
@get(r'/api/dns_api/domain/(?P<fqdn>[\w\.]+)/records') | ||
@endpoint(api=True) | ||
def handle_api_dns_list_records(self, http_context, fqdn): | ||
self.mgr.domains[fqdn].get_records() | ||
return [asdict(r) for r in self.mgr.domains[fqdn].records] | ||
|