Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
Resin
Server
Commits
440ffef5
Commit
440ffef5
authored
3 years ago
by
Antonin COQUET
Browse files
Options
Downloads
Patches
Plain Diff
fix: new endpoint for admin pannel, sorting and better algo
parent
49ab8644
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!96
release V1.10.0
,
!83
Dev
,
!79
feat: add endpoint for unclaimed structure
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/admin/admin.controller.ts
+19
-20
19 additions, 20 deletions
src/admin/admin.controller.ts
with
19 additions
and
20 deletions
src/admin/admin.controller.ts
+
19
−
20
View file @
440ffef5
import
{
Body
,
Delete
,
Param
}
from
'
@nestjs/common
'
;
import
{
Body
,
Delete
,
Param
,
Controller
,
Get
,
Post
,
UseGuards
}
from
'
@nestjs/common
'
;
import
{
Controller
,
Get
,
Post
,
UseGuards
}
from
'
@nestjs/common
'
;
import
{
ApiOperation
,
ApiParam
}
from
'
@nestjs/swagger
'
;
import
{
ApiOperation
,
ApiParam
}
from
'
@nestjs/swagger
'
;
import
{
JwtAuthGuard
}
from
'
../auth/guards/jwt-auth.guard
'
;
import
{
JwtAuthGuard
}
from
'
../auth/guards/jwt-auth.guard
'
;
import
{
NewsletterSubscription
}
from
'
../newsletter/newsletter-subscription.schema
'
;
import
{
NewsletterService
}
from
'
../newsletter/newsletter.service
'
;
import
{
NewsletterService
}
from
'
../newsletter/newsletter.service
'
;
import
{
StructuresService
}
from
'
../structures/services/structures.service
'
;
import
{
StructuresService
}
from
'
../structures/services/structures.service
'
;
import
{
Roles
}
from
'
../users/decorators/roles.decorator
'
;
import
{
Roles
}
from
'
../users/decorators/roles.decorator
'
;
...
@@ -24,7 +24,7 @@ export class AdminController {
...
@@ -24,7 +24,7 @@ export class AdminController {
@
ApiOperation
({
description
:
'
Get pending structre for validation
'
})
@
ApiOperation
({
description
:
'
Get pending structre for validation
'
})
public
async
getPendingAttachments
():
Promise
<
PendingStructureDto
[]
>
{
public
async
getPendingAttachments
():
Promise
<
PendingStructureDto
[]
>
{
const
pendingStructure
=
await
this
.
usersService
.
getPendingStructures
();
const
pendingStructure
=
await
this
.
usersService
.
getPendingStructures
();
return
await
Promise
.
all
(
return
Promise
.
all
(
pendingStructure
.
map
(
async
(
structure
)
=>
{
pendingStructure
.
map
(
async
(
structure
)
=>
{
structure
.
structureName
=
(
await
this
.
structuresService
.
findOne
(
structure
.
structureId
)).
structureName
;
structure
.
structureName
=
(
await
this
.
structuresService
.
findOne
(
structure
.
structureId
)).
structureName
;
return
structure
;
return
structure
;
...
@@ -32,14 +32,6 @@ export class AdminController {
...
@@ -32,14 +32,6 @@ export class AdminController {
);
);
}
}
@
UseGuards
(
JwtAuthGuard
,
RolesGuard
)
@
Roles
(
'
admin
'
)
@
Get
(
'
unclaimedStructures
'
)
@
ApiOperation
({
description
:
'
Get pending structre for validation
'
})
public
async
getUnclaimedStructures
():
Promise
<
UnclaimedStructureDto
[]
>
{
return
await
this
.
structuresService
.
findAllUnclaimed
();
}
@
UseGuards
(
JwtAuthGuard
,
RolesGuard
)
@
UseGuards
(
JwtAuthGuard
,
RolesGuard
)
@
Roles
(
'
admin
'
)
@
Roles
(
'
admin
'
)
@
Get
(
'
adminStructuresList
'
)
@
Get
(
'
adminStructuresList
'
)
...
@@ -50,11 +42,18 @@ export class AdminController {
...
@@ -50,11 +42,18 @@ export class AdminController {
structuresList
.
toClaim
=
(
await
this
.
structuresService
.
findAllUnclaimed
()).
filter
(
structuresList
.
toClaim
=
(
await
this
.
structuresService
.
findAllUnclaimed
()).
filter
(
(
demand
)
=>
!
structuresList
.
inClaim
.
find
((
elem
)
=>
elem
.
structureId
==
demand
.
structureId
)
(
demand
)
=>
!
structuresList
.
inClaim
.
find
((
elem
)
=>
elem
.
structureId
==
demand
.
structureId
)
);
);
structuresList
.
claimed
=
(
await
this
.
structuresService
.
findAll
()).
filter
(
structuresList
.
claimed
=
(
await
this
.
structuresService
.
findAll
())
(
demand
)
=>
.
filter
(
!
structuresList
.
inClaim
.
find
((
elem
)
=>
elem
.
structureId
==
demand
.
id
)
&&
(
demand
)
=>
!
structuresList
.
toClaim
.
find
((
elem
)
=>
elem
.
structureId
==
demand
.
id
)
!
structuresList
.
inClaim
.
find
((
elem
)
=>
elem
.
structureId
==
demand
.
id
)
&&
);
!
structuresList
.
toClaim
.
find
((
elem
)
=>
elem
.
structureId
==
demand
.
id
)
)
.
map
((
structure
)
=>
{
return
{
structureId
:
structure
.
id
,
structureName
:
structure
.
structureName
};
});
structuresList
.
claimed
.
sort
((
a
,
b
)
=>
a
.
structureName
.
localeCompare
(
b
.
structureName
));
structuresList
.
inClaim
.
sort
((
a
,
b
)
=>
a
.
structureName
.
localeCompare
(
b
.
structureName
));
structuresList
.
toClaim
.
sort
((
a
,
b
)
=>
a
.
structureName
.
localeCompare
(
b
.
structureName
));
return
structuresList
;
return
structuresList
;
}
}
...
@@ -71,7 +70,7 @@ export class AdminController {
...
@@ -71,7 +70,7 @@ export class AdminController {
true
true
);
);
const
pendingStructure
=
await
this
.
usersService
.
getPendingStructures
();
const
pendingStructure
=
await
this
.
usersService
.
getPendingStructures
();
return
await
Promise
.
all
(
return
Promise
.
all
(
pendingStructure
.
map
(
async
(
pendingStructureData
)
=>
{
pendingStructure
.
map
(
async
(
pendingStructureData
)
=>
{
pendingStructureData
.
structureName
=
(
pendingStructureData
.
structureName
=
(
await
this
.
structuresService
.
findOne
(
pendingStructureData
.
structureId
)
await
this
.
structuresService
.
findOne
(
pendingStructureData
.
structureId
)
...
@@ -94,7 +93,7 @@ export class AdminController {
...
@@ -94,7 +93,7 @@ export class AdminController {
false
false
);
);
const
pendingStructure
=
await
this
.
usersService
.
getPendingStructures
();
const
pendingStructure
=
await
this
.
usersService
.
getPendingStructures
();
return
await
Promise
.
all
(
return
Promise
.
all
(
pendingStructure
.
map
(
async
(
pendingStructureData
)
=>
{
pendingStructure
.
map
(
async
(
pendingStructureData
)
=>
{
pendingStructureData
.
structureName
=
(
pendingStructureData
.
structureName
=
(
await
this
.
structuresService
.
findOne
(
pendingStructureData
.
structureId
)
await
this
.
structuresService
.
findOne
(
pendingStructureData
.
structureId
)
...
@@ -149,7 +148,7 @@ export class AdminController {
...
@@ -149,7 +148,7 @@ export class AdminController {
@
Roles
(
'
admin
'
)
@
Roles
(
'
admin
'
)
@
Delete
(
'
newsletterSubscription/:email
'
)
@
Delete
(
'
newsletterSubscription/:email
'
)
@
ApiParam
({
name
:
'
email
'
,
type
:
String
,
required
:
true
})
@
ApiParam
({
name
:
'
email
'
,
type
:
String
,
required
:
true
})
public
async
unsubscribeUserFromNewsletter
(@
Param
()
params
)
{
public
async
unsubscribeUserFromNewsletter
(@
Param
()
params
)
:
Promise
<
NewsletterSubscription
>
{
return
await
this
.
newsletterService
.
deleteOneEmail
(
params
.
email
);
return
this
.
newsletterService
.
deleteOneEmail
(
params
.
email
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment