You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by lg...@apache.org on 2019/12/25 02:30:54 UTC

[incubator-dolphinscheduler] branch 1.2.0-release updated: replace cookie.js with js-cookie, add js-cookie license (#1562)

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

lgcareer pushed a commit to branch 1.2.0-release
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git


The following commit(s) were added to refs/heads/1.2.0-release by this push:
     new 449f83e  replace cookie.js with js-cookie, add js-cookie license (#1562)
449f83e is described below

commit 449f83ed2fec5a6d449efe44fd9670a09bbee864
Author: break60 <79...@qq.com>
AuthorDate: Wed Dec 25 10:30:43 2019 +0800

    replace cookie.js with js-cookie, add js-cookie license (#1562)
    
    * Front-end compliance modification
    
    * Front-end supplemental license
    
    * Modify naming
    
    * Repair license
    
    * replace cookie.js with js-cookie, add js-cookie license
---
 .../src/main/release-docs/LICENSE                  |  1 +
 .../main/release-docs/licenses/LICENSE-js-cookie   | 21 ++++++
 dolphinscheduler-ui/package.json                   |  1 +
 .../pages/dag/_source/formModel/tasks/http.vue     |  4 +-
 dolphinscheduler-ui/src/js/conf/login/App.vue      |  4 +-
 .../src/js/module/components/nav/nav.vue           |  6 +-
 dolphinscheduler-ui/src/js/module/i18n/index.js    |  8 +-
 dolphinscheduler-ui/src/js/module/io/index.js      |  4 +-
 dolphinscheduler-ui/src/js/module/util/cookie.js   | 88 ----------------------
 9 files changed, 36 insertions(+), 101 deletions(-)

diff --git a/dolphinscheduler-dist/dolphinscheduler-front/src/main/release-docs/LICENSE b/dolphinscheduler-dist/dolphinscheduler-front/src/main/release-docs/LICENSE
index 43330d3..16b13ba 100644
--- a/dolphinscheduler-dist/dolphinscheduler-front/src/main/release-docs/LICENSE
+++ b/dolphinscheduler-dist/dolphinscheduler-front/src/main/release-docs/LICENSE
@@ -221,6 +221,7 @@ MIT licenses
     html2canvas 0.5.0-beta4: https://github.com/niklasvh/html2canvas MIT
     jquery 3.3.1: https://github.com/jquery/jquery MIT
     jquery-ui 1.12.1: https://github.com/jquery/jquery-ui MIT
+    js-cookie 2.2.1: https://github.com/js-cookie/js-cookie MIT
     jsplumb 2.8.6: https://github.com/jsplumb/jsplumb MIT and GPLv2
     lodash 4.17.11: https://github.com/lodash/lodash MIT
     vue	2.5.17:	https://github.com/vuejs/vue	MIT
diff --git a/dolphinscheduler-dist/dolphinscheduler-front/src/main/release-docs/licenses/LICENSE-js-cookie b/dolphinscheduler-dist/dolphinscheduler-front/src/main/release-docs/licenses/LICENSE-js-cookie
new file mode 100644
index 0000000..69ed677
--- /dev/null
+++ b/dolphinscheduler-dist/dolphinscheduler-front/src/main/release-docs/licenses/LICENSE-js-cookie
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Copyright 2018 Klaus Hartl, Fagner Brack, GitHub Contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/dolphinscheduler-ui/package.json b/dolphinscheduler-ui/package.json
index 748521b..1a3fcef 100644
--- a/dolphinscheduler-ui/package.json
+++ b/dolphinscheduler-ui/package.json
@@ -23,6 +23,7 @@
     "html2canvas": "^0.5.0-beta4",
     "jquery": "3.3.1",
     "jquery-ui": "^1.12.1",
+    "js-cookie": "^2.2.1",
     "jsplumb": "^2.8.6",
     "lodash": "^4.17.11",
     "vue": "^2.5.17",
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/http.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/http.vue
index 2617c44..adb5441 100644
--- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/http.vue
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/http.vue
@@ -101,7 +101,7 @@
 <script>
   import _ from 'lodash'
   import i18n from '@/module/i18n'
-  import cookie from '@/module/util/cookie'
+  import cookies from 'js-cookie'
   import mLocalParams from './_source/localParams'
   import mHttpParams from './_source/httpParams'
   import mListBox from './_source/listBox'
@@ -117,7 +117,7 @@
         httpMethod: 'GET',
         httpMethodList: [{ code: 'GET' }, { code: 'POST' }, { code: 'HEAD' }, { code: 'PUT' }, { code: 'DELETE' }],
         httpCheckCondition: 'STATUS_CODE_DEFAULT',
-        httpCheckConditionList: cookie.get('language') == 'en_US'? [{ code: 'STATUS_CODE_DEFAULT',value:'Default response code 200' }, { code: 'STATUS_CODE_CUSTOM',value:'Custom response code' }, { code: 'BODY_CONTAINS',value:'Content includes' }, { code: 'BODY_NOT_CONTAINS',value:'Content does not contain' }]:[{ code: 'STATUS_CODE_DEFAULT',value:'默认响应码200' }, { code: 'STATUS_CODE_CUSTOM',value:'自定义响应码' }, { code: 'BODY_CONTAINS',value:'内容包含' }, { code: 'BODY_NOT_CONTAINS',value:'内容不包含' }]
+        httpCheckConditionList: cookies.get('language') == 'en_US'? [{ code: 'STATUS_CODE_DEFAULT',value:'Default response code 200' }, { code: 'STATUS_CODE_CUSTOM',value:'Custom response code' }, { code: 'BODY_CONTAINS',value:'Content includes' }, { code: 'BODY_NOT_CONTAINS',value:'Content does not contain' }]:[{ code: 'STATUS_CODE_DEFAULT',value:'默认响应码200' }, { code: 'STATUS_CODE_CUSTOM',value:'自定义响应码' }, { code: 'BODY_CONTAINS',value:'内容包含' }, { code: 'BODY_NOT_CONTAINS',value:'内容不包含' }]
       }
     },
     props: {
diff --git a/dolphinscheduler-ui/src/js/conf/login/App.vue b/dolphinscheduler-ui/src/js/conf/login/App.vue
index 45270a2..886ff2e 100644
--- a/dolphinscheduler-ui/src/js/conf/login/App.vue
+++ b/dolphinscheduler-ui/src/js/conf/login/App.vue
@@ -61,7 +61,7 @@
 <script>
   import i18n from '@/module/i18n'
   import io from '@/module/io'
-  import cookie from '@/module/util/cookie'
+  import cookies from 'js-cookie'
 
   export default {
     name: 'login-model',
@@ -85,7 +85,7 @@
             setTimeout(() => {
               this.spinnerLoading = false
               sessionStorage.setItem("sessionId", res.data)
-              cookie.set('sessionId', res.data,{ path: '/' })
+              cookies.set('sessionId', res.data,{ path: '/' })
               if (this.userName === 'admin') {
                 window.location.href = `${PUBLIC_PATH}/#/security/tenant`
               } else {
diff --git a/dolphinscheduler-ui/src/js/module/components/nav/nav.vue b/dolphinscheduler-ui/src/js/module/components/nav/nav.vue
index 1c950bf..486385e 100644
--- a/dolphinscheduler-ui/src/js/module/components/nav/nav.vue
+++ b/dolphinscheduler-ui/src/js/module/components/nav/nav.vue
@@ -151,7 +151,7 @@
 </template>
 <script>
   import _ from 'lodash'
-  import cookie from '@/module/util/cookie'
+  import cookies from 'js-cookie'
   import { mapState, mapActions } from 'vuex'
   import { findComponentDownward } from '@/module/util/'
   import mFileUpdate from '@/module/components/fileUpdate/fileUpdate'
@@ -276,14 +276,14 @@
        * Language switching
        */
       _toggleLanguage (language) {
-        cookie.set('language', language, { path: '/' })
+        cookies.set('language', language, { path: '/' })
         setTimeout(() => {
           window.location.reload()
         }, 100)
       }
     },
     created () {
-      let language = cookie.get('language')
+      let language = cookies.get('language')
       this.activeLocale = language ? findLocale(language) : '中文'
       this.docLink = process.env.NODE_ENV === 'true' ? 'docs' : `/view/docs/${this.activeLocale.code}/_book` // eslint-disable-line
     },
diff --git a/dolphinscheduler-ui/src/js/module/i18n/index.js b/dolphinscheduler-ui/src/js/module/i18n/index.js
index 72f8434..ca9ef87 100644
--- a/dolphinscheduler-ui/src/js/module/i18n/index.js
+++ b/dolphinscheduler-ui/src/js/module/i18n/index.js
@@ -19,7 +19,7 @@
 import Vue from 'vue'
 import { findLocale } from './config'
 import { template } from '@/module/util'
-import cookie from '@/module/util/cookie'
+import cookies from 'js-cookie'
 
 const globalScope = typeof window !== 'undefined' && window.document ? window : global
 
@@ -44,12 +44,12 @@ const $t = (str, data) => {
 const locale = (lang) => {
   // global
   globalScope.LOCALE = lang
-  // cookie
-  cookie.set('language', lang,{ path: '/' })
+  // cookies
+  cookies.set('language', lang,{ path: '/' })
 }
 
 const init = () => {
-  let language = cookie.get('language')
+  let language = cookies.get('language')
   if (language) {
     locale(language)
   }else{
diff --git a/dolphinscheduler-ui/src/js/module/io/index.js b/dolphinscheduler-ui/src/js/module/io/index.js
index 470514d..f5713a5 100644
--- a/dolphinscheduler-ui/src/js/module/io/index.js
+++ b/dolphinscheduler-ui/src/js/module/io/index.js
@@ -16,7 +16,7 @@
  */
 
 import io from '@/module/axios/index'
-import cookie from '@/module/util/cookie'
+import cookies from 'js-cookie'
 
 
 const apiPrefix = '/dolphinscheduler'
@@ -73,7 +73,7 @@ io.interceptors.response.use(
 // Global request interceptor registion
 io.interceptors.request.use(
   config => {
-    let sIdCookie = cookie.get('sessionId')
+    let sIdCookie = cookies.get('sessionId')
     let sessionId = sessionStorage.getItem("sessionId")
     let  requstUrl = config.url.substring(config.url.lastIndexOf("/")+1)
     if(requstUrl!=='login' && sIdCookie!=sessionId) {
diff --git a/dolphinscheduler-ui/src/js/module/util/cookie.js b/dolphinscheduler-ui/src/js/module/util/cookie.js
deleted file mode 100644
index c622243..0000000
--- a/dolphinscheduler-ui/src/js/module/util/cookie.js
+++ /dev/null
@@ -1,88 +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.
- */
-let document = window.document
-let trim = function (s) {
-  if (typeof s !== 'string') {
-    throw new Error('trim need a string as parameter')
-  }
-  let len = s.length, i = 0, j = len - 1, re = /(\u3000|\s|\t|\u00A0)/
-  while (i < len && re.test(s.charAt(i))) ++i
-  while (j >= 0 && re.test(s.charAt(j))) --j
-  return s.substring(i, j + 1)
-}
-let copy = function (o) {
-  let d = {}
-  for (let k in o) { if (o.hasOwnProperty(k)) d[k] = o[k] }
-  return d
-}
-/**
- * Cookie setter & setter
- *
- * @param {String} name The identify name of cookie.
- * @param {String} value (Optional) String to set cookie value. (`null` to remove cookie)
- * @param {Object} options (Optional) Set the cooke native options, (path domain, secure, expires)
- */
-let cookie = function (name, value, options) {
-  options = options || {}
-  if (value !== undefined) { // set cookie
-    options = copy(options)
-    if (value === null) {
-      value = ''
-      options.expires = -1
-    }
-    if (typeof options.expires === 'number') {
-      let days = options.expires, t = options.expires = new Date()
-      t.setTime(t.getTime() + days * 864e+5) // 24 * 60 * 60 * 1000
-    }
-    let encode = function (s) {
-      try {
-        return options.raw ? s : encodeURIComponent(s)
-      } catch (e) {
-      }
-      return s
-    }
-    return (document.cookie = [
-      encode(name), '=', encode(value),
-      options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
-      options.path ? '; path=' + options.path : '',
-      options.domain ? '; domain=' + options.domain : '',
-      options.secure ? '; secure' : ''
-    ].join(''))
-  } else {
-    let value = null,
-      cookie = document.cookie,
-      decode = function (s) {
-        return options.raw ? s : decodeURIComponent(s)
-      },
-      cookies = cookie ? cookie.split('; ') : []
-    for (let i = -1, l = cookies.length, c = name.length + 1; ++i < l;) {
-      cookie = trim(cookies[i])
-      if (cookie.substring(0, c) === (name + '=')) {
-        value = decode(cookie.substring(c))
-        break
-      }
-    }
-    return value
-  }
-}
-cookie.set = function (k, v, opts) {
-  return cookie(k, v, opts)
-}
-cookie.get = function (k) {
-  return cookie(k)
-}
-export default cookie