Adding in frontend javascript for sources

This commit is contained in:
kevgliss 2015-08-01 15:37:47 -07:00
parent e247d635fc
commit abf21d2931
7 changed files with 1 additions and 271 deletions

View File

@ -1,3 +0,0 @@
/**
* Created by kglisson on 1/19/15.
*/

View File

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
</html>

View File

@ -1,59 +0,0 @@
'use strict';
angular.module('lemur')
.service('ELBApi', function (LemurRestangular) {
LemurRestangular.extendModel('elbs', function (obj) {
return angular.extend(obj, {
attachListener: function (listener) {
if (this.listeners === undefined) {
this.listeners = [];
}
this.listeners.push(listener);
},
removeListener: function (index) {
this.listeners.splice(index, 1);
}
});
});
return LemurRestangular.all('elbs');
})
.service('ELBService', function ($location, ELBApi, toaster) {
var ELBService = this;
ELBService.findELBByName = function (filterValue) {
return ELBApi.getList({'filter[name]': filterValue})
.then(function (elbs) {
return elbs;
});
};
ELBService.getListeners = function (elb) {
elb.getList('listeners').then(function (listeners) {
elb.listeners = listeners;
});
return elb;
};
ELBService.create = function (elb) {
ELBApi.post(elb).then(function () {
toaster.pop({
type: 'success',
title: 'ELB ' + elb.name,
body: 'Has been successfully created!'
});
$location.path('elbs');
});
};
ELBService.update = function (elb) {
elb.put().then(function () {
toaster.pop({
type: 'success',
title: 'ELB ' + elb.name,
body: 'Has been successfully updated!'
});
$location.path('elbs');
});
};
return ELBService;
});

View File

@ -1,34 +0,0 @@
'use strict';
angular.module('lemur')
.config(function config($routeProvider) {
$routeProvider.when('/elbs', {
templateUrl: '/angular/elbs/view/view.tpl.html',
controller: 'ELBViewController'
});
})
.controller('ELBViewController', function ($scope, ELBApi, ELBService, ngTableParams) {
$scope.filter = {};
$scope.elbsTable = new ngTableParams({
page: 1, // show first page
count: 10, // count per page
sorting: {
id: 'desc' // initial sorting
},
filter: $scope.filter
}, {
total: 0, // length of data
getData: function ($defer, params) {
ELBApi.getList(params.url())
.then(function (data) {
params.total(data.total);
$defer.resolve(data);
});
}
});
$scope.toggleFilter = function (params) {
params.settings().$scope.show_filter = !params.settings().$scope.show_filter;
};
});

View File

