浏览代码

show plugin list

AE86 4 年之前
父节点
当前提交
137f4fa2ef

+ 2 - 1
dbsyncer-plugin/src/main/java/org/dbsyncer/plugin/PluginFactory.java

@@ -78,13 +78,14 @@ public class PluginFactory {
      */
     private void loadPlugin(File jar) {
         try {
+            String fileName = jar.getName();
             URL url = jar.toURI().toURL();
             URLClassLoader loader = new URLClassLoader(new URL[] {url}, Thread.currentThread().getContextClassLoader());
             ServiceLoader<ConvertService> services = ServiceLoader.load(ConvertService.class, loader);
             for (ConvertService s : services) {
                 String className = s.getClass().getName();
                 service.put(className, s);
-                plugins.add(new Plugin(s.getName() + "_" + s.getVersion(), className, s.getVersion()));
+                plugins.add(new Plugin(s.getName(), className, s.getVersion(), fileName));
             }
         } catch (MalformedURLException e) {
             logger.error(e.getMessage());

+ 14 - 1
dbsyncer-plugin/src/main/java/org/dbsyncer/plugin/config/Plugin.java

@@ -16,13 +16,17 @@ public class Plugin {
     // 版本号
     private String version;
 
+    // Jar名称
+    private String fileName;
+
     public Plugin() {
     }
 
-    public Plugin(String name, String className, String version) {
+    public Plugin(String name, String className, String version, String fileName) {
         this.name = name;
         this.className = className;
         this.version = version;
+        this.fileName = fileName;
     }
 
     public String getName() {
@@ -50,4 +54,13 @@ public class Plugin {
         this.version = version;
         return this;
     }
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public Plugin setFileName(String fileName) {
+        this.fileName = fileName;
+        return this;
+    }
 }

+ 1 - 0
dbsyncer-web/src/main/java/org/dbsyncer/web/controller/upload/UploadController.java

@@ -22,6 +22,7 @@ public class UploadController {
 
     @RequestMapping("")
     public String index(ModelMap model) {
+        model.put("plugins", pluginService.getPluginAll());
         return "upload/upload";
     }
 

+ 1 - 1
dbsyncer-web/src/main/resources/public/mapping/editPlugin.html

@@ -12,7 +12,7 @@
                 <div class="col-sm-9">
                     <select id="sourceStrategyConvertRule" name="pluginClassName" class="form-control select-control">
                         <option value="">无</option>
-                        <option th:value="${p?.className}" th:text="${p?.name}" th:each="p,state : ${plugin}" th:selected="${tableGroup eq null and p.className eq mapping?.plugin?.className or p.className eq tableGroup?.plugin?.className}">
+                        <option th:value="${p?.className}" th:text="${p?.name +'_'+ p?.version}" th:each="p,state : ${plugin}" th:selected="${tableGroup eq null and p.className eq mapping?.plugin?.className or p.className eq tableGroup?.plugin?.className}">
                     </select>
                 </div>
             </div>

+ 24 - 0
dbsyncer-web/src/main/resources/public/upload/upload.html

@@ -15,6 +15,29 @@
             </div>
         </div>
 
+        <div class="form-group">
+            <table class="table table-hover">
+                <caption>插件列表([[${plugins?.size()} ?: 0]])</caption>
+                <thead>
+                <tr>
+                    <th>名称</th>
+                    <th>类名</th>
+                    <th>版本</th>
+                    <th>文件</th>
+                    <th>操作</th>
+                </tr>
+                </thead>
+                <tbody id="pluginList">
+                <tr th:id="${p?.name}" th:each="p,state : ${plugins}">
+                    <td th:text="${p?.name}"/>
+                    <td th:text="${p?.className}"/>
+                    <td th:text="${p?.version}"/>
+                    <td th:text="${p?.fileName}"/>
+                    <td><a th:id="${p?.name}" class='fa fa-remove fa-2x pluginDelete dbsyncer_pointer' title='暂不支持' aria-disabled="true"></a></td>
+                </tr>
+                </tbody>
+            </table>
+        </div>
     </form>
 </div>
 
@@ -35,6 +58,7 @@
         if (!data.response.success) {
             bootGrowl(data.response.resultValue, "danger");
         }
+        doLoader("/upload");
     });
 </script>
 </html>