Skip to content

Commit

Permalink
Merge pull request #148 from Strayker-Software/feature/37-allow-user-…
Browse files Browse the repository at this point in the history
…to-showhide-completed-tasks

Allow User to show/hide completed tasks
  • Loading branch information
StraykerPL authored Jan 28, 2024
2 parents bb7db5a + 4be2ef4 commit 823d318
Show file tree
Hide file tree
Showing 50 changed files with 1,364 additions and 900 deletions.
13 changes: 10 additions & 3 deletions binder-web-backend/Binder.Api/Controllers/ToDoTasksController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Binder.Application.Models.Interfaces;
using Binder.Api.Models;
using Binder.Application.Models.Interfaces;
using Binder.Core.Models;
using Microsoft.AspNetCore.Mvc;

Expand All @@ -16,9 +17,15 @@ public ToDoTasksController(IToDoTasksService service)
}

[HttpGet]
public ActionResult<ToDoTask[]> Get(int tableId)
public ActionResult<ToDoTask[]> Get(int tableId, TaskShow showFiltering)
{
return Ok(_service.GetTasksForTable(tableId));
return showFiltering switch
{
TaskShow.ShowCompleted => Ok(_service.GetTasksForTable(tableId).Where(x => x.IsCompleted == true)),
TaskShow.HideCompleted => Ok(_service.GetTasksForTable(tableId).Where(x => x.IsCompleted == false)),
TaskShow.ShowAll => Ok(_service.GetTasksForTable(tableId)),
_ => NotFound(),
};
}
}
}
10 changes: 10 additions & 0 deletions binder-web-backend/Binder.Api/Models/TaskShow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Binder.Api.Models
{
public enum TaskShow
{
None,
ShowCompleted,
HideCompleted,
ShowAll
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public async Task InvokeAsync(HttpContext context)
catch (Exception e)
{
ProblemDetails problemDetails = GetProblemDetailsByExceptionFactory.GetProblemDetails(e);
context.Response.StatusCode = (int)problemDetails.Status;

context.Response.StatusCode = (int)problemDetails.Status!;
context.Response.ContentType = problemJsonType;

var json = JsonSerializer.Serialize(problemDetails);
Expand Down
1 change: 1 addition & 0 deletions binder-web-frontend/src/api/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ git_push.sh
index.ts
model/defaultTable.ts
model/models.ts
model/taskShow.ts
model/toDoTask.ts
param.ts
variables.ts
24 changes: 15 additions & 9 deletions binder-web-frontend/src/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
### 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!)
First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)

### consuming

Expand All @@ -33,25 +34,25 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_

In PATH_TO_GENERATED_PACKAGE/dist:

```
npm link
```

In your project:

```
npm link
npm link
```

__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
**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 '';
Expand Down Expand Up @@ -128,9 +129,11 @@ 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';
Expand All @@ -150,8 +153,8 @@ 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.

```
Expand All @@ -161,6 +164,7 @@ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]);
```

or

```
Expand All @@ -175,8 +179,8 @@ import { BASE_PATH } from '';
export class AppModule {}
```


#### Using @angular/cli

First extend your `src/environments/*.ts` files by adding the corresponding base path:

```
Expand All @@ -187,6 +191,7 @@ export const environment = {
```

In the src/app/app.module.ts:

```
import { BASE_PATH } from '';
import { environment } from '../environments/environment';
Expand Down Expand Up @@ -215,10 +220,11 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above).

Example value for use in your Configuration-Provider:

```typescript
new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param),
})
encodeParam: (param: Param) => myFancyParamEncoder(param),
});
```

[parameter-locations-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-locations
Expand Down
52 changes: 32 additions & 20 deletions binder-web-frontend/src/api/api.module.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core';
import {
NgModule,
ModuleWithProviders,
SkipSelf,
Optional,
} from '@angular/core';
import { Configuration } from './configuration';
import { HttpClient } from '@angular/common/http';


@NgModule({
imports: [],
imports: [],
declarations: [],
exports: [],
providers: []
exports: [],
providers: [],
})
export class ApiModule {
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders<ApiModule> {
return {
ngModule: ApiModule,
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
};
}
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');
}
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'
);
}
}
}
Loading

0 comments on commit 823d318

Please sign in to comment.