You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2023/03/13 14:47:29 UTC
[skywalking-banyandb] branch main updated: [UI] Add YAML language filter (#260)
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/main by this push:
new e68249a3 [UI] Add YAML language filter (#260)
e68249a3 is described below
commit e68249a385a720d075eab52b496d7c4b4679ba41
Author: Wu ChuSheng <a1...@gmail.com>
AuthorDate: Mon Mar 13 22:47:23 2023 +0800
[UI] Add YAML language filter (#260)
* Add Code Mirror
* Add YAML language filter
* Addtime selector cache
* Remove non-english characters
* Update CHANGES.md
---------
Signed-off-by: Gao Hongtao <ha...@gmail.com>
Co-authored-by: Gao Hongtao <ha...@gmail.com>
---
CHANGES.md | 1 +
dist/LICENSE | 9 +
dist/licenses/ui-licenses/license-argparse.txt | 254 +++++++++++++++++++++++
dist/licenses/ui-licenses/license-codemirror.txt | 21 ++
dist/licenses/ui-licenses/license-js-yaml.txt | 21 ++
dist/licenses/ui-licenses/license-yaml.txt | 13 ++
ui/LICENSE | 9 +
ui/package-lock.json | 57 ++++-
ui/package.json | 5 +-
ui/src/components2/CodeMirror/index.vue | 32 +--
ui/src/components2/Read/index.vue | 139 ++++++++++---
ui/src/utils/axios.js | 4 +-
ui/src/utils/yaml.js | 49 +++++
13 files changed, 554 insertions(+), 60 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 32aa38ea..0ff0aefd 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,7 @@ Release Notes.
### Features
- Add TSDB concept document.
+- [UI] Add YAML editor for inputting query criteria.
### Chores
diff --git a/dist/LICENSE b/dist/LICENSE
index 7764ee7c..75485dd4 100644
--- a/dist/LICENSE
+++ b/dist/LICENSE
@@ -388,6 +388,7 @@ ISC licenses
glob-parent 5.1.2 ISC
graceful-fs 4.2.10 ISC
picocolors 1.0.0 ISC
+ yaml 2.2.1 ISC
========================================================================
MIT licenses
@@ -426,6 +427,7 @@ MIT licenses
binary-extensions 2.2.0 MIT
braces 3.0.2 MIT
chokidar 3.5.3 MIT
+ codemirror 5.59.1 MIT
combined-stream 1.0.8 MIT
csstype 2.6.21 MIT
dayjs 1.11.7 MIT
@@ -441,6 +443,7 @@ MIT licenses
is-extglob 2.1.1 MIT
is-glob 4.0.3 MIT
is-number 7.0.0 MIT
+ js-yaml 4.1.0 MIT
jsonfile 6.1.0 MIT
lodash 4.17.21 MIT
lodash-es 4.17.21 MIT
@@ -462,3 +465,9 @@ MIT licenses
universalify 2.0.0 MIT
vue 3.2.45 MIT
vue-router 4.1.6 MIT
+
+========================================================================
+Python-2.0 licenses
+========================================================================
+
+ argparse 2.0.1 Python-2.0
diff --git a/dist/licenses/ui-licenses/license-argparse.txt b/dist/licenses/ui-licenses/license-argparse.txt
new file mode 100644
index 00000000..66a3ac80
--- /dev/null
+++ b/dist/licenses/ui-licenses/license-argparse.txt
@@ -0,0 +1,254 @@
+A. HISTORY OF THE SOFTWARE
+==========================
+
+Python was created in the early 1990s by Guido van Rossum at Stichting
+Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
+as a successor of a language called ABC. Guido remains Python's
+principal author, although it includes many contributions from others.
+
+In 1995, Guido continued his work on Python at the Corporation for
+National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
+in Reston, Virginia where he released several versions of the
+software.
+
+In May 2000, Guido and the Python core development team moved to
+BeOpen.com to form the BeOpen PythonLabs team. In October of the same
+year, the PythonLabs team moved to Digital Creations, which became
+Zope Corporation. In 2001, the Python Software Foundation (PSF, see
+https://www.python.org/psf/) was formed, a non-profit organization
+created specifically to own Python-related Intellectual Property.
+Zope Corporation was a sponsoring member of the PSF.
+
+All Python releases are Open Source (see http://www.opensource.org for
+the Open Source Definition). Historically, most, but not all, Python
+releases have also been GPL-compatible; the table below summarizes
+the various releases.
+
+ Release Derived Year Owner GPL-
+ from compatible? (1)
+
+ 0.9.0 thru 1.2 1991-1995 CWI yes
+ 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
+ 1.6 1.5.2 2000 CNRI no
+ 2.0 1.6 2000 BeOpen.com no
+ 1.6.1 1.6 2001 CNRI yes (2)
+ 2.1 2.0+1.6.1 2001 PSF no
+ 2.0.1 2.0+1.6.1 2001 PSF yes
+ 2.1.1 2.1+2.0.1 2001 PSF yes
+ 2.1.2 2.1.1 2002 PSF yes
+ 2.1.3 2.1.2 2002 PSF yes
+ 2.2 and above 2.1.1 2001-now PSF yes
+
+Footnotes:
+
+(1) GPL-compatible doesn't mean that we're distributing Python under
+ the GPL. All Python licenses, unlike the GPL, let you distribute
+ a modified version without making your changes open source. The
+ GPL-compatible licenses make it possible to combine Python with
+ other software that is released under the GPL; the others don't.
+
+(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
+ because its license has a choice of law clause. According to
+ CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
+ is "not incompatible" with the GPL.
+
+Thanks to the many outside volunteers who have worked under Guido's
+direction to make these releases possible.
+
+
+B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
+===============================================================
+
+PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
+--------------------------------------------
+
+1. This LICENSE AGREEMENT is between the Python Software Foundation
+("PSF"), and the Individual or Organization ("Licensee") accessing and
+otherwise using this software ("Python") in source or binary form and
+its associated documentation.
+
+2. Subject to the terms and conditions of this License Agreement, PSF hereby
+grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
+analyze, test, perform and/or display publicly, prepare derivative works,
+distribute, and otherwise use Python alone or in any derivative version,
+provided, however, that PSF's License Agreement and PSF's notice of copyright,
+i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation;
+All Rights Reserved" are retained in Python alone or in any derivative version
+prepared by Licensee.
+
+3. In the event Licensee prepares a derivative work that is based on
+or incorporates Python or any part thereof, and wants to make
+the derivative work available to others as provided herein, then
+Licensee hereby agrees to include in any such work a brief summary of
+the changes made to Python.
+
+4. PSF is making Python available to Licensee on an "AS IS"
+basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
+IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
+INFRINGE ANY THIRD PARTY RIGHTS.
+
+5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
+FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+
+6. This License Agreement will automatically terminate upon a material
+breach of its terms and conditions.
+
+7. Nothing in this License Agreement shall be deemed to create any
+relationship of agency, partnership, or joint venture between PSF and
+Licensee. This License Agreement does not grant permission to use PSF
+trademarks or trade name in a trademark sense to endorse or promote
+products or services of Licensee, or any third party.
+
+8. By copying, installing or otherwise using Python, Licensee
+agrees to be bound by the terms and conditions of this License
+Agreement.
+
+
+BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
+-------------------------------------------
+
+BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
+
+1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
+office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
+Individual or Organization ("Licensee") accessing and otherwise using
+this software in source or binary form and its associated
+documentation ("the Software").
+
+2. Subject to the terms and conditions of this BeOpen Python License
+Agreement, BeOpen hereby grants Licensee a non-exclusive,
+royalty-free, world-wide license to reproduce, analyze, test, perform
+and/or display publicly, prepare derivative works, distribute, and
+otherwise use the Software alone or in any derivative version,
+provided, however, that the BeOpen Python License is retained in the
+Software, alone or in any derivative version prepared by Licensee.
+
+3. BeOpen is making the Software available to Licensee on an "AS IS"
+basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
+IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
+INFRINGE ANY THIRD PARTY RIGHTS.
+
+4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
+SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
+AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
+DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+
+5. This License Agreement will automatically terminate upon a material
+breach of its terms and conditions.
+
+6. This License Agreement shall be governed by and interpreted in all
+respects by the law of the State of California, excluding conflict of
+law provisions. Nothing in this License Agreement shall be deemed to
+create any relationship of agency, partnership, or joint venture
+between BeOpen and Licensee. This License Agreement does not grant
+permission to use BeOpen trademarks or trade names in a trademark
+sense to endorse or promote products or services of Licensee, or any
+third party. As an exception, the "BeOpen Python" logos available at
+http://www.pythonlabs.com/logos.html may be used according to the
+permissions granted on that web page.
+
+7. By copying, installing or otherwise using the software, Licensee
+agrees to be bound by the terms and conditions of this License
+Agreement.
+
+
+CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
+---------------------------------------
+
+1. This LICENSE AGREEMENT is between the Corporation for National
+Research Initiatives, having an office at 1895 Preston White Drive,
+Reston, VA 20191 ("CNRI"), and the Individual or Organization
+("Licensee") accessing and otherwise using Python 1.6.1 software in
+source or binary form and its associated documentation.
+
+2. Subject to the terms and conditions of this License Agreement, CNRI
+hereby grants Licensee a nonexclusive, royalty-free, world-wide
+license to reproduce, analyze, test, perform and/or display publicly,
+prepare derivative works, distribute, and otherwise use Python 1.6.1
+alone or in any derivative version, provided, however, that CNRI's
+License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
+1995-2001 Corporation for National Research Initiatives; All Rights
+Reserved" are retained in Python 1.6.1 alone or in any derivative
+version prepared by Licensee. Alternately, in lieu of CNRI's License
+Agreement, Licensee may substitute the following text (omitting the
+quotes): "Python 1.6.1 is made available subject to the terms and
+conditions in CNRI's License Agreement. This Agreement together with
+Python 1.6.1 may be located on the Internet using the following
+unique, persistent identifier (known as a handle): 1895.22/1013. This
+Agreement may also be obtained from a proxy server on the Internet
+using the following URL: http://hdl.handle.net/1895.22/1013".
+
+3. In the event Licensee prepares a derivative work that is based on
+or incorporates Python 1.6.1 or any part thereof, and wants to make
+the derivative work available to others as provided herein, then
+Licensee hereby agrees to include in any such work a brief summary of
+the changes made to Python 1.6.1.
+
+4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
+basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
+IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
+INFRINGE ANY THIRD PARTY RIGHTS.
+
+5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
+1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+
+6. This License Agreement will automatically terminate upon a material
+breach of its terms and conditions.
+
+7. This License Agreement shall be governed by the federal
+intellectual property law of the United States, including without
+limitation the federal copyright law, and, to the extent such
+U.S. federal law does not apply, by the law of the Commonwealth of
+Virginia, excluding Virginia's conflict of law provisions.
+Notwithstanding the foregoing, with regard to derivative works based
+on Python 1.6.1 that incorporate non-separable material that was
+previously distributed under the GNU General Public License (GPL), the
+law of the Commonwealth of Virginia shall govern this License
+Agreement only as to issues arising under or with respect to
+Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
+License Agreement shall be deemed to create any relationship of
+agency, partnership, or joint venture between CNRI and Licensee. This
+License Agreement does not grant permission to use CNRI trademarks or
+trade name in a trademark sense to endorse or promote products or
+services of Licensee, or any third party.
+
+8. By clicking on the "ACCEPT" button where indicated, or by copying,
+installing or otherwise using Python 1.6.1, Licensee agrees to be
+bound by the terms and conditions of this License Agreement.
+
+ ACCEPT
+
+
+CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
+--------------------------------------------------
+
+Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
+The Netherlands. All rights reserved.
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Stichting Mathematisch
+Centrum or CWI not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
+FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/dist/licenses/ui-licenses/license-codemirror.txt b/dist/licenses/ui-licenses/license-codemirror.txt
new file mode 100644
index 00000000..ff7db4b9
--- /dev/null
+++ b/dist/licenses/ui-licenses/license-codemirror.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (C) 2017 by Marijn Haverbeke <ma...@gmail.com> and others
+
+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.
diff --git a/dist/licenses/ui-licenses/license-js-yaml.txt b/dist/licenses/ui-licenses/license-js-yaml.txt
new file mode 100644
index 00000000..09d3a29e
--- /dev/null
+++ b/dist/licenses/ui-licenses/license-js-yaml.txt
@@ -0,0 +1,21 @@
+(The MIT License)
+
+Copyright (C) 2011-2015 by Vitaly Puzrin
+
+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.
diff --git a/dist/licenses/ui-licenses/license-yaml.txt b/dist/licenses/ui-licenses/license-yaml.txt
new file mode 100644
index 00000000..e060aaa1
--- /dev/null
+++ b/dist/licenses/ui-licenses/license-yaml.txt
@@ -0,0 +1,13 @@
+Copyright Eemeli Aro <ee...@gmail.com>
+
+Permission to use, copy, modify, and/or distribute this software for any purpose
+with or without fee is hereby granted, provided that the above copyright notice
+and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
diff --git a/ui/LICENSE b/ui/LICENSE
index 29234d7d..4d5f4740 100644
--- a/ui/LICENSE
+++ b/ui/LICENSE
@@ -35,6 +35,7 @@ ISC licenses
glob-parent 5.1.2 ISC
graceful-fs 4.2.10 ISC
picocolors 1.0.0 ISC
+ yaml 2.2.1 ISC
========================================================================
MIT licenses
@@ -73,6 +74,7 @@ MIT licenses
binary-extensions 2.2.0 MIT
braces 3.0.2 MIT
chokidar 3.5.3 MIT
+ codemirror 5.59.1 MIT
combined-stream 1.0.8 MIT
csstype 2.6.21 MIT
dayjs 1.11.7 MIT
@@ -88,6 +90,7 @@ MIT licenses
is-extglob 2.1.1 MIT
is-glob 4.0.3 MIT
is-number 7.0.0 MIT
+ js-yaml 4.1.0 MIT
jsonfile 6.1.0 MIT
lodash 4.17.21 MIT
lodash-es 4.17.21 MIT
@@ -109,3 +112,9 @@ MIT licenses
universalify 2.0.0 MIT
vue 3.2.45 MIT
vue-router 4.1.6 MIT
+
+========================================================================
+Python-2.0 licenses
+========================================================================
+
+ argparse 2.0.1 Python-2.0
diff --git a/ui/package-lock.json b/ui/package-lock.json
index 2938bb15..65f66eb3 100644
--- a/ui/package-lock.json
+++ b/ui/package-lock.json
@@ -10,14 +10,17 @@
"dependencies": {
"@element-plus/icons-vue": "^2.0.10",
"axios": "^0.27.2",
+ "codemirror": "^5.59.1",
"echarts": "^5.3.3",
"element-plus": "^2.2.17",
+ "js-yaml": "^4.1.0",
"jsonfile": "^6.1.0",
"mitt": "^3.0.0",
"pinia": "^2.0.21",
"sass": "^1.54.9",
"vue": "^3.2.38",
- "vue-router": "^4.1.5"
+ "vue-router": "^4.1.5",
+ "yaml": "^2.2.1"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.0.3",
@@ -418,6 +421,11 @@
"node": ">= 8"
}
},
+ "node_modules/argparse": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
+ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
+ },
"node_modules/async-validator": {
"version": "4.2.5",
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz",
@@ -497,6 +505,11 @@
"fsevents": "~2.3.2"
}
},
+ "node_modules/codemirror": {
+ "version": "5.59.1",
+ "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.59.1.tgz",
+ "integrity": "sha512-d0SSW/PCCD4LoSCBPdnP0BzmZB1v3emomCUtVlIWgZHJ06yVeBOvBtOH7vYz707pfAvEeWbO9aP6akh8vl1V3w=="
+ },
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
@@ -810,6 +823,17 @@
"node": ">=0.12.0"
}
},
+ "node_modules/js-yaml": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
+ "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
+ "dependencies": {
+ "argparse": "^2.0.1"
+ },
+ "bin": {
+ "js-yaml": "bin/js-yaml.js"
+ }
+ },
"node_modules/jsonc-parser": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz",
@@ -1488,6 +1512,14 @@
"integrity": "sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==",
"dev": true
},
+ "node_modules/yaml": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.1.tgz",
+ "integrity": "sha512-e0WHiYql7+9wr4cWMx3TVQrNwejKaEe7/rHNmQmqRjazfOP5W8PB6Jpebb5o6fIapbz9o9+2ipcaTM2ZwDI6lw==",
+ "engines": {
+ "node": ">= 14"
+ }
+ },
"node_modules/zrender": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/zrender/-/zrender-5.4.1.tgz",
@@ -1791,6 +1823,11 @@
"picomatch": "^2.0.4"
}
},
+ "argparse": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
+ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
+ },
"async-validator": {
"version": "4.2.5",
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz",
@@ -1853,6 +1890,11 @@
"readdirp": "~3.6.0"
}
},
+ "codemirror": {
+ "version": "5.59.1",
+ "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.59.1.tgz",
+ "integrity": "sha512-d0SSW/PCCD4LoSCBPdnP0BzmZB1v3emomCUtVlIWgZHJ06yVeBOvBtOH7vYz707pfAvEeWbO9aP6akh8vl1V3w=="
+ },
"combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
@@ -2085,6 +2127,14 @@
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="
},
+ "js-yaml": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
+ "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
+ "requires": {
+ "argparse": "^2.0.1"
+ }
+ },
"jsonc-parser": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz",
@@ -2521,6 +2571,11 @@
"integrity": "sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==",
"dev": true
},
+ "yaml": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.1.tgz",
+ "integrity": "sha512-e0WHiYql7+9wr4cWMx3TVQrNwejKaEe7/rHNmQmqRjazfOP5W8PB6Jpebb5o6fIapbz9o9+2ipcaTM2ZwDI6lw=="
+ },
"zrender": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/zrender/-/zrender-5.4.1.tgz",
diff --git a/ui/package.json b/ui/package.json
index 6258cf08..cde82590 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -12,14 +12,17 @@
"dependencies": {
"@element-plus/icons-vue": "^2.0.10",
"axios": "^0.27.2",
+ "codemirror": "^5.59.1",
"echarts": "^5.3.3",
"element-plus": "^2.2.17",
+ "js-yaml": "^4.1.0",
"jsonfile": "^6.1.0",
"mitt": "^3.0.0",
"pinia": "^2.0.21",
"sass": "^1.54.9",
"vue": "^3.2.38",
- "vue-router": "^4.1.5"
+ "vue-router": "^4.1.5",
+ "yaml": "^2.2.1"
},
"devDependencies": {
"@vitejs/plugin-vue": "^3.0.3",
diff --git a/ui/src/components2/CodeMirror/index.vue b/ui/src/components2/CodeMirror/index.vue
index d7694897..1db30d14 100644
--- a/ui/src/components2/CodeMirror/index.vue
+++ b/ui/src/components2/CodeMirror/index.vue
@@ -27,10 +27,10 @@
import { onMounted, ref, watch } from 'vue'
import CodeMirror from 'codemirror'
import 'codemirror/lib/codemirror.css'
-import 'codemirror/mode/javascript/javascript.js'
import 'codemirror/mode/yaml/yaml.js'
import 'codemirror/mode/css/css.js'
import 'codemirror/addon/lint/yaml-lint.js'
+import 'codemirror/theme/rubyblue.css'
import jsYaml from 'js-yaml'
window.jsyaml = jsYaml
export default {
@@ -42,28 +42,24 @@ export default {
},
mode: {
type: String,
- default: 'javascript'
+ default: 'yaml'
},
lint: {
- // codemirror仅支持html、css、json、javascript、yaml这几种,请手动引入,且需要下载相关插件,具体插件参考源码(node_modules/codemirror/addon/lint/)或官方文档
type: Boolean,
- default: false
+ default: true
},
readonly: {
type: Boolean,
default: false
- },
- // 主题
+ },
theme: {
type: String,
- default: 'base16-dark' // 编辑器主题色
+ default: 'rubyblue'
},
- // 高亮选中行
styleActiveLine: {
type: Boolean,
default: true
},
- // 自动刷新
autoRefresh: {
type: Boolean,
default: true
@@ -73,7 +69,6 @@ export default {
setup(props, { emit }) {
const textarea = ref(null)
const code = ref(props.modelValue)
- // 编辑器实例
let coder
watch(
() => props.modelValue,
@@ -82,35 +77,29 @@ export default {
}
)
const options = {
- mode: props.mode,
- // 缩进格式
+ mode: 'text/x-yaml',
tabSize: 2,
- // 主题,对应主题库 JS 需要提前引入
theme: props.theme,
- // 行号码
lineNumbers: true,
line: true,
- // extraKeys: {'Ctrl': 'autocomplete'},//自定义快捷键
readOnly: props.readonly,
lint: props.lint,
gutters: ['CodeMirror-lint-markers'],
- // 光标背景行高亮
styleActiveLine: props.styleActiveLine,
- // 自动刷新
autoRefresh: props.autoRefresh,
height: '500px'
}
const initialize = async () => {
try {
- // 动态引入相关依赖
- await import(`codemirror/theme/${props.theme}.css`)
+ /* let theme = `codemirror/theme/${props.theme}.css`
+ await import(theme) */
if (props.lint) {
await import('codemirror/addon/lint/lint.js')
await import('codemirror/addon/lint/lint.css')
}
- if (props.mode) {
+ /* if (props.mode) {
await import(`codemirror/mode/${props.mode}/${props.mode}.js`)
- }
+ } */
if (props.autoRefresh) {
await import('codemirror/addon/display/autorefresh')
}
@@ -119,7 +108,6 @@ export default {
}
} catch (e) {
}
- // 初始化编辑器实例,传入需要被实例化的文本域对象和默认配置
coder = CodeMirror.fromTextArea(textarea.value, options)
coder.on('blur', coder => {
const newValue = coder.getValue()
diff --git a/ui/src/components2/Read/index.vue b/ui/src/components2/Read/index.vue
index c19f9ce3..cf01f477 100644
--- a/ui/src/components2/Read/index.vue
+++ b/ui/src/components2/Read/index.vue
@@ -23,14 +23,17 @@ import { useRoute } from 'vue-router'
import { watch, getCurrentInstance } from '@vue/runtime-core'
import { getStreamOrMeasure, getTableList } from '@/api/index'
import { Search, RefreshRight } from '@element-plus/icons-vue'
-/* import CodeMirror from '@/components2/CodeMirror/index.vue' */
+import { jsonToYaml, yamlToJson } from '@/utils/yaml'
+import CodeMirror from '@/components2/CodeMirror/index.vue'
+import { ElMessage } from 'element-plus'
const route = useRoute()
-/* const yamlRef = ref() */
+const yamlRef = ref()
// Loading
const { proxy } = getCurrentInstance()
+const $bus = getCurrentInstance().appContext.config.globalProperties.mittBus
const $loadingCreate = getCurrentInstance().appContext.config.globalProperties.$loadingCreate
const $loadingClose = proxy.$loadingClose
const tagType = {
@@ -102,23 +105,14 @@ const data = reactive({
timeValue: null,
loading: false,
total: 100,
- queryInfo: {
+ /* queryInfo: {
pagenum: 1,
pagesize: 100
- },
+ }, */
tableTags: [],
tableData: [],
- /* code: ref(`apiVersion: apps/v1
-kind: DaemonSet
-metadata:
- annotations:
- deprecated.daemonset.template.generation: "1"
- field.cattle.io/creatorId: user-jsgrs
- creationTimestamp: "2022-05-16T03:08:58Z"
- generation: 1
- labels:
- cattle.io/creator: norman
- workload.user.cattle.io/workloadselector: daemonSet-default-asdf`) */
+ code: null,
+ codeStorage: []
})
watch(() => route, () => {
@@ -127,14 +121,48 @@ watch(() => route, () => {
data.type = route.params.type
data.tableData = []
data.tableTags = []
+
if (data.group && data.name && data.type) {
+ initCode()
initData()
}
}, {
immediate: true,
deep: true
})
-
+watch(() => data.code, () => {
+ let index = data.codeStorage.findIndex(item => {
+ return item.params.group == route.params.group && item.params.name == route.params.name
+ })
+ if (index >= 0) {
+ data.codeStorage[index].params.code = data.code
+ } else {
+ route.params.code = data.code
+ data.codeStorage.push(JSON.parse(JSON.stringify(route)))
+ }
+})
+function initCode() {
+ let index = data.codeStorage.findIndex(item => {
+ return item.params.group == route.params.group && item.params.name == route.params.name
+ })
+ if (index >= 0) {
+ data.code = data.codeStorage[index].params.code
+ } else {
+ data.code = ref(
+ `timeRange:
+ begin: null
+ end: null
+offset: 1
+limit: 10
+`)
+ }
+ /* orderBy:
+ indexRuleName: ""
+ sort:
+ SORT_UNSPECIFIED: ""
+ SORT_DESC: ""
+ SORT_ASC: "" */
+}
function initData() {
$loadingCreate()
getStreamOrMeasure(data.type, data.group, data.name)
@@ -146,7 +174,7 @@ function initData() {
return { label: item.name, value: index }
})
data.tagFamily = 0
- getTableData()
+ handleCodeData()
}
})
.finally(() => {
@@ -158,8 +186,8 @@ function getTableData() {
data.loading = true
setTableParam()
let paramList = param
- paramList.offset = data.queryInfo.pagenum
- paramList.limit = data.queryInfo.pagesize
+ /* paramList.offset = data.queryInfo.pagenum
+ paramList.limit = data.queryInfo.pagesize */
paramList.metadata = data.resourceData.metadata
getTableList(paramList)
.then((res) => {
@@ -201,11 +229,55 @@ function changeTagFamilies() {
data.tableTags = data.resourceData.tagFamilies[data.tagFamily].tags
getTableData()
}
-/* function btnClick() {
- yamlRef.value.checkYaml(code).then(() => {
-
+function handleCodeData() {
+ const json = yamlToJson(data.code).data
+ param.offset = json.offset ? json.offset : param.offset
+ param.limit = json.limit ? json.limit : param.limit
+ /* json.orderBy ? param.orderBy = json.orderBy : null */
+ delete param.timeRange
+ if (json.timeRange && !isNaN(Date.parse(json.timeRange.begin)) && !isNaN(Date.parse(json.timeRange.end))) {
+ data.timeValue = [json.timeRange.begin, json.timeRange.end]
+ param.timeRange = json.timeRange
+ } else if (json.timeRange.begin || json.timeRange.end) {
+ data.timeValue = []
+ ElMessage({
+ dangerouslyUseHTMLString: true,
+ showClose: true,
+ message: 'Warning: Wrong time type',
+ type: 'warning',
+ duration: 5000
+ })
+ } else {
+ data.timeValue = []
+ }
+ getTableData()
+}
+function searchTableData() {
+ yamlRef.value.checkYaml(data.code).then(() => {
+ handleCodeData()
})
-} */
+ .catch((err) => {
+ ElMessage({
+ dangerouslyUseHTMLString: true,
+ showClose: true,
+ message: `<div>${err.message}</div>`,
+ type: 'error',
+ duration: 5000
+ })
+ })
+}
+function changeDatePicker() {
+ let json = yamlToJson(data.code)
+ if (!json.data.hasOwnProperty('timeRange')) {
+ json.data.timeRange = {
+ begin: "",
+ end: ""
+ }
+ }
+ json.data.timeRange.begin = data.timeValue ? data.timeValue[0] : null
+ json.data.timeRange.end = data.timeValue ? data.timeValue[1] : null
+ data.code = jsonToYaml(json.data).data
+}
</script>
<template>
@@ -230,10 +302,11 @@ function changeTagFamilies() {
:value="item.value">
</el-option>
</el-select>
- <el-date-picker style="margin: 0 10px 0 10px" v-model="data.timeValue" type="datetimerange" :shortcuts="shortcuts"
- range-separator="to" start-placeholder="begin" end-placeholder="end" align="right">
+ <el-date-picker @change="changeDatePicker" style="margin: 0 10px 0 10px" v-model="data.timeValue"
+ type="datetimerange" :shortcuts="shortcuts" range-separator="to" start-placeholder="begin"
+ end-placeholder="end" align="right">
</el-date-picker>
- <el-button size="small" :icon="Search" color="#6E38F7" plain></el-button>
+ <el-button size="small" :icon="Search" @click="searchTableData" color="#6E38F7" plain></el-button>
</div>
</el-col>
<el-col :span="12">
@@ -242,9 +315,8 @@ function changeTagFamilies() {
</div>
</el-col>
</el-row>
- <!-- <CodeMirror ref="yamlRef" v-model="data.code" mode="yaml" style="height: 200px" :lint="true"
- :readonly="true">
- </CodeMirror> -->
+ <CodeMirror ref="yamlRef" v-model="data.code" mode="yaml" style="height: 200px" :lint="true" :readonly="false">
+ </CodeMirror>
</el-card>
<el-card shadow="always">
<el-table v-loading="data.loading" element-loading-text="loading" element-loading-spinner="el-icon-loading"
@@ -259,11 +331,10 @@ function changeTagFamilies() {
:label="item.name" :prop="item.name" show-overflow-tooltip>
</el-table-column>
</el-table>
- <el-pagination v-if="data.tableData.length > 0" class="margin-top-bottom" @size-change="handleSizeChange"
- @current-change="handleCurrentChange" :current-page="data.queryInfo.pagenum"
- :page-sizes="[6, 12, 18, 24]" :page-size="data.queryInfo.pagesize"
- layout="total, sizes, prev, pager, next, jumper" :total="data.total">
- </el-pagination>
+ <!-- <el-pagination v-if="data.tableData.length > 0" class="margin-top-bottom" @size-change="handleSizeChange"
+ @current-change="handleCurrentChange" :current-page="data.queryInfo.pagenum" :page-sizes="[6, 12, 18, 24]"
+ :page-size="data.queryInfo.pagesize" layout="total, sizes, prev, pager, next, jumper" :total="data.total">
+ </el-pagination> -->
</el-card>
</div>
</template>
diff --git a/ui/src/utils/axios.js b/ui/src/utils/axios.js
index 50ad8cd4..8fe575a5 100644
--- a/ui/src/utils/axios.js
+++ b/ui/src/utils/axios.js
@@ -75,10 +75,10 @@ axiosService.interceptors.response.use(
* do some error handling
*/
const resErr = error.data
-
let msg = error.data && error.data.message ? error.data.message : error.message
ElMessage({
- message: msg,
+ dangerouslyUseHTMLString: true,
+ message: `${msg}<br/>Error:${error.response.data.message}`,
type: "error",
duration: 3000
})
diff --git a/ui/src/utils/yaml.js b/ui/src/utils/yaml.js
new file mode 100644
index 00000000..71894f8b
--- /dev/null
+++ b/ui/src/utils/yaml.js
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+import YAML from 'yaml'
+import yaml from 'js-yaml'
+
+export function jsonToYaml(jsonData) {
+ try {
+ return {
+ data: typeof (jsonData) == 'string' ? yaml.dump(JSON.parse(jsonData)) : yaml.dump(jsonData),
+ error: false
+ }
+ } catch (err) {
+ return {
+ data: '',
+ error: true
+ }
+ }
+}
+
+export function yamlToJson(yamlStr, returnString) {
+ try {
+ return {
+ data: returnString ? JSON.stringify(YAML.parse(yamlStr), null, 2) : YAML.parse(yamlStr),
+ error: false
+ }
+ } catch (err) {
+ return {
+ data: '',
+ error: true
+ }
+ }
+}
\ No newline at end of file