This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev by this push:
     new 5516ec3c9 [Feature] Supports viewing which applications a variable is 
referenced by (#1915)
5516ec3c9 is described below

commit 5516ec3c96b320ef62548d2e20c6b935d6288096
Author: macksonmu <[email protected]>
AuthorDate: Thu Oct 27 23:14:43 2022 +0800

    [Feature] Supports viewing which applications a variable is referenced by 
(#1915)
    
    * [Feature] Put the variable menu under StreamPark in pgsql-data.sql and 
1.2.4.sql #1889
    
    * [Feature] Supports viewing which applications a variable is referenced by 
#1876
---
 .../src/assembly/script/data/mysql-data.sql        |   1 +
 .../src/assembly/script/data/pgsql-data.sql        |   1 +
 .../src/assembly/script/upgrade/mysql/1.2.4.sql    |   1 +
 .../core/controller/VariableController.java        |  10 +-
 .../console/core/entity/Application.java           |  16 ++
 .../console/core/mapper/ApplicationMapper.java     |   1 -
 .../console/core/service/VariableService.java      |   3 +
 .../core/service/impl/VariableServiceImpl.java     |  40 ++++-
 .../src/main/resources/db/data-h2.sql              |   1 +
 .../resources/mapper/core/ApplicationMapper.xml    |   8 +
 .../streampark-console-webapp/src/api/index.js     |   1 +
 .../streampark-console-webapp/src/api/variable.js  |   4 +
 .../streampark-console-webapp/src/store/getters.js |   3 +-
 .../streampark-console-webapp/src/store/index.js   |   4 +-
 .../src/store/{index.js => modules/variable.js}    |  44 +++---
 .../system/variable/DependApps.less}               |  47 +++---
 .../src/views/system/variable/DependApps.vue       | 171 +++++++++++++++++++++
 .../src/views/system/variable/View.vue             |  16 +-
 18 files changed, 314 insertions(+), 58 deletions(-)

diff --git 
a/streampark-console/streampark-console-service/src/assembly/script/data/mysql-data.sql
 
b/streampark-console/streampark-console-service/src/assembly/script/data/mysql-data.sql
index 89600fd9b..01fef1de5 100644
--- 
a/streampark-console/streampark-console-service/src/assembly/script/data/mysql-data.sql
+++ 
b/streampark-console/streampark-console-service/src/assembly/script/data/mysql-data.sql
@@ -108,6 +108,7 @@ insert into `t_menu` VALUES (100054, 100013, 'Variable', 
'/system/variable', 'sy
 insert into `t_menu` VALUES (100055, 100054, 'add', NULL, NULL, 
'variable:add', NULL, '1', 1, NULL, now(), now());
 insert into `t_menu` VALUES (100056, 100054, 'update', NULL, NULL, 
'variable:update', NULL, '1', 1, NULL, now(), now());
 insert into `t_menu` VALUES (100057, 100054, 'delete', NULL, NULL, 
'variable:delete', NULL, '1', 1, NULL, now(), now());
+insert into `t_menu` VALUES (100058, 100013, 'Depend Apps', 
'/system/variable/depend_apps', 'system/variable/DependApps', 
'variable:dependApps', '', '0', 0, NULL, now(), now());
 
 -- ----------------------------
 -- Records of t_role
diff --git 
a/streampark-console/streampark-console-service/src/assembly/script/data/pgsql-data.sql
 
b/streampark-console/streampark-console-service/src/assembly/script/data/pgsql-data.sql
index 41e371bc1..d186a1f25 100644
--- 
a/streampark-console/streampark-console-service/src/assembly/script/data/pgsql-data.sql
+++ 
b/streampark-console/streampark-console-service/src/assembly/script/data/pgsql-data.sql
@@ -104,6 +104,7 @@ insert into "public"."t_menu" VALUES (100054, 100013, 
'Variable', '/system/varia
 insert into "public"."t_menu" VALUES (100055, 100054, 'add', NULL, NULL, 
'variable:add', NULL, '1', 1, NULL, now(), now());
 insert into "public"."t_menu" VALUES (100056, 100054, 'update', NULL, NULL, 
'variable:update', NULL, '1', 1, NULL, now(), now());
 insert into "public"."t_menu" VALUES (100057, 100054, 'delete', NULL, NULL, 
'variable:delete', NULL, '1', 1, NULL, now(), now());
+insert into "public"."t_menu" VALUES (100058, 100013, 'Depend Apps', 
'/system/variable/depend_apps', 'system/variable/DependApps', 
'variable:dependApps', '', '0', 0, NULL, now(), now());
 
 -- ----------------------------
 -- Records of t_role
diff --git 
a/streampark-console/streampark-console-service/src/assembly/script/upgrade/mysql/1.2.4.sql
 
b/streampark-console/streampark-console-service/src/assembly/script/upgrade/mysql/1.2.4.sql
index 3ba1b33dd..1901d9526 100644
--- 
a/streampark-console/streampark-console-service/src/assembly/script/upgrade/mysql/1.2.4.sql
+++ 
b/streampark-console/streampark-console-service/src/assembly/script/upgrade/mysql/1.2.4.sql
@@ -132,6 +132,7 @@ insert into `t_menu` VALUES (100054, 100013, 'Variable', 
'/system/variable', 'sy
 insert into `t_menu` VALUES (100055, 100054, 'add', NULL, NULL, 
'variable:add', NULL, '1', 1, NULL, now(), now());
 insert into `t_menu` VALUES (100056, 100054, 'update', NULL, NULL, 
'variable:update', NULL, '1', 1, NULL, now(), now());
 insert into `t_menu` VALUES (100057, 100054, 'delete', NULL, NULL, 
'variable:delete', NULL, '1', 1, NULL, now(), now());
+insert into `t_menu` VALUES (100058, 100013, 'Depend Apps', 
'/system/variable/depend_apps', 'system/variable/DependApps', 
'variable:dependApps', '', '0', 0, NULL, now(), now());
 
 update `t_menu` set order_num=4 where menu_id=100019;
 update `t_menu` set order_num=5 where menu_id=100034;
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/VariableController.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/VariableController.java
index c86039554..2c7e9d722 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/VariableController.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/VariableController.java
@@ -20,6 +20,7 @@ package org.apache.streampark.console.core.controller;
 import org.apache.streampark.console.base.domain.RestRequest;
 import org.apache.streampark.console.base.domain.RestResponse;
 import org.apache.streampark.console.base.exception.ApiAlertException;
+import org.apache.streampark.console.core.entity.Application;
 import org.apache.streampark.console.core.entity.Variable;
 import org.apache.streampark.console.core.service.VariableService;
 
@@ -44,8 +45,6 @@ import javax.validation.constraints.NotBlank;
 @RequestMapping("variable")
 public class VariableController {
 
-    private final String formatPattern = "^([A-Za-z])+([A-Za-z0-9._-])+$";
-
     @Autowired
     private VariableService variableService;
 
@@ -56,6 +55,13 @@ public class VariableController {
         return RestResponse.success(variableList);
     }
 
+    @PostMapping("dependApps")
+    @RequiresPermissions("variable:dependApps")
+    public RestResponse dependApps(RestRequest restRequest, Variable variable) 
{
+        IPage<Application> dependApps = 
variableService.dependAppsPage(variable, restRequest);
+        return RestResponse.success(dependApps);
+    }
+
     @PostMapping("post")
     @RequiresPermissions("variable:add")
     public RestResponse addVariable(@Valid Variable variable) throws Exception 
{
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java
index d7cbb1c75..e2fd6ebe3 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Application.java
@@ -740,6 +740,22 @@ public class Application implements Serializable {
 
     }
 
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        return id.equals(((Application) o).id);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id);
+    }
+
     @Data
     public static class Pom {
         private String groupId;
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/ApplicationMapper.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/ApplicationMapper.java
index 5b0fe77bf..8c8985193 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/ApplicationMapper.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/mapper/ApplicationMapper.java
@@ -38,7 +38,6 @@ public interface ApplicationMapper extends 
BaseMapper<Application> {
     @Select("select * from t_flink_app where project_id=#{projectId}")
     List<Application> getByProjectId(@Param("projectId") Long projectId);
 
-    @Select("select * from t_flink_app where team_id=#{teamId}")
     List<Application> getByTeamId(@Param("teamId") Long teamId);
 
     @Update("update t_flink_app set 
app_id=#{application.appId},job_id=#{application.jobId},state=14,end_time=null 
where id=#{application.id}")
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/VariableService.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/VariableService.java
index d82cbb9cb..1cd21a8d2 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/VariableService.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/VariableService.java
@@ -18,6 +18,7 @@
 package org.apache.streampark.console.core.service;
 
 import org.apache.streampark.console.base.domain.RestRequest;
+import org.apache.streampark.console.core.entity.Application;
 import org.apache.streampark.console.core.entity.Variable;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -57,4 +58,6 @@ public interface VariableService extends IService<Variable> {
     Variable findByVariableCode(Long teamId, String variableCode);
 
     String replaceVariable(Long teamId, String mixed);
+
+    IPage<Application> dependAppsPage(Variable variable, RestRequest request);
 }
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/VariableServiceImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/VariableServiceImpl.java
index 9b94cd134..8676b903e 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/VariableServiceImpl.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/VariableServiceImpl.java
@@ -42,6 +42,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -96,6 +97,24 @@ public class VariableServiceImpl extends 
ServiceImpl<VariableMapper, Variable> i
         return this.baseMapper.page(page, variable);
     }
 
+    @Override
+    public IPage<Application> dependAppsPage(Variable variable, RestRequest 
request) {
+        List<Application> applications = getDependApplicationsByCode(variable);
+
+        IPage<Application> page = new Page<>();
+        if (CollectionUtils.isEmpty(applications)) {
+            return page;
+        }
+        page.setCurrent(request.getPageNum());
+        page.setSize(request.getPageSize());
+        page.setTotal(applications.size());
+        int fromIndex = (request.getPageNum() - 1) * request.getPageSize();
+        int toIndex = request.getPageNum() * request.getPageSize();
+        toIndex = toIndex > applications.size() ? applications.size() : 
toIndex;
+        page.setRecords(applications.subList(fromIndex, toIndex));
+        return page;
+    }
+
     @Override
     public Variable findByVariableCode(Long teamId, String variableCode) {
         return baseMapper.selectOne(new LambdaQueryWrapper<Variable>()
@@ -138,26 +157,35 @@ public class VariableServiceImpl extends 
ServiceImpl<VariableMapper, Variable> i
     }
 
     private boolean isDependByApplications(Variable variable) {
-        // Detect whether the variable is dependent on the args of the 
application
+        return 
CollectionUtils.isNotEmpty(getDependApplicationsByCode(variable));
+    }
+
+    private List<Application> getDependApplicationsByCode(Variable variable) {
+        List<Application> dependApplications = new ArrayList<>();
         List<Application> applications = 
applicationService.getByTeamId(variable.getTeamId());
+        Map<Long, Application> applicationMap = 
applications.stream().collect(Collectors.toMap(Application::getId, application 
-> application));
+
+        // Get applications that depend on this variable in application args
         if (applications != null) {
             for (Application app : applications) {
                 if (isDepend(variable.getVariableCode(), app.getArgs())) {
-                    return true;
+                    dependApplications.add(app);
                 }
             }
         }
-
-        // Detect whether variables are dependent on all versions of flink sql
+        // Get the application that depends on this variable in flink sql
         List<FlinkSql> flinkSqls = 
flinkSqlService.getByTeamId(variable.getTeamId());
         if (flinkSqls != null) {
             for (FlinkSql flinkSql : flinkSqls) {
                 if (isDepend(variable.getVariableCode(), 
DeflaterUtils.unzipString(flinkSql.getSql()))) {
-                    return true;
+                    Application app = applicationMap.get(flinkSql.getAppId());
+                    if (!dependApplications.contains(app)) {
+                        
dependApplications.add(applicationMap.get(flinkSql.getAppId()));
+                    }
                 }
             }
         }
-        return false;
+        return dependApplications;
     }
 
     /**
diff --git 
a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
 
b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
index 449af593c..005080386 100644
--- 
a/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
+++ 
b/streampark-console/streampark-console-service/src/main/resources/db/data-h2.sql
@@ -103,6 +103,7 @@ insert into `t_menu` VALUES (100054, 100013, 'Variable', 
'/system/variable', 'sy
 insert into `t_menu` VALUES (100055, 100054, 'add', NULL, NULL, 
'variable:add', NULL, '1', 1, NULL, now(), now());
 insert into `t_menu` VALUES (100056, 100054, 'update', NULL, NULL, 
'variable:update', NULL, '1', 1, NULL, now(), now());
 insert into `t_menu` VALUES (100057, 100054, 'delete', NULL, NULL, 
'variable:delete', NULL, '1', 1, NULL, now(), now());
+insert into `t_menu` VALUES (100058, 100013, 'Depend Apps', 
'/system/variable/depend_apps', 'system/variable/DependApps', 
'variable:dependApps', '', '0', 0, NULL, now(), now());
 
 -- ----------------------------
 -- Records of t_role
diff --git 
a/streampark-console/streampark-console-service/src/main/resources/mapper/core/ApplicationMapper.xml
 
b/streampark-console/streampark-console-service/src/main/resources/mapper/core/ApplicationMapper.xml
index 8afa19ff8..0dc29da48 100644
--- 
a/streampark-console/streampark-console-service/src/main/resources/mapper/core/ApplicationMapper.xml
+++ 
b/streampark-console/streampark-console-service/src/main/resources/mapper/core/ApplicationMapper.xml
@@ -143,6 +143,14 @@
         where t.id = #{application.id}
     </select>
 
+    <select id="getByTeamId" resultType="application" parameterType="Long">
+        select t.*, u.username, case when trim(u.nick_name) = '' then 
u.username else u.nick_name end as nick_name
+        from t_flink_app t
+        inner join t_user u
+        on t.user_id = u.user_id
+        where t.team_id=#{teamId}
+    </select>
+
     <update id="updateTracking" parameterType="application">
         update t_flink_app
         <set>
diff --git a/streampark-console/streampark-console-webapp/src/api/index.js 
b/streampark-console/streampark-console-webapp/src/api/index.js
index cb6f087fb..1bc16589a 100644
--- a/streampark-console/streampark-console-webapp/src/api/index.js
+++ b/streampark-console/streampark-console-webapp/src/api/index.js
@@ -212,6 +212,7 @@ export default {
   },
   Variable: {
     LIST: '/variable/list',
+    DEPEND: '/variable/dependApps',
     UPDATE: '/variable/update',
     POST: '/variable/post',
     DELETE: '/variable/delete',
diff --git a/streampark-console/streampark-console-webapp/src/api/variable.js 
b/streampark-console/streampark-console-webapp/src/api/variable.js
index 443ad12fa..583930355 100644
--- a/streampark-console/streampark-console-webapp/src/api/variable.js
+++ b/streampark-console/streampark-console-webapp/src/api/variable.js
@@ -22,6 +22,10 @@ export function list (queryParam) {
   return http.post(api.Variable.LIST, queryParam)
 }
 
+export function dependApps (queryParam) {
+  return http.post(api.Variable.DEPEND, queryParam)
+}
+
 export function update (queryParam) {
   return http.put(api.Variable.UPDATE, queryParam)
 }
diff --git a/streampark-console/streampark-console-webapp/src/store/getters.js 
b/streampark-console/streampark-console-webapp/src/store/getters.js
index 48799f6c9..99a1da0c5 100644
--- a/streampark-console/streampark-console-webapp/src/store/getters.js
+++ b/streampark-console/streampark-console-webapp/src/store/getters.js
@@ -34,7 +34,8 @@ const getters = {
   multiTab: state => state.app.multiTab,
   applicationId: state => state.application.appId,
   clusterId: state => state.cluster.clusterId,
-  projectId: state => state.project.projectId
+  projectId: state => state.project.projectId,
+  variableCode: state => state.variable.variableCode
 }
 
 export default getters
diff --git a/streampark-console/streampark-console-webapp/src/store/index.js 
b/streampark-console/streampark-console-webapp/src/store/index.js
index 4e288fabe..9748ee877 100644
--- a/streampark-console/streampark-console-webapp/src/store/index.js
+++ b/streampark-console/streampark-console-webapp/src/store/index.js
@@ -23,6 +23,7 @@ import application from './modules/application'
 import project from './modules/project'
 import cluster from './modules/cluster'
 import user from './modules/user'
+import variable from './modules/variable'
 import getters from './getters'
 
 Vue.use(Vuex)
@@ -33,7 +34,8 @@ export default new Vuex.Store({
     user,
     application,
     cluster,
-    project
+    project,
+    variable
   },
   state: {},
   mutations: {},
diff --git a/streampark-console/streampark-console-webapp/src/store/index.js 
b/streampark-console/streampark-console-webapp/src/store/modules/variable.js
similarity index 62%
copy from streampark-console/streampark-console-webapp/src/store/index.js
copy to 
streampark-console/streampark-console-webapp/src/store/modules/variable.js
index 4e288fabe..b8c47785d 100644
--- a/streampark-console/streampark-console-webapp/src/store/index.js
+++ b/streampark-console/streampark-console-webapp/src/store/modules/variable.js
@@ -15,28 +15,28 @@
  * limitations under the License.
  */
 
-import Vue from 'vue'
-import Vuex from 'vuex'
+const variable = {
+  state: {
+    variableCode: null
+  },
 
-import app from './modules/app'
-import application from './modules/application'
-import project from './modules/project'
-import cluster from './modules/cluster'
-import user from './modules/user'
-import getters from './getters'
+  mutations: {
+    SET_VARIABLE_CODE: (state, variableCode) => {
+      state.variableCode = variableCode
+    },
+    CLEAN_VARIABLE_CODE: (state, empty) => {
+      state.variableCode = null
+    }
+  },
 
-Vue.use(Vuex)
+  actions: {
+    SetVariableCode ({ commit }, variableCode) {
+      commit('SET_VARIABLE_CODE', variableCode)
+    },
+    CleanVariableCode ({ commit }, empty) {
+      commit('CLEAN_VARIABLE_CODE', empty)
+    }
+  }
+}
 
-export default new Vuex.Store({
-  modules: {
-    app,
-    user,
-    application,
-    cluster,
-    project
-  },
-  state: {},
-  mutations: {},
-  actions: {},
-  getters
-})
+export default variable
diff --git a/streampark-console/streampark-console-webapp/src/store/index.js 
b/streampark-console/streampark-console-webapp/src/views/system/variable/DependApps.less
similarity index 60%
copy from streampark-console/streampark-console-webapp/src/store/index.js
copy to 
streampark-console/streampark-console-webapp/src/views/system/variable/DependApps.less
index 4e288fabe..ea538deea 100644
--- a/streampark-console/streampark-console-webapp/src/store/index.js
+++ 
b/streampark-console/streampark-console-webapp/src/views/system/variable/DependApps.less
@@ -15,28 +15,29 @@
  * limitations under the License.
  */
 
-import Vue from 'vue'
-import Vuex from 'vuex'
+  .app_type {
+    display: inline-block;
+    text-align: center;
+    vertical-align: middle;
+    line-height: 12px;
+    overflow: hidden;
+    overflow: hidden;
+  }
 
-import app from './modules/app'
-import application from './modules/application'
-import project from './modules/project'
-import cluster from './modules/cluster'
-import user from './modules/user'
-import getters from './getters'
+  .app_sql {
+    padding: 2px 4px;
+    border: 1px solid #0070cc;
+    background: rgba(0,112,204,.2);
+    color: rgba(0,0,0,.85);
+    font-size: 14px;
+    -webkit-transform: scale(0.7);
+  }
 
-Vue.use(Vuex)
-
-export default new Vuex.Store({
-  modules: {
-    app,
-    user,
-    application,
-    cluster,
-    project
-  },
-  state: {},
-  mutations: {},
-  actions: {},
-  getters
-})
+  .app_jar {
+    border: 1px solid #0066ff;
+    padding: 3px 5px;
+    background: #1890ff;
+    color: #f5f5f5;
+    font-size: 14px;
+    -webkit-transform: scale(0.7);
+  }
diff --git 
a/streampark-console/streampark-console-webapp/src/views/system/variable/DependApps.vue
 
b/streampark-console/streampark-console-webapp/src/views/system/variable/DependApps.vue
new file mode 100644
index 000000000..599641016
--- /dev/null
+++ 
b/streampark-console/streampark-console-webapp/src/views/system/variable/DependApps.vue
@@ -0,0 +1,171 @@
+<!--
+
+    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
+
+       https://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.
+
+-->
+
+<template>
+  <a-card :bordered="false" style="margin-top: 20px;">
+    <a-descriptions
+      bordered
+      size="middle"
+      layout="vertical">
+      <template slot="title">
+        <span class="app-bar">Variable "{{ this.variable }}" used list</span>
+        <a-button
+          type="primary"
+          shape="circle"
+          icon="arrow-left"
+          @click="handleGoBack()"
+          style="float: right;margin-top: -8px"/>
+        <a-divider
+          style="margin-top: 5px;margin-bottom: -5px"/>
+      </template>
+    </a-descriptions>
+
+    <!-- 表格区域 -->
+    <a-table
+      ref="TableInfo"
+      :columns="columns"
+      :data-source="dataSource"
+      :pagination="pagination"
+      :loading="loading"
+      :scroll="{ x: 900 }"
+      @change="handleTableChange">
+      <template
+        slot="jobName"
+        slot-scope="text, record">
+        <span
+          class="app_type app_jar"
+          v-if="record['jobType'] === 1">
+          JAR
+        </span>
+        <span
+          class="app_type app_sql"
+          v-if="record['jobType'] === 2">
+          SQL
+        </span>
+
+        <span>
+          <a-tooltip>
+            {{ record.jobName }}
+          </a-tooltip>
+        </span>
+      </template>
+    </a-table>
+  </a-card>
+</template>
+<script>
+import {mapActions, mapGetters} from 'vuex'
+import SvgIcon from '@/components/SvgIcon'
+import {dependApps} from '@/api/variable'
+
+export default {
+  components: {SvgIcon},
+  data() {
+    return {
+      variable: null,
+      queryParams: {},
+      filteredInfo: null,
+      sortedInfo: null,
+      paginationInfo: null,
+      dataSource: [],
+      loading: false,
+      pagination: {
+        pageSizeOptions: ['10', '20', '30', '40', '100'],
+        defaultCurrent: 1,
+        defaultPageSize: 10,
+        showQuickJumper: true,
+        showSizeChanger: true,
+        showTotal: (total, range) => `display ${range[0]} ~ ${range[1]} 
records,total ${total}`
+      }
+    }
+  },
+
+  computed: {
+    columns () {
+      let { sortedInfo, filteredInfo } = this  // eslint-disable-line 
no-unused-vars
+      sortedInfo = sortedInfo || {}
+      filteredInfo = filteredInfo || {}
+      return [{
+        title: 'Application Name',
+        dataIndex: 'jobName',
+        width: 500,
+        scopedSlots: {customRender: 'jobName'},
+      }, {
+        title: 'Owner',
+        dataIndex: 'nickName'
+      }, {
+        title: 'Create Time',
+        dataIndex: 'createTime'
+      }]
+    }
+  },
+
+  mounted() {
+    const variableCode = this.variableCode()
+    this.variable = variableCode
+    if (variableCode) {
+      this.CleanVariableCode()
+      const params = {variableCode: variableCode}
+      this.fetch(params)
+    }
+  },
+
+  methods: {
+    ...mapActions(['CleanVariableCode']),
+    ...mapGetters(['variableCode']),
+
+    fetch (params) {
+      this.loading = true
+      if (this.paginationInfo) {
+        this.$refs.TableInfo.pagination.current = this.paginationInfo.current
+        this.$refs.TableInfo.pagination.pageSize = this.paginationInfo.pageSize
+        params.pageSize = this.paginationInfo.pageSize
+        params.pageNum = this.paginationInfo.current
+      } else {
+        params.pageSize = this.pagination.defaultPageSize
+        params.pageNum = this.pagination.defaultCurrent
+      }
+      if(params.status != null && params.status.length>0) {
+        params.status = params.status[0]
+      } else {
+        delete params.status
+      }
+
+      dependApps({ ...params }).then((resp) => {
+        const pagination = { ...this.pagination }
+        pagination.total = parseInt(resp.data.total)
+        this.dataSource = resp.data.records
+        this.pagination = pagination
+        this.loading = false
+      })
+    },
+    handleTableChange (pagination, filters, sorter) {
+      this.paginationInfo = pagination
+      const params = {variableCode: this.variable}
+      this.fetch(params)
+    },
+    handleGoBack() {
+      this.$router.back(-1)
+    }
+  }
+}
+</script>
+
+<style lang="less">
+@import "DependApps";
+</style>
diff --git 
a/streampark-console/streampark-console-webapp/src/views/system/variable/View.vue
 
b/streampark-console/streampark-console-webapp/src/views/system/variable/View.vue
index a34a157b9..8932d06c0 100644
--- 
a/streampark-console/streampark-console-webapp/src/views/system/variable/View.vue
+++ 
b/streampark-console/streampark-console-webapp/src/views/system/variable/View.vue
@@ -117,6 +117,11 @@
           border
           @click.native="handleView(record)"
           title="view" />
+        <svg-icon
+          name="mapping"
+          border
+          @click.native="handleDependApps(record)"
+          title="depend apps" />
         <a-popconfirm
           v-permit="'variable:delete'"
           title="Are you sure delete this variable ?"
@@ -152,11 +157,12 @@ import VariableInfo from './Detail'
 import VariableAdd from './Add'
 import VariableEdit from './Edit'
 import SvgIcon from '@/components/SvgIcon'
-import { list, deleteVariable} from '@/api/variable'
+import {list, deleteVariable} from '@/api/variable'
+import {mapActions} from 'vuex'
 
 export default {
   name: 'Variable',
-  components: { VariableInfo, VariableAdd, VariableEdit, SvgIcon },
+  components: {VariableInfo, VariableAdd, VariableEdit, SvgIcon},
   data () {
     return {
       variableInfo: {
@@ -222,10 +228,16 @@ export default {
   },
 
   methods: {
+    ...mapActions(['SetVariableCode']),
+
     handleView (record) {
       this.variableInfo.data = record
       this.variableInfo.visible = true
     },
+    handleDependApps(record) {
+      this.SetVariableCode(record.variableCode)
+      this.$router.push({'path': '/system/variable/depend_apps'})
+    },
     handleAdd () {
       this.variableAdd.visible = true
     },

Reply via email to