Skip to content

Commit 83a5dd0

Browse files
committed
new dashboard api
1 parent 0eb5584 commit 83a5dd0

File tree

7 files changed

+51
-16
lines changed

7 files changed

+51
-16
lines changed

packages/backend-server/app/api/v1/web/dashboard/__init__.py

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from fastapi import APIRouter, Depends, BackgroundTasks, Request
2+
from app.api.v1.web.dashboard.services import get_dashboard_overview
3+
from app.api.v1.web.auth.schema import UserDetails
4+
from app.framework.permission_services.service import get_current_user
5+
from app.api.v1.web.route_constants import (
6+
DASHBOARD_OVERVIEW,
7+
DASHBOARD_RECENT_ACTIVITY,
8+
)
9+
10+
router = APIRouter()
11+
12+
13+
@router.get(DASHBOARD_OVERVIEW)
14+
async def get_dashboard_overview_api(
15+
request: Request,
16+
workspace_id: str,
17+
project_id: str,
18+
user: UserDetails = Depends(get_current_user),
19+
):
20+
21+
return await get_dashboard_overview(request, user)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from app.utils.utils import response_helper
2+
from app.managers import secrets as secret_manager
3+
from app.managers import project as project_manager
4+
5+
async def get_dashboard_overview(request, user):
6+
db=user.get("db")
7+
project_id = request.path_params.get("project_id")
8+
project_details = project_manager.find_one(db, {"project_id": project_id})
9+
if not project_details:
10+
return response_helper(404, "Project not found")
11+
12+
features = project_details.get("features", {})
13+
14+
data = {}
15+
for key, value in features.items():
16+
data[key] = secret_manager.get_project_secrets_count(user.get("db"), key, project_id)
17+
18+
return response_helper(200, "Dashboard overview fetched successfully", data)
19+

packages/backend-server/app/api/v1/web/route_constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,14 @@
4343
NOTES = BASE_URL + "/notes"
4444
NOTE_DETAILS = BASE_URL + "/notes/{doc_id}"
4545

46+
# Dashboard
47+
DASHBOARD_OVERVIEW = "/{workspace_id}/{project_id}/dashboard/overview"
48+
DASHBOARD_RECENT_ACTIVITY = "/{workspace_id}/{project_id}/dashboard/recent-activity"
49+
4650
# Password History
4751
PASSWORD_HISTORY = "/password-history"
4852

53+
4954
# Login
5055
LOGIN = "/login"
5156
LOGOUT = "/logout"

packages/backend-server/app/managers/secrets.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ def find(db, query, projection=None, sort=None, skip=0, limit=0):
5353

5454
def count_documents(db, query):
5555
return db_manager.count_documents(db, collection_name, query)
56+
57+
def get_project_secrets_count(db,data_type, project_id):
58+
return count_documents(db, {"project_id": project_id, "data_type": data_type, "access": {"$ne":False}})
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Secret Types
2-
SECRET_TYPE_LICENSE = "license"
32
SECRET_TYPE_API_KEY = "api_key"
4-
SECRET_TYPE_WALLET_PHRASE = "wallet_phrase"
3+
SECRET_TYPE_WALLET_PHRASE = "wallet_address"
54
SECRET_TYPE_WIFI = "wifi"
6-
SECRET_TYPE_LICENSE = "license"
5+
SECRET_TYPE_LICENSE = "software_license"
76
SECRET_TYPE_LOGIN = "login"
87
SECRET_TYPE_IDENTITY = "identity"
98
SECRET_TYPE_EMAIL = "email"
109
SECRET_TYPE_CARD = "card"
1110
SECRET_TYPE_SSH_KEY = "ssh_key"
1211
SECRET_TYPE_NOTE = "note"
1312
SECRET_TYPE_PASSWORD_HISTORY = "password_history"
13+

packages/taskfile.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)