Skip to content

Commit

Permalink
Merge pull request #371 from MetaCell/feature/SCKAN-355
Browse files Browse the repository at this point in the history
sckan-355- change column name in export csv and  sckan-168 - add version to UI
  • Loading branch information
ddelpiano authored Dec 7, 2024
2 parents ad12000 + 7d7decd commit beb38bd
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 31 deletions.
4 changes: 2 additions & 2 deletions backend/composer/services/export_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ def generate_csv_attributes_mapping() -> Dict[str, Callable]:
"Identifier": get_identifier,
"Relationship": get_relationship,
"Axonal course poset": get_layer,
"Connected From": get_connected_from_names,
"Connected From URIs": get_connected_from_uri,
"connected_from": get_connected_from_names,
"connected_from_uris": get_connected_from_uri,
"Predicate": get_predicate,
"Observed in species": get_observed_in_species,
"Different from existing": get_different_from_existing,
Expand Down
7 changes: 6 additions & 1 deletion backend/composer/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

from django.utils import timezone
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.template import loader
from django.urls import reverse
Expand All @@ -8,6 +9,7 @@
from composer.models import ConnectivityStatement
from composer.services.export_services import export_connectivity_statements

from version import VERSION

def index(request):
if not hasattr(request, "user") or not request.user.is_authenticated:
Expand Down Expand Up @@ -47,7 +49,10 @@ def export(request):
messages.add_message(request, messages.INFO, f"Exported {export_batch.get_count_connectivity_statements_in_this_export} connectivity statements.")
if os.path.exists(file_path):
with open(file_path, 'rb') as fh:
response = HttpResponse(fh.read(), content_type="application/text")
composer_version = f'# SCKAN Composer version: {VERSION}\n'
date_exported = f'# Export date: {timezone.now().strftime("%Y-%m-%d")}\n'
content = composer_version + date_exported + fh.read().decode()
response = HttpResponse(content.encode(), content_type="application/text")
response['Content-Disposition'] = 'inline; filename=' + os.path.basename(file_path)
return response
raise Http404
Expand Down
2 changes: 1 addition & 1 deletion backend/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import sys

from setuptools import find_packages, setup
from version import VERSION

NAME = "SCKAN Composer"
VERSION = "3.0.0"

# To install the library, run the following
#
Expand Down
1 change: 1 addition & 0 deletions backend/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION = "3.2.0"
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "3.0.0",
"version": "3.2.0",
"private": true,
"main": "index.js",
"proxy": "https://localhost:8000/",
Expand Down
61 changes: 35 additions & 26 deletions frontend/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import Typography from "@mui/material/Typography";
import { vars } from "../theme/variables";
import { userProfile } from "../services/UserService";
import { useNavigate, useLocation } from "react-router";
import { getSckanComposerVersion } from "../services/CommonService";

const Sidebar = () => {
const profile = userProfile.getProfile();
const navigate = useNavigate();
const location = useLocation();
const sckanComposerVersion = getSckanComposerVersion();

const userIsCuratorAndTriageOperator =
profile.is_triage_operator && (profile.is_curator || profile.is_reviewer);
Expand Down Expand Up @@ -40,38 +42,45 @@ const Sidebar = () => {
return (
<Drawer variant="permanent" sx={drawerStyle}>
<Toolbar />
<Box sx={{ overflow: "auto" }} color="#D0D5DD">
<Typography variant="caption" component="p" p={2.5} pb={1}>
Manage
</Typography>
<MenuList variant="selectedMenu" sx={{ p: 0 }}>
<MenuItem
sx={{ padding: "0.875rem 1.25rem" }}
selected={selectedItem === 0}
onClick={() => {
setSelectedItem(0);
navigate("/");
}}
>
<Typography variant="subtitle1">
{profile.is_triage_operator
? "Sentences List"
: "Statements List"}
</Typography>
</MenuItem>
{userIsCuratorAndTriageOperator && (
<Box flex={1} justifyContent="space-between" display="flex" flexDirection="column">
<Box sx={{ overflow: "auto" }} color="#D0D5DD">
<Typography variant="caption" component="p" p={2.5} pb={1}>
Manage
</Typography>
<MenuList variant="selectedMenu" sx={{ p: 0 }}>
<MenuItem
sx={{ padding: "0.875rem 1.25rem" }}
selected={selectedItem === 1}
selected={selectedItem === 0}
onClick={() => {
setSelectedItem(1);
navigate("/statement");
setSelectedItem(0);
navigate("/");
}}
>
<Typography variant="subtitle1">Statements List</Typography>
<Typography variant="subtitle1">
{profile.is_triage_operator
? "Sentences List"
: "Statements List"}
</Typography>
</MenuItem>
)}
</MenuList>
{userIsCuratorAndTriageOperator && (
<MenuItem
sx={{ padding: "0.875rem 1.25rem" }}
selected={selectedItem === 1}
onClick={() => {
setSelectedItem(1);
navigate("/statement");
}}
>
<Typography variant="subtitle1">Statements List</Typography>
</MenuItem>
)}
</MenuList>
</Box>
<Typography variant="caption" component="p"
mb={1.5} color="#D0D5DD" mx={'auto'}
>
SCKAN Composer version: {sckanComposerVersion}
</Typography>
</Box>
</Drawer>
);
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/services/CommonService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export const getSckanComposerVersion = () => {
return require('../../package.json').version;
}

0 comments on commit beb38bd

Please sign in to comment.