Skip to content

Commit

Permalink
Application Group Inspect. (#215)
Browse files Browse the repository at this point in the history
* adding stats

* comments fixed

regenerating bundle

* removing ctrl variables

* updating contiv-nginx.conf
  • Loading branch information
shampur authored and vishal-j committed Nov 22, 2016
1 parent 3bc2e1d commit e67539b
Show file tree
Hide file tree
Showing 12 changed files with 1,852 additions and 1,440 deletions.
51 changes: 20 additions & 31 deletions app/applicationgroups/applicationgroupdetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,20 @@
</button>
</div>
</div>
<div class="ui secondary pointing menu" *ngIf="mode=='details'">
<a class="blue item" [ngClass]="{active: infoselected}" (click)="infoselected=true">
<i class="details icon"></i>
DETAILS
</a>
<a class="blue item" [ngClass]="{active: !infoselected}" (click)="infoselected=false">
<i class="area chart icon"></i>
STATS
</a>
</div>

<div class="ui basic segment">
<div class="ui active inverted dimmer" *ngIf="showLoader">
<div class="ui loader"></div>
</div>
<div><h4 class="ui header">Basic Settings</h4></div> <!-- Top Margin is less,When h4 is first child in div -->
<table class="ui very basic selectable table">
<tbody>
<tr>
<td class="three wide column">Name</td>
<td>{{applicationGroup.groupName}}</td>
</tr>
<tr>
<td class="three wide column">Network</td>
<td>{{applicationGroup.networkName}}</td>
</tr>
</tbody>
</table>

<div class="ui section divider" style="margin-top: 30px"></div>

<ctv-collapsible title="Isolation Policies">
<ctv-isolationpolicy [mode]="mode" [applicationgroup]="applicationGroup"></ctv-isolationpolicy>
</ctv-collapsible>

<div class="ui section divider"></div>

<ctv-collapsible title="Bandwidth Policies">
<ctv-bandwidthpolicy [mode]="mode" [applicationgroup]="applicationGroup"></ctv-bandwidthpolicy>
</ctv-collapsible>

<div *ngIf="infoselected || mode == 'edit'">
<applicationgroupinfo [applicationGroup]="applicationGroup"
[mode]="mode" [showLoader]="showLoader"></applicationgroupinfo>
<div [ngSwitch]="mode" style="margin-top: 40px">
<div class="ui grid">
<div class="right aligned sixteen wide column">
Expand All @@ -92,6 +75,12 @@
[error]="serverErrorMessage">
</ctv-error>
</div>

</div>

<applicationgroupstats [statkey]="statskey"
*ngIf="!infoselected && mode != 'edit'"></applicationgroupstats>





28 changes: 25 additions & 3 deletions app/applicationgroups/applicationgroupdetailsctrl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Created by vjain3 on 3/15/16.
*/
import { Component, Inject } from '@angular/core';
import {Component, Inject, OnInit, NgZone} from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router";
import { ApplicationGroupsModel } from "../components/models/applicationgroupsmodel";
import { CRUDHelperService } from "../components/utils/crudhelperservice";
Expand All @@ -10,12 +10,18 @@ import { CRUDHelperService } from "../components/utils/crudhelperservice";
selector: 'applicationgroupdetails',
templateUrl: 'applicationgroups/applicationgroupdetails.html'
})
export class ApplicationGroupDetailsComponent {
export class ApplicationGroupDetailsComponent implements OnInit{
applicationGroup:any = {};
mode:string = 'details';
public infoselected: boolean;
public statskey: string;
public showLoader: boolean;
public showServerError: boolean;
public serverErrorMessage: string;

constructor(private activatedRoute: ActivatedRoute,
private router: Router,
private ngZone: NgZone,
private applicationGroupsModel:ApplicationGroupsModel,
private crudHelperService:CRUDHelperService) {
var applicationGroupDetailsCtrl = this;
Expand All @@ -31,15 +37,31 @@ export class ApplicationGroupDetailsComponent {
}
}

applicationGroupDetailsCtrl.crudHelperService.stopLoader(applicationGroupDetailsCtrl);
applicationGroupDetailsCtrl.crudHelperService.startLoader(applicationGroupDetailsCtrl);
applicationGroupDetailsCtrl.crudHelperService.hideServerError(applicationGroupDetailsCtrl);

applicationGroupDetailsCtrl.applicationGroupsModel.getModelByKey(activatedRoute.snapshot.params['key'], false, 'key')
.then(function (group) {
applicationGroupDetailsCtrl.applicationGroup = group;
applicationGroupDetailsCtrl.ngZone.run(() => {
applicationGroupDetailsCtrl.crudHelperService.stopLoader(applicationGroupDetailsCtrl);
});

}, (error) => {
applicationGroupDetailsCtrl.ngZone.run(() => {
applicationGroupDetailsCtrl.crudHelperService.stopLoader(applicationGroupDetailsCtrl);
});
});

setMode();
this.applicationGroup = {groupName: '', networkName: ''};
this.serverErrorMessage = '';
this.statskey = '';
this.infoselected = true;
}

ngOnInit(){
this.statskey = this.activatedRoute.snapshot.params['key'];
}

returnToApplicationGroup() {
Expand Down
27 changes: 27 additions & 0 deletions app/applicationgroups/applicationgroupinfo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="ui basic segment" [ngClass]="{loading: showLoader}">
<div><h4 class="ui header">Basic Settings</h4></div> <!-- Top Margin is less,When h4 is first child in div -->
<table class="ui very basic selectable table">
<tbody>
<tr>
<td class="three wide column">Name</td>
<td>{{applicationGroup.groupName}}</td>
</tr>
<tr>
<td class="three wide column">Network</td>
<td>{{applicationGroup.networkName}}</td>
</tr>
</tbody>
</table>

<div class="ui section divider" style="margin-top: 30px"></div>

<ctv-collapsible title="Isolation Policies">
<ctv-isolationpolicy [mode]="mode" [applicationgroup]="applicationGroup"></ctv-isolationpolicy>
</ctv-collapsible>

<div class="ui section divider"></div>

<ctv-collapsible title="Bandwidth Policies">
<ctv-bandwidthpolicy [mode]="mode" [applicationgroup]="applicationGroup"></ctv-bandwidthpolicy>
</ctv-collapsible>
</div>
23 changes: 23 additions & 0 deletions app/applicationgroups/applicationgroupinfoctrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Created by cshampur on 11/18/16.
*/


import {Component, Input, OnInit} from "@angular/core";
@Component({
selector: 'applicationgroupinfo',
templateUrl: 'applicationgroups/applicationgroupinfo.html'
})

export class ApplicationGroupInfoComponent{
@Input('applicationGroup') applicationGroup: any;
@Input('mode') mode: string;
@Input('showLoader') showLoader: boolean
constructor(){
this.applicationGroup= {
groupName: '',
networkName: ''
}
this.mode = 'details';
}
}
8 changes: 7 additions & 1 deletion app/applicationgroups/applicationgroups.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { ApplicationGroupDetailsComponent } from "./applicationgroupdetailsctrl"
import { IsolationPolicySelectionComponent } from "./isolationpolicydirective";
import { BandwidthPolicySelectionComponent } from "./bandwidthpolicydirective";
import { AppGrouplistComponent } from "./applicationgrouplistctrl";
import {ApplicationGroupStatsComponent} from "./applicationgroupstats";
import {ApplicationGroupInfoComponent} from "./applicationgroupinfoctrl";

@NgModule({
imports: [
Expand All @@ -26,14 +28,18 @@ import { AppGrouplistComponent } from "./applicationgrouplistctrl";
ApplicationGroupDetailsComponent,
IsolationPolicySelectionComponent,
BandwidthPolicySelectionComponent,
AppGrouplistComponent
AppGrouplistComponent,
ApplicationGroupStatsComponent,
ApplicationGroupInfoComponent
],
exports: [
AppGrouplistComponent,
ApplicationGroupCreateComponent,
ApplicationGroupDetailsComponent,
IsolationPolicySelectionComponent,
BandwidthPolicySelectionComponent,
ApplicationGroupStatsComponent,
ApplicationGroupInfoComponent,
FormsModule,
CommonModule,
RouterModule,
Expand Down
74 changes: 74 additions & 0 deletions app/applicationgroups/applicationgroupstats.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<div class="ui basic segment" [ngClass]="{loading: showLoader}">
<table class="ui very basic selectable table">
<tbody>
<tr>
<td class="ctv-header three wide column">Name</td>
<td>{{config['groupName']}}</td>
</tr>
<tr>
<td class="ctv-header three wide column">Network Name</td>
<td>{{config['networkName']}}</td>
</tr>
<tr>
<td class="ctv-header three wide column">External Packet Tag</td>
<td>{{applicationInspectStats.externalPktTag}}</td>
</tr>
<tr>
<td class="ctv-header three wide column">Number of Endpoints</td>
<td>{{applicationInspectStats.numEndpoints}}</td>
</tr>
<tr>
<td class="ctv-header three wide column">Packet Tag</td>
<td>{{applicationInspectStats.pktTag}}</td>
</tr>
</tbody>
</table>

<div class="ui section divider"></div>
<ctv-collapsible title="End Points">
<ctv-table #tableRef [defaultSortColumn]="'containerName'"
[items]="endpoints"
(filtereditems)="filteredendpoints=$event"
[size]="12">
<thead>
<tr>
<div class="ui grid" style="margin-top: 25px;margin-left: 25px;margin-bottom: 1px;">
<th class="five wide column"><ctv-th [sortfield]="'containerName'" (sortdata)="tableRef.applysort($event)" [sortobject]="tableRef.sortObj"> Container Name </ctv-th></th>
<th class="four wide column"><ctv-th [sortfield]="'ipAddress'" (sortdata)="tableRef.applysort($event)" [sortobject]="tableRef.sortObj"> IP Address </ctv-th></th>
<th class="three wide column"><ctv-th [sortfield]="'homingHost'" (sortdata)="tableRef.applysort($event)" [sortobject]="tableRef.sortObj"> Host </ctv-th></th>
<th class="four wide column">
<ctv-search (searchTextChange)="tableRef.showChunk(tableRef.table.pageNo,$event);" [placeholder]="'Search Containers...'"></ctv-search>
</th>
</div>
</tr>
</thead>

<tbody>
<tr *ngFor="let endpoint of filteredendpoints">
<td>
<ctv-accordion [items]="containerDetails[endpoint.containerID]">
<div class="ui grid" style="margin-top: -33px; margin-left: 30px;">
<div class="five wide column">{{endpoint.containerName.substr(1)}}</div>
<div class="four wide column">{{endpoint.ipAddress.join(' ')}}</div>
<div class="four wide column">{{endpoint.homingHost}}</div>
</div>
</ctv-accordion>
</td>
<td></td>
</tr>
</tbody>

<tfoot>
<tr>
<td colspan="5">
<ctv-tpagination [chunks]="tableRef.pageChunks"
(showPage)="tableRef.showChunk($event, tableRef.table.searchText)"
(prevChunk)="tableRef.showPrevChunk()"
(nextChunk)="tableRef.showNextChunk()">
</ctv-tpagination>
</td>
</tr>
</tfoot>
</ctv-table>
</ctv-collapsible>
</div>
83 changes: 83 additions & 0 deletions app/applicationgroups/applicationgroupstats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* Created by cshampur on 11/18/16.
*/

import {Component, NgZone, Input, OnInit, OnDestroy} from "@angular/core";
import {ApplicationGroupsModel} from "../components/models/applicationgroupsmodel";
import {CRUDHelperService} from "../components/utils/crudhelperservice";
import {InspectService} from "../components/utils/inspectservice";
import {Subscription, Observable} from "rxjs";
import {ContivGlobals} from "../components/models/contivglobals";
import {isUndefined} from "util";
@Component({
selector: 'applicationgroupstats',
templateUrl: 'applicationgroups/applicationgroupstats.html'
})

export class ApplicationGroupStatsComponent implements OnInit, OnDestroy{
@Input('statkey') statkey: string;
public applicationInspectStats: any;
private refresh: Subscription;
public showLoader: boolean;
config:any; endpoints:any; filteredendpoints: any; containerDetails: any;
constructor(private applicationGroupsModel: ApplicationGroupsModel,
private crudHelperService: CRUDHelperService,
private inspectService: InspectService,
private ngZone: NgZone){
this.statkey = '';
this.applicationInspectStats = {
externalPktTag: '',
numEndpoints: '',
pktTag: ''
}
this.config = {networkName: '', groupName: ''}
this.endpoints = [];
this.filteredendpoints = [];
this.containerDetails= {};
this.refresh = Observable.interval(5000).subscribe(() => {
if(this.statkey!='')
this.getApplicationgroupInspect(true);
});
}

ngOnInit(){
this.crudHelperService.startLoader(this);
if(this.statkey!='')
this.getApplicationgroupInspect(false);
}

getApplicationgroupInspect(reload: boolean){
var applicationStatsCtrl = this;
this.applicationGroupsModel.getInspectByKey(this.statkey, ContivGlobals.APPLICATIONGROUPS_INSPECT_ENDPOINT, reload)
.then((result) => {
applicationStatsCtrl['applicationInspectStats'] = result['Oper'];
applicationStatsCtrl['config'] = result['Config'];
if(!isUndefined(result['Oper'].endpoints)){
var containerDetails = applicationStatsCtrl.inspectService.buildEndPoints(result['Oper'].endpoints);
if(applicationStatsCtrl.inspectService.checkContainerChanged(applicationStatsCtrl['containerDetails'],containerDetails)){
applicationStatsCtrl['endpoints'] = result['Oper'].endpoints;
applicationStatsCtrl['containerDetails'] = containerDetails;
}
}
else{
applicationStatsCtrl['endpoints'] = [];
applicationStatsCtrl['containerDetails'] = {};
}
applicationStatsCtrl.ngZone.run(() => {
applicationStatsCtrl.crudHelperService.stopLoader(applicationStatsCtrl);
});
},
(error) => {
applicationStatsCtrl.ngZone.run(() => {
applicationStatsCtrl.crudHelperService.stopLoader(applicationStatsCtrl);
});
});


}

ngOnDestroy(){
this.refresh.unsubscribe();
}

}
1 change: 1 addition & 0 deletions app/components/models/contivglobals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const ContivGlobals = {
'POLICIES_ENDPOINT': '/netmaster/api/v1/policys/',
'RULES_ENDPOINT': '/netmaster/api/v1/rules/',
'APPLICATIONGROUPS_ENDPOINT': '/netmaster/api/v1/endpointGroups/',
'APPLICATIONGROUPS_INSPECT_ENDPOINT': 'netmaster/api/v1/inspect/endpointGroups/',
'SERVICELBS_ENDPOINT': '/netmaster/api/v1/serviceLBs/',
'ORGANIZATIONS_ENDPOINT':'/netmaster/api/v1/tenants/',
'NETWORK_SETTINGS_ENDPOINT': '/netmaster/api/v1/globals/',
Expand Down
Loading

0 comments on commit e67539b

Please sign in to comment.