Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tenants): Implement UI For switching active/prefered tenant #106

Merged
merged 15 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc4 // indirect
github.com/opencontainers/runc v1.1.5 // indirect
github.com/ory/nosurf v1.2.7 // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.m
github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI=
github.com/ory/client-go v1.5.1 h1:lVi1f8j994uXMbi2+YahdtJw4+WZEalDXiRJbSQBYhU=
github.com/ory/client-go v1.5.1/go.mod h1:6dx0Ir6q8O9mUvl3sqrlyR+0LalXLwwKedVDDmSPNQs=
github.com/ory/nosurf v1.2.7 h1:YrHrbSensQyU6r6HT/V5+HPdVEgrOTMJiLoJABSBOp4=
github.com/ory/nosurf v1.2.7/go.mod h1:d4L3ZBa7Amv55bqxCBtCs63wSlyaiCkWVl4vKf3OUxA=
github.com/pierrec/lz4/v4 v4.1.2/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc=
github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
Expand Down
11 changes: 10 additions & 1 deletion internal/pagination/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ func multiColumnCompare(columns []whereCol) sq.Sqlizer {
return clause
}

func columnAlias(name string) string {
for i := len(name) - 1; i > 0; i-- {
if name[i] == '.' {
return "paginated_" + name[i+1:]
}
}
return "paginated_" + name
}

