Skip to content

Commit

Permalink
Select client (#998)
Browse files Browse the repository at this point in the history
* Select client.

* Fixes to OpenAPI: Parameter order.
  • Loading branch information
SebastianStehle committed Jun 12, 2023
1 parent 190caaa commit b7bc76b
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 19 deletions.
5 changes: 5 additions & 0 deletions backend/i18n/frontend_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"api.generalApi": "General API",
"api.graphql": "GraphQL",
"api.graphqlPageTitle": "GraphQL",
"api.noClient": "Token of current user",
"api.pageTitle": "API",
"api.selectClient": "Select Client",
"api.selectClientDescription": "Select a client that should be used for authentication. Can be used to simulate permissions and headers.",
"api.title": "API",
"apps.allApps": "All Apps",
"apps.allTeams": "All Teams",
Expand Down Expand Up @@ -245,11 +248,13 @@
"common.cancelAll": "Cancel All",
"common.category": "Category",
"common.clear": "Clear",
"common.client": "Client",
"common.clientId": "Client Id",
"common.clients": "Clients",
"common.clientSecret": "Client Secret",
"common.clipboardAdded": "Value has been added to your clipboard.",
"common.clone": "Clone",
"common.close": "Close",
"common.cluster": "Cluster",
"common.clusterPageTitle": "Cluster",
"common.comments": "Comments",
Expand Down
5 changes: 5 additions & 0 deletions backend/i18n/frontend_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"api.generalApi": "API générale",
"api.graphql": "GraphQL",
"api.graphqlPageTitle": "GraphQL",
"api.noClient": "Token of current user",
"api.pageTitle": "API",
"api.selectClient": "Select Client",
"api.selectClientDescription": "Select a client that should be used for authentication. Can be used to simulate permissions and headers.",
"api.title": "API",
"apps.allApps": "Toutes les applications",
"apps.allTeams": "Toutes les équipes",
Expand Down Expand Up @@ -245,11 +248,13 @@
"common.cancelAll": "Annuler tout",
"common.category": "Catégorie",
"common.clear": "Clair",
"common.client": "Client",
"common.clientId": "Identité du client",
"common.clients": "Clients",
"common.clientSecret": "Clé secrète du client",
"common.clipboardAdded": "La valeur a été ajoutée à votre presse-papiers.",
"common.clone": "Cloner",
"common.close": "Close",
"common.cluster": "Grappe",
"common.clusterPageTitle": "Grappe",
"common.comments": "commentaires",
Expand Down
5 changes: 5 additions & 0 deletions backend/i18n/frontend_it.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"api.generalApi": "API generali",
"api.graphql": "GraphQL",
"api.graphqlPageTitle": "GraphQL",
"api.noClient": "Token of current user",
"api.pageTitle": "API",
"api.selectClient": "Select Client",
"api.selectClientDescription": "Select a client that should be used for authentication. Can be used to simulate permissions and headers.",
"api.title": "API",
"apps.allApps": "Tutte le Apps",
"apps.allTeams": "All Teams",
Expand Down Expand Up @@ -245,11 +248,13 @@
"common.cancelAll": "Cancel All",
"common.category": "Categoria",
"common.clear": "Pulisci",
"common.client": "Client",
"common.clientId": "Client Id",
"common.clients": "Client",
"common.clientSecret": "Client Secret",
"common.clipboardAdded": "Il valore è stato aggiunto nei tuoi appunti.",
"common.clone": "Clona",
"common.close": "Close",
"common.cluster": "Cluster",
"common.clusterPageTitle": "Cluster",
"common.comments": "Commenti",
Expand Down
5 changes: 5 additions & 0 deletions backend/i18n/frontend_nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"api.generalApi": "Algemene API",
"api.graphql": "GraphQL",
"api.graphqlPageTitle": "GraphQL",
"api.noClient": "Token of current user",
"api.pageTitle": "API",
"api.selectClient": "Select Client",
"api.selectClientDescription": "Select a client that should be used for authentication. Can be used to simulate permissions and headers.",
"api.title": "API",
"apps.allApps": "Alle apps",
"apps.allTeams": "All Teams",
Expand Down Expand Up @@ -245,11 +248,13 @@
"common.cancelAll": "Annulleer Alles",
"common.category": "Categorie",
"common.clear": "Wissen",
"common.client": "Client",
"common.clientId": "Client-ID",
"common.clients": "Clients",
"common.clientSecret": "Clientgeheim",
"common.clipboardAdded": "Waarde is toegevoegd aan uw klembord.",
"common.clone": "Kloon",
"common.close": "Close",
"common.cluster": "Cluster",
"common.clusterPageTitle": "Cluster",
"common.comments": "Reacties",
Expand Down
5 changes: 5 additions & 0 deletions backend/i18n/frontend_pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"api.generalApi": "API Geral",
"api.graphql": "GraphQL",
"api.graphqlPageTitle": "GraphQL",
"api.noClient": "Token of current user",
"api.pageTitle": "API",
"api.selectClient": "Select Client",
"api.selectClientDescription": "Select a client that should be used for authentication. Can be used to simulate permissions and headers.",
"api.title": "API",
"apps.allApps": "Todas as aplicações",
"apps.allTeams": "Todas as Equipas",
Expand Down Expand Up @@ -245,11 +248,13 @@
"common.cancelAll": "cancelar todos",
"common.category": "Categorias",
"common.clear": "Claro",
"common.client": "Client",
"common.clientId": "ID do cliente",
"common.clients": "Clientes",
"common.clientSecret": "Segredo do Cliente",
"common.clipboardAdded": "O valor foi adicionado à sua área de transferência.",
"common.clone": "Clone",
"common.close": "Close",
"common.cluster": "Cluster",
"common.clusterPageTitle": "Cluster",
"common.comments": "Comentários",
Expand Down
5 changes: 5 additions & 0 deletions backend/i18n/frontend_zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"api.generalApi": "通用 API",
"api.graphql": "GraphQL",
"api.graphqlPageTitle": "GraphQL",
"api.noClient": "Token of current user",
"api.pageTitle": "API",
"api.selectClient": "Select Client",
"api.selectClientDescription": "Select a client that should be used for authentication. Can be used to simulate permissions and headers.",
"api.title": "API",
"apps.allApps": "所有应用程序",
"apps.allTeams": "All Teams",
Expand Down Expand Up @@ -245,11 +248,13 @@
"common.cancelAll": "Cancel All",
"common.category": "类别",
"common.clear": "清除",
"common.client": "Client",
"common.clientId": "客户端 ID",
"common.clients": "客户端",
"common.clientSecret": "客户端密码",
"common.clipboardAdded": "值已添加到您的剪贴板。",
"common.clone": "克隆",
"common.close": "Close",
"common.cluster": "集群",
"common.clusterPageTitle": "集群",
"common.comments": "评论",
Expand Down
5 changes: 5 additions & 0 deletions backend/i18n/source/frontend_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"api.generalApi": "General API",
"api.graphql": "GraphQL",
"api.graphqlPageTitle": "GraphQL",
"api.noClient": "Token of current user",
"api.pageTitle": "API",
"api.selectClient": "Select Client",
"api.selectClientDescription": "Select a client that should be used for authentication. Can be used to simulate permissions and headers.",
"api.title": "API",
"apps.allApps": "All Apps",
"apps.allTeams": "All Teams",
Expand Down Expand Up @@ -245,11 +248,13 @@
"common.cancelAll": "Cancel All",
"common.category": "Category",
"common.clear": "Clear",
"common.client": "Client",
"common.clientId": "Client Id",
"common.clients": "Clients",
"common.clientSecret": "Client Secret",
"common.clipboardAdded": "Value has been added to your clipboard.",
"common.clone": "Clone",
"common.close": "Close",
"common.cluster": "Cluster",
"common.clusterPageTitle": "Cluster",
"common.comments": "Comments",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,39 @@ public AcceptHeader_NoSlowTotal()

public class AcceptHeaderAttribute : OpenApiOperationProcessorAttribute
{
public AcceptHeaderAttribute(string name, string description, JsonObjectType type = JsonObjectType.String)
: base(typeof(Processor), name, description, type)
public AcceptHeaderAttribute(string name, string description, JsonObjectType schemaType = JsonObjectType.String)
: base(typeof(Processor), name, description, schemaType)
{
}

public sealed class Processor : IOperationProcessor
{
private readonly string name;
private readonly string description;
private readonly JsonObjectType type;
private readonly JsonObjectType schemaType;

public Processor(string name, string description, JsonObjectType type)
public Processor(string name, string description, JsonObjectType schemaType)
{
this.name = name;
this.description = description;
this.type = type;
this.schemaType = schemaType;
}

public bool Process(OperationProcessorContext context)
{
context.OperationDescription.Operation.Parameters.Add(new OpenApiParameter
var parameter = new OpenApiParameter
{
Name = name,
Kind = OpenApiParameterKind.Header,
Schema = new JsonSchema
{
Type = type
Type = schemaType
},
Description = description,
});
Description = description
};

context.OperationDescription.Operation.Parameters.Add(parameter);
context.OperationDescription.Operation.SetPositions();

return true;
}
Expand Down
12 changes: 12 additions & 0 deletions backend/src/Squidex/Areas/Api/Config/OpenApi/QueryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,17 @@ void AddParameterQuery(OpenApiParameter parameter)
Name = "ids",
Description = FieldDescriptions.QueryIds
});

