Skip to content

Commit

Permalink
fix: merge ProjectDashboard and DomainDashboard into Dashboard Resource
Browse files Browse the repository at this point in the history
  • Loading branch information
stat-kwon committed Dec 18, 2023
1 parent 44c683a commit 7d1a891
Show file tree
Hide file tree
Showing 49 changed files with 1,311 additions and 2,219 deletions.
23 changes: 9 additions & 14 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@
from setuptools import setup, find_packages

setup(
name='spaceone-dashboard',
version=os.environ.get('PACKAGE_VERSION'),
description='SpaceONE dashboard service',
long_description='',
url='https://www.spaceone.dev/',
author='MEGAZONE SpaceONE Team',
author_email='[email protected]',
license='Apache License 2.0',
name="spaceone-dashboard",
version=os.environ.get("PACKAGE_VERSION"),
description="SpaceONE dashboard service",
long_description="",
url="https://www.spaceone.dev/",
author="MEGAZONE SpaceONE Team",
author_email="[email protected]",
license="Apache License 2.0",
packages=find_packages(),
install_requires=[
'spaceone-core',
'spaceone-api',
'mongoengine',
'boto3'
],
install_requires=["spaceone-core", "spaceone-api", "mongoengine", "boto3"],
zip_safe=False,
)
2 changes: 1 addition & 1 deletion src/spaceone/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
36 changes: 17 additions & 19 deletions src/spaceone/dashboard/conf/global_conf.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,53 @@
# Database Settings
DATABASES = {
'default': {
'db': 'dashboard',
'host': 'localhost',
'port': 27017,
'username': '',
'password': ''
"default": {
"db": "dashboard",
"host": "localhost",
"port": 27017,
"username": "",
"password": "",
}
}

# Cache Settings
CACHES = {
'default': {
"default": {
# Redis Example
# 'backend': 'spaceone.core.cache.redis_cache.RedisCache',
# 'host': '<host>',
# 'port': 6379,
# 'db': 0
}
}

# Handler Configuration
HANDLERS = {
'authentication': [
"authentication": [
# Default Authentication Handler
# {
# 'backend': 'spaceone.core.handler.authentication_handler.AuthenticationGRPCHandler',
# 'uri': 'grpc://identity:50051/v1/Domain/get_public_key'
# }
],
'authorization': [
"authorization": [
# Default Authorization Handler
# {
# 'backend': 'spaceone.core.handler.authorization_handler.AuthorizationGRPCHandler',
# 'uri': 'grpc://identity:50051/v1/Authorization/verify'
# }
],
'mutation': [],
'event': []
"mutation": [],
"event": [],
}

# Connector Settings
CONNECTORS = {
'SpaceConnector': {
'backend': 'spaceone.core.connector.space_connector.SpaceConnector',
'endpoints': {
'identity': 'grpc://identity:50051',
}
"SpaceConnector": {
"backend": "spaceone.core.connector.space_connector.SpaceConnector",
"endpoints": {
"identity": "grpc://identity:50051",
},
}
}

# Log Settings
LOG = {
}
LOG = {}
5 changes: 0 additions & 5 deletions src/spaceone/dashboard/conf/proto_conf.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/spaceone/dashboard/error/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from spaceone.dashboard.error.common_dashboard import *
from spaceone.dashboard.error.dashboard import *
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class ERROR_LATEST_VERSION(ERROR_INVALID_ARGUMENT):
_message = 'Do not remove latest version. (version = {version})'
_message = "Do not remove latest version. (version = {version})"
4 changes: 0 additions & 4 deletions src/spaceone/dashboard/info/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
from spaceone.dashboard.info.common_info import *
from spaceone.dashboard.info.domain_dashboard_info import *
from spaceone.dashboard.info.domain_dashboard_version_info import *
from spaceone.dashboard.info.project_dashboard_info import *
from spaceone.dashboard.info.project_dashboard_version_info import *
from spaceone.dashboard.info.custom_widget_info import *
12 changes: 0 additions & 12 deletions src/spaceone/dashboard/info/common_info.py

This file was deleted.

36 changes: 0 additions & 36 deletions src/spaceone/dashboard/info/custom_widget_info.py

This file was deleted.

47 changes: 47 additions & 0 deletions src/spaceone/dashboard/info/dashboard_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import functools
from spaceone.api.dashboard.v1 import domain_dashboard_pb2
from spaceone.core.pygrpc.message_type import *
from spaceone.core import utils
from spaceone.dashboard.model.dashboard_model import Dashboard

__all__ = ["DomainDashboardInfo", "DomainDashboardsInfo"]


def DomainDashboardInfo(domain_dashboard_vo: Dashboard, minimal=False):
info = {
"domain_dashboard_id": domain_dashboard_vo.domain_dashboard_id,
"name": domain_dashboard_vo.name,
"viewers": domain_dashboard_vo.viewers,
"version": domain_dashboard_vo.version,
"labels": change_list_value_type(domain_dashboard_vo.labels),
"user_id": domain_dashboard_vo.user_id,
"domain_id": domain_dashboard_vo.domain_id,
}

if not minimal:
info.update(
{
"layouts": change_list_value_type(domain_dashboard_vo.layouts)
if domain_dashboard_vo.layouts
else None,
"variables": change_struct_type(domain_dashboard_vo.variables),
"settings": change_struct_type(domain_dashboard_vo.settings),
"variables_schema": change_struct_type(
domain_dashboard_vo.variables_schema
),
"tags": change_struct_type(domain_dashboard_vo.tags),
"created_at": utils.datetime_to_iso8601(domain_dashboard_vo.created_at),
"updated_at": utils.datetime_to_iso8601(domain_dashboard_vo.updated_at),
}
)

return domain_dashboard_pb2.DomainDashboardInfo(**info)


def DomainDashboardsInfo(domain_dashboard_vos, total_count, **kwargs):
return domain_dashboard_pb2.DomainDashboardsInfo(
results=list(
map(functools.partial(DomainDashboardInfo, **kwargs), domain_dashboard_vos)
),
total_count=total_count,
)
52 changes: 52 additions & 0 deletions src/spaceone/dashboard/info/dashboard_version_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import functools
from spaceone.api.dashboard.v1 import domain_dashboard_pb2
from spaceone.core.pygrpc.message_type import *
from spaceone.core import utils
from spaceone.dashboard.model import DashboardVersion

__all__ = ["DomainDashboardVersionInfo", "DomainDashboardVersionsInfo"]


def DomainDashboardVersionInfo(
domain_dashboard_version_vo: DashboardVersion, minimal=False, latest_version=None
):
info = {
"domain_dashboard_id": domain_dashboard_version_vo.domain_dashboard_id,
"version": domain_dashboard_version_vo.version,
"created_at": utils.datetime_to_iso8601(domain_dashboard_version_vo.created_at),
"domain_id": domain_dashboard_version_vo.domain_id,
}

if latest_version:
if latest_version == domain_dashboard_version_vo.version:
info.update({"latest": True})
else:
info.update({"latest": False})

if not minimal:
info.update(
{
"layouts": change_list_value_type(domain_dashboard_version_vo.layouts)
if domain_dashboard_version_vo.layouts
else None,
"variables": change_struct_type(domain_dashboard_version_vo.variables),
"settings": change_struct_type(domain_dashboard_version_vo.settings),
"variables_schema": change_struct_type(
domain_dashboard_version_vo.variables_schema
),
}
)

return domain_dashboard_pb2.DomainDashboardVersionInfo(**info)


def DomainDashboardVersionsInfo(domain_dashboard_version_vos, total_count, **kwargs):
return domain_dashboard_pb2.DomainDashboardVersionsInfo(
results=list(
map(
functools.partial(DomainDashboardVersionInfo, **kwargs),
domain_dashboard_version_vos,
)
),
total_count=total_count,
)
38 changes: 0 additions & 38 deletions src/spaceone/dashboard/info/domain_dashboard_info.py

This file was deleted.

43 changes: 0 additions & 43 deletions src/spaceone/dashboard/info/domain_dashboard_version_info.py

This file was deleted.

Loading

0 comments on commit 7d1a891

Please sign in to comment.