Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gce): select external ip for http(s) load balancers
- Loading branch information
1 parent
1aeb53b
commit 0fa0338
Showing
18 changed files
with
202 additions
and
77 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
26 changes: 17 additions & 9 deletions
26
app/scripts/modules/google/cache/cacheRefresh.component.html
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,9 +1,17 @@ | ||
<p> | ||
<span ng-if="$ctrl.refreshing"><span class="small glyphicon glyphicon-refresh glyphicon-spinning"></span></span> | ||
{{::$ctrl.capitalizedKey}} | ||
<span ng-if="!$ctrl.refreshing">last refreshed {{ $ctrl.getRefreshTime() | timestamp }}</span> | ||
<span ng-if="$ctrl.refreshing"> refreshing...</span> | ||
</p> | ||
<p>If you're not finding a {{::$ctrl.depluralizedKey}} that was recently added, | ||
<a href ng-click="$ctrl.refresh()">click here</a> to refresh the list. | ||
</p> | ||
<div ng-if="!$ctrl.renderCompact"> | ||
<p> | ||
<span ng-if="$ctrl.refreshing"><span class="small glyphicon glyphicon-refresh glyphicon-spinning" ></span></span> | ||
{{::$ctrl.capitalizedKey}} | ||
<span ng-if="!$ctrl.refreshing">last refreshed {{ $ctrl.getRefreshTime() | timestamp }}</span> | ||
<span ng-if="$ctrl.refreshing"> refreshing...</span> | ||
</p> | ||
<p>If you're not finding a {{::$ctrl.depluralizedKey}} that was recently added, | ||
<a href ng-click="$ctrl.refresh()">click here</a> to refresh the list. | ||
</p> | ||
</div> | ||
<div ng-if="$ctrl.renderCompact"> | ||
<a href uib-tooltip-template="$ctrl.tooltipTemplate"> | ||
<span class="small glyphicon glyphicon-refresh" ng-click="$ctrl.refresh()" | ||
ng-class="{'glyphicon-spinning': $ctrl.refreshing}"></span> | ||
</a> | ||
</div> |
32 changes: 0 additions & 32 deletions
32
app/scripts/modules/google/cache/cacheRefresh.component.js
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
app/scripts/modules/google/cache/cacheRefresh.component.ts
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import {module, IComponentOptions, IComponentController} from 'angular'; | ||
import {INFRASTRUCTURE_CACHE_SERVICE, InfrastructureCacheService} from 'core/cache/infrastructureCaches.service'; | ||
import {CACHE_INITIALIZER_SERVICE, CacheInitializerService} from 'core/cache/cacheInitializer.service'; | ||
|
||
class GceCacheRefreshCtrl implements IComponentController { | ||
public capitalizedKey: string; | ||
public depluralizedKey: string; | ||
public renderCompact: boolean; | ||
public refreshing = false; | ||
public tooltipTemplate = require('./cacheRefreshTooltip.html'); | ||
private onRefresh: Function; | ||
private cacheKey: string; | ||
private cacheKeyAlias: string; | ||
|
||
static get $inject() { return ['cacheInitializer', 'infrastructureCaches']; } | ||
|
||
constructor(private cacheInitializer: CacheInitializerService, | ||
private infrastructureCaches: InfrastructureCacheService) {} | ||
|
||
public $onInit(): void { | ||
let cacheKeyAlias = this.cacheKeyAlias || this.cacheKey; | ||
this.capitalizedKey = cacheKeyAlias[0].toUpperCase() + cacheKeyAlias.substring(1); | ||
this.depluralizedKey = cacheKeyAlias.substring(0, cacheKeyAlias.length - 1); | ||
} | ||
|
||
public getRefreshTime(): number { | ||
return this.infrastructureCaches.get(this.cacheKey).getStats().ageMax; | ||
} | ||
|
||
public refresh(): void { | ||
this.refreshing = true; | ||
this.cacheInitializer.refreshCache(this.cacheKey) | ||
.then(() => this.onRefresh()) | ||
.then(() => { this.refreshing = false; }); | ||
}; | ||
} | ||
|
||
class GceCacheRefresh implements IComponentOptions { | ||
public bindings: any = { | ||
onRefresh: '&', | ||
cacheKey: '@', | ||
cacheKeyAlias: '@', | ||
renderCompact: '<' | ||
}; | ||
public controller: any = GceCacheRefreshCtrl; | ||
public templateUrl = require('./cacheRefresh.component.html'); | ||
} | ||
|
||
export const GCE_CACHE_REFRESH = 'spinnaker.gce.cacheRefresh.component'; | ||
module(GCE_CACHE_REFRESH, [ | ||
CACHE_INITIALIZER_SERVICE, | ||
INFRASTRUCTURE_CACHE_SERVICE | ||
]).component('gceCacheRefresh', new GceCacheRefresh()); | ||
|
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p ng-if="$ctrl.refreshing">{{$ctrl.capitalizedKey}} data is <strong>refreshing</strong></p> | ||
<p ng-if="!$ctrl.refreshing">(click <span class="small glyphicon glyphicon-refresh"></span> to refresh)</p> | ||
<p>Last refresh: {{$ctrl.getRefreshTime() | timestamp }}</p> |
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
47 changes: 47 additions & 0 deletions
47
app/scripts/modules/google/loadBalancer/configure/common/addressSelector.component.ts
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import {module, IComponentOptions, IComponentController} from 'angular'; | ||
import {IGceAddress} from 'google/address/address.reader'; | ||
|
||
class GceAddressSelectorCtrl implements IComponentController { | ||
public selectedAddress: IGceAddress; | ||
public addressList: IGceAddress[]; | ||
public account: string; | ||
// The IP address string is the only piece that we can expect a parent resource to keep track of. | ||
// We'll try to match this IP to a full address map. | ||
private initialIpAddress: string; | ||
|
||
public $onInit(): void { | ||
this.selectedAddress = this.addressList.find(address => address.address === this.initialIpAddress); | ||
if (!this.selectedAddress) { | ||
this.selectedAddress = {address: this.initialIpAddress, account: this.account}; | ||
} | ||
} | ||
} | ||
|
||
class GceAddressSelector implements IComponentOptions { | ||
public bindings: any = { | ||
initialIpAddress: '<', | ||
addressList: '<', | ||
readOnly: '<', | ||
onAddressSelect: '&', | ||
account: '<', | ||
}; | ||
public template = ` | ||
<ui-select on-select="$ctrl.onAddressSelect({address: $ctrl.selectedAddress})" | ||
ng-disabled="$ctrl.readOnly" | ||
ng-model="$ctrl.selectedAddress" | ||
class="form-control input-sm"> | ||
<ui-select-match allow-clear> | ||
{{$ctrl.selectedAddress.address}} <span ng-if="$ctrl.selectedAddress.name">({{$ctrl.selectedAddress.name}})</span> | ||
</ui-select-match> | ||
<ui-select-choices repeat="address in $ctrl.addressList | filter: {name: $select.search, account: $ctrl.account}"> | ||
<span> | ||
{{address.address}} <span ng-if="address.name">({{address.name}})</span> <br> | ||
</span> | ||
</ui-select-choices> | ||
</ui-select>`; | ||
public controller: any = GceAddressSelectorCtrl; | ||
} | ||
|
||
export const GCE_ADDRESS_SELECTOR = 'spinnaker.gce.addressSelector.component'; | ||
module(GCE_ADDRESS_SELECTOR, []) | ||
.component('gceAddressSelector', new GceAddressSelector()); |
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
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
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
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
Oops, something went wrong.