Skip to content

Commit 525cc58

Browse files
committed
Polish UI
1 parent 83e6888 commit 525cc58

File tree

8 files changed

+194
-25
lines changed

8 files changed

+194
-25
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ public class ApiConstants {
581581
public static final String SUITABLE_FOR_VM = "suitableforvirtualmachine";
582582
public static final String SUPPORTS_STORAGE_SNAPSHOT = "supportsstoragesnapshot";
583583
public static final String TARGET_IQN = "targetiqn";
584+
public static final String TASKS_FILTER = "tasksfilter";
584585
public static final String TEMPLATE_FILTER = "templatefilter";
585586
public static final String TEMPLATE_ID = "templateid";
586587
public static final String TEMPLATE_IDS = "templateids";

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ListImportVMTasksCmd.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.apache.cloudstack.api.response.ListResponse;
3636
import org.apache.cloudstack.api.response.ZoneResponse;
3737
import org.apache.cloudstack.context.CallContext;
38-
import org.apache.cloudstack.vm.ImportVmTask;
3938
import org.apache.cloudstack.vm.ImportVmTasksManager;
4039

4140
import javax.inject.Inject;
@@ -76,8 +75,8 @@ public class ListImportVMTasksCmd extends BaseListCmd {
7675
description = "Conversion host of the importing task")
7776
private Long convertHostId;
7877

79-
@Parameter(name = ApiConstants.STATE, type = CommandType.STRING, description = "List tasks by status, valid options are: Running, Completed, Failed")
80-
private String state;
78+
@Parameter(name = ApiConstants.TASKS_FILTER, type = CommandType.STRING, description = "Filter tasks by status, valid options are: All, Running, Completed, Failed")
79+
private String tasksFilter;
8180

8281
public Long getZoneId() {
8382
return zoneId;
@@ -95,8 +94,8 @@ public Long getConvertHostId() {
9594
return convertHostId;
9695
}
9796

98-
public String getState() {
99-
return state == null ? ImportVmTask.TaskState.Running.name() : state;
97+
public String getTasksFilter() {
98+
return tasksFilter;
10099
}
101100

102101
@Override

engine/schema/src/main/java/com/cloud/vm/dao/ImportVMTaskDaoImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ public Pair<List<ImportVMTaskVO>, Integer> listImportVMTasks(Long zoneId, Long a
6565
if (convertHostId != null) {
6666
sc.setParameters("convertHostId", convertHostId);
6767
}
68-
sc.setParameters("state", state);
68+
if (state != null) {
69+
sc.setParameters("state", state);
70+
}
6971
Filter filter = new Filter(ImportVMTaskVO.class, "created", false, startIndex, pageSizeVal);
7072
return searchAndCount(sc, filter);
7173
}

server/src/main/java/org/apache/cloudstack/vm/ImportVmTasksManagerImpl.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.cloudstack.api.command.admin.vm.ListImportVMTasksCmd;
3636
import org.apache.cloudstack.api.response.ImportVMTaskResponse;
3737
import org.apache.cloudstack.api.response.ListResponse;
38+
import org.apache.commons.lang3.StringUtils;
3839
import org.apache.logging.log4j.LogManager;
3940
import org.apache.logging.log4j.Logger;
4041

@@ -78,13 +79,7 @@ public ListResponse<ImportVMTaskResponse> listImportVMTasks(ListImportVMTasksCmd
7879
Long startIndex = cmd.getStartIndex();
7980
Long pageSizeVal = cmd.getPageSizeVal();
8081

81-
ImportVmTask.TaskState state;
82-
try {
83-
state = ImportVmTask.TaskState.getValue(cmd.getState());
84-
} catch (IllegalArgumentException e) {
85-
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid value for task state: " + cmd.getState());
86-
}
87-
82+
ImportVmTask.TaskState state = getStateFromFilter(cmd.getTasksFilter());
8883
Pair<List<ImportVMTaskVO>, Integer> result = importVMTaskDao.listImportVMTasks(zoneId, accountId, vcenter, convertHostId, state, startIndex, pageSizeVal);
8984
List<ImportVMTaskVO> tasks = result.first();
9085

@@ -97,6 +92,17 @@ public ListResponse<ImportVMTaskResponse> listImportVMTasks(ListImportVMTasksCmd
9792
return listResponses;
9893
}
9994

95+
private ImportVmTask.TaskState getStateFromFilter(String tasksFilter) {
96+
if (StringUtils.isBlank(tasksFilter) || tasksFilter.equalsIgnoreCase("all")) {
97+
return null;
98+
}
99+
try {
100+
return ImportVmTask.TaskState.getValue(tasksFilter);
101+
} catch (IllegalArgumentException e) {
102+
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, String.format("Invalid value for task state: %s", tasksFilter));
103+
}
104+
}
105+
100106
@Override
101107
public ImportVmTask createImportVMTaskRecord(DataCenter zone, Account owner, long userId, String displayName, String vcenter, String datacenterName, String sourceVMName, Host convertHost, Host importHost) {
102108
logger.debug("Creating import VM task entry for VM: {} for account {} on zone {} " +

ui/public/config.json

Lines changed: 144 additions & 1 deletion
Large diffs are not rendered by default.

ui/public/locales/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@
635635
"label.continue": "Continue",
636636
"label.continue.install": "Continue with installation",
637637
"label.controlnodes": "Control nodes",
638+
"label.conversionhost": "Conversion Host",
638639
"label.copied.clipboard": "Copied to clipboard",
639640
"label.copy": "Copy",
640641
"label.copy.clipboard": "Copy to clipboard",
@@ -699,6 +700,8 @@
699700
"label.crosszones": "Cross Zones",
700701
"label.currency": "Currency",
701702
"label.current": "Current",
703+
"label.currentstep": "Current step",
704+
"label.currentstep.duration": "Current step duration",
702705
"label.current.storage": "Current storage",
703706
"label.currentpassword": "Current password",
704707
"label.custom": "Custom",
@@ -2313,6 +2316,7 @@
23132316
"label.sourcenattype": "Supported source NAT type",
23142317
"label.sourceport": "Source port",
23152318
"label.sourcetype": "Source type",
2319+
"label.sourcevmname": "Source VM Name",
23162320
"label.specifyasnumber": "Specify AS Number",
23172321
"label.specifyipranges": "Specify IP ranges",
23182322
"label.specifyvlan": "Specify VLAN",
@@ -2880,6 +2884,7 @@
28802884
"label.leaseexpiryaction": "Lease expiry action",
28812885
"label.remainingdays": "Lease",
28822886
"label.leased": "Leased",
2887+
"label.totalduration": "Total duration",
28832888
"label.usestoragereplication": "Use primary storage replication",
28842889
"message.acquire.ip.failed": "Failed to acquire IP.",
28852890
"message.action.acquire.ip": "Please confirm that you want to acquire new IP.",

ui/src/views/tools/ImportVmTasks.vue

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
<router-link v-if="record.virtualmachineid" :to="{ path: '/vm/' + record.virtualmachineid }">{{ record.displayname }}</router-link>
7171
<span v-else>{{ record.displayname }}</span>
7272
</template>
73+
<template v-else-if="column.key === 'created'">
74+
<span>{{ $toLocaleDate(record.created) }}</span>
75+
</template>
7376
</template>
7477
</a-table>
7578
<div class="instances-card-footer">
@@ -125,55 +128,65 @@ export default {
125128
},
126129
data () {
127130
const columns = [
131+
{
132+
key: 'created',
133+
title: this.$t('label.created'),
134+
dataIndex: 'created'
135+
},
128136
{
129137
key: 'displayname',
130-
title: 'VM Display Name',
138+
title: this.$t('label.displayname'),
131139
dataIndex: 'displayname'
132140
},
133141
{
134142
key: 'convertinstancehostid',
135-
title: 'Conversion Host',
143+
title: this.$t('label.conversionhost'),
136144
dataIndex: 'convertinstancehostid'
137145
},
138146
{
139147
key: 'step',
140-
title: 'Current Step',
148+
title: this.$t('label.currentstep'),
141149
dataIndex: 'step'
142150
},
143151
{
144152
key: 'stepduration',
145-
title: 'Current Step Duration',
153+
title: this.$t('label.currentstep.duration'),
146154
dataIndex: 'stepduration'
147155
},
148156
{
149157
key: 'description',
150-
title: 'Description',
158+
title: this.$t('label.description'),
151159
dataIndex: 'description'
152160
},
153161
{
154162
key: 'duration',
155-
title: 'Total Duration',
163+
title: this.$t('label.totalduration'),
156164
dataIndex: 'duration'
157165
},
158166
{
159167
key: 'sourcevmname',
160-
title: 'Source VM Name',
168+
title: this.$t('label.sourcevmname'),
161169
dataIndex: 'sourcevmname'
162170
},
163171
{
164172
key: 'vcenter',
165-
title: 'vCenter',
173+
title: this.$t('label.vcenter'),
166174
dataIndex: 'vcenter'
167175
},
168176
{
169177
key: 'datacentername',
170-
title: 'Datacenter Name',
178+
title: this.$t('label.vcenter.datacenter'),
171179
dataIndex: 'datacentername'
180+
},
181+
{
182+
key: 'state',
183+
title: this.$t('label.state'),
184+
dataIndex: 'state'
172185
}
173186
]
174187
return {
175188
columns,
176-
filters: ['running', 'completed', 'failed'],
189+
filters: ['all', 'running', 'completed', 'failed'],
177190
filterValue: 'running'
178191
}
179192
},

ui/src/views/tools/ManageInstances.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ export default {
12041204
zoneid: this.zoneId,
12051205
page: this.page.tasks,
12061206
pagesize: this.pageSize.tasks,
1207-
state: this.importVmTasksFilter
1207+
tasksfilter: this.importVmTasksFilter
12081208
}
12091209
getAPI('listImportVmTasks', params).then(response => {
12101210
this.itemCount.tasks = response.listimportvmtasksresponse.count

0 commit comments

Comments
 (0)