Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Deval Plugin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
charitha.p
Deval Plugin
Commits
152169ba
Commit
152169ba
authored
Oct 25, 2023
by
charitha.p
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes in to 1.1
parent
9ef99b14
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
3 deletions
+92
-3
Deval/backend/scripts/config/__init__.py
Deval/backend/scripts/config/__init__.py
+1
-1
Deval/backend/scripts/core/handlers/defaults.py
Deval/backend/scripts/core/handlers/defaults.py
+52
-0
Deval/backend/scripts/core/services/defaults.py
Deval/backend/scripts/core/services/defaults.py
+37
-0
Deval/backend/scripts/core/services/widget.py
Deval/backend/scripts/core/services/widget.py
+1
-1
Deval/manifest.json
Deval/manifest.json
+1
-1
No files found.
Deval/backend/scripts/config/__init__.py
View file @
152169ba
...
@@ -5,7 +5,7 @@ class _Service(BaseSettings):
...
@@ -5,7 +5,7 @@ class _Service(BaseSettings):
HOST
:
str
=
Field
(
default
=
"0.0.0.0"
,
env
=
"service_host"
)
HOST
:
str
=
Field
(
default
=
"0.0.0.0"
,
env
=
"service_host"
)
PORT
:
int
=
Field
(
default
=
9192
,
env
=
"service_port"
)
PORT
:
int
=
Field
(
default
=
9192
,
env
=
"service_port"
)
BUILD_DIR
:
str
=
Field
(
default
=
"scripts/templates"
)
BUILD_DIR
:
str
=
Field
(
default
=
"scripts/templates"
)
PROXY
:
str
=
Field
(
default
=
"gateway/plugin/
<gen-proxy>
"
)
PROXY
:
str
=
Field
(
default
=
"gateway/plugin/
deval
"
)
BACKEND_DIR
:
str
=
Field
(
default
=
"."
)
BACKEND_DIR
:
str
=
Field
(
default
=
"."
)
...
...
Deval/backend/scripts/core/handlers/defaults.py
0 → 100644
View file @
152169ba
import
json
import
logging
import
os
from
fastapi.responses
import
FileResponse
from
scripts.config
import
Service
,
PathToDir
from
scripts.core.schemas.response_models
import
DefaultSuccessResponse
,
DefaultResponse
from
scripts.core.schemas.response_models
import
LoadStylesResponse
class
DefaultHandler
:
@
staticmethod
def
load_styles
():
try
:
response
=
LoadStylesResponse
()
for
each_file
in
os
.
listdir
(
Service
.
BUILD_DIR
):
path
=
f
"{Service.PROXY}/widget/load_file?filename={each_file}"
if
each_file
.
endswith
(
".js"
):
response
.
js_files
.
append
(
path
)
elif
each_file
.
endswith
(
".css"
):
response
.
styles
.
append
(
path
)
elif
each_file
==
"assets"
:
response
.
assetPath
=
f
"{Service.PROXY}/assets"
return
DefaultSuccessResponse
(
message
=
"Styles loaded successfully"
,
data
=
response
)
except
Exception
as
e
:
logging
.
exception
(
e
)
return
DefaultResponse
(
message
=
"Failed to load file paths"
,
status
=
"failed"
)
@
staticmethod
def
download_resources
(
filename
:
str
):
try
:
file_path
=
os
.
path
.
join
(
Service
.
BUILD_DIR
,
filename
)
if
os
.
path
.
isfile
(
os
.
path
.
join
(
Service
.
BUILD_DIR
,
filename
))
and
filename
.
endswith
(
".js"
):
return
FileResponse
(
file_path
,
media_type
=
'application/octet-stream'
,
filename
=
filename
)
else
:
return
DefaultResponse
(
message
=
"Failed to load resources"
)
except
Exception
as
e
:
logging
.
error
(
"Exception "
+
str
(
e
))
return
DefaultResponse
(
message
=
"Filename is not available"
)
@
staticmethod
def
load_configuration
():
try
:
with
open
(
f
"{PathToDir.ASSETS}/widgetConfig.json"
,
"r"
)
as
file
:
file_content
=
json
.
loads
(
file
.
read
())
return
file_content
except
Exception
as
e
:
logging
.
error
(
e
)
return
DefaultResponse
(
message
=
"Failed to load configurations"
)
\ No newline at end of file
Deval/backend/scripts/core/services/defaults.py
0 → 100644
View file @
152169ba
from
fastapi
import
APIRouter
from
scripts.api
import
EndPoints
from
scripts.core.handlers.defaults
import
DefaultHandler
router
=
APIRouter
(
prefix
=
"/widget"
)
handler
=
DefaultHandler
@
router
.
get
(
EndPoints
.
load_styles
)
async
def
load_styles
():
"""
Default: Loads required endpoints to get filenames in the build
Do not edit this
"""
return
handler
.
load_styles
()
@
router
.
get
(
EndPoints
.
load_file
)
def
download_resource
(
filename
:
str
):
"""Default: Request Build Files to redner widget configurations on the frontend
Do not edit this
"""
return
handler
.
download_resources
(
filename
)
# TODO: Add preview logic. Do not change the API endpoint
@
router
.
get
(
EndPoints
.
load_configuration
)
async
def
load_configuration
():
"""
Default: Load widget configuration JSON for listing plugins while creating widgets
Do not edit this
"""
return
handler
.
load_configuration
()
\ No newline at end of file
Deval/backend/scripts/core/services/widget.py
View file @
152169ba
...
@@ -73,7 +73,7 @@ async def preview(request_type: str = "refresh"):
...
@@ -73,7 +73,7 @@ async def preview(request_type: str = "refresh"):
if
request_type
not
in
[
"refresh"
,
"preview"
]:
if
request_type
not
in
[
"refresh"
,
"preview"
]:
return
DefaultResponse
(
message
=
"Invalid Query Parameter"
)
return
DefaultResponse
(
message
=
"Invalid Query Parameter"
)
# Route to Handler for Processing Chart json
# Route to Handler for Processing Chart json
return
{}
return
{
"Hello World"
}
except
Exception
as
e
:
except
Exception
as
e
:
logging
.
error
(
e
)
logging
.
error
(
e
)
return
DefaultResponse
(
message
=
"Not found"
)
return
DefaultResponse
(
message
=
"Not found"
)
Deval/manifest.json
View file @
152169ba
...
@@ -5,5 +5,5 @@
...
@@ -5,5 +5,5 @@
"branch"
:
"master"
,
"branch"
:
"master"
,
"environment_variables"
:
{
"environment_variables"
:
{
},
},
"version"
:
"1.
0
"
"version"
:
"1.
1
"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment