Parcourir la source

add api

master
Christian Ziermann il y a 3 ans
Parent
révision
54ceffe7f3
34 fichiers modifiés avec 4322 ajouts et 7293 suppressions
  1. +17
    -0
      .vscode/launch.json
  2. +4
    -0
      api/.gitignore
  3. +23
    -0
      api/.openapi-generator-ignore
  4. +17
    -0
      api/.openapi-generator/FILES
  5. +1
    -0
      api/.openapi-generator/VERSION
  6. +203
    -0
      api/README.md
  7. +31
    -0
      api/api.module.ts
  8. +4
    -0
      api/api/api.ts
  9. +300
    -0
      api/api/rules.service.ts
  10. +55
    -0
      api/api/rules.serviceInterface.ts
  11. +130
    -0
      api/configuration.ts
  12. +20
    -0
      api/encoder.ts
  13. +58
    -0
      api/git_push.sh
  14. +5
    -0
      api/index.ts
  15. +25
    -0
      api/model/createRuleDto.ts
  16. +2
    -0
      api/model/models.ts
  17. +21
    -0
      api/model/rule.ts
  18. +6
    -0
      api/ng-package.json
  19. +30
    -0
      api/package.json
  20. +28
    -0
      api/tsconfig.json
  21. +9
    -0
      api/variables.ts
  22. +7
    -0
      openapitools.json
  23. +3251
    -7276
      package-lock.json
  24. +4
    -0
      package.json
  25. +15
    -0
      src/app/admin/admin.module.ts
  26. +1
    -0
      src/app/admin/create-rule/create-rule.component.html
  27. +0
    -0
      src/app/admin/create-rule/create-rule.component.scss
  28. +25
    -0
      src/app/admin/create-rule/create-rule.component.spec.ts
  29. +15
    -0
      src/app/admin/create-rule/create-rule.component.ts
  30. +0
    -5
      src/app/rules/class/rule.class.ts
  31. +1
    -1
      src/app/rules/rule-list/rule-list.component.html
  32. +1
    -1
      src/app/rules/rule-list/rule-list.component.ts
  33. +4
    -4
      src/app/rules/rules.module.ts
  34. +9
    -6
      src/app/rules/rules/rules.component.ts

+ 17
- 0
.vscode/launch.json Voir le fichier

@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to NestJS",
"port": 9229,
"restart": true,
"stopOnEntry": false,
"protocol": "inspector"
}
]
}

+ 4
- 0
api/.gitignore Voir le fichier

