Browse Source

IO build replace with source code (#1142)

* Dependency workflow add dependency correction value

* Download workflow instance map width adjustment and change "desc" field to "description"

* The third-party library that builds the dependency is recommended to be placed in 'devDependencies'

* Tree chart and Gantt chart style modification

* The workflow instance can be deleted only when its status is success, failure, stop and pause.

* change desc to description

* Maximum width of tooltip is set to 500px, note the copyright number of login page

* Delete copyright number

* No tenant in the list of selected tenants the default is default, and the status not shown in the repair page

* repair

* Repair security center module prompt

* Remove blank character during verification

* Remove blank character during verification

* Non admin users cannot create users, tenants, alarm groups, queues and worker groups

* Remove CI windows detection

* The value of loadaverage should be two decimal places

* Add license

* delete docs

* update package.json

* delete LICENSE

* Display icon when there is no data in process definition

* Worker group add IP format verification

* Modify MySQL page of monitoring center

* DB page rename and background color modification

* IO build replace with source code
break60 5 years ago
parent
commit
f787dcc5a5

+ 1 - 0
dolphinscheduler-ui/package.json

@@ -27,6 +27,7 @@
     "echarts": "^4.1.0",
     "html2canvas": "^0.5.0-beta4",
     "jsplumb": "^2.8.6",
+    "axios": "^0.16.2",
     "lodash": "^4.17.11",
     "vuex-router-sync": "^4.1.2"
   },

+ 183 - 0
dolphinscheduler-ui/src/js/module/axios/index.js

@@ -0,0 +1,183 @@
+/*
+ * 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.
+ */
+const _ = require('lodash')
+const axios = require('axios')
+const combineURLs = require('axios/lib/helpers/combineURLs')
+const buildURL = require('axios/lib/helpers/buildURL')
+
+const qs = require('./querystring')
+const jsonp = require('./jsonp')
+
+const preflightDataMethods = ['post', 'put', 'patch']
+const API_ASSERT_OK = 0
+
+const def = (o, p, v, desc) =>
+  Object.defineProperty(o, p,
+    Object.assign({ writable: false, enumerable: false, configurable: false }, desc, { value: v }))
+
+const normalizeArgs = (method, url, data, success, fail, config) => {
+  if (_.isFunction(data)) {
+    config = fail
+    fail = success
+    success = data
+  }
+  if (_.isPlainObject(data)) {
+    if (!_.includes(preflightDataMethods, method)) {
+      config = _.merge({}, config, { params: data })
+    } else {
+      config = _.merge({}, config, { data })
+    }
+  } else {
+    config = config || {}
+  }
+  config.method = method
+  config.url = url
+  return {
+    success, fail, config
+  }
+}
+
+const generalHandle = (data, res, resolve, reject, success, fail) => {
+  if (!data || +(data.code || 0) !== API_ASSERT_OK) {
+    fail && fail(data)
+    reject(data)
+  } else {
+    success && success(data)
+    resolve(data)
+  }
+}
+
+const isAbsUrl = (url) => {
+  return /^(https?:)?\/\//i.test(url)
+}
+
+const resolveURL = (base, path) => {
+  if (!base || (path && isAbsUrl(path))) {
+    return path
+  }
+  return combineURLs(base, path)
+}
+
+const create = (cfg) => new InnerCtor(cfg)
+
+class InnerCtor {
+  constructor (defaults) {
+    const inter = axios.create(defaults)
+
+    // { baseURL, timeout, ... }
+    this.config = Object.assign(
+      {
+        baseURL: '',
+        timeout: 0,
+        resolveURL: u => u
+      },
+      defaults
+    )
+
+    this.inter = inter
+    this.interceptors = inter.interceptors
+
+    this.jsonp = this.jsonp.bind(this)
+
+    // Exporse the internal json api
+    this.jsonp.inter = jsonp
+
+    // Generates shortcuts by http method.
+    ;['get', 'delete', 'head', 'options', 'post', 'put', 'patch'].forEach((method) => {
+      this[method] = function (url, data, success, fail, config) {
+        return this.request({ url, method, data, success, fail, config })
+      }.bind(this)
+    })
+  }
+
+  request ({ url, method, data, success, fail, config }) {
+    const configs = normalizeArgs(method, this.config.resolveURL(url), data, success, fail, config)
+    configs.config = _.merge({}, this.config, configs.config)
+
+    // fallback application/json to application/x-www-form-urlencoded
+    if (configs.config.emulateJSON !== false) {
+      configs.config.data = qs(configs.config.data)
+    }
+
+    return new Promise((resolve, reject) => {
+      this.inter.request(configs.config)
+        .then((res) => {
+          if (method === 'head' || method === 'options') {
+            res.data = res.headers
+          }
+          generalHandle(res.data, res, resolve, reject, configs.success, configs.fail)
+        })
+        .catch(err => {
+          let ret, code
+          /* istanbul ignore else */
+          if (err.response && err.response.status) {
+            code = err.response.status
+          } else {
+            code = 500
+          }
+          if (err.response && (method === 'head' || method === 'options')) {
+            err.response.data = err.response.headers
+          }
+          /* istanbul ignore else */
+          if (err.response && err.response.data) {
+            if (_.isString(err.response.data)) {
+              ret = {
+                message: err.message,
+                code,
+                data: err.response.data
+              }
+            } else {
+              ret = err.response.data
+            }
+          } else {
+            ret = {
+              code,
+              message: err.message,
+              data: null
+            }
+          }
+          def(ret, '$error', err)
+          reject(ret)
+        })
+    })
+  }
+
+  jsonp (url, data, success, fail, config) {
+    const configs = normalizeArgs('jsonp', this.config.resolveURL(url), data, success, fail, config)
+
+    configs.config = _.merge({}, this.config, configs.config)
+    configs.url = buildURL(resolveURL(configs.config.baseURL, configs.config.url), configs.config.params)
+
+    return new Promise((resolve, reject) => {
+      jsonp(configs.url, configs.config, (err, data) => {
+        if (err) {
+          const ret = {
+            code: 500,
+            message: err.message,
+            data: null
+          }
+          def(ret, '$error', err)
+          reject(ret)
+        } else {
+          generalHandle(data, data, resolve, reject, configs.success, configs.fail)
+        }
+      })
+    })
+  }
+}
+
+module.exports = Object.assign(create({}), { create, axios })

