Skip to content

Commit

Permalink
Merge branch 'master' into fe-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Jul 3, 2018
2 parents e46c0e5 + d2c3153 commit 172b3bb
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 57 deletions.
1 change: 0 additions & 1 deletion app/Http/Controllers/Api/V4/VlanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public function getIPAddresses( Request $request, int $id ) : JsonResponse {
*
* @see VlanEntity::usedAcrossVlans() for array structure.
*
* @param string $ipAddress The IP address to check
* @return JsonResponse array of object
*/
public function usedAcrossVlans( Request $request ) : JsonResponse {
Expand Down
6 changes: 6 additions & 0 deletions app/Http/Controllers/Interfaces/CoreBundleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,19 @@ public function storeWizard( StoreCoreBundle $request ): RedirectResponse {
}

foreach( [ 'a' => $via , 'b' => $vib ] as $side => $vi ){
/** @var $vi VirtualInterfaceEntity */
// Set value to the Virtual Interface side A and B
$vi->setCustomer( $cust );
$vi->setMtu( $request->input( "mtu" ) );
$vi->setName( $request->input( "vi-name-$side" ) );
$vi->setChannelgroup( $request->input( "vi-channel-number-$side" ) );
$vi->setTrunk( $request->input( 'framing' ) ?? false );
$vi->setFastLACP( $request->input( 'fast-lacp' ) ?? false );

if( $request->input( "type" ) == CoreBundleEntity::TYPE_L2_LAG ){
$vi->setLagFraming( true );
}

}

// CHeck if there is at least 1 core link created for the core bundle
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/RouterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function edit( int $id = null ): View {
// fill the form with router data
Former::populate([
'handle' => array_key_exists( 'handle', $old ) ? $old['handle'] : $rt->getHandle(),
'vlan' => array_key_exists( 'vlan', $old ) ? $old['vlan'] : $rt->getVlan(),
'vlan' => array_key_exists( 'vlan', $old ) ? $old['vlan'] : $rt->getVlan()->getId(),
'protocol' => array_key_exists( 'protocol', $old ) ? $old['protocol'] : $rt->getProtocol(),
'type' => array_key_exists( 'type', $old ) ? $old['type'] : $rt->getType(),
'name' => array_key_exists( 'name', $old ) ? $old['name'] : $rt->getName(),
Expand Down
4 changes: 2 additions & 2 deletions database/Proxies/__CG__EntitiesCustomerTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function setDisplayAs(string $display_as): \Entities\CustomerTag
/**
* {@inheritDoc}
*/
public function getDescription(): string
public function getDescription()
{

$this->__initializer__ && $this->__initializer__->__invoke($this, 'getDescription', []);
Expand All @@ -231,7 +231,7 @@ public function getDescription(): string
/**
* {@inheritDoc}
*/
public function setDescription(string $description): \Entities\CustomerTag
public function setDescription($description): \Entities\CustomerTag
{

$this->__initializer__ && $this->__initializer__->__invoke($this, 'setDescription', [$description]);
Expand Down
9 changes: 7 additions & 2 deletions resources/views/customer/overview-tabs/logins.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
<?php foreach( $t->c->getUsers() as $u ): ?>
<tr>
<td>
<a href="<?= url( "contact/edit/id/" . $u->getContact()->getId() . "/cid/". $u->getCustomer()->getId() ) ?>">
<?php if( $u->getContact() ): ?>
<a href="<?= url( "contact/edit/id/" . $u->getContact()->getId() . "/cid/". $u->getCustomer()->getId() ) ?>">
<?= $t->ee ( $u->getUsername() ) ?>
</a>

<?php else: ?>
<?= $t->ee ( $u->getUsername() ) ?>
</a>
<?php endif; ?>
</td>
<td>
<?= $t->ee( $u->getEmail() ) ?>
Expand Down
3 changes: 0 additions & 3 deletions resources/views/customer/overview-tabs/ports/port.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,6 @@
<?php if( $t->vi->isTypePeering() ): ?>
<p>
No VLAN interfaces defined.
<?php if( Auth::getUser()->isSuperUser() ): ?>
<a href="<?= route( "interfaces/vlan/edit/from-virtual-interface", [ "id" => $t->vi->getId() ] ) ?>">Add one...</a>
<?php endif; ?>
</p>
<?php endif; ?>
<?php endif; ?>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/customer/overview-tabs/users.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<i class="glyphicon glyphicon-pencil"></i>
</a>

<a class="btn btn-default" id="usr-list-delete-<?= $u->getId() ?>" data-object-id="<?= $u->getContact()->getId() ?>"
<a class="btn btn-default" id="usr-list-delete-<?= $u->getId() ?>" data-object-id="<?= $u->getContact() ? $u->getContact()->getId() : null ?>"
href="#">
<i class="glyphicon glyphicon-trash"></i>
</a>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/interfaces/common/vli/ipv4.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<?= Former::select( 'ipv4-address' )
->label( 'IPv4 Address' )
->placeholder( 'Choose an IPv4 Address' )
->class( "chzn-select-deselect" )
->class( "chzn-select-deselect-tag" )
->blockHelp( 'Select the IP address to assign to this VLAN interface. If empty, ensure you have selected a VLAN above and that the VLAN has available addresses. '
. 'You can also create a new IPv4 address by entering it here but please use clue as validation is minimal.');
?>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/interfaces/common/vli/ipv6.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<?= Former::select( 'ipv6-address' )
->label( 'IPv6 Address' )
->placeholder( 'Choose an IPv6 Address' )
->class( "chzn-select-deselect" )
->class( "chzn-select-deselect-tag" )
->blockHelp( 'Select the IP address to assign to this VLAN interface. If empty, ensure you have selected a VLAN above and that the VLAN has available addresses.'
. 'You can also create a new IPv6 address by entering it here but please use clue as validation is minimal. Also ensure you use standard short form with lower case letters.' );
?>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/patch-panel-port/index.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<?php endif; ?>
<div class="btn-group btn-group-xs" role="group">
<?php if( $t->pp ): ?>
<a type="button" class="btn btn-default" href="<?= route('patch-panel-port@edit' , [ 'id' => $t->pp->getId() ] ) ?>" title="Edit Patch Panel">
<a type="button" class="btn btn-default" href="<?= route('patch-panel/edit' , [ 'id' => $t->pp->getId() ] ) ?>" title="Edit Patch Panel">
<span class="glyphicon glyphicon-pencil"></span>
</a>
<a type="button" class="btn btn-default" href="<?= route('patch-panel-port@view' , [ 'id' => $t->pp->getId() ] ) ?>" title="View Patch Panel">
<a type="button" class="btn btn-default" href="<?= route('patch-panel@view' , [ 'id' => $t->pp->getId() ] ) ?>" title="View Patch Panel">
<span class="glyphicon glyphicon-eye-open"></span>
</a>
<?php endif;?>
Expand Down
26 changes: 14 additions & 12 deletions resources/views/patch-panel-port/js/action-dd.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,17 @@ function popup( pppId, action, url ) {

function uploadPopup( pppid ){

let html = '<form id="upload" method="post" action="<?= url("patch-panel-port/upload-file" )?>/' + pppid + '" enctype="multipart/form-data">' +
'<div id="drop">Drop Files Here &nbsp;' +
' <a id="upload-drop-a" class="btn btn-success">' +
' <i class="glyphicon glyphicon-upload"></i> Browse</a> <br/>' +
' <span class="info"> (max size <?= $t->maxFileUploadSize() ?> </span>' +
' <input type="file" name="upl" multiple />' +
'</div>' +
'<ul id="upload-ul"><!-- The file uploads will be shown here --> </ul>' +
'</form>';

let html = `<form id="upload" method="post" action='<?= url("patch-panel-port/upload-file" )?>/${pppid}' enctype='multipart/form-data'>
<div id='drop'>Drop Files Here &nbsp;
<a id="upload-drop-a" class="btn btn-success">
<i class="glyphicon glyphicon-upload"></i> Browse</a> <br/>
<span class="info"> (max size <?= $t->maxFileUploadSize() ?> </span>
<input type="file" name="upl" multiple />
</div>
<ul id="upload-ul"></ul>
</form>`;


let dialog = bootbox.dialog({
message: html,
Expand Down Expand Up @@ -291,9 +293,9 @@ function uploadPopup( pppid ){
tpl.addClass( 'success' );
tpl.attr( 'id','uploaded-file-' + result.id );
tpl.find( 'span' ).addClass( 'success' );
tpl.append( '<span id="uploaded-file-toggle-private-' + result.id + '" class="private fa fa-unlock fa-lg"></span>' );
tpl.append( '<span id="uploaded-file-delete-' + result.id + '" class="delete glyphicon glyphicon-trash"></span>' );
tpl.find('p').append( '<i id="message-'+ result.id + '" class="success">' + result.message + '</i>' );
tpl.append( `<span id="uploaded-file-toggle-private-${result.id}" class="private fa fa-unlock fa-lg"></span>` );
tpl.append( `<span id="uploaded-file-delete-${result.id}" class="delete glyphicon glyphicon-trash"></span>` );
tpl.find('p').append( `<i id="message-${result.id}" class="success">${result.message}</i>` );

$('#uploaded-file-toggle-private-' + result.id).on( 'click', toggleFilePrivacy );
$('#uploaded-file-delete-' + result.id).on( 'click', deleteFile );
Expand Down
22 changes: 11 additions & 11 deletions resources/views/patch-panel-port/js/edit.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
* set data to the switch dropdown related to the customer selected
*/
dd_customer.change( function(){
dd_switch.html( "<option value=\"\">Loading please wait</option>\n" ).trigger('change.select2');
dd_switch.html( `<option value=''>Loading please wait</option>` ).trigger('change.select2');
dd_switch_port.html("").trigger('change.select2');

let customerId = dd_customer.val();
Expand All @@ -107,9 +107,9 @@
})
.done( function( data ) {
if( data.switchesFound ){
let options = "<option value=\"\">Choose a switch</option>\n";
let options = `<option value=''>Choose a switch</option>`;
$.each( data.switches, function( key, value ){
options += "<option value=\"" + key + "\">" + value + "</option>\n";
options += `<option value='${key}'>${value}</option>`;
});
dd_switch.html( options );
}
Expand All @@ -131,11 +131,11 @@
*/
$( ".reset-btn" ).click( function(){
let $switch;
let options = "<option value=''> Choose a Switch</option>\n";
let options = `<option value=''> Choose a Switch</option>`;

<?php foreach ( $t->switches as $id => $switch ): ?>
$switch = '<?= $switch ?>';
options += "<option value=\"" + <?= $id ?> + "\">" + $switch + "</option>\n";
$switch = `<?= $switch ?>`;
options += `<option value='<?= $id ?>'>${$switch}</option>`;
<?php endforeach; ?>

dd_switch.html( options ).trigger('change.select2');
Expand Down Expand Up @@ -164,7 +164,7 @@ function setSwitchPort(){
let spOption = false;
let spOptionset = false;

dd_switch_port.html( "<option value=\"\">Loading please wait</option>\n" ).trigger('change.select2');
dd_switch_port.html( `<option value=''>Loading please wait</option>` ).trigger('change.select2');

<?php if ($t->prewired): ?>
url = "<?= url( '/api/v4/switch' )?>/" + switchId + "/switch-port-prewired";
Expand Down Expand Up @@ -277,12 +277,12 @@ function setSwitchPort(){
function setCustomer(){
if( dd_switch.val() != ''){
let switchPortId = dd_switch_port.val();
dd_customer.html( "<option value=\"\">Loading please wait</option>\n" );
dd_customer.html( `<option value=''>Loading please wait</option>` );
dd_customer.trigger('change.select2');
$.ajax( "<?= url( '/api/v4/switch-port' ) ?>/" + switchPortId + "/customer" )
.done( function( data ) {
if( data.customerFound ) {
dd_customer.html( '<option value="' + data.id + '">' + data.name + "</option>\n" );
dd_customer.html( `<option value='${data.id}'>${data.name}</option>` );
} else {
dd_customer.html("");
}
Expand All @@ -305,8 +305,8 @@ function resetCustomer(){
let options = "<option value=''> Choose a customer</option>\n";

<?php foreach ( $t->customers as $id => $customer ): ?>
customer = '<?= $customer ?>';
options += "<option value=\"" + <?= $id ?> + "\">" + customer + "</option>\n";
customer = `<?= $customer ?>`;
options += `<option value='<?= $id ?>'>${customer}</option>`;
<?php endforeach; ?>
dd_customer.html( options ).trigger('change.select2');
}
Expand Down
4 changes: 2 additions & 2 deletions resources/views/patch-panel-port/js/move.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ function setPPP(){
type: 'POST'
})
.done( function( data ) {
let options = "<option value=\"\">Choose a switch port</option>\n";
let options = `<option value="">Choose a switch port</option>`;
$.each( data.listPorts, function( key, value ){
options += "<option value=\"" + key + "\">" + value + "</option>\n";
options += `<option value="${key}">${value}</option>`;
});
dd_master.html( options );
<?php if( $t->ppp->hasSlavePort() ): ?>
Expand Down
37 changes: 19 additions & 18 deletions routes/apiv4.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,28 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ASN Number
//
Route::get( 'aut-num/{asn}', function( $asn) {
return response()->json( Cache::remember('aut-num', 120, function() use( $asn ) {
$infos = [];
if( $values = file_get_contents("https://rest.db.ripe.net/ripe/aut-num/". $asn . ".json" ) ) {
$i = 0;

foreach( json_decode( $values)->objects->object[0]->attributes->attribute as $val ) {
$infos[ $i ][ 'name' ] = $val->name;
$infos[ $i ][ 'value' ] = $val->value;
if( isset( $val->link ) ){
$infos[ $i ][ 'link' ] = $val->link->href;
}
Route::get( 'aut-num/{asn}', function( $asn ) {

if( isset( $val->comment ) ){
$infos[ $i ][ 'comment' ] = $val->comment;
}
$infos = [];

if( $values = file_get_contents("https://rest.db.ripe.net/ripe/aut-num/". $asn . ".json" ) ) {
$i = 0;

foreach( json_decode( $values)->objects->object[0]->attributes->attribute as $val ) {
$infos[ $i ][ 'name' ] = $val->name;
$infos[ $i ][ 'value' ] = $val->value;
if( isset( $val->link ) ){
$infos[ $i ][ 'link' ] = $val->link->href;
}

$i++;
if( isset( $val->comment ) ){
$infos[ $i ][ 'comment' ] = $val->comment;
}

$i++;
}
return $infos;
}));
}

return response()->json( $infos );
})->name('api-v4-aut-num');

0 comments on commit 172b3bb

Please sign in to comment.