feat(http): dashboards protos pagination
parent
70921b6014
commit
e8ecc6a712
|
@ -122,6 +122,7 @@ func (h *ProtoHandler) handleGetProtos(w http.ResponseWriter, r *http.Request) {
|
|||
type createProtoResourcesRequest struct {
|
||||
ProtoID platform.ID `json:"-"`
|
||||
OrganizationID platform.ID `json:"orgID"`
|
||||
opts platform.FindOptions
|
||||
}
|
||||
|
||||
// Decode turns an http request into a createProtoResourceRequest.
|
||||
|
@ -132,6 +133,12 @@ func (r *createProtoResourcesRequest) Decode(req *http.Request) error {
|
|||
return err
|
||||
}
|
||||
|
||||
opts, err := decodeFindOptions(ctx, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.opts = *opts
|
||||
|
||||
r.ProtoID = id
|
||||
|
||||
if err := json.NewDecoder(req.Body).Decode(r); err != nil {
|
||||
|
@ -157,7 +164,7 @@ func (h *ProtoHandler) handlePostProtosDashboards(w http.ResponseWriter, r *http
|
|||
}
|
||||
|
||||
filter := platform.DashboardFilter{OrganizationID: &req.OrganizationID}
|
||||
if err := encodeResponse(ctx, w, http.StatusCreated, newGetDashboardsResponse(ctx, ds, filter, h.LabelService)); err != nil {
|
||||
if err := encodeResponse(ctx, w, http.StatusCreated, newGetDashboardsResponse(ctx, ds, filter, req.opts, h.LabelService)); err != nil {
|
||||
logEncodingError(h.Logger, r, err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -197,7 +197,7 @@ func TestProtoHandler(t *testing.T) {
|
|||
}
|
||||
],
|
||||
"links": {
|
||||
"self": "/api/v2/dashboards?orgID=0000000000000001"
|
||||
"self": "/api/v2/dashboards?descending=false&limit=20&offset=0&orgID=0000000000000001"
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
|
Loading…
Reference in New Issue