operation.SetPositions();
}

public static void SetPositions(this OpenApiOperation operation)
{
var position = 0;

foreach (var parameter in operation.Parameters)
{
parameter.Position = position++;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private OperationBuilder AddParameter(string name, JsonSchema schema, OpenApiPar
}

operation.Parameters.Add(parameter);
operation.SetPositions();

return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,39 @@

<sqx-layout layout="main" [hideHeader]="true" [hideSidebar]="true">
<div inner #graphiQLContainer></div>
</sqx-layout>

<button class="btn btn-simple btn-options" *ngIf="clientsReadable" (click)="clientsDialog.show()">
<i class="icon-clients"></i>
</button>
</sqx-layout>

<ng-container *sqxModal="clientsDialog">
<sqx-modal-dialog (close)="clientsDialog.hide()">
<ng-container title>
{{ 'api.selectClient' | sqxTranslate }}
</ng-container>

<ng-container content>
<sqx-form-hint>
{{ 'api.selectClientDescription' | sqxTranslate }}
</sqx-form-hint>

<div class="form-group">
<label for="client">{{ 'common.client' | sqxTranslate }}</label>

<select class="form-control" id="client"
[ngModel]="clientSelected"
(ngModelChange)="selectClient($event)">
<option [ngValue]="null">{{ 'api.noClient' | sqxTranslate }}</option>
<option *ngFor="let client of clientsState.clients | async" [ngValue]="client">{{client.id}}</option>
</select>
</div>
</ng-container>

<ng-container footer>
<button type="button" class="btn btn-text-secondary" (click)="clientsDialog.hide()">
{{ 'common.close' | sqxTranslate }}
</button>
</ng-container>
</sqx-modal-dialog>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,32 @@
--color-primary: #{hsl-str($color-theme-brand)};
--color-success: #{hsl-str($color-theme-success)};
--color-error: #{hsl-str($color-theme-error)};
--color-neutral: #{hsl-str($color-text)};
--border-radius-4: #{$border-radius};
--border-radius-8: #{$border-radius};
--border-radius-12: #{$border-radius};

.graphiql-sessions {
border-radius: $border-radius;
}

* {
box-sizing: content-box;
}
}

.graphiql-logo {
display: none;
}
}

.btn-options {
@include absolute(null, null, 175px, 8px);
font-size: 1.2rem;
font-weight: normal;
width: 44px;

&:hover {
background: rgba(59, 75, 104, 7%);
}
}
Loading

0 comments on commit b7bc76b

Please sign in to comment.