├── .gitignore ├── MANIFEST.in ├── README.md ├── console ├── __init__.py ├── config │ ├── __init__.py │ ├── desktop.py │ └── docs.py ├── console │ └── __init__.py ├── hooks.py ├── modules.txt ├── patches.txt ├── public │ ├── build.json │ └── js │ │ └── console.js └── templates │ ├── __init__.py │ └── pages │ └── __init__.py ├── license.txt ├── requirements.txt └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.pyc 3 | *.egg-info 4 | *.swp 5 | tags 6 | console/docs/current -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include MANIFEST.in 2 | include requirements.txt 3 | include *.json 4 | include *.md 5 | include *.py 6 | include *.txt 7 | recursive-include console *.css 8 | recursive-include console *.csv 9 | recursive-include console *.html 10 | recursive-include console *.ico 11 | recursive-include console *.js 12 | recursive-include console *.json 13 | recursive-include console *.md 14 | recursive-include console *.png 15 | recursive-include console *.py 16 | recursive-include console *.svg 17 | recursive-include console *.txt 18 | recursive-exclude console *.pyc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## **Console** 2 | 3 | **Powerful Console for Frappe Backend** 4 | It allows you to use the same as the `console` statement in Python as it is in JavaScript 5 | 6 | ### **How to Install** 7 | 8 | 1. `bench get-app https://github.com/yrestom/Console.git` 9 | 2. `bench build --app console` 10 | 3. `bench --site [your.site.name] install-app console` 11 | 4. `bench restart` 12 | 13 | ### How to use: 14 | 15 | in python file: 16 | 17 | ```python 18 | from console import console 19 | 20 | my_list = ['foo', 4, 5, 'bar', 0.4] 21 | 22 | console(my_list).log() 23 | ``` 24 | 25 | In browser console: 26 | 27 | ```jsx 28 | >(5) ["foo", 4, 5, "bar", 0.4] 29 | ``` 30 | 31 | ### Supported methods : 32 | 33 | `log , table, warn, error, info, group, groupEnd, time, timeEnd, debug, trace, count` 34 | 35 | ### **License** 36 | 37 | MIT -------------------------------------------------------------------------------- /console/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | import frappe 4 | __version__ = '1.0.0' 5 | 6 | 7 | # def console(*data): 8 | # frappe.publish_realtime('console', data, user=frappe.session.user) 9 | 10 | def console(*data): 11 | return Console(msg=data) 12 | 13 | class Console(): 14 | def __init__(self, msg="null"): 15 | self.msg = msg 16 | 17 | def log(self, *msg): 18 | if not msg: 19 | msg = self.msg 20 | frappe.publish_realtime('log', msg, user=frappe.session.user) 21 | 22 | def warn(self, *msg): 23 | if not msg: 24 | msg = self.msg 25 | frappe.publish_realtime('warn', msg, user=frappe.session.user) 26 | 27 | def table(self, *msg): 28 | if not msg: 29 | msg = self.msg 30 | frappe.publish_realtime('table', msg, user=frappe.session.user) 31 | 32 | def error(self, *msg): 33 | if not msg: 34 | msg = self.msg 35 | frappe.publish_realtime('error', msg, user=frappe.session.user) 36 | 37 | def info(self, *msg): 38 | if not msg: 39 | msg = self.msg 40 | frappe.publish_realtime('info', msg, user=frappe.session.user) 41 | 42 | def group(self, *msg): 43 | if not msg: 44 | msg = self.msg 45 | frappe.publish_realtime('group', msg, user=frappe.session.user) 46 | 47 | def groupEnd(self, *msg): 48 | frappe.publish_realtime('groupEnd', msg, user=frappe.session.user) 49 | 50 | def time(self, *msg): 51 | if not msg: 52 | msg = self.msg 53 | frappe.publish_realtime('time', msg, user=frappe.session.user) 54 | 55 | def timeEnd(self, *msg): 56 | frappe.publish_realtime('timeEnd', msg, user=frappe.session.user) 57 | 58 | def debug(self, *msg): 59 | if not msg: 60 | msg = self.msg 61 | frappe.publish_realtime('debug', msg, user=frappe.session.user) 62 | 63 | def trace(self, *msg): 64 | if not msg: 65 | msg = self.msg 66 | frappe.publish_realtime('trace', msg, user=frappe.session.user) 67 | 68 | def count(self, *msg): 69 | if not msg: 70 | msg = self.msg 71 | frappe.publish_realtime('count', msg, user=frappe.session.user) -------------------------------------------------------------------------------- /console/config/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yrestom/Console/e9a5d96b240a28865644f069e1146a39decd967d/console/config/__init__.py -------------------------------------------------------------------------------- /console/config/desktop.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | from frappe import _ 4 | 5 | def get_data(): 6 | return [ 7 | { 8 | "module_name": "Console", 9 | "color": "grey", 10 | "icon": "octicon octicon-file-directory", 11 | "type": "module", 12 | "label": _("Console") 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /console/config/docs.py: -------------------------------------------------------------------------------- 1 | """ 2 | Configuration for docs 3 | """ 4 | 5 | # source_link = "https://github.com/[org_name]/console" 6 | # docs_base_url = "https://[org_name].github.io/console" 7 | # headline = "App that does everything" 8 | # sub_heading = "Yes, you got that right the first time, everything" 9 | 10 | def get_context(context): 11 | context.brand_html = "Console" 12 | -------------------------------------------------------------------------------- /console/console/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yrestom/Console/e9a5d96b240a28865644f069e1146a39decd967d/console/console/__init__.py -------------------------------------------------------------------------------- /console/hooks.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import unicode_literals 3 | from . import __version__ as app_version 4 | 5 | app_name = "console" 6 | app_title = "Console" 7 | app_publisher = "Youssef Restom" 8 | app_description = "Powerful Console for Frappe Backend" 9 | app_icon = "octicon octicon-file-directory" 10 | app_color = "grey" 11 | app_email = "youssef@totrox.com" 12 | app_license = "MIT" 13 | 14 | # Includes in 15 | # ------------------ 16 | 17 | # include js, css files in header of desk.html 18 | # app_include_css = "/assets/console/css/console.css" 19 | app_include_js = "/assets/js/console.min.js" 20 | 21 | # include js, css files in header of web template 22 | # web_include_css = "/assets/console/css/console.css" 23 | # web_include_js = "/assets/console/js/console.js" 24 | 25 | # include custom scss in every website theme (without file extension ".scss") 26 | # website_theme_scss = "console/public/scss/website" 27 | 28 | # include js, css files in header of web form 29 | # webform_include_js = {"doctype": "public/js/doctype.js"} 30 | # webform_include_css = {"doctype": "public/css/doctype.css"} 31 | 32 | # include js in page 33 | # page_js = {"page" : "public/js/file.js"} 34 | 35 | # include js in doctype views 36 | # doctype_js = {"doctype" : "public/js/doctype.js"} 37 | # doctype_list_js = {"doctype" : "public/js/doctype_list.js"} 38 | # doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"} 39 | # doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"} 40 | 41 | # Home Pages 42 | # ---------- 43 | 44 | # application home page (will override Website Settings) 45 | # home_page = "login" 46 | 47 | # website user home page (by Role) 48 | # role_home_page = { 49 | # "Role": "home_page" 50 | # } 51 | 52 | # Generators 53 | # ---------- 54 | 55 | # automatically create page for each record of this doctype 56 | # website_generators = ["Web Page"] 57 | 58 | # Installation 59 | # ------------ 60 | 61 | # before_install = "console.install.before_install" 62 | # after_install = "console.install.after_install" 63 | 64 | # Desk Notifications 65 | # ------------------ 66 | # See frappe.core.notifications.get_notification_config 67 | 68 | # notification_config = "console.notifications.get_notification_config" 69 | 70 | # Permissions 71 | # ----------- 72 | # Permissions evaluated in scripted ways 73 | 74 | # permission_query_conditions = { 75 | # "Event": "frappe.desk.doctype.event.event.get_permission_query_conditions", 76 | # } 77 | # 78 | # has_permission = { 79 | # "Event": "frappe.desk.doctype.event.event.has_permission", 80 | # } 81 | 82 | # DocType Class 83 | # --------------- 84 | # Override standard doctype classes 85 | 86 | # override_doctype_class = { 87 | # "ToDo": "custom_app.overrides.CustomToDo" 88 | # } 89 | 90 | # Document Events 91 | # --------------- 92 | # Hook on document methods and events 93 | 94 | # doc_events = { 95 | # "*": { 96 | # "on_update": "method", 97 | # "on_cancel": "method", 98 | # "on_trash": "method" 99 | # } 100 | # } 101 | 102 | # Scheduled Tasks 103 | # --------------- 104 | 105 | # scheduler_events = { 106 | # "all": [ 107 | # "console.tasks.all" 108 | # ], 109 | # "daily": [ 110 | # "console.tasks.daily" 111 | # ], 112 | # "hourly": [ 113 | # "console.tasks.hourly" 114 | # ], 115 | # "weekly": [ 116 | # "console.tasks.weekly" 117 | # ] 118 | # "monthly": [ 119 | # "console.tasks.monthly" 120 | # ] 121 | # } 122 | 123 | # Testing 124 | # ------- 125 | 126 | # before_tests = "console.install.before_tests" 127 | 128 | # Overriding Methods 129 | # ------------------------------ 130 | # 131 | # override_whitelisted_methods = { 132 | # "frappe.desk.doctype.event.event.get_events": "console.event.get_events" 133 | # } 134 | # 135 | # each overriding function accepts a `data` argument; 136 | # generated from the base implementation of the doctype dashboard, 137 | # along with any modifications made in other Frappe apps 138 | # override_doctype_dashboards = { 139 | # "Task": "console.task.get_dashboard_data" 140 | # } 141 | 142 | # exempt linked doctypes from being automatically cancelled 143 | # 144 | # auto_cancel_exempted_doctypes = ["Auto Repeat"] 145 | 146 | -------------------------------------------------------------------------------- /console/modules.txt: -------------------------------------------------------------------------------- 1 | Console -------------------------------------------------------------------------------- /console/patches.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yrestom/Console/e9a5d96b240a28865644f069e1146a39decd967d/console/patches.txt -------------------------------------------------------------------------------- /console/public/build.json: -------------------------------------------------------------------------------- 1 | { 2 | "js/console.min.js": [ 3 | "public/js/console.js" 4 | ] 5 | } -------------------------------------------------------------------------------- /console/public/js/console.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | frappe.realtime.on('log', (data) => data.forEach(element => console.log(element))); 3 | frappe.realtime.on('table', (data) => data.forEach(element => console.table(element))); 4 | frappe.realtime.on('warn', (data) => data.forEach(element => console.warn(element))); 5 | frappe.realtime.on('error', (data) => data.forEach(element => console.error(element))); 6 | frappe.realtime.on('info', (data) => data.forEach(element => console.info(element))); 7 | frappe.realtime.on('group', (data) => data.forEach(element => console.group(element))); 8 | frappe.realtime.on('groupEnd', (data) => console.groupEnd()); 9 | frappe.realtime.on('time', (data) => data.forEach(element => console.time(element))); 10 | frappe.realtime.on('timeEnd', (data) => console.timeEnd()); 11 | frappe.realtime.on('debug', (data) => data.forEach(element => console.debug(element))); 12 | frappe.realtime.on('trace', (data) => data.forEach(element => console.trace(element))); 13 | frappe.realtime.on('count', (data) => data.forEach(element => console.count(element))); 14 | }); -------------------------------------------------------------------------------- /console/templates/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yrestom/Console/e9a5d96b240a28865644f069e1146a39decd967d/console/templates/__init__.py -------------------------------------------------------------------------------- /console/templates/pages/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yrestom/Console/e9a5d96b240a28865644f069e1146a39decd967d/console/templates/pages/__init__.py -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | License: MIT -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # frappe # https://github.com/frappe/frappe is installed during bench-init -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from setuptools import setup, find_packages 3 | 4 | with open('requirements.txt') as f: 5 | install_requires = f.read().strip().split('\n') 6 | 7 | # get version from __version__ variable in console/__init__.py 8 | from console import __version__ as version 9 | 10 | setup( 11 | name='console', 12 | version=version, 13 | description='Powerful Console for Frappe Backend', 14 | author='Youssef Restom', 15 | author_email='youssef@totrox.com', 16 | packages=find_packages(), 17 | zip_safe=False, 18 | include_package_data=True, 19 | install_requires=install_requires 20 | ) 21 | --------------------------------------------------------------------------------