@@ -0,0 +1,4 @@
wwwroot/*.js
node_modules
typings
dist

+ 23
- 0
api/.openapi-generator-ignore Voir le fichier

@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

+ 17
- 0
api/.openapi-generator/FILES Voir le fichier

@@ -0,0 +1,17 @@
.gitignore
README.md
api.module.ts
api/api.ts
api/rules.service.ts
api/rules.serviceInterface.ts
configuration.ts
encoder.ts
git_push.sh
index.ts
model/createRuleDto.ts
model/models.ts
model/rule.ts
ng-package.json
package.json
tsconfig.json
variables.ts

+ 1
- 0
api/.openapi-generator/VERSION Voir le fichier

@@ -0,0 +1 @@
5.1.1

+ 203
- 0
api/README.md Voir le fichier

@@ -0,0 +1,203 @@
## restClient@1.0

### Building

To install the required dependencies and to build the typescript sources run:
```
npm install
npm run build
```

### publishing

First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!)

### consuming

Navigate to the folder of your consuming project and run one of next commands.

_published:_

```
npm install restClient@1.0 --save
```

_without publishing (not recommended):_

```
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
```

_It's important to take the tgz file, otherwise you'll get trouble with links on windows_

_using `npm link`:_

In PATH_TO_GENERATED_PACKAGE/dist:
```
npm link
```

In your project:
```
npm link restClient
```

__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround.
Published packages are not effected by this issue.


#### General usage

In your Angular project:


```
// without configuring providers
import { ApiModule } from 'restClient';
import { HttpClientModule } from '@angular/common/http';

@NgModule({
imports: [
ApiModule,
// make sure to import the HttpClientModule in the AppModule only,
// see https://github.com/angular/angular/issues/20575
HttpClientModule
],
declarations: [ AppComponent ],
providers: [],
bootstrap: [ AppComponent ]
})
export class AppModule {}
```

```
// configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from 'restClient';

export function apiConfigFactory (): Configuration {
const params: ConfigurationParameters = {
// set configuration parameters here.
}
return new Configuration(params);
}

@NgModule({
imports: [ ApiModule.forRoot(apiConfigFactory) ],
declarations: [ AppComponent ],
providers: [],
bootstrap: [ AppComponent ]
})
export class AppModule {}
```

```
// configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from 'restClient';

@NgModule({
imports: [ ApiModule ],
declarations: [ AppComponent ],
providers: [
{
provide: Configuration,
useFactory: (authService: AuthService) => new Configuration(
{
basePath: environment.apiUrl,
accessToken: authService.getAccessToken.bind(authService)
}
),
deps: [AuthService],
multi: false
}
],
bootstrap: [ AppComponent ]
})
export class AppModule {}
```

```
import { DefaultApi } from 'restClient';

export class AppComponent {
constructor(private apiGateway: DefaultApi) { }
}
```

Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons.

#### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules
in order to avoid naming conflicts:
```
import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http';

@NgModule({
imports: [
ApiModule,
OtherApiModule,
// make sure to import the HttpClientModule in the AppModule only,
// see https://github.com/angular/angular/issues/20575
HttpClientModule
]
})
export class AppModule {

}
```


### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service.

```
import { BASE_PATH } from 'restClient';

bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]);
```
or

```
import { BASE_PATH } from 'restClient';

@NgModule({
imports: [],
declarations: [ AppComponent ],
providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ],
bootstrap: [ AppComponent ]
})
export class AppModule {}
```


#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path:

```
export const environment = {
production: false,
API_BASE_PATH: 'http://127.0.0.1:8080'
};
```

In the src/app/app.module.ts:
```
import { BASE_PATH } from 'restClient';
import { environment } from '../environments/environment';

@NgModule({
declarations: [
AppComponent
],
imports: [ ],
providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }],
bootstrap: [ AppComponent ]
})
export class AppModule { }
```

+ 31
- 0
api/api.module.ts Voir le fichier

@@ -0,0 +1,31 @@
import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core';
import { Configuration } from './configuration';
import { HttpClient } from '@angular/common/http';

import { RulesService } from './api/rules.service';

@NgModule({
imports: [],
declarations: [],
exports: [],
providers: []
})
export class ApiModule {
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders<ApiModule> {
return {
ngModule: ApiModule,
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
};
}

constructor( @Optional() @SkipSelf() parentModule: ApiModule,
@Optional() http: HttpClient) {
if (parentModule) {
throw new Error('ApiModule is already loaded. Import in your base AppModule only.');
}
if (!http) {
throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
'See also https://github.com/angular/angular/issues/20575');
}
}
}

+ 4
- 0
api/api/api.ts Voir le fichier

@@ -0,0 +1,4 @@
export * from './rules.service';
import { RulesService } from './rules.service';
export * from './rules.serviceInterface'
export const APIS = [RulesService];

+ 300
- 0
api/api/rules.service.ts Voir le fichier

@@ -0,0 +1,300 @@
/**
* Rules
* API for create rules
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/* tslint:disable:no-unused-variable member-ordering */

import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams,
HttpResponse, HttpEvent, HttpParameterCodec } from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';

import { CreateRuleDto } from '../model/models';
import { Rule } from '../model/models';

import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
import {
RulesServiceInterface
} from './rules.serviceInterface';



@Injectable({
providedIn: 'root'
})
export class RulesService implements RulesServiceInterface {

protected basePath = 'http://localhost';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
public encoder: HttpParameterCodec;

constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
if (configuration) {
this.configuration = configuration;
}
if (typeof this.configuration.basePath !== 'string') {
if (typeof basePath !== 'string') {
basePath = this.basePath;
}
this.configuration.basePath = basePath;
}
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
}


private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams {
if (typeof value === "object" && value instanceof Date === false) {
httpParams = this.addToHttpParamsRecursive(httpParams, value);
} else {
httpParams = this.addToHttpParamsRecursive(httpParams, value, key);
}
return httpParams;
}

