Skip to content

Commit

Permalink
Blitz - Add cf events page to cf, org and space levels (#4066)
Browse files Browse the repository at this point in the history
* Basic events view

* Improve events view

* Tidying up a tad

* Add events pages to org and space levels

* Create copy-to-clipboard component, use for `copy guid` of actee

* Wrap filters & list in component, inject filters into list

* First pass of todos

* Fix bug where new q overwrite previous q

* Fix more todos

* Improvements, apply new event list to org/space levels

* Fix unit tests, code climate

* Fix some api component test warnings

* Fix new failing unit test

* Fix failing e2e tests

* Handle large details sections which borked the list performance

* Tweaks following review

* Show link instead of copy button, fix multiple api requests after single change

* Fix unit test

* Add clear button to the Actee GUID filter

Co-authored-by: Neil MacDougall <nwmac@users.noreply.github.com>
  • Loading branch information
richard-cox and nwmac committed Jan 8, 2020
1 parent 7c94858 commit 33770f2
Show file tree
Hide file tree
Showing 98 changed files with 1,565 additions and 438 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { HttpParams, HttpRequest } from '@angular/common/http';

import { QParam, QParamJoiners } from '../../../store/src/q-param';
import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { cfEntityFactory } from '../cf-entity-factory';
import { appEventEntityType } from '../cf-entity-types';
import { cfEventEntityType } from '../cf-entity-types';
import { CFStartAction } from './cf-action.types';
import { HttpRequest, HttpParams } from '@angular/common/http';

export const AppGetAllEvents = {
GET_ALL: '[Application Event] Get all',
Expand Down Expand Up @@ -34,8 +35,8 @@ export class GetAllAppEvents extends CFStartAction implements PaginatedAction {
AppGetAllEvents.GET_ALL_FAILED
];

entity = [cfEntityFactory(appEventEntityType)];
entityType = appEventEntityType;
entity = [cfEntityFactory(cfEventEntityType)];
entityType = cfEventEntityType;
options: HttpRequest<any>;
initialParams = {
'order-direction': 'desc',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { HttpParams, HttpRequest } from '@angular/common/http';

import { endpointSchemaKey } from '../../../store/src/helpers/entity-factory';
import { PaginatedAction } from '../../../store/src/types/pagination.types';
import { cfEntityFactory } from '../cf-entity-factory';
import { cfEventEntityType } from '../cf-entity-types';
import { createEntityRelationPaginationKey } from '../entity-relations/entity-relations.types';
import { CFStartAction } from './cf-action.types';

export const CfGetAllEvents = {
GET_ALL: '[Cf Event] Get all',
GET_ALL_SUCCESS: '[Cf Event] Get all success',
GET_ALL_FAILED: '[Cf Event] Get all failed',
};

export class GetAllCfEvents extends CFStartAction implements PaginatedAction {
private static sortField = 'timestamp'; // This is the field that 'order-direction' is applied to. Cannot be changed

constructor(public paginationKey: string, public endpointGuid) {
super();
this.paginationKey = this.paginationKey || createEntityRelationPaginationKey(endpointSchemaKey, endpointGuid);
this.options = new HttpRequest(
'GET',
'events',
{
params: new HttpParams({
fromObject: {
'': ''
}
})
}
);
}
actions = [
CfGetAllEvents.GET_ALL,
CfGetAllEvents.GET_ALL_SUCCESS,
CfGetAllEvents.GET_ALL_FAILED
];

entity = [cfEntityFactory(cfEventEntityType)];
entityType = cfEventEntityType;
options: HttpRequest<any>;
initialParams = {
'order-direction': 'desc',
'order-direction-field': GetAllCfEvents.sortField,
q: []
// q: [
// new QParam('actee', this.appGuid, QParamJoiners.colon).toString(),
// ]
};
}
6 changes: 3 additions & 3 deletions src/frontend/packages/cloud-foundry/src/cf-entity-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
} from './cf-entity-schema-types';
import {
appEnvVarsEntityType,
appEventEntityType,
applicationEntityType,
appStatsEntityType,
appSummaryEntityType,
buildpackEntityType,
cfEventEntityType,
cfInfoEntityType,
cfUserEntityType,
domainEntityType,
Expand Down Expand Up @@ -73,8 +73,8 @@ entityCache[gitCommitEntityType] = GithubCommitSchema;
const CFInfoSchema = new CFEntitySchema(cfInfoEntityType);
entityCache[cfInfoEntityType] = CFInfoSchema;

const EventSchema = new CFEntitySchema(appEventEntityType, {}, { idAttribute: getAPIResourceGuid });
entityCache[appEventEntityType] = EventSchema;
const EventSchema = new CFEntitySchema(cfEventEntityType, {}, { idAttribute: getAPIResourceGuid });
entityCache[cfEventEntityType] = EventSchema;

const StackSchema = new CFEntitySchema(stackEntityType, {}, { idAttribute: getAPIResourceGuid });
entityCache[stackEntityType] = StackSchema;
Expand Down
24 changes: 13 additions & 11 deletions src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ import { cfEntityFactory } from './cf-entity-factory';
import { addCfQParams, addCfRelationParams } from './cf-entity-relations.getters';
import {
appEnvVarsEntityType,
appEventEntityType,
applicationEntityType,
appStatsEntityType,
appSummaryEntityType,
buildpackEntityType,
cfEventEntityType,
cfInfoEntityType,
cfUserEntityType,
domainEntityType,
Expand Down Expand Up @@ -85,11 +85,11 @@ import {
import { CfErrorResponse, getCfError } from './cf-error-helpers';
import { IAppFavMetadata, IBasicCFMetaData, IOrgFavMetadata, ISpaceFavMetadata } from './cf-metadata-types';
import { appEnvVarActionBuilders } from './entity-action-builders/application-env-var.action-builders';
import { applicationEventActionBuilders } from './entity-action-builders/application-event.action-builders';
import { appStatsActionBuilders } from './entity-action-builders/application-stats.action-builders';
import { appSummaryActionBuilders } from './entity-action-builders/application-summary.action-builders';
import { applicationActionBuilder } from './entity-action-builders/application.action-builders';
import { buildpackActionBuilders } from './entity-action-builders/buildpack.action-builders';
import { cfEventActionBuilders } from './entity-action-builders/cf-event.action-builders';
import {
CfInfoDefinitionActionBuilders,
cfInfoDefinitionActionBuilders,
Expand Down Expand Up @@ -736,10 +736,10 @@ function generateGitBranchEntity(endpointDefinition: StratosEndpointExtensionDef

function generateEventEntity(endpointDefinition: StratosEndpointExtensionDefinition) {
const definition: IStratosEntityDefinition = {
type: appEventEntityType,
schema: cfEntityFactory(appEventEntityType),
label: 'Application Event',
labelPlural: 'Application Events',
type: cfEventEntityType,
schema: cfEntityFactory(cfEventEntityType),
label: 'Event',
labelPlural: 'Events',
endpoint: endpointDefinition
};
return new StratosCatalogueEntity<IBasicCFMetaData, APIResource>(
Expand All @@ -748,12 +748,14 @@ function generateEventEntity(endpointDefinition: StratosEndpointExtensionDefinit
dataReducers: [
endpointDisconnectRemoveEntitiesReducer()
],
actionBuilders: applicationEventActionBuilders,
actionBuilders: cfEventActionBuilders,
entityBuilder: {
getMetadata: app => ({
guid: app.metadata.guid,
name: app.metadata.guid,
}),
getMetadata: event => {
return {
guid: event.metadata.guid,
name: event.metadata.guid,
};
},
getGuid: metadata => metadata.guid,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/packages/cloud-foundry/src/cf-entity-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const routeEntityType = 'route';
export const domainEntityType = 'domain';
export const organizationEntityType = 'organization';
export const quotaDefinitionEntityType = 'quota_definition';
export const appEventEntityType = 'applicationEvent';
export const cfEventEntityType = 'cloudFoundryEvent';
export const cfInfoEntityType = 'cloudFoundryInfo';
export const cfUserEntityType = 'user';
export const appSummaryEntityType = 'applicationSummary';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { OrchestratedActionBuilders } from '../../../core/src/core/entity-catalogue/action-orchestrator/action-orchestrator';
import { GetAllCfEvents } from '../actions/cf-event.actions';

export interface CfEventActionBuilders extends OrchestratedActionBuilders {
getMultiple: (
endpointGuid: string,
paginationKey: string,
) => GetAllCfEvents;
}

export const cfEventActionBuilders: CfEventActionBuilders = {
getMultiple: (
endpointGuid: string,
paginationKey: string,
) => new GetAllCfEvents(paginationKey, endpointGuid)
};
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
<div class="events-tab">
<app-list></app-list>
</div>
<app-cloud-foundry-events-list [typeMustContain]="'audit.app'"></app-cloud-foundry-events-list>
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ import { PaginatedAction } from '../../../../../../../../store/src/types/paginat
import { WrapperRequestActionSuccess } from '../../../../../../../../store/src/types/request.types';
import { generateCfStoreModules } from '../../../../../../../test-framework/cloud-foundry-endpoint-service.helper';
import { cfEntityFactory } from '../../../../../../cf-entity-factory';
import { appEventEntityType } from '../../../../../../cf-entity-types';
import { cfEventEntityType } from '../../../../../../cf-entity-types';
import {
CloudFoundryEventsListComponent,
} from '../../../../../../shared/components/cloud-foundry-events-list/cloud-foundry-events-list.component';
import { ApplicationService } from '../../../../application.service';
import { ApplicationEnvVarsHelper } from '../build-tab/application-env-vars.service';
import { EventsTabComponent } from './events-tab.component';



describe('EventsTabComponent', () => {
class ApplicationServiceMock {
cfGuid = 'mockCfGuid';
Expand All @@ -35,11 +36,14 @@ describe('EventsTabComponent', () => {

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [EventsTabComponent],
declarations: [
EventsTabComponent,
CloudFoundryEventsListComponent
],
providers: [
{ provide: ApplicationService, useClass: ApplicationServiceMock },
ApplicationStateService,
ApplicationEnvVarsHelper,
ApplicationEnvVarsHelper
],
imports: [
...generateCfStoreModules(),
Expand All @@ -50,7 +54,7 @@ describe('EventsTabComponent', () => {
]
})
.compileComponents();
const eventsConfig: EntityCatalogueEntityConfig = cfEntityFactory(appEventEntityType);
const eventsConfig: EntityCatalogueEntityConfig = cfEntityFactory(cfEventEntityType);

const mappedData = {
entities: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component } from '@angular/core';

import { ListConfig } from '../../../../../../../../core/src/shared/components/list/list.component.types';
import {
CfAppEventsConfigService,
} from '../../../../../../shared/components/list/list-types/app-event/cf-app-events-config.service';
import { ListConfig } from '../../../../../../../../core/src/shared/components/list/list.component.types';
} from '../../../../../../shared/components/list/list-types/cf-events/types/cf-app-events-config.service';

@Component({
selector: 'app-events-tab',
Expand All @@ -14,7 +14,4 @@ import { ListConfig } from '../../../../../../../../core/src/shared/components/l
useClass: CfAppEventsConfigService,
}]
})

export class EventsTabComponent {

}
export class EventsTabComponent { }
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class CloudFoundryTabsBaseComponent implements OnInit {
{ link: 'stacks', label: 'Stacks', icon: 'code' },
{ link: 'security-groups', label: 'Security Groups', icon: 'security' },
{ link: 'quota-definitions', label: 'Organization Quotas', icon: 'data_usage' },
{ link: 'events', label: 'Events', icon: 'watch_later' },
...getTabsFromExtensions(StratosTabType.CloudFoundry)
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ import {
import { UsersRolesSelectComponent } from './users/manage-users/manage-users-select/manage-users-select.component';
import { UsersRolesComponent } from './users/manage-users/manage-users.component';
import { RemoveUserComponent } from './users/remove-user/remove-user.component';
import { CloudFoundryEventsComponent } from './tabs/cloud-foundry-events/cloud-foundry-events.component';
import { CloudFoundryOrganizationEventsComponent } from './tabs/cloud-foundry-organizations/cloud-foundry-organization-events/cloud-foundry-organization-events.component';
import { CloudFoundrySpaceEventsComponent } from './tabs/cloud-foundry-organizations/cloud-foundry-organization-spaces/tabs/cloud-foundry-space-events/cloud-foundry-space-events.component';


@NgModule({
Expand Down Expand Up @@ -213,6 +216,9 @@ import { RemoveUserComponent } from './users/remove-user/remove-user.component';
CfAdminAddUserWarningComponent,
QuotaDefinitionComponent,
SpaceQuotaDefinitionComponent,
CloudFoundryEventsComponent,
CloudFoundryOrganizationEventsComponent,
CloudFoundrySpaceEventsComponent,
],
providers: [
CFEndpointsListConfigService,
Expand Down
Loading

0 comments on commit 33770f2

Please sign in to comment.