Skip to content

Commit

Permalink
Merge pull request #160 from frappe/develop
Browse files Browse the repository at this point in the history
chore: merge `develop` into `main`
  • Loading branch information
nextchamp-saqib authored Sep 23, 2023
2 parents 2985e83 + 6c63e68 commit a07ed5d
Show file tree
Hide file tree
Showing 171 changed files with 6,625 additions and 12,159 deletions.
155 changes: 141 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,128 @@ locale
.wnf-lang-status
*.swp
*.egg-info
dist/
# build/
.vscode
.vs
node_modules
.kdev4/
*.kdev4
*debug.log
insights/docs/current
insights/public/frontend
insights/www/insights.html
.nyc_output
coverage/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
# build/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
Expand All @@ -54,6 +144,43 @@ venv.bak/
# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# build/
.vscode
.idea
.vs
node_modules
.kdev4/
*.kdev4
*debug.log
insights/docs/current
insights/public/frontend
insights/www/insights.html
.nyc_output
coverage/

# Runtime data
pids
Expand Down
2 changes: 1 addition & 1 deletion frappe-ui
Submodule frappe-ui updated 44 files
+0 −1 .gitignore
+0 −17 .storybook/main.js
+0 −3 .storybook/preview-head.html
+0 −24 .storybook/preview.js
+ frappe-ui-logo-200.png
+ frappe-ui-only-logo.png
+38 −0 histoire.config.ts
+18 −0 histoire.css
+2 −0 histoire.setup.ts
+2 −2 netlify.toml
+6 −13 package.json
+6 −0 postcss.config.ts
+25 −0 src/components/Autocomplete.story.vue
+35 −25 src/components/Autocomplete.vue
+28 −0 src/components/Avatar.story.vue
+26 −0 src/components/Badge.story.vue
+31 −0 src/components/Button.story.vue
+22 −0 src/components/Checkbox.story.vue
+110 −0 src/components/CommandPalette/CommandPalette.vue
+28 −0 src/components/CommandPalette/CommandPaletteItem.vue
+39 −0 src/components/Dialog.story.vue
+98 −0 src/components/Dropdown.story.vue
+28 −0 src/components/ErrorMessage.story.vue
+34 −0 src/components/FileUploader.story.vue
+101 −0 src/components/FormControl.story.vue
+29 −0 src/components/ListView/ListRow.vue
+10 −0 src/components/ListView/ListRowItem.vue
+116 −0 src/components/ListView/ListView.vue
+29 −0 src/components/Popover.story.vue
+34 −0 src/components/Progress.story.vue
+21 −0 src/components/Select.story.vue
+14 −0 src/components/Spinner.story.vue
+28 −0 src/components/Switch.story.vue
+11 −15 src/components/Switch.vue
+81 −0 src/components/TextInput.story.vue
+7 −2 src/components/TextInput.vue
+11 −0 src/components/Tooltip.story.vue
+2 −0 src/env.d.ts
+5 −0 src/index.js
+1 −0 src/resources/listResource.js
+62 −57 src/utils/fileUploadHandler.ts
+1 −1 src/utils/frappeRequest.js
+0 −1 src/vite-env.d.ts
+1,110 −5,332 yarn.lock
11 changes: 8 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"name": "frappe-ui-frontend",
"name": "insights-frontend",
"private": true,
"version": "0.0.0",
"engines": {
"node": ">=16.0.0"
},
"scripts": {
"dev": "vite",
"serve": "vite preview",
Expand All @@ -13,14 +16,17 @@
"@codemirror/lang-python": "^6.1.3",
"@codemirror/lang-sql": "^6.4.0",
"@playwright/test": "^1.32.1",
"@types/vue-router": "^2.0.0",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"@vueuse/core": "^9.1.0",
"codemirror": "^6.0.1",
"dayjs": "^1.11.6",
"dom-to-image": "^2.6.0",
"echarts": "^5.4.0",
"feather-icons": "^4.28.0",
"frappe-ui": "0.1.0-alpha.11",
"frappe-ui": "^0.1.0-alpha.12",
"grid-layout-plus": "^1.0.2",
"lucide-vue-next": "^0.259.0",
"pinia": "^2.0.30",
"tailwindcss": "3.2.7",
Expand All @@ -30,7 +36,6 @@
"vue-codemirror": "^6.0.1",
"vue-router": "^4.0.12",
"vue-tsc": "^1.6.5",
"vue3-drr-grid-layout": "^1.9.7",
"vuedraggable": "^4.1.0"
},
"devDependencies": {
Expand Down
23 changes: 10 additions & 13 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
<template>
<div class="flex h-screen w-screen bg-white antialiased">
<template v-if="route.meta.allowGuest">
<router-view></router-view>
</template>
<template v-else>
<RouterView v-if="isGuestView" />
<Suspense>
<AppShell />
<Toasts />
<Dialog v-model="prompt.show" :options="prompt.options" />
</template>
</Suspense>
<Toasts />
</div>
</template>

<script setup>
import AppShell from '@/components/AppShell.vue'
import usePrompt from '@/utils/prompt'
import Toasts from '@/utils/toasts'
import { inject, onBeforeUnmount } from 'vue'
import { inject, onBeforeUnmount, computed } from 'vue'
import { useRoute } from 'vue-router'
import sessionStore from '@/stores/sessionStore'
const route = useRoute()
const prompt = usePrompt()
const isGuestView = computed(() => route.meta.isGuestView)
if (!route.meta.allowGuest) {
if (!isGuestView.value) {
const $socket = inject('$socket')
const $notify = inject('$notify')
const $auth = inject('$auth')
const session = sessionStore()
$socket.on('insights_notification', (data) => {
if (data.user == $auth.user.user_id) {
if (data.user == session.user.user_id) {
$notify({
title: data.title || data.message,
message: data.title ? data.message : '',
Expand Down
52 changes: 52 additions & 0 deletions frontend/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { call, createDocumentResource, createListResource, createResource } from 'frappe-ui'
import getWhitelistedMethods from './whitelistedMethods'

export const login = (email: string, password: string): Promise<User> => {
return call('login', { usr: email, pwd: password })
}
export const logout = (): Promise<any> => call('logout')

export const fetchUserInfo = (): Promise<any> => call('insights.api.get_user_info')
export const trackActiveSite = (): Promise<any> => call('insights.api.telemetry.track_active_site')

export const createLastViewedLog = (recordType: string, recordName: string) => {
return call('insights.api.home.create_last_viewed_log', {
record_type: recordType,
record_name: recordName,
}) as Promise<any>
}

export const getListResource = (listResourceOption: ListResourceParams): ListResource => {
return createListResource(listResourceOption)
}

export const createDataSource: Resource = createResource({ url: 'insights.api.setup.add_database' })
export const testDataSourceConnection: Resource = createResource({
url: 'insights.api.setup.test_database_connection',
})

export const getDocumentResource = (
doctype: string,
docname?: string,
options?: object
) => {
const resource = createDocumentResource({
doctype: doctype,
name: docname || doctype,
whitelistedMethods: getWhitelistedMethods(doctype),
...options,
})
resource.fetchIfNeeded = async () => {
if (!resource.get.loading) {
await resource.get.fetch()
}
}
return resource
}

export const fetchTableName = async (data_source: string, table: string) => {
return call('insights.api.get_table_name', {
data_source: data_source,
table: table,
})
}
19 changes: 19 additions & 0 deletions frontend/src/api/whitelistedMethods.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const whitelistedMethods = {
'Insights Settings': {
update_settings: 'update_settings',
send_support_login_link: 'send_support_login_link',
},
'Insights Data Source': {
enqueue_sync_tables: 'enqueue_sync_tables',
get_tables: 'get_tables',
},
'Insights Table': {
syncTable: 'sync_table',
updateVisibility: 'update_visibility',
getPreview: 'get_preview',
update_column_type: 'update_column_type',
},
}
export default function getWhitelistedMethods(doctype: string) {
return whitelistedMethods[doctype as keyof typeof whitelistedMethods] || {}
}
17 changes: 7 additions & 10 deletions frontend/src/components/AppShell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<component :is="Component" :key="$route.fullPath" />
</div>
<template #fallback>
<div class="flex h-full flex-col items-center justify-center">
<FeatherIcon name="loader" class="h-8 w-8 animate-spin text-gray-500" />
</div>
<SuspenseFallback />
</template>
</Suspense>
</RouterView>
Expand All @@ -18,15 +16,14 @@

<script setup>
import Sidebar from '@/components/Sidebar.vue'
import auth from '@/utils/auth'
import settings from '@/utils/settings'
import systemSettings from '@/utils/systemSettings'
import SuspenseFallback from '@/components/SuspenseFallback'
import sessionStore from '@/stores/sessionStore'
import settingsStore from '@/stores/settingsStore'
import { computed, onMounted } from 'vue'
import { useRoute } from 'vue-router'
const session = sessionStore()
const route = useRoute()
const hideSidebar = computed(() => {
return route.meta.hideSidebar || !auth.isLoggedIn
})
onMounted(() => auth.isLoggedIn && settings.get.fetch() && systemSettings.get.fetch())
const hideSidebar = computed(() => route.meta.hideSidebar || !session.isLoggedIn)
onMounted(() => session.isLoggedIn && settingsStore())
</script>
Loading

0 comments on commit a07ed5d

Please sign in to comment.