private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams {
if (value == null) {
return httpParams;
}

if (typeof value === "object") {
if (Array.isArray(value)) {
(value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key));
} else if (value instanceof Date) {
if (key != null) {
httpParams = httpParams.append(key,
(value as Date).toISOString().substr(0, 10));
} else {
throw Error("key may not be null if value is Date");
}
} else {
Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive(
httpParams, value[k], key != null ? `${key}.${k}` : k));
}
} else if (key != null) {
httpParams = httpParams.append(key, value);
} else {
throw Error("key may not be null if value is not object or array");
}
return httpParams;
}

/**
* @param createRuleDto
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public create(createRuleDto: CreateRuleDto, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<Rule>;
public create(createRuleDto: CreateRuleDto, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<HttpResponse<Rule>>;
public create(createRuleDto: CreateRuleDto, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<HttpEvent<Rule>>;
public create(createRuleDto: CreateRuleDto, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json'}): Observable<any> {
if (createRuleDto === null || createRuleDto === undefined) {
throw new Error('Required parameter createRuleDto was null or undefined when calling create.');
}

let headers = this.defaultHeaders;

let credential: string | undefined;
// authentication (basic) required
credential = this.configuration.lookupCredential('basic');
if (credential) {
headers = headers.set('Authorization', 'Basic ' + credential);
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (httpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
httpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}


// to determine the Content-Type header
const consumes: string[] = [
'application/json'
];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
headers = headers.set('Content-Type', httpContentTypeSelected);
}

let responseType_: 'text' | 'json' = 'json';
if(httpHeaderAcceptSelected && httpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
}

return this.httpClient.post<Rule>(`${this.configuration.basePath}/rules`,
createRuleDto,
{
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}

/**
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public findAll(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<Array<Rule>>;
public findAll(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<HttpResponse<Array<Rule>>>;
public findAll(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<HttpEvent<Array<Rule>>>;
public findAll(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json'}): Observable<any> {

let headers = this.defaultHeaders;

let credential: string | undefined;
// authentication (basic) required
credential = this.configuration.lookupCredential('basic');
if (credential) {
headers = headers.set('Authorization', 'Basic ' + credential);
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (httpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
httpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}


let responseType_: 'text' | 'json' = 'json';
if(httpHeaderAcceptSelected && httpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
}

return this.httpClient.get<Array<Rule>>(`${this.configuration.basePath}/rules`,
{
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}

/**
* @param id
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public findOne(id: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<Rule>;
public findOne(id: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<HttpResponse<Rule>>;
public findOne(id: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json'}): Observable<HttpEvent<Rule>>;
public findOne(id: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json'}): Observable<any> {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling findOne.');
}

let headers = this.defaultHeaders;

let credential: string | undefined;
// authentication (basic) required
credential = this.configuration.lookupCredential('basic');
if (credential) {
headers = headers.set('Authorization', 'Basic ' + credential);
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (httpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
'application/json'
];
httpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}


let responseType_: 'text' | 'json' = 'json';
if(httpHeaderAcceptSelected && httpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
}

return this.httpClient.get<Rule>(`${this.configuration.basePath}/rules/${encodeURIComponent(String(id))}`,
{
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}

/**
* @param id
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public remove(id: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined}): Observable<any>;
public remove(id: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined}): Observable<HttpResponse<any>>;
public remove(id: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined}): Observable<HttpEvent<any>>;
public remove(id: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined}): Observable<any> {
if (id === null || id === undefined) {
throw new Error('Required parameter id was null or undefined when calling remove.');
}

let headers = this.defaultHeaders;

let credential: string | undefined;
// authentication (basic) required
credential = this.configuration.lookupCredential('basic');
if (credential) {
headers = headers.set('Authorization', 'Basic ' + credential);
}

let httpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
if (httpHeaderAcceptSelected === undefined) {
// to determine the Accept header
const httpHeaderAccepts: string[] = [
];
httpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
}
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}


let responseType_: 'text' | 'json' = 'json';
if(httpHeaderAcceptSelected && httpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
}

return this.httpClient.delete<any>(`${this.configuration.basePath}/rules/${encodeURIComponent(String(id))}`,
{
responseType: <any>responseType_,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}

}

+ 55
- 0
api/api/rules.serviceInterface.ts Voir le fichier

@@ -0,0 +1,55 @@
/**
* Rules
* API for create rules
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { HttpHeaders } from '@angular/common/http';

import { Observable } from 'rxjs';

import { CreateRuleDto } from '../model/models';
import { Rule } from '../model/models';


import { Configuration } from '../configuration';



export interface RulesServiceInterface {
defaultHeaders: HttpHeaders;
configuration: Configuration;

/**
*
*
* @param createRuleDto
*/
create(createRuleDto: CreateRuleDto, extraHttpRequestParams?: any): Observable<Rule>;

