Skip to content

Commit 62b332e

Browse files
authored
api, ui: listing archived events (#7396)
Fixes #7217 Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 59a2b31 commit 62b332e

9 files changed

Lines changed: 62 additions & 7 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class ApiConstants {
3232
public static final String ALLOCATED_ONLY = "allocatedonly";
3333
public static final String ANNOTATION = "annotation";
3434
public static final String API_KEY = "apikey";
35+
public static final String ARCHIVED = "archived";
3536
public static final String ASYNC_BACKUP = "asyncbackup";
3637
public static final String AUTO_SELECT = "autoselect";
3738
public static final String USER_API_KEY = "userapikey";

api/src/main/java/org/apache/cloudstack/api/command/user/event/ListEventsCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public class ListEventsCmd extends BaseListProjectAndAccountResourcesCmd {
7272
@Parameter(name = ApiConstants.RESOURCE_TYPE, type = CommandType.STRING, description = "the type of the resource associated with the event", since="4.17.0")
7373
private String resourceType;
7474

75+
@Parameter(name = ApiConstants.ARCHIVED, type = CommandType.BOOLEAN, description = "true to list archived events otherwise false", since="4.19.0")
76+
private Boolean archived;
77+
7578
/////////////////////////////////////////////////////
7679
/////////////////// Accessors ///////////////////////
7780
/////////////////////////////////////////////////////
@@ -116,6 +119,10 @@ public String getResourceType() {
116119
return resourceType;
117120
}
118121

122+
public boolean getArchived() {
123+
return archived != null && archived;
124+
}
125+
119126
/////////////////////////////////////////////////////
120127
/////////////// API Implementation///////////////////
121128
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/response/EventResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public class EventResponse extends BaseResponse implements ControlledViewEntityR
9393
@Param(description = "whether the event is parented")
9494
private String parentId;
9595

96+
@SerializedName(ApiConstants.ARCHIVED)
97+
@Param(description = "whether the event has been archived or not")
98+
private Boolean archived;
99+
96100
public void setId(String id) {
97101
this.id = id;
98102
}
@@ -173,4 +177,8 @@ public void setProjectId(String projectId) {
173177
public void setProjectName(String projectName) {
174178
this.projectName = projectName;
175179
}
180+
181+
public void setArchived(Boolean archived) {
182+
this.archived = archived;
183+
}
176184
}

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,9 @@ private Pair<List<EventJoinVO>, Integer> searchForEventsInternal(ListEventsCmd c
790790
sc.setParameters("resourceType", resourceType.toString());
791791
}
792792

793-
sc.setParameters("archived", false);
793+
if (id == null) {
794+
sc.setParameters("archived", cmd.getArchived());
795+
}
794796

795797
Pair<List<EventJoinVO>, Integer> eventPair = null;
796798
// event_view will not have duplicate rows for each event, so

server/src/main/java/com/cloud/event/dao/EventJoinDaoImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ public EventResponse newEventResponse(EventJoinVO event) {
110110
responseEvent.setParentId(event.getStartUuid());
111111
responseEvent.setState(event.getState());
112112
responseEvent.setUsername(event.getUserName());
113+
if (event.getArchived()) {
114+
responseEvent.setArchived(true);
115+
}
113116
Long resourceId = event.getResourceId();
114117
responseEvent.setResourceType(event.getResourceType());
115118
ApiCommandResourceType resourceType = ApiCommandResourceType.fromString(event.getResourceType());

ui/public/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
"label.action.vmsnapshot.revert": "Revert to VM snapshot",
188188
"label.action.vmstoragesnapshot.create": "Take VM volume snapshot",
189189
"label.actions": "Actions",
190+
"label.active": "Active",
190191
"label.activate.project": "Activate project",
191192
"label.activeviewersessions": "Active sessions",
192193
"label.add": "Add",
@@ -329,6 +330,7 @@
329330
"label.apply.tungsten.network.policy": "Apply Network Policy",
330331
"label.apply.tungsten.tag": "Apply tag",
331332
"label.archive": "Archive",
333+
"label.archived": "Archived",
332334
"label.archive.alerts": "Archive alerts",
333335
"label.archive.events": "Archive events",
334336
"label.as.default": "as default",

ui/src/components/view/InfoCard.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
<a-tag v-if="resource.internetprotocol && ['IPv6', 'DualStack'].includes(resource.internetprotocol)">
8585
{{ resource.internetprotocol ? $t('label.ip.v4.v6') : resource.internetprotocol }}
8686
</a-tag>
87+
<a-tag v-if="resource.archived" :color="this.$config.theme['@warning-color']">
88+
{{ $t('label.archived') }}
89+
</a-tag>
8790
<a-tooltip placement="right" >
8891
<template #title>
8992
<span>{{ $t('label.view.console') }}</span>

ui/src/config/section/event.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export default {
2929
title: 'label.event.timeline',
3030
param: 'startid'
3131
}],
32+
filters: () => {
33+
return ['active', 'archived']
34+
},
3235
actions: [
3336
{
3437
api: 'archiveEvents',
@@ -45,6 +48,12 @@ export default {
4548
ids: {
4649
value: (record) => { return record.id }
4750
}
51+
},
52+
show: (record) => {
53+
return !(record.archived)
54+
},
55+
groupShow: (selectedItems) => {
56+
return selectedItems.filter(x => { return !(x.archived) }).length > 0
4857
}
4958
},
5059
{

ui/src/views/AutogenView.vue

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@
5353
<a-select
5454
v-if="!dataView && filters && filters.length > 0"
5555
:placeholder="$t('label.filterby')"
56-
:value="$route.query.filter || (projectView && $route.name === 'vm' ||
57-
['Admin', 'DomainAdmin'].includes($store.getters.userInfo.roletype) && ['vm', 'iso', 'template'].includes($route.name)
58-
? 'all' : ['publicip'].includes($route.name)
59-
? 'allocated' : ['guestnetwork', 'guestvlans'].includes($route.name)
60-
? 'all' : ['volume'].includes($route.name)
61-
? 'user' : 'self')"
56+
:value="filterValue"
6257
style="min-width: 120px; margin-left: 10px"
6358
@change="changeFilter"
6459
showSearch
@@ -670,6 +665,25 @@ export default {
670665
return [...new Set(sizes)].sort(function (a, b) {
671666
return a - b
672667
}).map(String)
668+
},
669+
filterValue () {
670+
if (this.$route.query.filter) {
671+
return this.$route.query.filter
672+
}
673+
const routeName = this.$route.name
674+
if ((this.projectView && routeName === 'vm') || (['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype) && ['vm', 'iso', 'template'].includes(routeName)) || ['guestnetwork', 'guestvlans'].includes(routeName)) {
675+
return 'all'
676+
}
677+
if (['publicip'].includes(routeName)) {
678+
return 'allocated'
679+
}
680+
if (['volume'].includes(routeName)) {
681+
return 'user'
682+
}
683+
if (['event'].includes(routeName)) {
684+
return 'active'
685+
}
686+
return 'self'
673687
}
674688
},
675689
methods: {
@@ -1593,6 +1607,12 @@ export default {
15931607
} else if (filter === 'allocatedonly') {
15941608
query.allocatedonly = 'true'
15951609
}
1610+
} else if (this.$route.name === 'event') {
1611+
if (filter === 'archived') {
1612+
query.archived = true
1613+
} else {
1614+
delete query.archived
1615+
}
15961616
}
15971617
query.filter = filter
15981618
query.page = '1'

0 commit comments

Comments
 (0)