+ 120 - 0
dolphinscheduler-ui/src/js/module/axios/jsonp.js

@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+module.exports = jsonp
+
+/**
+ * Callback index.
+ */
+
+var count = 0
+
+/**
+ * Noop function.
+ */
+
+/* istanbul ignore next */
+function noop () {
+}
+
+/**
+ * JSONP handler
+ *
+ * Options:
+ *  - param {String} qs parameter (`callback`)
+ *  - prefix {String} qs parameter (`__jp`)
+ *  - name {String} qs parameter (`prefix` + incr)
+ *  - timeout {Number} how long after a timeout error is emitted (`60000`)
+ *
+ * @param {String} url
+ * @param {Object|Function} optional options / callback
+ * @param {Function} optional callback
+ */
+
+function jsonp (url, opts, fn) {
+  if (typeof opts === 'function') {
+    fn = opts
+    opts = {}
+  }
+  if (!opts) opts = {}
+
+  var prefix = opts.prefix || '__jp'
+
+  // use the callback name that was passed if one was provided.
+  // otherwise generate a unique name by incrementing our counter.
+  var id = opts.name || (prefix + (count++))
+
+  var param = opts.param || 'callback'
+  var timeout = opts.timeout != null ? opts.timeout : 60000
+  var enc = encodeURIComponent
+  /* istanbul ignore next */
+  var target = document.getElementsByTagName('script')[0] || document.head
+  var script
+  var timer
+  /* istanbul ignore else */
+  if (timeout) {
+    timer = setTimeout(
+      /* istanbul ignore next */
+      function () {
+        cleanup()
+        if (fn) fn(new Error('Timeout'))
+      }, timeout)
+  }
+
+  function cleanup () {
+    script.onerror = null
+    script.onload = null
+    /* istanbul ignore else */
+    if (script.parentNode) script.parentNode.removeChild(script)
+    window[id] = noop
+    /* istanbul ignore else */
+    if (timer) clearTimeout(timer)
+  }
+
+  function cancel () {
+    /* istanbul ignore else */
+    if (window[id]) {
+      cleanup()
+    }
+  }
+
+  window[id] = function (data) {
+    // debug('jsonp got', data);
+    cleanup()
+    if (fn) fn(null, data)
+  }
+
+  // add qs component
+  url += (~url.indexOf('?') ? '&' : '?') + param + '=' + enc(id)
+  url = url.replace('?&', '?')
+
+  // debug('jsonp req "%s"', url);
+  var handler = ({ type }) => {
+    /* istanbul ignore else */
+    if (type === 'error') {
+      cleanup()
+      fn(new Error('http error'))
+    }
+  }
+  // create script
+  script = document.createElement('script')
+  script.src = url
+  script.onload = handler
+  script.onerror = handler
+  target.parentNode.insertBefore(script, target)
+
+  return cancel
+}