@ -1,128 +0,0 @@
<div class="row">
<div class="col-md-12">
<h2 class="featurette-heading">ELBs
<span class="text-muted"><small>Bring Balance to the Force</small></span></h2>
<div class="panel panel-default">
<div class="panel-heading">
<div class="btn-group pull-right">
</div>
<div class="btn-group">
<button ng-click="toggleFilter(elbsTable)" class="btn btn-default">Filter</button>
</div>
<div class="clearfix"></div>
</div>
<div class="table-responsive">
<table ng-table="elbsTable" show-filter="false" class="table" template-pagination="angular/pager.html" >
<tbody>
<tr ng-class="{'even-row': $even }" ng-repeat-start="elb in $data track by $index">
<td data-title="'Name'" sortable="'name'" filter="{ 'name': 'text' }">
<div class="text-center">{{ elb.name }}</div>
</td>
<td data-title="'Account'" sortable="'account_id'">
<div class="text-center"><span class="label label-primary">{{ elb.account.label }}</span>
</div>
</td>
<td data-title="'Region'" sortable="'region'" filter="{ 'region': 'text' }">
<div class="text-center">{{ elb.region }}</div>
</td>
<td data-title="'VPC'">
<div class="text-center">
<i class="fa fa-check" ng-show="elb.vpcId" data-placement="top"
data-title="{{ elb.vpcId }}" bs-tooltip></i>
<i class="fa fa-times" ng-show="!elb.vpcId"></i>
</div>
</td>
<td data-title="'Internet Accessible'" sortable="'scheme'">
<div class="text-center">
<i class="fa fa-check" ng-show="elb.scheme == 'internet-facing'"></i>
<i class="fa fa-times" ng-show="elb.scheme == 'internal'"></i>
</div>
</td>
<td>
<div class="text-center">
<i ng-show="!button.toggle" class="fa fa-chevron-down" ng-model="button.toggle"
bs-checkbox></i>
<i ng-show="button.toggle" class="fa fa-chevron-up" ng-model="button.toggle"
bs-checkbox></i>
</div>
</td>
</tr>
<tr class="warning" ng-show="button.toggle" ng-repeat-end>
<td colspan="6">
<table class="table">
<tbody>
<tr>
<th>
<!--<button data-placement="right" data-title="Add Listener" class="btn btn-sm btn-default pull-left" ng-click="addListener()" bs-tooltip><i class="fa fa-plus"></i></button>--></th>
<th>Certificate Name</th>
<th>Instance Port</th>
<th>Instance Protocol</th>
<th>Load Balancer Port</th>
<th>Load Balancer Protocol</th>
<th></th>
</tr>
<tr class="warning" ng-repeat="listener in elb.listeners">
<td>
<div>
<button data-title="Remove listener" data-placement="right"
class="btn btn-sm btn-danger"
ng-click="removeListener(elb, listener, $index)" bs-tooltip><i
class="fa fa-remove"></i></button>
</div>
</td>
<td>
<div class="text-center">
<input type="text" class="form-control input-sm"
ng-model="listener.certificate.name"
ng-options="cert.name for cert in getCertificate($viewValue, elb)"
placeholder="Certificate name..." bs-typeahead>
<div ng-show="showCert">
</div>
</div>
</td>
<td>
<div class="text-center">
<input type="text" ng-model="listener.instancePort"
placeholder="Port number..." class="form-control input-sm"/>
</div>
</td>
<td>
<div class="text-center">
<button type="button" class="btn btn-default btn-sm"
ng-model="listener.instanceProtocol"
ng-options="value for value in protocols" bs-select>
Action <span class="caret"></span>
</button>
</div>
</td>
<td>
<div class="text-center">
<input type="text" ng-model="listener.loadBalancerPort"
placeholder="Port number..." class="form-control input-sm"/>
</div>
</td>
<td>
<div class="text-center">
<button type="button" class="btn btn-default btn-sm"
ng-model="listener.loadBalancerProtocol"
ng-options="value for value in protocols" bs-select>
Action <span class="caret"></span>
</button>
</div>
</td>
<td>
<button data-placement="right" data-title="Save" class="btn btn-sm btn-primary"
ng-click="saveListener(listener)" bs-tooltip><i
class="fa fa-floppy-o"></i></button>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

View File

@ -1,37 +0,0 @@
'use strict';
angular.module('lemur')
.service('ListenerApi', function (LemurRestangular) {
return LemurRestangular.all('listeners');
})
.service('ListenerService', function ($location, ListenerApi) {
var ListenerService = this;
ListenerService.findListenerByName = function (filterValue) {
return ListenerApi.getList({'filter[name]': filterValue})
.then(function (roles) {
return roles;
});
};
ListenerService.create = function (role) {
ListenerApi.post(role).then(function () {
toaster.pop({
type: 'success',
title: 'Listener ' + role.name,
body: 'Has been successfully created!'
});
$location.path('roles/view');
});
};
ListenerService.update = function (role) {
role.put().then(function () {
toaster.pop({
type: 'success',
title: 'Listener ' + role.name,
body: 'Has been successfully updated!'
});
$location.path('roles/view');
});
};
});

View File

@ -54,6 +54,7 @@
<li><a href="/#/authorities">Authorities</a></li>
<li><a href="/#/notifications">Notifications</a></li>
<li><a href="/#/destinations">Destinations</a></li>
<li><a href="/#/sources">Sources</a></li>
<li></li>
<li class="dropdown" dropdown on-toggle="toggled(open)">
<a href class="dropdown-toggle" dropdown-toggle>Settings <span class="caret"></span></a>