Skip to content

Commit

Permalink
Added object detail viewer function of k8s page
Browse files Browse the repository at this point in the history
  • Loading branch information
yongsikgi committed Dec 3, 2021
1 parent 81ecb40 commit 005fd85
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 137 deletions.
9 changes: 1 addition & 8 deletions backend/server/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,14 +688,7 @@ func (s *Service) OrganizationUpdateUser(w http.ResponseWriter, r *http.Request)
return
}

// change req.Roles in u.Roles
for i, existRule := range u.Roles {
for _, role := range roles {
if existRule.Organization == role.Organization {
u.Roles[i] = role
}
}
}
u.Roles = roles

// If the request contains a name, it must be the same as the
// one on the user. This is particularly useful to the front-end
Expand Down
25 changes: 5 additions & 20 deletions frontend/src/hosts/components/KubernetesContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import _ from 'lodash'
// Component
import Threesizer from 'src/shared/components/threesizer/Threesizer'
import FancyScrollbar from 'src/shared/components/FancyScrollbar'
import {ButtonShape, Radio} from 'src/reusable_ui'
import {TableBody, TableBodyRowItem} from 'src/addon/128t/reusable/layout'

import KubernetesBasicsTable from 'src/hosts/components/KubernetesBasicsTable'
Expand Down Expand Up @@ -181,13 +180,7 @@ class KubernetesContents extends PureComponent<Props, State> {
}