+ 61 - 0
dolphinscheduler-ui/src/js/module/axios/querystring.js

@@ -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.
+ */
+/* istanbul ignore next */
+var param = function (a) {
+  var s = [],
+    rbracket = /\[\]$/,
+    isArray = function (obj) {
+      return Object.prototype.toString.call(obj) === '[object Array]'
+    },
+    add = function (k, v) {
+      v = typeof v === 'function' ? v() : v === null ? '' : v === undefined ? '' : v
+      s[s.length] = encodeURIComponent(k) + '=' + encodeURIComponent(v)
+    },
+    buildParams = function (prefix, obj) {
+      var i, len, key
+
+      if (prefix) {
+        if (isArray(obj)) {
+          for (i = 0, len = obj.length; i < len; i++) {
+            if (rbracket.test(prefix)) {
+              add(prefix, obj[i])
+            } else {
+              buildParams(prefix + '[' + (typeof obj[i] === 'object' ? i : '') + ']', obj[i])
+            }
+          }
+        } else if (obj && String(obj) === '[object Object]') {
+          for (key in obj) {
+            buildParams(prefix + '[' + key + ']', obj[key])
+          }
+        } else {
+          add(prefix, obj)
+        }
+      } else if (isArray(obj)) {
+        for (i = 0, len = obj.length; i < len; i++) {
+          add(obj[i].name, obj[i].value)
+        }
+      } else {
+        for (key in obj) {
+          buildParams(key, obj[key])
+        }
+      }
+      return s
+    }
+  return buildParams('', a).join('&').replace(/%20/g, '+')
+}
+
+module.exports = param

+ 1 - 1
dolphinscheduler-ui/src/js/module/io/index.js

@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-import io from '~/@fedor/io/dist/io'
+import io from '@/module/axios/index'
 import cookie from '@/module/util/cookie'
 
 

+ 0 - 127
dolphinscheduler-ui/src/lib/@fedor/io/README.md

@@ -1,127 +0,0 @@
-# io
-
-Promise based HTTP client for the browser and node.js wrapper axios and add jsonp support
-
-## Installing
-
-Using npm:
-
-```bash
-$ npm install @fedor/io
-```
-
-## Test
-```bash
-//test in browser with karma
-$ npm run test
-//test in node with mocha
-$ npm run node-test
-```
-
-## Build
-```bash
-$ npm run build
-```
-
-## Example
-
-Performing a request
-
-```js
-io[method](url,data,success,fail,config)
-io.get(
-  // request url
-  '/user',
-  // optional request query data or request data
-  {ID: 12345},
-  //handle business success
-  function (data) {
-    console.log(data);
-  },
-  //handle business fail when code is not false value or server error
-  function (error) {
-    console.log(error)
-  },
-  //extra config  or axios config
-  {
-    // use application/json with modern api
-    emulateJSON:false
-  })
-  //handle success in promise
-  .then(function (data) {
-    console.log(data);
-  })
-  //handle error in promise
-  .catch(function (error) {
-    console.log(error);
-    //error.$ is origin error throw by axios
-    console.log(error.$);
-  });
-```
-## response
-response data is formatted as
-```js
-{
-  code:0,
-  data:"data from server"
-  message:"message from server"
-}
-```
-response error is formatted as
-```js
-{
-  code:"error code",
-  data:"error data from server",
-  message:"error message from server",
-  $:axios throw error
-}
-```
-
-## config
-see <https://github.com/mzabriskie/axios#request-config>
-```js
-{
-    // use application/json with modern api
-    emulateJSON:false
-}
-```
-
-## axios
-
-```
-//the axios instance is in io.fetch and origin axios is in io.axios
-//if you want to use interceptors
-// request interceptor
-io.interceptors.request.use(function (config) {
-    // Do something before request is sent
-    return config;
-  }, function (error) {
-    // Do something with request error
-    return Promise.reject(error);
-  });
-
-// response interceptor
-io.interceptors.response.use(function (response) {
-    // Do something with response data
-    return response;
-  }, function (error) {
-    // Do something with response error
-    return Promise.reject(error);
-  });
-
-```
-## instance
-create instance with config
-```js
-const instance = io.create({
-  baseURL:"http://www.analysys.cn",
-  emulateJSON:false
-})
-```
-## defaults
-set default config in all instance
-```js
-io.config.emulateJSON = false
-```
-
-for more detail see <http://git.analysys.cn/npm/io/tree/master/test>

