Skip to content

Commit

Permalink
feat(config map): add binary data to config map detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
lsq645599166 committed Nov 1, 2024
1 parent 41611ad commit b4bf1f1
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 4 deletions.
9 changes: 7 additions & 2 deletions modules/api/pkg/resource/configmap/detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ type ConfigMapDetail struct {
// Data contains the configuration data.
// Each key must be a valid DNS_SUBDOMAIN with an optional leading dot.
Data map[string]string `json:"data,omitempty"`

// BinaryData contains the configuration binary data.
// Each key must be a valid DNS_SUBDOMAIN with an optional leading dot.
BinaryData map[string][]byte `json:"binaryData,omitempty"`
}

// GetConfigMapDetail returns detailed information about a config map
Expand All @@ -49,7 +53,8 @@ func GetConfigMapDetail(client kubernetes.Interface, namespace, name string) (*C

func getConfigMapDetail(rawConfigMap *v1.ConfigMap) *ConfigMapDetail {
return &ConfigMapDetail{
ConfigMap: toConfigMap(rawConfigMap.ObjectMeta),
Data: rawConfigMap.Data,
ConfigMap: toConfigMap(rawConfigMap.ObjectMeta),
Data: rawConfigMap.Data,
BinaryData: rawConfigMap.BinaryData,
}
}
10 changes: 8 additions & 2 deletions modules/api/schema/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -9999,10 +9999,16 @@
},
"configmap.ConfigMapDetail": {
"required": [
"typeMeta",
"objectMeta"
"objectMeta",
"typeMeta"
],
"properties": {
"binaryData": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"data": {
"type": "object",
"additionalProperties": {
Expand Down
12 changes: 12 additions & 0 deletions modules/web/i18n/de/messages.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2680,6 +2680,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/es/messages.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/fr/messages.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2668,6 +2668,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/ja/messages.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/ko/messages.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
9 changes: 9 additions & 0 deletions modules/web/i18n/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,15 @@
<trans-unit id="8967487471439603323" datatype="html">
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/zh-Hans/messages.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/zh-Hant-HK/messages.zh-Hant-HK.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
12 changes: 12 additions & 0 deletions modules/web/i18n/zh-Hant/messages.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,18 @@
<source>Hides all-namespaces option from the namespaces dropdown list in UI.</source>
<target state="new">Hides all-namespaces option from the namespaces dropdown list in UI.</target>
</trans-unit>
<trans-unit id="881679026777341622" datatype="html">
<source> Binary Data </source>
<target state="new"> Binary Data </target>
</trans-unit>
<trans-unit id="5313896736024470177" datatype="html">
<source> Key </source>
<target state="new"> Key </target>
</trans-unit>
<trans-unit id="2390412373676968256" datatype="html">
<source> Size </source>
<target state="new"> Size </target>
</trans-unit>
</body>
</file>
</xliff>
16 changes: 16 additions & 0 deletions modules/web/src/resource/config/configmap/detail/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,20 @@ export class ConfigMapDetailComponent implements OnInit, OnDestroy {

return JSON.stringify(cm.data);
}

getConfigMapBinaryData(cm: ConfigMapDetail): {
name: string;
size: number;
}[] {
if (!cm) {
return [];
}

return Object.entries(cm.binaryData).map(([name, value]) => ({
name,
size: atob(value).length,
}));
}

displayedBinaryDataColumns: string[] = ['name', 'size'];
}
49 changes: 49 additions & 0 deletions modules/web/src/resource/config/configmap/detail/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,52 @@
</div>
</div>
</kd-card>

<kd-card
[initialized]="isInitialized"
role="table"
>
<div
title
i18n
>
Binary Data
</div>
<div content>
<mat-table
*ngIf="configMap?.binaryData"
[dataSource]="getConfigMapBinaryData(configMap)"
>
<ng-container matColumnDef="name">
<mat-header-cell
*matHeaderCellDef
i18n
>
Key
</mat-header-cell>
<mat-cell *matCellDef="let cm"> {{ cm.name }} </mat-cell>
</ng-container>

<ng-container matColumnDef="size">
<mat-header-cell
*matHeaderCellDef
i18n
>
Size
</mat-header-cell>
<mat-cell *matCellDef="let cm"> {{ cm.size }} bytes </mat-cell>
</ng-container>

<mat-header-row *matHeaderRowDef="displayedBinaryDataColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedBinaryDataColumns"></mat-row>
</mat-table>

<div
*ngIf="!configMap?.binaryData"
class="kd-card-padding"
i18n
>
There is no data to display.
</div>
</div>
</kd-card>
1 change: 1 addition & 0 deletions modules/web/src/typings/root.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ export interface IngressClassDetail extends ResourceDetail {

export interface ConfigMapDetail extends ResourceDetail {
data: StringMap;
binaryData: StringMap;
}

export interface CRDDetail extends ResourceDetail {
Expand Down

0 comments on commit b4bf1f1

Please sign in to comment.