Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONApi plugin for Spreadsheet #265

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions sdkjs-plugins/content/jsonAPI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Overview

The plugin is designed for receiving, parsing and inserting the results of a get request from a third-party site or service into spreadsheet cells.
Arbitrary get requests are implemented, parsing using JSONPath expressions, saving previously made requests in a separate (special) sheet, updating cell values in accordance with previously generated queries on the sheet.

![Example JSON API plugin](https://github.com/VyachL05/onlyoffice.github.io/assets/93988186/6c8d4dcd-f11b-48ce-ab1a-9c7867661590)

## Install
Follow onlyoffice instructions:
https://api.onlyoffice.com/plugin/installation/onpremises#plugin-folder

## How to use

1. Start SpreadsheetEditor
2. Select some range of cells in which you want to paste your data from request
3. Open the Plugins tab and press "JSON API"/ API JSON
4. Edit "Request URL" field
5. Edit JSON path expression field. If you want to get several rows you can provide sevevral JsonPath expressions separated by ;
6. Tap Ok button and enjoy with your result
7. If you want to update values in your cells, tap JSON API/ Start

## Using example

![Start this gif](https://github.com/VyachL05/onlyoffice.github.io/blob/703ada8fd431d4a4f2c9277eccfb7626dadefb78/sdkjs-plugins/content/jsonAPI/resources/img/JSONApi.gif)

If you need more information about how to use or write your own plugin, please see this https://api.onlyoffice.com/plugin/basic
91 changes: 91 additions & 0 deletions sdkjs-plugins/content/jsonAPI/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"name": "JSON API",
"guid": "asc.{795B6112-98F9-496B-B630-F7D1F787BFF5}",
"baseUrl": "",
"nameLocale": {
"ru": "JSON API"
},
"variations": [{
"description": "JSON API plugin",
"descriptionLocale": {
"ru": "Плагин JSON API"
},
"url": "index.html",
"icons": ["resources/img/icon.png", "resources/img/[email protected]"],
"isViewer": false,
"EditorsSupport": ["cell"],
"isVisual": false,
"isModal": true,
"isInsideMode": false,
"initDataType": "none",
"initData": "",
"isUpdateOleOnResize": true,
"buttons": [{
"text": "Update",
"primary": true,
"textLocale": {
"ru": "OK"
}
}, {
"text": "Cancel",
"primary": false,
"textLocale": {
"ru": "Отмена"
}
}
]
},
{
"description": "API JSON",
"descriptionLocale": {
"ru": "API JSON ПРОСТОР"
},
"url": "json_api.html",
"icons": ["resources/img/icon.png", "resources/img/[email protected]"],
"isViewer": false,
"EditorsSupport": ["cell"],
"isVisual": true,
"isModal": true,
"isInsideMode": false,
"initDataType": "none",
"initData": "",
"isUpdateOleOnResize": true,
"buttons": [{
"text": "Ok",
"primary": true,
"textLocale": {
"ru": "Выполнить"
}
}, {
"text": "Cancel",
"primary": false,
"textLocale": {
"ru": "Отмена"
}
}
]
}, {
"description": "About",
"descriptionLocale": {
"ru": "О плагине"
},
"url": "index_about.html",
"icons": ["resources/img/icon.png", "resources/img/[email protected]"],
"isViewer": false,
"EditorsSupport": ["cell"],
"isVisual": true,
"isModal": true,
"isInsideMode": false,
"initDataType": "none",
"initData": "",
"isUpdateOleOnResize": true,
"buttons": [{
"text": "Ok",
"primary": true
}
],

"size": [392, 147]
}
]
}
14 changes: 14 additions & 0 deletions sdkjs-plugins/content/jsonAPI/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>ПРОСТОР</title>
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins-ui.js"></script>
<link rel="stylesheet" href="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css">
<script src="scripts/jsonpath-0.8.0.js"></script>
<script type="text/javascript" src="scripts/update.js"></script>
</head>
<body>
</body>
</html>
55 changes: 55 additions & 0 deletions sdkjs-plugins/content/jsonAPI/index_about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>About plugin</title>
<style>
p, a{
font-size: 12px;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}


a:link {
color: darkgrey;
}

/* visited link */
a:visited {
color: darkgrey;
}

/* mouse over link */
a:hover {
color: #8d8d8d;
}

/* selected link */
a:active {
color: darkgrey;
}
</style>
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins-ui.js"></script>
<link rel="stylesheet" href="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.css">
<script type="text/javascript">
window.Asc.plugin.init = function()
{
this.resizeWindow(392, 147, 392, 147, 392, 147);
// none
};

window.Asc.plugin.button = function(id)
{
this.executeCommand("close", "");
};

</script>
</head>
<body style="padding-left: 20px; padding-right: 20px">
<p style="font-size: 15px">JSON api</p>
<p style="font-size: 12px">Receiving, parsing and inserting the results of a get request from a third-party site or service into spreadsheet cells. Parsing using JSONPath expressions, saving previously requests in a separate (special) sheet, updating cell values with previously generated queries on the sheet.
</p>
<a href> https://github.com/VyachL84/JsonAPIOnlyofficePlugin </a>
</body>
</html>
49 changes: 49 additions & 0 deletions sdkjs-plugins/content/jsonAPI/json_api.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8" />
<title>JSON API</title>
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins.js"></script>
<script type="text/javascript" src="https://onlyoffice.github.io/sdkjs-plugins/v1/plugins-ui.js"></script>
<script type="text/javascript" src="scripts/code.jquery.com_jquery-3.7.0.js"></script>
<link rel="stylesheet" href="resources/vakata-jstree-8c1bcc8/dist/themes/default/style.css" />
<script src="resources/vakata-jstree-8c1bcc8/dist/jstree.min.js"></script>
<script src="scripts/jsonpath-0.8.0.js"></script>
<script src="scripts/jsonToJsTreeObject.js"></script>
</head>

<body>
<div class="item-settings">
<label for="UrlRequest">Request URL</label>
<div style="display: flex;">
<input type="text" class="form-control" id="UrlRequest"
value="https://jsonplaceholder.typicode.com/posts/1/comments"
style="margin-left: 5px; width: 100%; height: 14px;">
<!-- <input id="UrlRequest" type="string" value="http://es-prostor-prch:30000/v2/StationModels/getEntity?entityId=74e0ebd1-d7a9-430d-a366-2a77f603a41f&withProps=true&withRefs=true&hierarchical=true" style="margin-left: 5px;"> -->
</div>
<label for="JsonPathExpr">JSON path expression </label>
<a href="https://jsonpath.com/">https://jsonpath.com/</a>
<div style="display: flex;">
<input id="JsonPathExpr" type="text" class="form-control" value="$.[name];$.[email];$.[id]"
style="margin-left: 1%; width: 100%; height: 14px;">
<label for="btn" class="defaultlable"> </label>
<button id="btn" class="btn-text-default" title="Query button">Update</button>
</div>
<!-- <div>
<input type="checkbox" id="IsVisiblePluginSheet" name="IsVisiblePluginSheet" />
<label for="IsVisiblePluginSheet">Queries sheet is visible</label>
</div> -->
</div>
<h1>json tree</h1>
<div style="overflow-y:auto; overflow-x:auto; height: 200px; width: 800px">
<input id="dataSearch" class="form-control" type="text" value="Search"
style="overflow-y:auto; width: 100%; height: 14px;">
<div id="data" class="demo"></div>
<button id="btnCopy" class="btn-text-default" title="Copy json">Copy</button>
</div>
<h3>Result API + jsonpath</h3>
<script src="scripts/json_api.js"></script>
</body>

</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sdkjs-plugins/content/jsonAPI/resources/img/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2014 Ivan Bozhanov

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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# jstree

[jsTree](http://www.jstree.com/) is jquery plugin, that provides interactive trees. It is absolutely free, [open source](https://github.com/vakata/jstree) and distributed under the MIT license.

jsTree is easily extendable, themable and configurable, it supports HTML & JSON data sources, AJAX & async callback loading.

jsTree functions properly in either box-model (content-box or border-box), can be loaded as an AMD module, and has a built in mobile theme for responsive design, that can easily be customized. It uses jQuery's event system, so binding callbacks on various events in the tree is familiar and easy.

You also get:
* drag & drop support
* keyboard navigation
* inline edit, create and delete
* tri-state checkboxes
* fuzzy searching
* customizable node types

_For more information, examples and API docs head on over to [the wiki page](https://github.com/vakata/jstree/wiki) and [jstree.com](http://www.jstree.com)_.
_Feel free to ask any questions on the [discussions board](https://github.com/vakata/jstree/discussions)._
_The PHP demos are now in a [separate repository](https://github.com/vakata/jstree-php-demos)._

## License & Contributing

_Please do NOT edit files in the "dist" subdirectory as they are generated via grunt. You'll find source code in the "src" subdirectory!_

If you want to you can always [sponsor me](https://github.com/sponsors/vakata) or [donate a small amount][paypal] to help the development of jstree.

[paypal]: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&[email protected]&currency_code=USD&amount=&return=http://jstree.com/donation&item_name=Buy+me+a+coffee+for+jsTree

Copyright (c) 2020 Ivan Bozhanov (http://vakata.com)

Licensed under the [MIT license](http://www.opensource.org/licenses/mit-license.php).
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "jstree",
"license": "MIT",
"version": "3.3.15",
"main" : [
"./dist/jstree.js",
"./dist/themes/default/style.css"
],
"ignore": [
"**/.*",
"docs",
"demo",
"libs",
"node_modules",
"test",
"libs",
"jstree.jquery.json",
"gruntfile.js",
"package.json",
"bower.json",
"component.json",
"LICENCE-MIT",
"README.md"
],
"dependencies": {
"jquery": ">=1.9.1"
},
"keywords": [
"ui",
"tree",
"jstree"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "jstree",
"repo": "vakata/jstree",
"description": "jsTree is jquery plugin, that provides interactive trees.",
"version": "3.3.15",
"license": "MIT",
"keywords": [
"ui",
"tree",
"jstree"
],
"scripts": [
"dist/jstree.js",
"dist/jstree.min.js"
],
"images": [
"dist/themes/default/32px.png",
"dist/themes/default/40px.png",
"dist/themes/default/throbber.gif"
],
"styles": [
"dist/themes/default/style.css",
"dist/themes/default/style.min.css"
],
"dependencies": {
"components/jquery": ">=1.9.1"
}
}
Loading