Skip to content

Commit bfcf79c

Browse files
(feat): UI agregar página que lista namespaces (#75)
* Add namespace sunat info * Fix license * Save changes * Save changes * Make test work except 1 * Add webpage template * Remove security conditionals * Removed unused code * List namespaces * add polling context * Remove unused files * Remove ui build from jvm tests * Remove enterprise comment * Fix docker-compose.yml
1 parent ca8bd45 commit bfcf79c

File tree

25 files changed

+490
-845
lines changed

25 files changed

+490
-845
lines changed

.github/workflows/ci-actions.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
distribution: temurin
2323
cache: maven
2424
- name: Maven
25-
run: mvn test -Pui
25+
run: mvn test
2626
- name: Prepare failure archive (if maven failed)
2727
if: failure()
2828
shell: bash
@@ -34,18 +34,18 @@ jobs:
3434
name: test-reports-jvm
3535
path: "test-reports.tgz"
3636

37-
native-tests:
38-
name: Native Tests
39-
runs-on: ubuntu-latest
40-
steps:
41-
- uses: actions/checkout@v2.4.0
42-
- uses: actions/setup-java@v2
43-
with:
44-
java-version: 11
45-
distribution: temurin
46-
cache: maven
47-
- name: Build with Maven
48-
run: mvn verify -Dquarkus.native.container-build=true -P native,ui
37+
# native-tests:
38+
# name: Native Tests
39+
# runs-on: ubuntu-latest
40+
# steps:
41+
# - uses: actions/checkout@v2.4.0
42+
# - uses: actions/setup-java@v2
43+
# with:
44+
# java-version: 11
45+
# distribution: temurin
46+
# cache: maven
47+
# - name: Build with Maven
48+
# run: mvn verify -Dquarkus.native.container-build=true -P native,ui
4949

5050
ui-tests:
5151
name: UI Tests

.github/workflows/container-images.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,29 @@ jobs:
1717
java-version: 11
1818
distribution: temurin
1919
cache: maven
20-
- name: Build container image
21-
run: |
22-
mvn -U -B package --file pom.xml -DskipTests \
23-
-Dquarkus.native.container-build=true \
24-
-Dquarkus.container-image.push=true \
25-
-Dquarkus.container-image.build=true \
26-
-Dquarkus.container-image.registry=quay.io \
27-
-Dquarkus.container-image.group=projectopenubl \
28-
-Dquarkus.container-image.name=ublhub \
29-
-Dquarkus.container-image.tag=early-access \
30-
-Dquarkus.container-image.username=${{ secrets.QUAYIO_USERNAME }} \
31-
-Dquarkus.container-image.password=${{ secrets.QUAYIO_PASSWORD }} \
32-
-P native,ui
20+
# - name: Build native container image
21+
# run: |
22+
# mvn -U -B package --file pom.xml -DskipTests \
23+
# -Dquarkus.native.container-build=true \
24+
# -Dquarkus.container-image.push=true \
25+
# -Dquarkus.container-image.build=true \
26+
# -Dquarkus.container-image.registry=quay.io \
27+
# -Dquarkus.container-image.group=projectopenubl \
28+
# -Dquarkus.container-image.name=ublhub \
29+
# -Dquarkus.container-image.tag=early-access \
30+
# -Dquarkus.container-image.username=${{ secrets.QUAYIO_USERNAME }} \
31+
# -Dquarkus.container-image.password=${{ secrets.QUAYIO_PASSWORD }} \
32+
# -P native,ui
33+
- name: Build jvm container image
34+
run: mvn -U -B package --file pom.xml -Pcontainer-image -DskipTests \
35+
-Dquarkus.native.container-build=false \
36+
-Dquarkus.container-image.push=true \
37+
-Dquarkus.container-image.build=true \
38+
-Dquarkus.container-image.registry=quay.io \
39+
-Dquarkus.container-image.group=projectopenubl \
40+
-Dquarkus.container-image.name=ublhub \
41+
-Dquarkus.container-image.tag=early-access \
42+
-Dquarkus.container-image.username=${{ secrets.QUAYIO_USERNAME }} \
43+
-Dquarkus.container-image.password=${{ secrets.QUAYIO_PASSWORD }} \
44+
-P ui
45+

.github/workflows/pr-build-container-images-comment-boot.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
The creation of the container image might take aproximately 10 minutes. Once it is available you can pull it using:
1919
```shell
2020
docker pull ghcr.io/${{github.event.pull_request.head.repo.full_name}}/${{github.event.repository.name}}:${{github.event.pull_request.head.ref}}
21-
docker pull ghcr.io/${{github.event.pull_request.head.repo.full_name}}/${{github.event.repository.name}}-enterprise:${{github.event.pull_request.head.ref}}
2221
```
2322
2423
- To watch the current status of the container image creation visit [Workflow runs](https://github.com/${{github.event.pull_request.head.repo.full_name}}/actions/workflows/pr-build-container-images.yml?query=branch%3A${{github.event.pull_request.head.ref}})

.github/workflows/pr-build-container-images.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,20 @@ jobs:
2020
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
2121
id: extract_branch
2222

23-
- name: Build container image
23+
# - name: Build native container image
24+
# run: |
25+
# mvn -U -B package --file pom.xml -DskipTests \
26+
# -Dquarkus.container-image.build=true \
27+
# -Dquarkus.container-image.push=true \
28+
# -Dquarkus.container-image.build=true \
29+
# -Dquarkus.container-image.registry=ghcr.io \
30+
# -Dquarkus.container-image.group=${{ github.repository_owner }} \
31+
# -Dquarkus.container-image.name=${{ github.event.repository.name }}/ublhub \
32+
# -Dquarkus.container-image.tag=${{ steps.extract_branch.outputs.branch }} \
33+
# -Dquarkus.container-image.username=${{ github.actor }} \
34+
# -Dquarkus.container-image.password=${{ secrets.GITHUB_TOKEN }} \
35+
# -P native,ui
36+
- name: Build jvm container image
2437
run: |
2538
mvn -U -B package --file pom.xml -DskipTests \
2639
-Dquarkus.container-image.build=true \
@@ -32,4 +45,4 @@ jobs:
3245
-Dquarkus.container-image.tag=${{ steps.extract_branch.outputs.branch }} \
3346
-Dquarkus.container-image.username=${{ github.actor }} \
3447
-Dquarkus.container-image.password=${{ secrets.GITHUB_TOKEN }} \
35-
-P native,ui
48+
-P ui

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ services:
4040
QUARKUS_HTTP_PORT: 8080
4141
QUARKUS_DATASOURCE_USERNAME: db_username
4242
QUARKUS_DATASOURCE_PASSWORD: db_password
43-
QUARKUS_DATASOURCE_JDBC_URL: jdbc:postgresql://postgresql:5432/ublhub_db
43+
QUARKUS_DATASOURCE_REACTIVE_URL: vertx-reactive:postgresql://postgresql:5432/ublhub_db
4444
healthcheck:
4545
test: [ "CMD", "curl", "-f", "http://localhost:8080/q/health" ]
4646
interval: 10s

src/main/java/io/github/project/openubl/ublhub/resources/CurrentUserResource.java

Lines changed: 0 additions & 116 deletions
This file was deleted.

src/main/java/io/github/project/openubl/ublhub/resources/NamespaceResource.java

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,19 @@
1818
*/
1919

2020
import io.github.project.openubl.ublhub.idm.NamespaceRepresentation;
21+
import io.github.project.openubl.ublhub.idm.PageRepresentation;
22+
import io.github.project.openubl.ublhub.keys.DefaultKeyProviders;
2123
import io.github.project.openubl.ublhub.keys.KeyManager;
2224
import io.github.project.openubl.ublhub.keys.component.utils.ComponentUtil;
25+
import io.github.project.openubl.ublhub.models.PageBean;
26+
import io.github.project.openubl.ublhub.models.SortBean;
2327
import io.github.project.openubl.ublhub.models.jpa.ComponentRepository;
2428
import io.github.project.openubl.ublhub.models.jpa.NamespaceRepository;
29+
import io.github.project.openubl.ublhub.models.jpa.entities.NamespaceEntity;
30+
import io.github.project.openubl.ublhub.models.jpa.entities.SunatEntity;
2531
import io.github.project.openubl.ublhub.models.utils.EntityToRepresentation;
2632
import io.github.project.openubl.ublhub.models.utils.RepresentationToEntity;
33+
import io.github.project.openubl.ublhub.resources.utils.ResourceUtils;
2734
import io.quarkus.hibernate.reactive.panache.Panache;
2835
import io.quarkus.hibernate.reactive.panache.PanacheEntityBase;
2936
import io.smallrye.mutiny.Uni;
@@ -34,12 +41,11 @@
3441

3542
import javax.enterprise.context.ApplicationScoped;
3643
import javax.inject.Inject;
44+
import javax.validation.Valid;
3745
import javax.validation.constraints.NotNull;
3846
import javax.ws.rs.*;
3947
import javax.ws.rs.core.Response;
40-
import java.util.HashMap;
41-
import java.util.List;
42-
import java.util.Objects;
48+
import java.util.*;
4349
import java.util.stream.Collectors;
4450

4551
@Path("/namespaces")
@@ -62,6 +68,66 @@ public class NamespaceResource {
6268
@Inject
6369
ComponentUtil componentUtil;
6470

71+
@Inject
72+
DefaultKeyProviders defaultKeyProviders;
73+
74+
@POST
75+
@Path("/")
76+
public Uni<Response> createNameSpace(@NotNull @Valid NamespaceRepresentation rep) {
77+
return namespaceRepository.findByName(rep.getName())
78+
.onItem().ifNotNull().transform(entity -> Response.status(Response.Status.CONFLICT).build())
79+
.onItem().ifNull().switchTo(() -> Panache
80+
.withTransaction(() -> {
81+
final NamespaceEntity namespaceEntity = new NamespaceEntity();
82+
namespaceEntity.id = UUID.randomUUID().toString();
83+
namespaceEntity.name = rep.getName();
84+
namespaceEntity.description = rep.getDescription();
85+
namespaceEntity.createdOn = new Date();
86+
87+
namespaceEntity.sunat = new SunatEntity();
88+
namespaceEntity.sunat.sunatUsername = rep.getCredentials().getUsername();
89+
namespaceEntity.sunat.sunatPassword = rep.getCredentials().getPassword();
90+
namespaceEntity.sunat.sunatUrlFactura = rep.getWebServices().getFactura();
91+
namespaceEntity.sunat.sunatUrlGuiaRemision = rep.getWebServices().getGuia();
92+
namespaceEntity.sunat.sunatUrlPercepcionRetencion = rep.getWebServices().getRetenciones();
93+
94+
return namespaceRepository.persist(namespaceEntity)
95+
.chain(namespace -> defaultKeyProviders.createProviders(namespace))
96+
.map(unused -> namespaceEntity);
97+
})
98+
.map(namespaceEntity -> Response.ok()
99+
.entity(EntityToRepresentation.toRepresentation(namespaceEntity))
100+
.build()
101+
)
102+
);
103+
}
104+
105+
@GET
106+
@Path("/")
107+
public Uni<PageRepresentation<NamespaceRepresentation>> getNamespaces(
108+
@QueryParam("filterText") String filterText,
109+
@QueryParam("offset") @DefaultValue("0") Integer offset,
110+
@QueryParam("limit") @DefaultValue("10") Integer limit,
111+
@QueryParam("sort_by") @DefaultValue("createdOn:desc") List<String> sortBy
112+
) {
113+
PageBean pageBean = ResourceUtils.getPageBean(offset, limit);
114+
List<SortBean> sortBeans = ResourceUtils.getSortBeans(sortBy, NamespaceRepository.SORT_BY_FIELDS);
115+
116+
if (filterText != null && !filterText.trim().isEmpty()) {
117+
return Panache.withTransaction(() -> namespaceRepository
118+
.list(filterText, pageBean, sortBeans)
119+
.asTuple()
120+
.map(tuple2 -> EntityToRepresentation.toRepresentation(tuple2.getItem1(), tuple2.getItem2(), EntityToRepresentation::toRepresentation))
121+
);
122+
} else {
123+
return Panache.withTransaction(() -> namespaceRepository
124+
.list(pageBean, sortBeans)
125+
.asTuple()
126+
.map(tuple2 -> EntityToRepresentation.toRepresentation(tuple2.getItem1(), tuple2.getItem2(), EntityToRepresentation::toRepresentation))
127+
);
128+
}
129+
}
130+
65131
@GET
66132
@Path("/{namespaceId}")
67133
public Uni<Response> getNamespace(@PathParam("namespaceId") @NotNull String namespaceId) {

src/main/webapp/src/api-client/resources/core.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,6 @@ export class CoreClusterResource extends ClusterResource {
2121
}
2222
}
2323

24-
export class AdminClusterResource extends ClusterResource {
25-
private _gvk: IGroupVersionKindPlural;
26-
27-
constructor(kind: AdminClusterResourceKind) {
28-
super();
29-
this._gvk = {
30-
group: "",
31-
version: "",
32-
kindPlural: kind,
33-
};
34-
}
35-
36-
gvk(): IGroupVersionKindPlural {
37-
return this._gvk;
38-
}
39-
40-
public listPath(): string {
41-
return ["/admin", this.gvk().kindPlural].join("/");
42-
}
43-
}
44-
4524
export enum CoreClusterResourceKind {
46-
Version = "versions",
47-
Contribuyente = "contribuyentes",
48-
}
49-
50-
export enum AdminClusterResourceKind {
51-
User = "users",
25+
Namespace = "namespaces",
5226
}

0 commit comments

Comments
 (0)