Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blitz - Add cf events page to cf, org and space levels #4066

Merged
merged 21 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
28 changes: 15 additions & 13 deletions src/frontend/packages/cloud-foundry/src/cf-entity-generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as moment from 'moment';

import {
IService,
IServiceBinding,
Expand Down Expand Up @@ -39,6 +40,7 @@ import {
JetstreamError,
} from '../../store/src/entity-request-pipeline/entity-request-base-handlers/handle-multi-endpoints.pipe';
import { JetstreamResponse } from '../../store/src/entity-request-pipeline/entity-request-pipeline.types';
import { EntitySchema } from '../../store/src/helpers/entity-schema';
import { endpointDisconnectRemoveEntitiesReducer } from '../../store/src/reducers/endpoint-disconnect-application.reducer';
import { APIResource } from '../../store/src/types/api.types';
import { IFavoriteMetadata } from '../../store/src/types/user-favorites.types';
Expand All @@ -47,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 @@ -83,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 @@ -129,8 +131,6 @@ import { AppStat } from './store/types/app-metadata.types';
import { CFResponse } from './store/types/cf-api.types';
import { GitBranch, GitCommit, GitRepo } from './store/types/git.types';
import { CfUser } from './store/types/user.types';
import { CfApplicationState } from './store/types/application.types';
import { EntitySchema } from '../../store/src/helpers/entity-schema';

export interface CFBasePipelineRequestActionMeta {
includeRelations?: string[];
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