func Apply[T any](q sq.SelectBuilder, c Cursor[T]) (sq.SelectBuilder, error) {
q = q.Limit(c.Limit)
rt := reflect.TypeOf(c.Columns)
Expand All @@ -172,7 +181,7 @@ func Apply[T any](q sq.SelectBuilder, c Cursor[T]) (sq.SelectBuilder, error) {
if order != "ASC" && order != "DESC" {
return q, fmt.Errorf("invalid order in pagination tag on struct %s, for field %s", rt.Name(), rf.Name)
}
q = q.OrderBy(column + " " + order).Column(column)
q = q.OrderBy(column + " " + order).Column(column + " AS " + columnAlias(column))

rvf := rv.Field(ix)
if rvf.IsZero() {
Expand Down
5 changes: 0 additions & 5 deletions package.json

This file was deleted.

5 changes: 5 additions & 0 deletions pkg/api/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ client.go
configuration.go
model_add_sensor_to_sensor_group_201_response.go
model_add_sensor_to_sensor_group_request.go
model_add_tenant_member_201_response.go
model_add_tenant_member_request.go
model_api_error.go
model_api_key.go
model_api_key_created.go
Expand Down Expand Up @@ -67,6 +69,8 @@ model_paginated_response_links.go
model_pipeline.go
model_query_measurements_200_response.go
model_query_measurements_200_response_all_of.go
model_remove_tenant_member_200_response.go
model_revoke_api_key_200_response.go
model_sensor.go
model_sensor_group.go
model_tenant.go
Expand All @@ -78,6 +82,7 @@ model_update_pipeline_200_response.go
model_update_pipeline_request.go
model_update_sensor_group_200_response.go
model_update_sensor_group_request.go
model_update_tenant_member_request.go
model_update_worker_200_response.go
model_update_worker_request.go
model_user_worker.go
Expand Down
19 changes: 14 additions & 5 deletions pkg/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Developed and designed by Provincie Zeeland and Pollex
## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.

- API version: 1.0
- API version: 1.1-rc1
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen
For more information, please visit [https://sensorbucket.nl](https://sensorbucket.nl)
Expand Down Expand Up @@ -88,9 +88,10 @@ All URIs are relative to *https://sensorbucket.nl/api*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*ApiKeysApi* | [**CreateApiKey**](docs/ApiKeysApi.md#createapikey) | **Post** /api-keys | Creates a new API key for the given Tenant
*ApiKeysApi* | [**ListApiKeys**](docs/ApiKeysApi.md#listapikeys) | **Get** /api-keys/list | List API Keys
*ApiKeysApi* | [**RevokeApiKey**](docs/ApiKeysApi.md#revokeapikey) | **Delete** /api-keys/{api_key_id} | Revokes an API key
*APIKeysApi* | [**CreateApiKey**](docs/APIKeysApi.md#createapikey) | **Post** /api-keys | Creates a new API key for the given Tenant
*APIKeysApi* | [**GetAPIKey**](docs/APIKeysApi.md#getapikey) | **Get** /api-keys/{api_key_id} | Get an API Key by ID
*APIKeysApi* | [**ListApiKeys**](docs/APIKeysApi.md#listapikeys) | **Get** /api-keys | List API Keys
*APIKeysApi* | [**RevokeApiKey**](docs/APIKeysApi.md#revokeapikey) | **Delete** /api-keys/{api_key_id} | Revokes an API key
*DevicesApi* | [**AddSensorToSensorGroup**](docs/DevicesApi.md#addsensortosensorgroup) | **Post** /sensor-groups/{id}/sensors | Add sensor to a sensor group
*DevicesApi* | [**CreateDevice**](docs/DevicesApi.md#createdevice) | **Post** /devices | Create device
*DevicesApi* | [**CreateDeviceSensor**](docs/DevicesApi.md#createdevicesensor) | **Post** /devices/{device_id}/sensors | Create sensor for device
Expand All @@ -114,7 +115,10 @@ Class | Method | HTTP request | Description
*PipelinesApi* | [**GetPipeline**](docs/PipelinesApi.md#getpipeline) | **Get** /pipelines/{id} | Get pipeline
*PipelinesApi* | [**ListPipelines**](docs/PipelinesApi.md#listpipelines) | **Get** /pipelines | List pipelines
*PipelinesApi* | [**UpdatePipeline**](docs/PipelinesApi.md#updatepipeline) | **Patch** /pipelines/{id} | Update pipeline
*TenantsApi* | [**ListTenants**](docs/TenantsApi.md#listtenants) | **Get** /tenants/list | Retrieves tenants
*TenantsApi* | [**AddTenantMember**](docs/TenantsApi.md#addtenantmember) | **Post** /tenants/{tenant_id}/members | Add a User to a Tenant as member
*TenantsApi* | [**ListTenants**](docs/TenantsApi.md#listtenants) | **Get** /tenants | Retrieves tenants
*TenantsApi* | [**RemoveTenantMember**](docs/TenantsApi.md#removetenantmember) | **Delete** /tenants/{tenant_id}/members/{user_id} | Removes a member from a tenant
*TenantsApi* | [**UpdateTenantMember**](docs/TenantsApi.md#updatetenantmember) | **Patch** /tenants/{tenant_id}/members/{user_id} | Update a tenant member's permissions
*TracingApi* | [**ListIngresses**](docs/TracingApi.md#listingresses) | **Get** /ingresses | List ingresses
*TracingApi* | [**ListTraces**](docs/TracingApi.md#listtraces) | **Get** /tracing | List traces
*UplinkApi* | [**ProcessUplinkData**](docs/UplinkApi.md#processuplinkdata) | **Post** /uplinks/{pipeline_id} | Process uplink message
Expand All @@ -129,6 +133,8 @@ Class | Method | HTTP request | Description

- [AddSensorToSensorGroup201Response](docs/AddSensorToSensorGroup201Response.md)
- [AddSensorToSensorGroupRequest](docs/AddSensorToSensorGroupRequest.md)
- [AddTenantMember201Response](docs/AddTenantMember201Response.md)
- [AddTenantMemberRequest](docs/AddTenantMemberRequest.md)
- [ApiError](docs/ApiError.md)
- [ApiKey](docs/ApiKey.md)
- [ApiKeyCreated](docs/ApiKeyCreated.md)
Expand Down Expand Up @@ -184,6 +190,8 @@ Class | Method | HTTP request | Description
- [Pipeline](docs/Pipeline.md)
- [QueryMeasurements200Response](docs/QueryMeasurements200Response.md)
- [QueryMeasurements200ResponseAllOf](docs/QueryMeasurements200ResponseAllOf.md)
- [RemoveTenantMember200Response](docs/RemoveTenantMember200Response.md)
- [RevokeApiKey200Response](docs/RevokeApiKey200Response.md)
- [Sensor](docs/Sensor.md)
- [SensorGroup](docs/SensorGroup.md)
- [Tenant](docs/Tenant.md)
Expand All @@ -195,6 +203,7 @@ Class | Method | HTTP request | Description
- [UpdatePipelineRequest](docs/UpdatePipelineRequest.md)
- [UpdateSensorGroup200Response](docs/UpdateSensorGroup200Response.md)
- [UpdateSensorGroupRequest](docs/UpdateSensorGroupRequest.md)
- [UpdateTenantMemberRequest](docs/UpdateTenantMemberRequest.md)
- [UpdateWorker200Response](docs/UpdateWorker200Response.md)
- [UpdateWorkerRequest](docs/UpdateWorkerRequest.md)
- [UserWorker](docs/UserWorker.md)
Expand Down
Loading
Loading