private KubernetesInformation = () => {
const {
handleOnSetActiveEditorTab,
handleOnClickPodName,
activeTab,
script,
focuseNode,
} = this.props
const {handleOnClickPodName, activeTab, script, focuseNode} = this.props
const {HeaderWidth, DataWidth} = KUBERNETES_BASICS_TABLE_SIZE

return (
Expand All @@ -198,33 +191,25 @@ class KubernetesContents extends PureComponent<Props, State> {
<div className="hosts-table--tr">
<div
className={'hosts-table--th align--start'}
style={{width: HeaderWidth}}
style={{width: HeaderWidth, padding: '4px 8px'}}
>
Kind
</div>
<TableBodyRowItem
title={
<div className="pod-name" onClick={handleOnClickPodName}>
{focuseNode.type}
</div>
}
title={<div className="pod-name">{focuseNode.type}</div>}
width={DataWidth}
className={'align--start'}
/>
</div>
<div className="hosts-table--tr">
<div
className={'hosts-table--th align--start'}
style={{width: HeaderWidth}}
style={{width: HeaderWidth, padding: '4px 8px'}}
>
Label
</div>
<TableBodyRowItem
title={
<div className="pod-name" onClick={handleOnClickPodName}>
{focuseNode.label}
</div>
}
title={<div className="pod-name">{focuseNode.label}</div>}
width={DataWidth}
className={'align--start'}
/>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hosts/components/KubernetesRawData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class KubernetesRawData extends PureComponent<Props> {
const options = {
tabIndex: 1,
readonly: false,
lineNumbers: true,
lineNumbers: false,
autoRefresh: true,
completeSingle: false,
lineWrapping: true,
Expand Down
9 changes: 4 additions & 5 deletions frontend/src/hosts/components/host.scss
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,11 @@
}

.pod-name {
cursor: pointer;
color: #ce9178;
color: #999dab;

&:hover {
color: #e35833;
}
// &:hover {
// color: #e35833;
// }
}

.kubernetes-header--bar {
Expand Down
167 changes: 167 additions & 0 deletions frontend/src/hosts/constants/kubernetes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
export enum K8sNodeType {
SVC = 'Service',
IGS = 'Ingress',
CM = 'Configmap',
SR = 'Secret',
SA = 'ServiceAccount',
CR = 'ClusterRole',
CRB = 'ClusterRoleBinding',
RL = 'Role',
RB = 'RoleBinding',
PV = 'PersistentVolume',
PVC = 'PersistentVolumeClaim',
RS = 'ReplicaSet',
DP = 'Deployment',
RC = 'ReplicationController',
DS = 'DaemonSet',
SS = 'StatefulSet',
Job = 'Job',
CJ = 'CronJob',
Pod = 'Pod',
Node = 'Node',
Namespace = 'Namespace',
}

export const k8sNodeTypeAttrs = {
Namespace: {
name: K8sNodeType.Namespace,
saltParam: {
fun: 'kubernetes.show_namespace',
kwarg: {name: ''},
},
},
Node: {
name: K8sNodeType.Node,
saltParam: {fun: 'kubernetes.node', kwarg: {name: ''}},
},
Pod: {
name: K8sNodeType.Pod,
saltParam: {fun: 'kubernetes.show_pod', kwarg: {namespace: '', name: ''}},
},
DP: {
name: K8sNodeType.DP,
saltParam: {
fun: 'kubernetes.show_deployment',
kwarg: {namespace: '', name: ''},
},
},
RS: {
name: K8sNodeType.RS,
saltParam: {
fun: 'kubernetes.show_replica_set',
kwarg: {namespace: '', name: ''},
},
},
RC: {
name: K8sNodeType.RC,
saltParam: {
fun: 'kubernetes.show_replication_controller',
kwarg: {namespace: '', name: ''},
},
},
DS: {
name: K8sNodeType.DS,
saltParam: {
fun: 'kubernetes.show_daemon_set',
kwarg: {namespace: '', name: ''},
},
},
SS: {
name: K8sNodeType.SS,
saltParam: {
fun: 'kubernetes.show_stateful_set',
kwarg: {namespace: '', name: ''},
},
},
Job: {
name: K8sNodeType.Job,
saltParam: {
fun: 'kubernetes.show_job',
kwarg: {namespace: '', name: ''},
},
},
CJ: {
name: K8sNodeType.CJ,
saltParam: {
fun: 'kubernetes.show_cron_job',
kwarg: {namespace: '', name: ''},
},
},
SVC: {
name: K8sNodeType.SVC,
saltParam: {
fun: 'kubernetes.show_service',
kwarg: {namespace: '', name: ''},
},
},
IGS: {
name: K8sNodeType.IGS,
saltParam: {
fun: 'kubernetes.show_ingress',
kwarg: {namespace: '', name: ''},
},
},
CM: {
name: K8sNodeType.CM,
saltParam: {
fun: 'kubernetes.show_configmap',
kwarg: {namespace: '', name: ''},
},
},
SR: {
name: K8sNodeType.SR,
saltParam: {
fun: 'kubernetes.show_secret',
kwarg: {namespace: '', name: ''},
},
},
SA: {
name: K8sNodeType.SA,
saltParam: {
fun: 'kubernetes.show_service_account',
kwarg: {namespace: '', name: ''},
},
},
CR: {
name: K8sNodeType.CR,
saltParam: {
fun: 'kubernetes.show_cluster_role',
kwarg: {name: ''},
},
},
CRB: {
name: K8sNodeType.CRB,
saltParam: {
fun: 'kubernetes.show_cluster_role_binding',
kwarg: {name: ''},
},
},
RL: {
name: K8sNodeType.RL,
saltParam: {
fun: 'kubernetes.show_role',
kwarg: {namespace: '', name: ''},
},
},
RB: {
name: K8sNodeType.RB,
saltParam: {
fun: 'kubernetes.show_role_binding',
kwarg: {namespace: '', name: ''},
},
},
PV: {
name: K8sNodeType.PV,
saltParam: {
fun: 'kubernetes.show_persistent_volume',
kwarg: {name: ''},
},
},
PVC: {
name: K8sNodeType.PVC,
saltParam: {
fun: 'kubernetes.show_persistent_volume_claim',
kwarg: {namespace: '', name: ''},
},
},
}
4 changes: 2 additions & 2 deletions frontend/src/hosts/constants/tableSizing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ export const VCENTER_VM_TABLE_SIZING = {
}

export const KUBERNETES_BASICS_TABLE_SIZE = {
HeaderWidth: '40%',
DataWidth: '60%',
HeaderWidth: '15%',
DataWidth: '85%',
}
Loading

0 comments on commit 005fd85

Please sign in to comment.