File diff suppressed because it is too large
+ 0 - 1426
dolphinscheduler-ui/src/lib/@fedor/io/dist/io.esm.js


File diff suppressed because it is too large
+ 0 - 1430
dolphinscheduler-ui/src/lib/@fedor/io/dist/io.js


File diff suppressed because it is too large
+ 0 - 4
dolphinscheduler-ui/src/lib/@fedor/io/dist/io.min.js


+ 0 - 73
dolphinscheduler-ui/src/lib/@fedor/io/package.json

@@ -1,73 +0,0 @@
-{
-  "name": "@fedor/io",
-  "version": "1.0.5",
-  "description": "generic io toolchain both for browser and node",
-  "main": "dist/io.min.js",
-  "module": "dist/io.esm.js",
-  "author": "ljw <leijiawang@analysys.com.cn>",
-  "license": "MIT",
-  "repository": {
-    "type": "git",
-    "url": "git+https://git.analysys.cn/npm/io"
-  },
-  "dependencies": {
-  },
-  "devDependencies": {
-    "axios": "^0.16.2",
-    "lodash": "^4.17.4",
-    "@fedor/standard": "latest",
-    "babel-core": "^6.25.0",
-    "babel-loader": "^7.1.1",
-    "babel-plugin-external-helpers": "^6.22.0",
-    "babel-plugin-istanbul": "^4.1.4",
-    "babel-plugin-transform-class-properties": "^6.24.1",
-    "babel-plugin-transform-runtime": "^6.23.0",
-    "babel-preset-env": "^1.5.2",
-    "body-parser": "^1.17.2",
-    "chai": "^4.1.1",
-    "cors": "^2.8.4",
-    "express": "^4.15.4",
-    "istanbul-instrumenter-loader": "^3.0.0",
-    "karma": "^1.7.0",
-    "karma-chrome-launcher": "^2.2.0",
-    "karma-coverage": "^1.1.1",
-    "karma-coverage-istanbul-reporter": "^1.3.0",
-    "karma-mocha": "^1.3.0",
-    "karma-mocha-reporter": "^2.2.3",
-    "karma-sourcemap-loader": "^0.3.7",
-    "karma-webpack": "^2.0.4",
-    "mocha": "^3.5.0",
-    "rollup-plugin-babel": "^3.0.3",
-    "rollup-plugin-cleanup": "^2.0.0",
-    "rollup-worker": "^1.0.1",
-    "sinon": "^3.1.0",
-    "webpack": "^3.5.1"
-  },
-  "scripts": {
-    "build": "npm run lint:fix && rollup-bundle --config .config/build.js",
-    "prepublishOnly": "npm run build",
-    "test:node": "mocha",
-    "test:browser": "karma start",
-    "lint:fix": "standard --fix",
-    "lint": "standard",
-    "test": "npm run lint && npm run test:node"
-  },
-  "standard": {
-    "ignore": [
-      "test"
-    ]
-  },
-  "files": [
-    "dist/"
-  ],
-  "maintainers": [
-    {
-      "name": "public",
-      "email": "rayjump@163.com"
-    },
-    {
-      "name": "allex",
-      "email": "allex.wxn@gmail.com"
-    }
-  ]
-}