From b545ce1a3de2ad1f84c762aa322f8688cd9bceac Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Tue, 6 Feb 2024 15:11:50 -0600 Subject: [PATCH] plugins --- config.json | 132 ++++++++++++++++++++++------------- www/parser/_plugins/store.py | 13 ++-- www/parser/_plugins/users.py | 7 +- www/parser/_plugins/utils.py | 13 ++++ 4 files changed, 110 insertions(+), 55 deletions(-) create mode 100644 www/parser/_plugins/utils.py diff --git a/config.json b/config.json index b6e2b4e..e84e248 100644 --- a/config.json +++ b/config.json @@ -1,53 +1,89 @@ { - "system":{ - "logo":"www/parser/_images/cog-red.png","context":"", "theme":"oss.css", - "app":{ - - "debug":true,"port":8000}, - "version":0.6,"mode":"portal", - "source":{ - "id":"cloud", - "auth":"nextcloud-auth.json", - "store":"/home/steve/git/sites/parser/store-auth.json" - }, - "routes":{ - "data-transport":{ - "menu":"tools", - "path":"/home/steve/git/sites/data-transport/config.json" - } - } - - + "system": { + "logo": "www/parser/_images/cog-red.png", + "context": "", + "theme": "oss.css", + "app": { + "debug": true, + "port": 8000 }, - "plugins":{ - "store":["init","plans"], - "users":["signup"] + "version": 0.6, + "mode": "portal", + "source": { + "id": "cloud", + "auth": "nextcloud-auth.json", + "store": "/home/steve/git/sites/parser/store-auth.json", + "key": "/home/steve/dev/data/qcms/parser.json" }, - "layout":{ - "header":{"title":"{x12} Parser :: Healthcare/IO","logo":true,"subtitle":"Open, Simple & Extensible - Powered by data-transport"}, - "icons":[], - "root":"www/parser", - "index":"index.html", - "order":{ - "menu":["tools","resources","about"] - }, - "overwrite":{ - "license":{ - "title":"MIT License", - "text":"license", - "type":"dialog", - "uri":"www/parser/about/license.md" - }, - "source-code":{ - "text":"Source Code", - "type":"redirect", - "url":"https://hiplab.mc.vanderbilt.edu/git/hiplab/parser.git" - }, - "credit":{ - "title":"{x12} Parser Credit", - "type":"dialog","uri":"www/parser/about/credit.html" - } - }, - "footer":[{"text":"Health Information Privacy Laboratory"},{"text":"Powered By - QCMS"}] + "routes": { + "data-transport": { + "menu": "tools", + "path": "/home/steve/git/sites/data-transport/config.json" + }, + "privacykit": { + "menu": "tools", + "path": "/home/steve/git/sites/privacykit/config.json" + } } + }, + "plugins": { + "store": ["init","plans","version" + ], + "users": [ + "signup" + ] + }, + "layout": { + "header": { + "title": "{x12} Parser :: Healthcare/IO", + "logo": true, + "subtitle": "Open, Simple & Extensible - Powered by data-transport" + }, + "icons": [], + "root": "www/parser", + "index": "index.html", + "order": { + "menu": ["tools","tutorials", "about" + ] + }, + "overwrite": { + "1-parse":{ + "text":"{12} Parsing", "title":"{x12} Parsing","type":"dialog","uri":"www/parser/tutorials/1-parse.md" + }, + "license": { + "title": "MIT License", + "text": "license", + "type": "dialog", + "uri": "www/parser/about/license.md" + }, + "source-code": { + "text": "Source Code", + "type": "redirect", + "url": "https://hiplab.mc.vanderbilt.edu/git/hiplab/parser.git" + }, + "change-database":{ + "title":"Change Database", + "text":"change database", + "type":"dialog", + "uri":"www/parser/tutorials/change-database.md" + }, + "embed-in-code":{ + "title":"embed in code","text":"{x12} Import Library","type":"dialog","uri":"www/parser/tutorials/embed-in-code.md" + }, + "export-data":{"title":"Export Data","text":"Export Data","type":"dialog","uri":"www/parser/tutorials/export-data.md"}, + "credit": { + "title": "{x12} Parser Credit", + "type": "dialog", + "uri": "www/parser/about/credit.html" + } + }, + "footer": [ + { + "text": "Health Information Privacy Laboratory" + }, + { + "text": "Powered By - QCMS" + } + ] + } } diff --git a/www/parser/_plugins/store.py b/www/parser/_plugins/store.py index f3da5a2..4981f6d 100644 --- a/www/parser/_plugins/store.py +++ b/www/parser/_plugins/store.py @@ -3,6 +3,7 @@ import stripe import json import os import pandas as pd +import healthcareio def copyright(**_args): return [store.__name__,store.__version__] @@ -23,9 +24,10 @@ def plans (**_args) : """ This function will return plans associated with a product """ + _config = _args['config'] if not store.isready() : print (['Initializing Store']) - init(**_args) + init(config = _config) _plans = store.get.plans('healthcareio') _df = {} @@ -43,11 +45,14 @@ def plans (**_args) : # _df = pd.concat([_features,_lrow]) return _df.to_json() -def signup (**_args): - _email = _args['email'] - _name = None if 'name' in _args else _args['name'] +def signup (**_args): + _request = _args['request'] + _email = _request.headers['email'] + _name = None if 'name' in _request.headers else _request.headers['name'] product = store.get.product('healthcareio') # # If the user is already signed up customer = store.get.customer(_email) +def version (**_args): + return str(healthcareio.meta.__version__) \ No newline at end of file diff --git a/www/parser/_plugins/users.py b/www/parser/_plugins/users.py index d2ed98d..3a23253 100644 --- a/www/parser/_plugins/users.py +++ b/www/parser/_plugins/users.py @@ -19,9 +19,11 @@ def signup(**_args): """ This function creates or pulls a customer's key from the backend (stripe) """ + _config = _args['config'] + _request= _args['request'] if not store.isready() : - __init__(**_args) - _email = _args['email'] + __init__(config = _config) + _email = _request.headers['email'] _customer = store.get.customer(_email) _user = {} if not _customer : @@ -40,7 +42,6 @@ def signup(**_args): _user['token'] = _customer['id'] return json.dumps(_user) - def upgrade (**_args): pass diff --git a/www/parser/_plugins/utils.py b/www/parser/_plugins/utils.py new file mode 100644 index 0000000..a2bcf4f --- /dev/null +++ b/www/parser/_plugins/utils.py @@ -0,0 +1,13 @@ +""" + +""" +import transport +_QUERY = { + "missing_elements":{ + transport.providers.SQLITE3:"select count(*) counts, date, json_extract(data,'$.element') element, json_extract(data,'$.anchor') qualifier from logs where action = 'missing-plugin' group by element, qualifier ", + transport.providers.MONGODB:{"mongo":{"aggregate":"x12logs"}}, + } +} +def query(**_args): + _request = _args['request'] + \ No newline at end of file