From b2e13a7df72297b8170e36869b5bcb2e303d8fdb Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Thu, 4 Jan 2024 14:53:19 +0800 Subject: [PATCH 01/17] Set up CI --- .github/workflows/build.yaml | 18 +++++++--- .github/workflows/ci.yml | 61 ++++++++++++++++++++++++++++++++++ docker/Dockerfile | 2 +- src/main/resources/logback.xml | 2 +- 4 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index be2c833e..e8c512e9 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,11 +16,11 @@ # specific language governing permissions and limitations # under the License. # -name: Build +name: Docker on: push: - branches: - - main + tags: + - 'v*' jobs: docker: @@ -31,12 +31,20 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v2 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: ${{ secrets.DOCKERHUB_USER }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + apache/eventmesh-dashboard + - name: Build and push uses: docker/build-push-action@v4 with: push: true - tags: apache/eventmesh-dashboard:latest + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} file: docker/Dockerfile context: . diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..0d47514b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name: "Continuous Integration" + +on: + push: + branches: [ '*' ] + pull_request: + branches: [ '*' ] + +jobs: + build: + name: Build + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + java: [ 8 ] + language: ['java'] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-gradle- + + - name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: ${{ matrix.java }} + + - name: Build + run: ./gradlew clean build bootJar --parallel --daemon + env: + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }} diff --git a/docker/Dockerfile b/docker/Dockerfile index 625bdac2..326c8b19 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -15,7 +15,7 @@ # limitations under the License. # -FROM openjdk:8-jre-alpine +FROM openjdk:8-jdk VOLUME /tmp COPY build/libs/eventmesh-dashboard-*.jar eventmesh-dashboard.jar ENV JAVA_OPTS="" diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 447ace7c..dbed6dce 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -42,7 +42,7 @@ - + From 52384c8e22808dfcdd7e36b16111d6108ce54afc Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Thu, 4 Jan 2024 16:00:57 +0800 Subject: [PATCH 02/17] Add LICENSE --- .gitattributes | 20 +++++ LICENSE | 201 +++++++++++++++++++++++++++++++++++++++++++++++++ NOTICE | 5 ++ 3 files changed, 226 insertions(+) create mode 100644 .gitattributes create mode 100644 LICENSE create mode 100644 NOTICE diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..b27bb300 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +*.sh text eol=lf +gradlew text eol=lf +*.{cmd,[cC][mM][dD]} text eol=crlf +*.{bat,[bB][aA][tT]} text eol=crlf \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..910ee067 --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +Apache EventMesh +Copyright 2021-2024 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). From eb98fb76e754792f8dcc37c7c9915e153c0e1b21 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Thu, 4 Jan 2024 19:53:22 +0800 Subject: [PATCH 03/17] Add CheckStyle --- style/checkStyle.xml | 370 +++++++++++++++++++++++++++++++++ style/checkstyle-header1.txt | 17 ++ style/checkstyle-header2.txt | 16 ++ style/checkstyle-header3.txt | 18 ++ style/eventmesh-code-style.xml | 299 ++++++++++++++++++++++++++ 5 files changed, 720 insertions(+) create mode 100644 style/checkStyle.xml create mode 100644 style/checkstyle-header1.txt create mode 100644 style/checkstyle-header2.txt create mode 100644 style/checkstyle-header3.txt create mode 100644 style/eventmesh-code-style.xml diff --git a/style/checkStyle.xml b/style/checkStyle.xml new file mode 100644 index 00000000..cfa19728 --- /dev/null +++ b/style/checkStyle.xml @@ -0,0 +1,370 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/style/checkstyle-header1.txt b/style/checkstyle-header1.txt new file mode 100644 index 00000000..6a9c0641 --- /dev/null +++ b/style/checkstyle-header1.txt @@ -0,0 +1,17 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + diff --git a/style/checkstyle-header2.txt b/style/checkstyle-header2.txt new file mode 100644 index 00000000..b1312a09 --- /dev/null +++ b/style/checkstyle-header2.txt @@ -0,0 +1,16 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/style/checkstyle-header3.txt b/style/checkstyle-header3.txt new file mode 100644 index 00000000..446e3fb4 --- /dev/null +++ b/style/checkstyle-header3.txt @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Licensed to Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Apache Software Foundation (ASF) licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. diff --git a/style/eventmesh-code-style.xml b/style/eventmesh-code-style.xml new file mode 100644 index 00000000..c8bddd49 --- /dev/null +++ b/style/eventmesh-code-style.xml @@ -0,0 +1,299 @@ + + + + + + + + From 4b39c6d766d6969d09da8d7b48e5a603fb7865a6 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Thu, 4 Jan 2024 23:56:34 +0800 Subject: [PATCH 04/17] Set up DB --- build.gradle | 14 +++- .../EventMeshDashboardApplication.java | 2 + src/main/resources/application-dev.yml | 75 +++++++++++++++++++ src/main/resources/application.yml | 42 +++-------- src/main/resources/logback.xml | 2 +- 5 files changed, 97 insertions(+), 38 deletions(-) create mode 100644 src/main/resources/application-dev.yml diff --git a/build.gradle b/build.gradle index 5b676ab6..2db74388 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,6 @@ repositories { ext { // utility commonsLang3Version = '3.13.0' - guavaVersion = '32.1.2-jre' // not used for now fastjsonVersion = '2.0.40' // swagger springdocVersion = '1.7.0' @@ -64,13 +63,20 @@ dependencies { // utility implementation "org.apache.commons:commons-lang3:${commonsLang3Version}" - implementation("com.alibaba.fastjson2:fastjson2:${fastjsonVersion}") + implementation "com.alibaba.fastjson2:fastjson2:${fastjsonVersion}" // swagger implementation "org.springdoc:springdoc-openapi-ui:${springdocVersion}" implementation "org.springdoc:springdoc-openapi-javadoc:${springdocVersion}" annotationProcessor 'com.github.therapi:therapi-runtime-javadoc-scribe:0.15.0' // unit test - testImplementation("org.mockito:mockito-core:${mockitoVersion}") + testImplementation "org.mockito:mockito-core:${mockitoVersion}" // meta - implementation("com.alibaba.nacos:nacos-client:${nacosVersion}") + implementation "com.alibaba.nacos:nacos-client:${nacosVersion}" + // Event Store + implementation 'org.apache.rocketmq:rocketmq-client:4.9.7' + + // Database + implementation 'com.alibaba:druid-spring-boot-starter:1.2.21' + implementation 'com.baomidou:mybatis-plus-boot-starter:3.5.5' + runtimeOnly 'com.mysql:mysql-connector-j' } diff --git a/src/main/java/org/apache/eventmesh/dashboard/EventMeshDashboardApplication.java b/src/main/java/org/apache/eventmesh/dashboard/EventMeshDashboardApplication.java index 60d61254..dea37fd4 100644 --- a/src/main/java/org/apache/eventmesh/dashboard/EventMeshDashboardApplication.java +++ b/src/main/java/org/apache/eventmesh/dashboard/EventMeshDashboardApplication.java @@ -19,7 +19,9 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +@ServletComponentScan // Druid Monitor @SpringBootApplication public class EventMeshDashboardApplication { diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 00000000..87d20de2 --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,75 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/eventmesh-dashboard?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + username: root + password: + + initial-size: 1 + max-active: 50 + min-idle: 5 + max-wait: 6000 + validation-query: select 'x' + validation-query-timeout: 15 + test-on-borrow: false + test-while-idle: true + min-evictable-idle-time-millis: 300000 + + stat-view-servlet: + enabled: true + url-pattern: /druid/* + filter: + wall: + config: + multi-statement-allow: true # corresponding to allowMultiQueries=true + +eventmesh: + meta: + # registry type: nacos, etcd + type: nacos + nacos: + addr: 127.0.0.1:8848 + namespace: # namespace id, empty by default + authEnabled: false + protocol: http # http or https + username: + password: + # Alibaba Cloud MSE Nacos auth, not nacos.token.secret.key + accessKey: + secretKey: + etcd: + addr: # TODO + # timeout for admin client + timeoutMs: 5000 + store: + # Event Store type, should be consistent with the EventMesh Runtime configuration. + type: rocketmq + standalone: + # TODO + rocketmq: + namesrvAddr: 127.0.0.1:9876;127.0.0.1:9876 + clusterName: DefaultCluster + accessKey: '********' + secretKey: '********' + kafka: + namesrvAddr: localhost:9092;localhost:9092 + partitions: 1 + replicationFactors: 1 \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 518a124a..434cf55a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -14,10 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - spring: application: name: eventmesh-dashboard + profiles: + active: dev server: port: 8080 @@ -30,35 +31,10 @@ server: logging: config: classpath:logback.xml -eventmesh: - meta: - # registry type: nacos, etcd - type: nacos - nacos: - addr: 127.0.0.1:8848 - namespace: # namespace id, empty by default - authEnabled: false - protocol: http # http or https - username: - password: - # Alibaba Cloud MSE Nacos auth, not nacos.token.secret.key - accessKey: - secretKey: - etcd: - addr: # TODO - # timeout for admin client - timeoutMs: 5000 - store: - # Event Store type, should be consistent with the EventMesh Runtime configuration. - type: rocketmq - standalone: - # TODO - rocketmq: - namesrvAddr: 127.0.0.1:9876;127.0.0.1:9876 - clusterName: DefaultCluster - accessKey: '********' - secretKey: '********' - kafka: - namesrvAddr: localhost:9092;localhost:9092 - partitions: 1 - replicationFactors: 1 \ No newline at end of file +mybatis-plus: + mapper-locations: classpath*:mappers/**/*.xml # Default value + typeAliasesPackage: org.apache.eventmesh.dashboard.entity + configuration: + call-setters-on-nulls: true # Display fields with null values in query results + map-underscore-to-camel-case: true # Convert database underscore naming convention to camel case (default is true) +# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # Output SQL execution logs to console (for debugging) \ No newline at end of file diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index dbed6dce..447ace7c 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -42,7 +42,7 @@ - + From 6a61862b6f39c926ba4ab507738345284b276de0 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Thu, 4 Jan 2024 23:58:43 +0800 Subject: [PATCH 05/17] Add druid StatFilter controller --- .../controller/MetricsController.java | 31 +++++++++++++++++++ src/main/resources/application-dev.yml | 4 +-- 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/apache/eventmesh/dashboard/controller/MetricsController.java diff --git a/src/main/java/org/apache/eventmesh/dashboard/controller/MetricsController.java b/src/main/java/org/apache/eventmesh/dashboard/controller/MetricsController.java new file mode 100644 index 00000000..dfe3a463 --- /dev/null +++ b/src/main/java/org/apache/eventmesh/dashboard/controller/MetricsController.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.eventmesh.dashboard.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.alibaba.druid.stat.DruidStatManagerFacade; + +@RestController +public class MetricsController { + @GetMapping("/druid/stat") + public Object druidStat() { + return DruidStatManagerFacade.getInstance().getDataSourceStatDataList(); + } +} \ No newline at end of file diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 87d20de2..91377864 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -19,7 +19,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/eventmesh-dashboard?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://localhost:3306/eventmesh-dashboard?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 username: root password: @@ -39,7 +39,7 @@ spring: filter: wall: config: - multi-statement-allow: true # corresponding to allowMultiQueries=true + multi-statement-allow: true # corresponds to allowMultiQueries eventmesh: meta: From 8df7c43d642f6dc1a2aa91c84c52a3cbce420eb2 Mon Sep 17 00:00:00 2001 From: Pil0tXia Date: Fri, 5 Jan 2024 14:58:25 +0800 Subject: [PATCH 06/17] sync CI change in https://github.com/apache/eventmesh/pull/4722 --- .github/workflows/ci.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d47514b..dba06dcd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,19 +40,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Cache Gradle packages - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: ${{ runner.os }}-gradle- + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 - name: Set up JDK ${{ matrix.java }} uses: actions/setup-java@v3 with: - distribution: 'zulu' + distribution: 'corretto' java-version: ${{ matrix.java }} - name: Build From fac7d3dc08cae1465a30e0b1cbfcb3ad5eccf8e5 Mon Sep 17 00:00:00 2001 From: laohu <2732554140@qq.com> Date: Mon, 8 Jan 2024 12:52:58 +0800 Subject: [PATCH 07/17] =?UTF-8?q?fix(*)1.=20=E5=AE=8C=E6=88=90=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E8=AE=BE=E8=AE=A1=202.=20=E5=AE=8C=E6=88=90=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=B8=8E=E6=A8=A1=E5=9D=97=E6=90=AD=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .asf.yaml | 47 --- .dockerignore | 2 - .gitignore | 251 ++++++------ README.md | 54 +-- components/client/GrpcClientTable.tsx | 217 ---------- components/client/HTTPClientTable.tsx | 217 ---------- components/client/TCPClientTable.tsx | 223 ----------- components/event/EventTable.tsx | 371 ----------------- components/eventCatalogs/Create.tsx | 137 ------- components/eventCatalogs/Details.tsx | 121 ------ components/eventCatalogs/constant.ts | 27 -- components/eventCatalogs/types.ts | 40 -- components/index/Configuration.tsx | 249 ------------ components/index/Endpoint.tsx | 105 ----- components/metrics/MetricsTable.tsx | 313 --------------- components/navigation/MenuItem.tsx | 115 ------ components/navigation/Menus.tsx | 179 --------- components/navigation/MenusMobile.tsx | 58 --- components/navigation/Sidebar.tsx | 63 --- components/registry/RegistryTable.tsx | 170 -------- components/topic/TopicTable.tsx | 275 ------------- components/workflow/Create.tsx | 136 ------- components/workflow/Details/Details.tsx | 285 ------------- components/workflow/Details/Instances.tsx | 164 -------- components/workflow/Details/index.ts | 22 - components/workflow/constant.ts | 41 -- components/workflow/types.ts | 54 --- context/context.tsx | 87 ---- context/reducer.ts | 40 -- context/type.ts | 40 -- docker/Dockerfile | 10 - docker/default.conf | 13 - eventmesh-dashboard-common/pom.xml | 21 + .../eventmesh/dashboard/common/Main.java | 7 + eventmesh-dashboard-console/pom.xml | 21 + .../eventmesh/dashboard/console/Main.java | 7 + eventmesh-dashboard-core/pom.xml | 21 + .../apache/eventmesh/dashboard/core/Main.java | 7 + eventmesh-dashboard-observe/pom.xml | 21 + .../eventmesh/dashboard/observe/Main.java | 7 + eventmesh-dashboard-service/pom.xml | 21 + .../eventmesh/dashboard/service/Main.java | 7 + next.config.js | 29 -- package.json | 46 --- pages/_app.tsx | 46 --- pages/_document.tsx | 38 -- pages/event.tsx | 33 -- pages/eventCatalogs.tsx | 223 ----------- pages/grpc.tsx | 33 -- pages/http.tsx | 33 -- pages/index.tsx | 35 -- pages/metrics.tsx | 33 -- pages/registry.tsx | 33 -- pages/tcp.tsx | 33 -- pages/topic.tsx | 33 -- pages/workflows.tsx | 375 ------------------ pom.xml | 96 +++++ public/favicon.ico | Bin 25931 -> 0 bytes static/images/logo.png | Bin 58522 -> 0 bytes tsconfig.json | 20 - 60 files changed, 369 insertions(+), 5036 deletions(-) delete mode 100644 .asf.yaml delete mode 100644 .dockerignore delete mode 100644 components/client/GrpcClientTable.tsx delete mode 100644 components/client/HTTPClientTable.tsx delete mode 100644 components/client/TCPClientTable.tsx delete mode 100644 components/event/EventTable.tsx delete mode 100644 components/eventCatalogs/Create.tsx delete mode 100644 components/eventCatalogs/Details.tsx delete mode 100644 components/eventCatalogs/constant.ts delete mode 100644 components/eventCatalogs/types.ts delete mode 100755 components/index/Configuration.tsx delete mode 100755 components/index/Endpoint.tsx delete mode 100755 components/metrics/MetricsTable.tsx delete mode 100644 components/navigation/MenuItem.tsx delete mode 100644 components/navigation/Menus.tsx delete mode 100644 components/navigation/MenusMobile.tsx delete mode 100644 components/navigation/Sidebar.tsx delete mode 100644 components/registry/RegistryTable.tsx delete mode 100644 components/topic/TopicTable.tsx delete mode 100644 components/workflow/Create.tsx delete mode 100644 components/workflow/Details/Details.tsx delete mode 100644 components/workflow/Details/Instances.tsx delete mode 100644 components/workflow/Details/index.ts delete mode 100644 components/workflow/constant.ts delete mode 100644 components/workflow/types.ts delete mode 100644 context/context.tsx delete mode 100644 context/reducer.ts delete mode 100644 context/type.ts delete mode 100644 docker/Dockerfile delete mode 100644 docker/default.conf create mode 100644 eventmesh-dashboard-common/pom.xml create mode 100644 eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/Main.java create mode 100644 eventmesh-dashboard-console/pom.xml create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/Main.java create mode 100644 eventmesh-dashboard-core/pom.xml create mode 100644 eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/Main.java create mode 100644 eventmesh-dashboard-observe/pom.xml create mode 100644 eventmesh-dashboard-observe/src/main/java/org/apache/eventmesh/dashboard/observe/Main.java create mode 100644 eventmesh-dashboard-service/pom.xml create mode 100644 eventmesh-dashboard-service/src/main/java/org/apache/eventmesh/dashboard/service/Main.java delete mode 100644 next.config.js delete mode 100644 package.json delete mode 100644 pages/_app.tsx delete mode 100644 pages/_document.tsx delete mode 100644 pages/event.tsx delete mode 100644 pages/eventCatalogs.tsx delete mode 100644 pages/grpc.tsx delete mode 100644 pages/http.tsx delete mode 100755 pages/index.tsx delete mode 100644 pages/metrics.tsx delete mode 100644 pages/registry.tsx delete mode 100644 pages/tcp.tsx delete mode 100644 pages/topic.tsx delete mode 100644 pages/workflows.tsx create mode 100644 pom.xml delete mode 100644 public/favicon.ico delete mode 100644 static/images/logo.png delete mode 100644 tsconfig.json diff --git a/.asf.yaml b/.asf.yaml deleted file mode 100644 index ec35b205..00000000 --- a/.asf.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -github: - description: EventMesh dashboard - features: - # Enable issue management - issues: true - # Enable wiki - wiki: true - homepage: https://eventmesh.apache.org/ - labels: - - pubsub - enabled_merge_buttons: - squash: true - merge: true - rebase: false - protected_branches: - main: - required_status_checks: - strict: true - required_pull_request_reviews: - dismiss_stale_reviews: true - required_approving_review_count: 1 -notifications: - commits: commits@eventmesh.apache.org - # Send all issue emails (new, closed, comments) to issues@ - issues: issues@eventmesh.apache.org - # Send new/closed PR notifications to dev@ - pullrequests_status: dev@eventmesh.apache.org - # Send individual PR comments/reviews to issues@ - pullrequests_comment: issues@eventmesh.apache.org - jira_options: link label worklog diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 252089de..00000000 --- a/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules/ -out/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7415ebb1..b1f31d2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,131 +1,122 @@ -# https://github.com/github/gitignore/blob/main/Node.gitignore -# Logs -logs +.settings/ +.project +.classpath +.target +./**/.settings/ +./**/.project +./**/.classpath +./**/target/ + + +#gitignore文件的内容 +.factorypath +.DS_Store +.project +*.prefs +.classpath +.setting/h +.settings/ +.idea/ +*.iml +*.ipr +*.iws +logs/ + +#忽略eclipse相关 +org.eclipse.core.resources.prefs +org.eclipse.jdt.core.prefs +org.eclipse.m2e.core.prefs +org.eclipse.wst.common.component +org.eclipse.wst.common.project.facet.core.xml + +#忽略java相关的文件 +*.class +*.trc +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +#忽略maven相关的文件 +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties + +# Built application files +*.apk +*.ap_ + + +#忽略andriod相关的文件 +# Files for the Dalvik VM +*.dex +# Generated files +bin/ +gen/ +# Gradle files +.gradle/ +build/ +*/build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ +# Log Files *.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variable files -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# vuepress v2.x temp and cache directory -.temp -.cache - -# Docusaurus cache and generated files -.docusaurus - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* \ No newline at end of file +# Android Studio Navigation editor temp files +.navigation/ +# Android Studio captures folder +captures/ + +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index c6d90a59..1d3574c3 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,24 @@ -This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). -## Getting Started -First, run the development server: +## 介绍 -```bash -npm run dev -# or -yarn dev -``` -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. +## 业务架构 -You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. -[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`. +## 技术架构 -The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. -## Getting Started with Docker +### 模块依赖图 -Pull the image and run the container by following commands: +### 模块介绍 -``` -docker pull apache/eventmesh-dashboard:latest -``` +1. eventmesh-dashboard-console 业务模块的代码 +2. eventmesh-dashboard-observe 监控模块的代码 +3. eventmesh-dashboard-core 对eventmesh以及相关组件的代码 +4. eventmesh-dashboard-service 公用接口 +5. eventmesh-dashboard-common 公共模块的代码 +6. eventmesh-dashboard-view 前端代码 -``` -docker run -d --name eventmesh-dashboard -p 8080:80 -t apache/eventmesh-dashboard:latest -``` -Open [http://localhost:8080](http://localhost:8080) in your browser to see the result. - -You can also build a mirror of your own by executing the following command in the root of your git repository: - -``` -docker build -t /eventmesh-dashboard:latest -f docker/Dockerfile . -``` - -## Learn More - -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! - -## Deploy on Vercel - -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. - -Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. +### eventmesh-dashboard-core 介绍 diff --git a/components/client/GrpcClientTable.tsx b/components/client/GrpcClientTable.tsx deleted file mode 100644 index 1ffdfeaa..00000000 --- a/components/client/GrpcClientTable.tsx +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { - HStack, - Select, - Input, - Table, - Thead, - Tbody, - Tr, - Th, - Td, - TableContainer, - useToast, - Box, - Button, -} from '@chakra-ui/react'; -import axios from 'axios'; -import { useContext, useEffect, useState } from 'react'; -import { AppContext } from '../../context/context'; - -interface GrpcClient { - env: string, - subsystem: string, - url: string, - pid: number, - host: string, - port: number, - version: string, - idc: string, - group: string, - purpose: string, - protocol: string, -} - -interface GrpcClientProps { - url: string, - group: string, -} - -interface RemoveGrpcClientRequest { - url: string, -} - -const GrpcClientRow = ({ - url, group, -}: GrpcClientProps) => { - const { state } = useContext(AppContext); - - const toast = useToast(); - const [loading, setLoading] = useState(false); - const onRemoveClick = async () => { - try { - setLoading(true); - await axios.delete(`${state.endpoint}/client/grpc`, { - data: { - url, - }, - }); - setLoading(false); - } catch (error) { - if (axios.isAxiosError(error)) { - toast({ - title: 'Failed to remove the gRPC Client', - description: error.message, - status: 'error', - duration: 3000, - isClosable: true, - }); - } - } - }; - - return ( - - {url} - {group} - - - - - - - ); -}; - -const GrpcClientTable = () => { - const { state } = useContext(AppContext); - - const [searchInput, setSearchInput] = useState(''); - const handleSearchInputChange = (event: React.FormEvent) => { - setSearchInput(event.currentTarget.value); - }; - - const [groupSet, setGroupSet] = useState>(new Set()); - const [groupFilter, setGroupFilter] = useState(''); - const handleGroupSelectChange = (event: React.FormEvent) => { - setGroupFilter(event.currentTarget.value); - }; - - const [GrpcClientList, setGrpcClientList] = useState([]); - const toast = useToast(); - useEffect(() => { - const fetch = async () => { - try { - const { data } = await axios.get(`${state.endpoint}/client/grpc`); - setGrpcClientList(data); - - const nextGroupSet = new Set(); - data.forEach(({ group }) => { - nextGroupSet.add(group); - }); - setGroupSet(nextGroupSet); - } catch (error) { - if (axios.isAxiosError(error)) { - toast({ - title: 'Failed to fetch the list of gRPC Clients', - description: 'Unable to connect to the EventMesh daemon', - status: 'error', - duration: 3000, - isClosable: true, - }); - setGrpcClientList([]); - } - } - }; - - fetch(); - }, []); - - return ( - - - - - - - - - - - - - - - - - {GrpcClientList && GrpcClientList.filter(({ - url, group, - }) => { - if (searchInput && !url.includes(searchInput)) { - return false; - } - if (groupFilter && groupFilter !== group) { - return false; - } - return true; - }).map(({ - url, group, - }) => ( - - ))} - -
URLGroupAction
-
-
- ); -}; - -export default GrpcClientTable; diff --git a/components/client/HTTPClientTable.tsx b/components/client/HTTPClientTable.tsx deleted file mode 100644 index 832ea91b..00000000 --- a/components/client/HTTPClientTable.tsx +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { - HStack, - Select, - Input, - Table, - Thead, - Tbody, - Tr, - Th, - Td, - TableContainer, - useToast, - Box, - Button, -} from '@chakra-ui/react'; -import axios from 'axios'; -import { useContext, useEffect, useState } from 'react'; -import { AppContext } from '../../context/context'; - -interface HTTPClient { - env: string, - subsystem: string, - url: string, - pid: number, - host: string, - port: number, - version: string, - idc: string, - group: string, - purpose: string, - protocol: string, -} - -interface HTTPClientProps { - url: string, - group: string, -} - -interface RemoveHTTPClientRequest { - url: string, -} - -const HTTPClientRow = ({ - url, group, -}: HTTPClientProps) => { - const { state } = useContext(AppContext); - - const toast = useToast(); - const [loading, setLoading] = useState(false); - const onRemoveClick = async () => { - try { - setLoading(true); - await axios.delete(`${state.endpoint}/client/http`, { - data: { - url, - }, - }); - setLoading(false); - } catch (error) { - if (axios.isAxiosError(error)) { - toast({ - title: 'Failed to remove the HTTP Client', - description: error.message, - status: 'error', - duration: 3000, - isClosable: true, - }); - } - } - }; - - return ( - - {url} - {group} - - - - - - - ); -}; - -const HTTPClientTable = () => { - const { state } = useContext(AppContext); - - const [searchInput, setSearchInput] = useState(''); - const handleSearchInputChange = (event: React.FormEvent) => { - setSearchInput(event.currentTarget.value); - }; - - const [groupSet, setGroupSet] = useState>(new Set()); - const [groupFilter, setGroupFilter] = useState(''); - const handleGroupSelectChange = (event: React.FormEvent) => { - setGroupFilter(event.currentTarget.value); - }; - - const [HTTPClientList, setHTTPClientList] = useState([]); - const toast = useToast(); - useEffect(() => { - const fetch = async () => { - try { - const { data } = await axios.get(`${state.endpoint}/client/http`); - setHTTPClientList(data); - - const nextGroupSet = new Set(); - data.forEach(({ group }) => { - nextGroupSet.add(group); - }); - setGroupSet(nextGroupSet); - } catch (error) { - if (axios.isAxiosError(error)) { - toast({ - title: 'Failed to fetch the list of HTTP Clients', - description: 'Unable to connect to the EventMesh daemon', - status: 'error', - duration: 3000, - isClosable: true, - }); - setHTTPClientList([]); - } - } - }; - - fetch(); - }, []); - - return ( - - - - - - - - - - - - - - - - - {HTTPClientList && HTTPClientList.filter(({ - url, group, - }) => { - if (searchInput && !url.includes(searchInput)) { - return false; - } - if (groupFilter && groupFilter !== group) { - return false; - } - return true; - }).map(({ - url, group, - }) => ( - - ))} - -
URLGroupAction
-
-
- ); -}; - -export default HTTPClientTable; diff --git a/components/client/TCPClientTable.tsx b/components/client/TCPClientTable.tsx deleted file mode 100644 index dc245890..00000000 --- a/components/client/TCPClientTable.tsx +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { - HStack, - Select, - Input, - Table, - Thead, - Tbody, - Tr, - Th, - Td, - TableContainer, - useToast, - Box, - Button, -} from '@chakra-ui/react'; -import axios from 'axios'; -import { useContext, useEffect, useState } from 'react'; -import { AppContext } from '../../context/context'; - -interface TCPClient { - env: string, - subsystem: string, - url: string, - pid: number, - host: string, - port: number, - version: string, - idc: string, - group: string, - purpose: string, - protocol: string, -} - -interface TCPClientProps { - host: string, - port: number, - group: string, -} - -interface RemoveTCPClientRequest { - host: string, - port: number, -} - -const TCPClientRow = ({ - host, port, group, -}: TCPClientProps) => { - const { state } = useContext(AppContext); - - const toast = useToast(); - const [loading, setLoading] = useState(false); - const onRemoveClick = async () => { - try { - setLoading(true); - await axios.delete(`${state.endpoint}/client/tcp`, { - data: { - host, - port, - }, - }); - setLoading(false); - } catch (error) { - if (axios.isAxiosError(error)) { - toast({ - title: 'Failed to remove the TCP Client', - description: error.message, - status: 'error', - duration: 3000, - isClosable: true, - }); - } - } - }; - - return ( - - {`${host}:${port}`} - {group} - - - - - - - ); -}; - -const TCPClientTable = () => { - const { state } = useContext(AppContext); - - const [searchInput, setSearchInput] = useState(''); - const handleSearchInputChange = (event: React.FormEvent) => { - setSearchInput(event.currentTarget.value); - }; - - const [groupSet, setGroupSet] = useState>(new Set()); - const [groupFilter, setGroupFilter] = useState(''); - const handleGroupSelectChange = (event: React.FormEvent) => { - setGroupFilter(event.currentTarget.value); - }; - - const [TCPClientList, setTCPClientList] = useState([]); - const toast = useToast(); - useEffect(() => { - const fetch = async () => { - try { - const { data } = await axios.get(`${state.endpoint}/client/tcp`); - setTCPClientList(data); - - const nextGroupSet = new Set(); - data.forEach(({ group }) => { - nextGroupSet.add(group); - }); - setGroupSet(nextGroupSet); - } catch (error) { - if (axios.isAxiosError(error)) { - toast({ - title: 'Failed to fetch the list of TCP Clients', - description: 'Unable to connect to the EventMesh daemon', - status: 'error', - duration: 3000, - isClosable: true, - }); - setTCPClientList([]); - } - } - }; - - fetch(); - }, []); - - return ( - - - - - - - - - - - - - - - - - - {TCPClientList && TCPClientList.filter(({ - host, port, group, - }) => { - const address = `${host}:${port}`; - if (searchInput && !address.includes(searchInput)) { - return false; - } - if (groupFilter && groupFilter !== group) { - return false; - } - return true; - }).map(({ - host, port, group, - }) => ( - - ))} - -
HostHostGroupAction
-
-
- ); -}; - -export default TCPClientTable; diff --git a/components/event/EventTable.tsx b/components/event/EventTable.tsx deleted file mode 100644 index b0d0a13d..00000000 --- a/components/event/EventTable.tsx +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { - HStack, - Input, - Table, - Thead, - Tbody, - Tr, - Th, - Td, - TableContainer, - useToast, - Box, - Button, - Modal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalFooter, - ModalHeader, - ModalOverlay, - useDisclosure, - Select, - VStack, - Textarea, -} from '@chakra-ui/react'; -import axios from 'axios'; -import { useContext, useEffect, useState } from 'react'; -import { CloudEvent } from 'cloudevents'; -import { AppContext } from '../../context/context'; - -interface Topic { - name: string, - messageCount: number, -} - -interface EventProps { - event: CloudEvent, -} - -interface CreateEventRequest { - event: CloudEvent, -} - -const CreateEventModal = () => { - const { state } = useContext(AppContext); - - const { isOpen, onOpen, onClose } = useDisclosure(); - - const [id, setId] = useState(''); - const handleIdChange = (event: React.FormEvent) => { - setId(event.currentTarget.value); - }; - - const [source, setSource] = useState(''); - const handleSourceChange = (event: React.FormEvent) => { - setSource(event.currentTarget.value); - }; - - const [subject, setSubject] = useState(''); - const handleSubjectChange = (event: React.FormEvent) => { - setSubject(event.currentTarget.value); - }; - - const [type, setType] = useState(''); - const handleTypeChange = (event: React.FormEvent) => { - setType(event.currentTarget.value); - }; - - const [data, setData] = useState(''); - const handleDataChange = (event: React.FormEvent) => { - setData(event.currentTarget.value); - }; - - const toast = useToast(); - const [loading, setLoading] = useState(false); - const onCreateClick = async () => { - try { - setLoading(true); - await axios.post(`${state.endpoint}/event`, new CloudEvent({ - source, - subject, - type, - data, - specversion: '1.0', - })); - onClose(); - } catch (error) { - if (axios.isAxiosError(error)) { - toast({ - title: 'Failed to publish the event', - description: error.message, - status: 'error', - duration: 3000, - isClosable: true, - }); - } - } finally { - setLoading(false); - } - }; - - return ( - <> - - - - - Create Event - - - - - - - - - - - - - - - - - - - ); -}; - -const EventRow = ({ - event, -}: EventProps) => { - const { isOpen, onOpen, onClose } = useDisclosure(); - const eventDataBase64 = event.data_base64 || ''; - const eventData = Buffer.from(eventDataBase64, 'base64').toString('utf-8'); - - return ( - <> - - - - Event Data - - - -