Skip to content

Commit 84da023

Browse files
Sebastian Florekmaciaszczykm
authored andcommitted
Add frontend pagination support to all resources (#1073)
1 parent 5d28086 commit 84da023

File tree

94 files changed

+1004
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1004
-480
lines changed

i18n/messages-en.xtb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,4 +523,5 @@
523523
<translation id="7249897739191369792" key="MSG_CONTAINER_DETAILS_NO_ENV_VARS" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label when there is no container environment variables.">-</translation>
524524
<translation id="3684607543489263600" key="MSG_ENV_FROM_CONFIG_MAP" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label for environment variable that comes from a Config Map">value from ConfigMap <ph name="NAME" />/<ph name="KEY" /></translation>
525525
<translation id="6987669710926523285" key="MSG_NODE_LIST_READY_LABEL" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Ready' which appears as a column label in the table of nodes (node list view).">Ready</translation>
526+
<translation id="6106340570580081121" key="MSG_DAEMON_SET_DETAIL_SERVICES_TITLE" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Title 'Services' for the services information section on the daemon set detail page.">Services</translation>
526527
</translationbundle>

i18n/messages-ja.xtb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,4 +712,5 @@
712712
<translation id="7249897739191369792" key="MSG_CONTAINER_DETAILS_NO_ENV_VARS" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label when there is no container environment variables.">-</translation>
713713
<translation id="3684607543489263600" key="MSG_ENV_FROM_CONFIG_MAP" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label for environment variable that comes from a Config Map">value from ConfigMap <ph name="NAME" />/<ph name="KEY" /></translation>
714714
<translation id="6987669710926523285" key="MSG_NODE_LIST_READY_LABEL" source="/usr/local/google/home/bryk/src/github.com/kubernetes/dashboard/.tmp/serve/app-dev.js" desc="Label 'Ready' which appears as a column label in the table of nodes (node list view).">Ready</translation>
715+
<translation id="6106340570580081121" key="MSG_DAEMON_SET_DETAIL_SERVICES_TITLE" source="/home/floreks/Projects/dashboard/.tmp/serve/app-dev.js" desc="Title 'Services' for the services information section on the daemon set detail page.">Services</translation>
715716
</translationbundle>

src/app/backend/handler/apihandler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ func (apiHandler *APIHandler) handleGetServicePods(request *restful.Request,
458458

459459
// Handles get node list API call.
460460
func (apiHandler *APIHandler) handleGetNodeList(request *restful.Request, response *restful.Response) {
461-
result, err := node.GetNodeList(apiHandler.client)
461+
pagination := parsePaginationPathParameter(request)
462+
result, err := node.GetNodeList(apiHandler.client, pagination)
462463
if err != nil {
463464
handleInternalError(response, err)
464465
return

src/app/backend/resource/node/nodecommon.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
package node
1616

1717
import (
18+
"github.com/kubernetes/dashboard/src/app/backend/resource/common"
19+
1820
"k8s.io/kubernetes/pkg/api"
1921
)
2022

@@ -28,3 +30,14 @@ func getContainerImages(node api.Node) []string {
2830
}
2931
return containerImages
3032
}
33+
34+
func paginate(nodes []api.Node, pQuery *common.PaginationQuery) []api.Node {
35+
startIndex, endIndex := pQuery.GetPaginationSettings(len(nodes))
36+
37+
// Return all items if provided settings do not meet requirements
38+
if !pQuery.CanPaginate(len(nodes), startIndex) {
39+
return nodes
40+
}
41+
42+
return nodes[startIndex:endIndex]
43+
}

src/app/backend/resource/node/nodelist.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Node struct {
4343
}
4444

4545
// GetNodeList returns a list of all Nodes in the cluster.
46-
func GetNodeList(client client.Interface) (*NodeList, error) {
46+
func GetNodeList(client client.Interface, pQuery *common.PaginationQuery) (*NodeList, error) {
4747
log.Printf("Getting list of all nodes in the cluster")
4848

4949
nodes, err := client.Nodes().List(api.ListOptions{
@@ -55,15 +55,17 @@ func GetNodeList(client client.Interface) (*NodeList, error) {
5555
return nil, err
5656
}
5757

58-
return toNodeList(nodes.Items), nil
58+
return toNodeList(nodes.Items, pQuery), nil
5959
}
6060

61-
func toNodeList(nodes []api.Node) *NodeList {
61+
func toNodeList(nodes []api.Node, pQuery *common.PaginationQuery) *NodeList {
6262
nodeList := &NodeList{
6363
Nodes: make([]Node, 0),
6464
ListMeta: common.ListMeta{TotalItems: len(nodes)},
6565
}
6666

67+
nodes = paginate(nodes, pQuery)
68+
6769
for _, node := range nodes {
6870
nodeList.Nodes = append(nodeList.Nodes, toNode(node))
6971
}

src/app/backend/resource/replicationcontroller/replicationcontrollercommon.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func CreateReplicationControllerList(replicationControllers []api.ReplicationCon
114114
ListMeta: common.ListMeta{TotalItems: len(replicationControllers)},
115115
}
116116

117-
// TODO support pagination
117+
replicationControllers = paginate(replicationControllers, pQuery)
118118

119119
for _, rc := range replicationControllers {
120120
matchingPods := common.FilterNamespacedPodsBySelector(pods, rc.ObjectMeta.Namespace,
@@ -128,3 +128,16 @@ func CreateReplicationControllerList(replicationControllers []api.ReplicationCon
128128

129129
return rcList
130130
}
131+
132+
func paginate(replicationControllers []api.ReplicationController,
133+
pQuery *common.PaginationQuery) []api.ReplicationController {
134+
135+
startIndex, endIndex := pQuery.GetPaginationSettings(len(replicationControllers))
136+
137+
// Return all items if provided settings do not meet requirements
138+
if !pQuery.CanPaginate(len(replicationControllers), startIndex) {
139+
return replicationControllers
140+
}
141+
142+
return replicationControllers[startIndex:endIndex]
143+
}

src/app/backend/resource/workload/workloads.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,13 @@ func GetWorkloadsFromChannels(channels *common.ResourceChannels,
9494
}()
9595

9696
go func() {
97-
// TODO(floreks) enable pagination with frontend support
98-
jobList, err := job.GetJobListFromChannels(channels, common.NoPagination)
97+
jobList, err := job.GetJobListFromChannels(channels, pQuery)
9998
errChan <- err
10099
jobChan <- jobList
101100
}()
102101

103102
go func() {
104-
// TODO(floreks) enable pagination with frontend support
105-
deploymentList, err := deployment.GetDeploymentListFromChannels(channels,
106-
common.NoPagination)
103+
deploymentList, err := deployment.GetDeploymentListFromChannels(channels, pQuery)
107104
errChan <- err
108105
deploymentChan <- deploymentList
109106
}()
@@ -115,15 +112,13 @@ func GetWorkloadsFromChannels(channels *common.ResourceChannels,
115112
}()
116113

117114
go func() {
118-
// TODO(floreks) enable pagination with frontend support
119-
dsList, err := daemonset.GetDaemonSetListFromChannels(channels, common.NoPagination)
115+
dsList, err := daemonset.GetDaemonSetListFromChannels(channels, pQuery)
120116
errChan <- err
121117
dsChan <- dsList
122118
}()
123119

124120
go func() {
125-
// TODO(floreks) enable pagination with frontend support
126-
psList, err := petset.GetPetSetListFromChannels(channels, common.NoPagination)
121+
psList, err := petset.GetPetSetListFromChannels(channels, pQuery)
127122
errChan <- err
128123
psChan <- psList
129124
}()

src/app/externs/backendapi.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,8 @@ backendApi.DaemonSetDetail;
525525
* @typedef {{
526526
* objectMeta: !backendApi.ObjectMeta,
527527
* typeMeta: !backendApi.TypeMeta,
528-
* labelSelector: !Object<string, string>,
528+
* pods: !backendApi.PodInfo,
529529
* containerImages: !Array<string>,
530-
* podInfo: !backendApi.PodInfo,
531530
* }}
532531
*/
533532
backendApi.DaemonSet;

src/app/frontend/common/components/actionbar/actionbar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
<div class="md-toolbar-tools" layout="row">
1919
<kd-breadcrumbs class="kd-actionbar-breadcrumbs" limit="2" flex="auto"></kd-breadcrumbs>
2020
<span flex="auto"></span>
21-
<ng-transclude ui-view="actionbar"></ng-transclude>
21+
<div ui-view="actionbar"></div>
2222
</div>
2323
</md-toolbar>

src/app/frontend/configmaplist/configmapcardlist.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,19 @@
2828
<kd-resource-card-header-column size="small" grow="nogrow">
2929
</kd-resource-card-header-column>
3030
</kd-resource-card-header-columns>
31-
<kd-config-map-card dir-paginate="configMap in $ctrl.configMapList.items | itemsPerPage: default"
32-
config-map="configMap" pagination-id="configmaps">
31+
<kd-config-map-card ng-if="::$ctrl.configMapListResource"
32+
dir-paginate="configMap in $ctrl.configMapList.items | itemsPerPage: default"
33+
config-map="configMap" pagination-id="configmaps"
34+
total-items="::$ctrl.configMapList.listMeta.totalItems">
35+
</kd-config-map-card>
36+
37+
<kd-config-map-card ng-if="::!$ctrl.configMapListResource"
38+
dir-paginate="configMap in $ctrl.configMapList.items | itemsPerPage: default"
39+
config-map="configMap" pagination-id="configmaps">
3340
</kd-config-map-card>
3441
<kd-resource-card-list-footer>
35-
<kd-resource-card-list-pagination pagination-id="configmaps" list="$ctrl.configMapList">
42+
<kd-resource-card-list-pagination pagination-id="configmaps" list="$ctrl.configMapList"
43+
list-resource="$ctrl.configMapListResource">
3644
</kd-resource-card-list-pagination>
3745
</kd-resource-card-list-footer>
3846
</kd-resource-card-list>

0 commit comments

Comments
 (0)