/**
*
*
*/
findAll(extraHttpRequestParams?: any): Observable<Array<Rule>>;

/**
*
*
* @param id
*/
findOne(id: string, extraHttpRequestParams?: any): Observable<Rule>;

/**
*
*
* @param id
*/
remove(id: string, extraHttpRequestParams?: any): Observable<{}>;

}

+ 130
- 0
api/configuration.ts Voir le fichier

@@ -0,0 +1,130 @@
import { HttpParameterCodec } from '@angular/common/http';

export interface ConfigurationParameters {
/**
* @deprecated Since 5.0. Use credentials instead
*/
apiKeys?: {[ key: string ]: string};
username?: string;
password?: string;
/**
* @deprecated Since 5.0. Use credentials instead
*/
accessToken?: string | (() => string);
basePath?: string;
withCredentials?: boolean;
encoder?: HttpParameterCodec;
/**
* The keys are the names in the securitySchemes section of the OpenAPI
* document. They should map to the value used for authentication
* minus any standard prefixes such as 'Basic' or 'Bearer'.
*/
credentials?: {[ key: string ]: string | (() => string | undefined)};
}

export class Configuration {
/**
* @deprecated Since 5.0. Use credentials instead
*/
apiKeys?: {[ key: string ]: string};
username?: string;
password?: string;
/**
* @deprecated Since 5.0. Use credentials instead
*/
accessToken?: string | (() => string);
basePath?: string;
withCredentials?: boolean;
encoder?: HttpParameterCodec;
/**
* The keys are the names in the securitySchemes section of the OpenAPI
* document. They should map to the value used for authentication
* minus any standard prefixes such as 'Basic' or 'Bearer'.
*/
credentials: {[ key: string ]: string | (() => string | undefined)};

constructor(configurationParameters: ConfigurationParameters = {}) {
this.apiKeys = configurationParameters.apiKeys;
this.username = configurationParameters.username;
this.password = configurationParameters.password;
this.accessToken = configurationParameters.accessToken;
this.basePath = configurationParameters.basePath;
this.withCredentials = configurationParameters.withCredentials;
this.encoder = configurationParameters.encoder;
if (configurationParameters.credentials) {
this.credentials = configurationParameters.credentials;
}
else {
this.credentials = {};
}

// init default basic credential
if (!this.credentials['basic']) {
this.credentials['basic'] = () => {
return (this.username || this.password)
? btoa(this.username + ':' + this.password)
: undefined;
};
}
}

/**
* Select the correct content-type to use for a request.
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
* If no content type is found return the first found type if the contentTypes is not empty
* @param contentTypes - the array of content types that are available for selection
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
*/
public selectHeaderContentType (contentTypes: string[]): string | undefined {
if (contentTypes.length === 0) {
return undefined;
}

const type = contentTypes.find((x: string) => this.isJsonMime(x));
if (type === undefined) {
return contentTypes[0];
}
return type;
}

/**
* Select the correct accept content-type to use for a request.
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
* If no content type is found return the first found type if the contentTypes is not empty
* @param accepts - the array of content types that are available for selection.
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
*/
public selectHeaderAccept(accepts: string[]): string | undefined {
if (accepts.length === 0) {
return undefined;
}

const type = accepts.find((x: string) => this.isJsonMime(x));
if (type === undefined) {
return accepts[0];
}
return type;
}

/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}

public lookupCredential(key: string): string | undefined {
const value = this.credentials[key];
return typeof value === 'function'
? value()
: value;
}
}

+ 20
- 0
api/encoder.ts Voir le fichier

@@ -0,0 +1,20 @@
import { HttpParameterCodec } from '@angular/common/http';

