Skip to content
Draft
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
22 changes: 20 additions & 2 deletions Config API/Config API Endpoint and Property Viewer/API_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
# * access properties to HTTP Methods
# * 0.0.4: Added Doc Endpoint Information to text box to provide user additional
# * information
# * 0.0.5: Added version to title bar
# * Audit Log schema access for visualization
# *
# * Version: 0.0.4
# * Version: 0.0.5
# ******************************************************************************

from tkinter import *
Expand All @@ -30,6 +32,8 @@
from widgets import searchbar, treevscroll, textscroll
from server import server_doc

VERSION = '0.0.5'

COLUMNS = ['doc_path', 'endpoint', 'parent_endpoint']

class App(ttk.Frame):
Expand Down Expand Up @@ -114,6 +118,7 @@ def __init__(self, *args, **kwargs):
self.event_add('<<tree_select>>', '<Double-1>', '<Return>')
self.treeframe.treev.tag_bind('item', '<<tree_select>>', self.item_click)
self.treeframe.treev.tag_bind('root', '<<tree_select>>', self.root_click)
self.treeframe.treev.tag_bind('names', '<<tree_select>>', self.names_click)

# Text Frame Object for Output of Documentation
self.textframe = textscroll(self.dataframe, row=0)
Expand Down Expand Up @@ -204,6 +209,19 @@ def root_click(self, event: Event):
r = self.server.get_doc(info['values'][COLUMNS.index('doc_path')])
self.update_text_window(r, info['values'][COLUMNS.index('endpoint')], info['values'][COLUMNS.index('doc_path')])

# Event for Names Branches
# Primarily used as a work around to access audit log schema. Doc endpoint does not provide context to
# point to how to access property definitions or "schemas" which is a new paradigm for audit log
def names_click(self, event: Event):
item = event.widget.selection()
info = event.widget.item(item[0])
if 'audit_log' in info['text']:
doc_url = '/config/v1/audit_log?content=schema'
r = self.server.get_doc(doc_url)
self.update_text_window(r, info['text'], doc_url)
else:
self.update_text_window()

# Event for other branches
def item_click(self, event: Event):
item = event.widget.selection()
Expand Down Expand Up @@ -351,7 +369,7 @@ def update_text_window(self, DATA = None, endpoint = '', docEndpoint = ''):

if __name__ == "__main__":
root = Tk()
root.title("Kepware Server API Documentation Viewer")
root.title(f"Kepware Server API Documentation Viewer v{VERSION}")
root.minsize(width=500, height=200)
root.columnconfigure(0, minsize=200, weight=1)
root.rowconfigure(0, weight=1)
Expand Down
6 changes: 6 additions & 0 deletions Config API/Config API Endpoint and Property Viewer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ This provides a simple UI application to help navigate the documentation endpoin
## Use the Application

1. Open a CMD and cd to the [API_gui.py](API_gui.py) location before launching the script or double-click on [API_gui.py](API_gui.py) from File Explorer. This will launch the UI.

![](../../docs/images/api-viewer-main-ui.png)

2. Provide the correct parameters to connect to the Kepware Server instance and click the *Connect* button.
3. Once connected navigate the components in the tree by double clicking on each item. If there are children of the object, they will appear.

![](../../docs/images/api-viewer-connected-ui.png)

4. Search is available for the text within the property definition window.
Binary file added docs/images/api-viewer-connected-ui.png
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 docs/images/api-viewer-main-ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.