Skip to content

Commit 1b0ee3e

Browse files
committed
changes for resource icon
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent e8f8378 commit 1b0ee3e

File tree

8 files changed

+31
-7
lines changed

8 files changed

+31
-7
lines changed

api/src/main/java/com/cloud/server/ResourceTag.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public enum ResourceObjectType {
6666
LBStickinessPolicy(false, true),
6767
LBHealthCheckPolicy(false, true),
6868
SnapshotPolicy(true, true),
69+
GuestOsCategory(false, false, true),
6970
GuestOs(false, true),
7071
NetworkOffering(false, true),
7172
VpcOffering(true, false),

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import com.cloud.storage.GuestOsCategory;
2727

2828
@EntityReference(value = GuestOsCategory.class)
29-
public class GuestOSCategoryResponse extends BaseResponse {
29+
public class GuestOSCategoryResponse extends BaseResponse implements SetResourceIconResponse {
3030
@SerializedName(ApiConstants.ID)
3131
@Param(description = "the ID of the OS category")
3232
private String id;
@@ -36,9 +36,13 @@ public class GuestOSCategoryResponse extends BaseResponse {
3636
private String name;
3737

3838
@SerializedName(ApiConstants.IS_FEATURED)
39-
@Param(description = "Whether the OS category is featured")
39+
@Param(description = "Whether the OS category is featured", since = "4.20.1")
4040
private Boolean featured;
4141

42+
@SerializedName(ApiConstants.RESOURCE_ICON)
43+
@Param(description = "Base64 string representation of the resource icon", since = "4.20.1")
44+
private ResourceIconResponse resourceIconResponse;
45+
4246
public String getId() {
4347
return id;
4448
}
@@ -58,4 +62,9 @@ public void setName(String name) {
5862
public void setFeatured(Boolean featured) {
5963
this.featured = featured;
6064
}
65+
66+
@Override
67+
public void setResourceIconResponse(ResourceIconResponse resourceIconResponse) {
68+
this.resourceIconResponse = resourceIconResponse;
69+
}
6170
}

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import com.cloud.dc.dao.ASNumberRangeDao;
4949
import com.cloud.dc.dao.VlanDetailsDao;
5050
import com.cloud.hypervisor.Hypervisor;
51+
import com.cloud.resource.icon.ResourceIconVO;
5152
import com.cloud.storage.BucketVO;
5253
import org.apache.cloudstack.acl.ControlledEntity;
5354
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
@@ -3884,6 +3885,12 @@ public GuestOSCategoryResponse createGuestOSCategoryResponse(GuestOsCategory gue
38843885
categoryResponse.setId(guestOsCategory.getUuid());
38853886
categoryResponse.setName(guestOsCategory.getName());
38863887
categoryResponse.setFeatured(guestOsCategory.isFeatured());
3888+
ResourceIconVO resourceIcon = ApiDBUtils.getResourceIconByResourceUUID(guestOsCategory.getUuid(),
3889+
ResourceObjectType.GuestOsCategory);
3890+
if (resourceIcon != null) {
3891+
ResourceIconResponse iconResponse = ApiDBUtils.newResourceIconResponse(resourceIcon);
3892+
categoryResponse.setResourceIconResponse(iconResponse);
3893+
}
38873894
categoryResponse.setObjectName("oscategory");
38883895
return categoryResponse;
38893896
}

server/src/main/java/com/cloud/tags/ResourceManagerUtilImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import com.cloud.server.ResourceTag;
5959
import com.cloud.service.ServiceOfferingVO;
6060
import com.cloud.storage.DiskOfferingVO;
61+
import com.cloud.storage.GuestOsCategory;
6162
import com.cloud.storage.SnapshotPolicyVO;
6263
import com.cloud.storage.SnapshotVO;
6364
import com.cloud.storage.VMTemplateVO;
@@ -117,6 +118,7 @@ public class ResourceManagerUtilImpl implements ResourceManagerUtil {
117118
s_typeMap.put(ResourceTag.ResourceObjectType.NetworkOffering, NetworkOfferingVO.class);
118119
s_typeMap.put(ResourceTag.ResourceObjectType.VpcOffering, VpcOfferingVO.class);
119120
s_typeMap.put(ResourceTag.ResourceObjectType.Domain, DomainVO.class);
121+
s_typeMap.put(ResourceTag.ResourceObjectType.GuestOsCategory, GuestOsCategory.class);
120122
}
121123

122124
@Inject

ui/src/components/view/InfoCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<resource-icon :image="getImage(resource.icon && resource.icon.base64image || images.template || images.iso || resourceIcon)" size="4x" style="margin-right: 5px"/>
3535
</span>
3636
<span v-else>
37-
<os-logo v-if="resource.ostypeid || resource.ostypename" :osId="resource.ostypeid" :osName="resource.ostypename" size="3x" @update-osname="setResourceOsType"/>
37+
<os-logo v-if="resource.ostypeid || resource.ostypename || ['guestoscategory'].includes($route.path.split('/')[1])" :osId="resource.ostypeid" :osName="resource.ostypename || resource.name" size="3x" @update-osname="setResourceOsType"/>
3838
<render-icon v-else-if="typeof $route.meta.icon ==='string'" style="font-size: 36px" :icon="$route.meta.icon" />
3939
<font-awesome-icon
4040
v-else-if="$route.meta.icon && Array.isArray($route.meta.icon)"

ui/src/components/view/ListView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
</span>
5959
<span v-if="$showIcon() && !['vm', 'vnfapp'].includes($route.path.split('/')[1])" style="margin-right: 5px">
6060
<resource-icon v-if="$showIcon() && record.icon && record.icon.base64image" :image="record.icon.base64image" size="2x"/>
61-
<os-logo v-else-if="record.ostypename" :osName="record.ostypename" size="xl" />
61+
<os-logo v-else-if="record.ostypename || ['guestoscategory'].includes($route.path.split('/')[1])" :osName="record.ostypename || record.name" size="xl" />
6262
<render-icon v-else-if="typeof $route.meta.icon ==='string'" style="font-size: 16px;" :icon="$route.meta.icon"/>
6363
<render-icon v-else style="font-size: 16px;" :svgIcon="$route.meta.icon" />
6464
</span>

ui/src/utils/plugins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export const showIconPlugin = {
338338
if (resource) {
339339
resourceType = resource
340340
}
341-
if (['zone', 'zones', 'template', 'iso', 'account', 'accountuser', 'vm', 'domain', 'project', 'vpc', 'guestnetwork'].includes(resourceType)) {
341+
if (['zone', 'zones', 'template', 'iso', 'account', 'accountuser', 'vm', 'domain', 'project', 'vpc', 'guestnetwork', 'guestoscategory'].includes(resourceType)) {
342342
return true
343343
} else {
344344
return false

ui/src/views/compute/DeployVM.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,15 @@
212212
style="border-width: 2px"
213213
:class="'square-block-radio-button'">
214214
<div style="text-align: center;">
215+
<resource-icon
216+
v-if="item.icon && item.icon.base64image"
217+
class="radio-group__os-logo"
218+
:image="item.icon.base64image"
219+
size="2x"/>
215220
<os-logo
221+
v-else
216222
class="radio-group__os-logo"
217223
size="2x"
218-
:osId="item.id"
219224
:os-name="item.name" />
220225
<br>
221226
{{ item.name }}
@@ -241,7 +246,7 @@
241246
<a-select-option v-for="item in options.guestOsCategories" :key="item.id" :label="item.name">
242247
<span>
243248
<resource-icon v-if="item.icon && item.icon.base64image" :image="item.icon.base64image" size="2x" style="margin-right: 5px"/>
244-
<global-outlined v-else style="margin-right: 5px" />
249+
<os-logo v-else :os-name="item.name" style="margin-right: 5px" />
245250
{{ item.name }}
246251
</span>
247252
</a-select-option>

0 commit comments

Comments
 (0)