/**
* Custom HttpParameterCodec
* Workaround for https://github.com/angular/angular/issues/18261
*/
export class CustomHttpParameterCodec implements HttpParameterCodec {
encodeKey(k: string): string {
return encodeURIComponent(k);
}
encodeValue(v: string): string {
return encodeURIComponent(v);
}
decodeKey(k: string): string {
return decodeURIComponent(k);
}
decodeValue(v: string): string {
return decodeURIComponent(v);
}
}

+ 58
- 0
api/git_push.sh Voir le fichier

@@ -0,0 +1,58 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"

git_user_id=$1
git_repo_id=$2
release_note=$3
git_host=$4

if [ "$git_host" = "" ]; then
git_host="github.com"
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
fi

if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi

if [ "$git_repo_id" = "" ]; then
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi

if [ "$release_note" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi

# Initialize the local directory as a Git repository
git init

# Adds the files in the local repository and stages them for commit.
git add .

# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"

# Sets the new remote
git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined

if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
fi

fi

git pull origin master

# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'


+ 5
- 0
api/index.ts Voir le fichier

@@ -0,0 +1,5 @@
export * from './api/api';
export * from './model/models';
export * from './variables';
export * from './configuration';
export * from './api.module';

+ 25
- 0
api/model/createRuleDto.ts Voir le fichier

@@ -0,0 +1,25 @@
/**
* Rules
* API for create rules
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


export interface CreateRuleDto {
/**
* the paragraph of the rule.
*/
paragraph: string;
/**
* the rule
*/
text: string;
subRuleIds: Array<string>;
}


+ 2
- 0
api/model/models.ts Voir le fichier

@@ -0,0 +1,2 @@
export * from './createRuleDto';
export * from './rule';

+ 21
- 0
api/model/rule.ts Voir le fichier

