Some unit tests

This commit is contained in:
Curtis Castrapel
2018-04-25 11:19:34 -07:00
parent 51d2990eb9
commit f0f2092fb4
12 changed files with 175 additions and 54 deletions

View File

@ -5,6 +5,10 @@ angular.module('lemur')
.controller('DnsProviderCreateController', function ($scope, $uibModalInstance, PluginService, DnsProviderService, LemurRestangular, toaster) {
$scope.dns_provider = LemurRestangular.restangularizeElement(null, {}, 'dns_providers');
PluginService.getByName('acme-issuer').then(function (acme) {
$scope.acme = acme;
});
PluginService.getByType('dns_provider').then(function (plugins) {
$scope.plugins = plugins;
});
@ -45,30 +49,13 @@ angular.module('lemur')
DnsProviderApi.get(editId).then(function (dns_provider) {
$scope.dns_provider = dns_provider;
PluginService.getByType('dns_provider').then(function (plugins) {
$scope.plugins = plugins;
PluginService.getByName('acme-issuer').then(function (acme) {
$scope.acme = acme;
_.each($scope.plugins, function (plugin) {
if (plugin.slug === $scope.dns_provider.plugin.slug) {
plugin.pluginOptions = $scope.dns_provider.plugin.pluginOptions;
$scope.dns_provider.plugin = plugin;
_.each($scope.dns_provider.plugin.pluginOptions, function (option) {
if (option.type === 'export-plugin') {
PluginService.getByType('export').then(function (plugins) {
$scope.exportPlugins = plugins;
_.each($scope.exportPlugins, function (plugin) {
if (plugin.slug === option.value.slug) {
plugin.pluginOptions = option.value.pluginOptions;
option.value = plugin;
}
});
});
}
});
}
_.each($scope.acme, function (opts) {
console.log(opts);
});
});
});
});
$scope.save = function (dns_provider) {

View File

@ -2,19 +2,19 @@
<button type="button" class="close" ng-click="cancel()" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
<h3><span ng-show="!dns_provider.fromServer">Create</span><span ng-show="dns_provider.fromServer">Edit</span>
DnsProvider <span class="text-muted"><small>oh the places you will go!</small></span></h3>
Dns Provider <span class="text-muted"><small>route all the things</small></span></h3>
</div>
<div class="modal-body">
<form name="createForm" class="form-horizontal" role="form" novalidate>
<div class="form-group"
ng-class="{'has-error': createForm.label.$invalid, 'has-success': !createForm.label.$invalid&&createForm.label.$dirty}">
<label class="control-label col-sm-2">
Label
Name
</label>
<div class="col-sm-10">
<input name="label" ng-model="dns_provider.label" placeholder="Label" class="form-control" required/>
<input name="name" ng-model="dns_provider.name" placeholder="Name" class="form-control" required/>
<p ng-show="createForm.label.$invalid && !createForm.label.$pristine" class="help-block">You must enter an
dns_provider label</p>
dns_provider name</p>
</div>
</div>
<div class="form-group">
@ -22,16 +22,16 @@
Description
</label>
<div class="col-sm-10">
<textarea name="comments" ng-model="dns_provider.description" placeholder="Something elegant"
<textarea name="description" ng-model="dns_provider.description" placeholder="Something elegant"
class="form-control"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">
Plugin
Provider Type
</label>
<div class="col-sm-10">
<select class="form-control" ng-model="dns_provider.plugin" ng-options="plugin.title for plugin in plugins"
<select class="form-control" ng-model="dns_provider.provider_type" ng-options="plugin for plugin in ['route53', 'cloudflare']"
required></select>
</div>
</div>

View File

@ -50,7 +50,7 @@ angular.module('lemur')
var uibModalInstance = $uibModal.open({
animation: true,
templateUrl: '/angular/dns_providers/dns_provider/dns_provider.tpl.html',
controller: 'DnsProvidersEditController',
controller: 'DnsProviderEditController',
size: 'lg',
backdrop: 'static',
resolve: {
@ -69,7 +69,7 @@ angular.module('lemur')
$scope.create = function () {
var uibModalInstance = $uibModal.open({
animation: true,
controller: 'DnsProvidersCreateController',
controller: 'DnsProviderCreateController',
templateUrl: '/angular/dns_providers/dns_provider/dns_provider.tpl.html',
size: 'lg',
backdrop: 'static'

View File

@ -29,12 +29,6 @@
<li>{{ dns_provider.providerType }}</li>
</ul>
</td>
<td data-title="'Domains'" sortable="'domains'" filter="{ 'domains': 'text' }">
<ul class="list-unstyled">
<li>{{ dns_provider.domains }}</li>
<li><span class="text-muted">{{ dns_provider.description }}</span></li>
</ul>
</td>
<td data-title="''">
<div class="btn-group-vertical pull-right">
<button uib-tooltip="Edit DNS Provider" ng-click="edit(dns_provider.id)" class="btn btn-sm btn-info">