@@ -0,0 +1,21 @@
/**
* Rules
* API for create rules
*
* The version of the OpenAPI document: 1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


export interface Rule {
id: string;
paragraph: string;
text: string;
parentRule?: Rule | null;
subRule?: Array<Rule> | null;
}


+ 6
- 0
api/ng-package.json Voir le fichier

@@ -0,0 +1,6 @@
{
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
"lib": {
"entryFile": "index.ts"
}
}

+ 30
- 0
api/package.json Voir le fichier

@@ -0,0 +1,30 @@
{
"name": "restClient",
"version": "1.0",
"description": "OpenAPI client for restClient",
"author": "OpenAPI-Generator Contributors",
"keywords": [
"openapi-client",
"openapi-generator"
],
"license": "Unlicense",
"scripts": {
"build": "ng-packagr -p ng-package.json"
},
"peerDependencies": {
"@angular/core": "^11.0.0",
"rxjs": "^6.6.0"
},
"devDependencies": {
"@angular/common": "^11.0.0",
"@angular/compiler": "^11.0.0",
"@angular/compiler-cli": "^11.0.0",
"@angular/core": "^11.0.0",
"@angular/platform-browser": "^11.0.0",
"ng-packagr": "^11.0.2",
"reflect-metadata": "^0.1.3",
"rxjs": "^6.6.0",
"tsickle": "^0.39.1",
"typescript": ">=4.0.0 <4.1.0",
"zone.js": "^0.11.3"
}}

+ 28
- 0
api/tsconfig.json Voir le fichier

@@ -0,0 +1,28 @@
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "es6",
"module": "es6",
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,
"outDir": "./dist",
"noLib": false,
"declaration": true,
"lib": [ "es6", "dom" ],
"typeRoots": [
"node_modules/@types"
]
},
"exclude": [
"node_modules",
"dist"
],
"filesGlob": [
"./model/*.ts",
"./api/*.ts"
]
}

+ 9
- 0
api/variables.ts Voir le fichier

@@ -0,0 +1,9 @@
import { InjectionToken } from '@angular/core';

export const BASE_PATH = new InjectionToken<string>('basePath');
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',
'ssv': ' ',
'pipes': '|'
}

+ 7
- 0
openapitools.json Voir le fichier

@@ -0,0 +1,7 @@
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "5.1.1"
}
}

+ 3251
- 7276
package-lock.json
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 4
- 0
package.json Voir le fichier

@@ -3,7 +3,10 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
"gen": "openapi-generator-cli generate -i http://localhost:3000/api-json -g typescript-angular -o api/ --additional-properties=npmName=restClient,supportsES6=true,withInterfaces=true",
"start": "ng serve",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
@@ -21,6 +24,7 @@
"@angular/platform-browser": "~11.2.11",
"@angular/platform-browser-dynamic": "~11.2.11",
"@angular/router": "~11.2.11",
"@openapitools/openapi-generator-cli": "^2.2.6",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.3"

+ 15
- 0
src/app/admin/admin.module.ts Voir le fichier

@@ -0,0 +1,15 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CreateRuleComponent } from './create-rule/create-rule.component';



@NgModule({
declarations: [
CreateRuleComponent
],
imports: [
CommonModule
]
})
export class AdminModule { }

+ 1
- 0
src/app/admin/create-rule/create-rule.component.html Voir le fichier

@@ -0,0 +1 @@
<p>create-rule works!</p>

+ 0
- 0
src/app/admin/create-rule/create-rule.component.scss Voir le fichier


+ 25
- 0
src/app/admin/create-rule/create-rule.component.spec.ts Voir le fichier

@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CreateRuleComponent } from './create-rule.component';

describe('CreateRuleComponent', () => {
let component: CreateRuleComponent;
let fixture: ComponentFixture<CreateRuleComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ CreateRuleComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(CreateRuleComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});

+ 15
- 0
src/app/admin/create-rule/create-rule.component.ts Voir le fichier

@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-create-rule',
templateUrl: './create-rule.component.html',
styleUrls: ['./create-rule.component.scss']
})
export class CreateRuleComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}

+ 0
- 5
src/app/rules/class/rule.class.ts Voir le fichier

@@ -1,5 +0,0 @@
export type Rule = {
paragraph: string;
text: string,
subRule?: Rule[];
}

+ 1
- 1
src/app/rules/rule-list/rule-list.component.html Voir le fichier

@@ -3,7 +3,7 @@
<div mat-line>
§{{ rule.paragraph }} {{ rule.text }}
</div>
<mat-list-item mat-line *ngIf="rule.subRule">
<mat-list-item mat-line *ngIf="rule.subRule?.length">
<app-rule-list [rules]="rule.subRule"></app-rule-list>
</mat-list-item>
</mat-list-item>

+ 1
- 1
src/app/rules/rule-list/rule-list.component.ts Voir le fichier

@@ -1,5 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { Rule } from '../class/rule.class';
import { Rule } from '../../../../api/model/rule';

@Component({
selector: 'app-rule-list',

+ 4
- 4
src/app/rules/rules.module.ts Voir le fichier

@@ -6,10 +6,8 @@ import { MatListModule } from '@angular/material/list';
import { MatTreeModule } from '@angular/material/tree';
import { RuleListComponent } from './rule-list/rule-list.component';
import { RulesComponent } from './rules/rules.component';




import { ApiModule } from '../../../api/api.module';
import { HttpClientModule } from '@angular/common/http';
@NgModule({
declarations: [
RuleListComponent,
@@ -21,6 +19,8 @@ import { RulesComponent } from './rules/rules.component';
MatCardModule,
MatIconModule,
MatTreeModule,
ApiModule,
HttpClientModule,
],
exports: [
RulesComponent

+ 9
- 6
src/app/rules/rules/rules.component.ts Voir le fichier

@@ -1,18 +1,21 @@
import { Component, OnInit } from '@angular/core';
import { Rule } from '../class/rule.class';
import { Rule } from '../../../../api/model/rule';
import { RulesService } from '../../../../api/api/rules.service';
@Component({
selector: 'app-rules',
templateUrl: './rules.component.html',
styleUrls: ['./rules.component.scss']
})
export class RulesComponent implements OnInit {
rules: Rule[] = [
{ paragraph: "1", text: "Hier könnte eine regel stehen!", subRule: [{ paragraph: "1", text: "sub rule" }] },
{ paragraph: "2", text: "Regel 2!" }
]
constructor() { }
rules: Rule[] = []
constructor(protected rulesService: RulesService) {
rulesService.configuration.basePath = 'http://localhost:3000';
}

ngOnInit(): void {
this.rulesService.findAll('body').subscribe((rules: Rule[]) => {
this.rules = rules;
})
}

}

Chargement…
Annuler
Enregistrer