Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • frank/uhepp.org
1 result
Show changes
Commits on Source (9)
...@@ -152,3 +152,18 @@ body { ...@@ -152,3 +152,18 @@ body {
.alert-success { .alert-success {
border-color: theme-color("success"); border-color: theme-color("success");
} }
.plot-caption {
cursor: pointer;
justify-content: space-between;
display: flex;
}
.plot-caption .pen{
visibility: hidden;
}
.plot-caption:hover .pen{
visibility: visible;
}
import React, { useState } from "react";
const Caption = ({editable, comment, handleUpdate}) => {
const [editMode, setEditMode] = useState(false)
const [cmt, setCmt] = useState(comment)
const updateComment = (e) => {
if (editable) {
const comment = e.target.value;
setCmt(comment)
}
}
const handleSubmit = (e) => {
e.preventDefault()
handleUpdate(cmt)
}
const softLeave = () => {
if (comment == cmt) {
setEditMode(false)
}
}
const handleClick = () => {
if (editable) {
setEditMode(true)
}
}
console.log(style)
if (editMode) {
return (<form method="post" className="my-2 d-flex" onSubmit={e => handleSubmite(e)}>
<textarea name="comment" cols="40" autoFocus className="textarea form-control"
onBlur={() => softLeave()}
id="id_comment" rows="2" value={cmt} onChange={e => updateComment(e)} />
<div>
<button type="submit" className="btn btn-outline-secondary ml-1">
<i className="fas fa-save"></i>
</button>
</div>
</form>)
} else {
return <div className="plot-caption mx-5" onClick={() => handleClick()}>
<p>{comment}</p>
<i className="fas fa-pen m-1 pen text-muted"></i>
</div>
}
}
export default Caption
...@@ -34,7 +34,7 @@ class UheppWithData extends React.Component { ...@@ -34,7 +34,7 @@ class UheppWithData extends React.Component {
if (!uhepp.version) { if (!uhepp.version) {
return Error("Missing uhepp version") return Error("Missing uhepp version")
} }
if (uhepp.version != "0.1") { if (uhepp.version != "0.1" && uhepp.version != "0.2") {
return Error(`Unsupported uhepp version: ${uhepp.version}`) return Error(`Unsupported uhepp version: ${uhepp.version}`)
} }
......
...@@ -694,10 +694,10 @@ const UheppHistPost = ({width, height, uhepp}) => { ...@@ -694,10 +694,10 @@ const UheppHistPost = ({width, height, uhepp}) => {
const margin = { const margin = {
top: 10, top: 5,
bottom: 60, bottom: 40,
left: 80, left: 80,
right: 80, right: 10,
sep: 3, sep: 3,
} }
...@@ -1000,6 +1000,7 @@ const UheppHistPost = ({width, height, uhepp}) => { ...@@ -1000,6 +1000,7 @@ const UheppHistPost = ({width, height, uhepp}) => {
</Group> } </Group> }
</svg> </svg>
</div> </div>
<div className="container text-right"> <div className="container text-right">
<canvas className="d-none" ref={canvasRef} width={canvasWidth} height={canvasHeight}></canvas> <canvas className="d-none" ref={canvasRef} width={canvasWidth} height={canvasHeight}></canvas>
{ !pngDownload && { !pngDownload &&
......
...@@ -93,4 +93,4 @@ class PlotSerializer(serializers.HyperlinkedModelSerializer): ...@@ -93,4 +93,4 @@ class PlotSerializer(serializers.HyperlinkedModelSerializer):
class Meta: class Meta:
model = Plot model = Plot
fields = ["uuid", "collection", "url", "uhepp"] fields = ["uuid", "collection", "url", "uhepp", "comment"]
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://uhepp.org/uhepp_v0_1.schema.json", "$id": "https://uhepp.org/uhepp_v0_3.schema.json",
"title": "UHepp", "title": "UHepp",
"description": "Universal high-energy physics plots", "description": "Universal high-energy physics plots",
"type": "object", "type": "object",
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
"properties": { "properties": {
"version": { "version": {
"type": "string", "type": "string",
"enum": ["0.1"] "enum": ["0.1", "0.2", "0.3"]
}, },
"type": { "type": {
"type": "string", "type": "string",
...@@ -81,13 +81,15 @@ ...@@ -81,13 +81,15 @@
"enum": ["step", "stepfilled", "points"] "enum": ["step", "stepfilled", "points"]
}, },
"error": {"$ref": "#/definitions/error"}, "error": {"$ref": "#/definitions/error"},
"x_errorbar": {"type": "boolean"},
"keep_zero": {"type": "boolean"},
"content": { "content": {
"type": "array", "type": "array",
"items": { "items": {
"type": "object", "type": "object",
"properties": { "properties": {
"yield": {"$ref": "#/definitions/yield_list"}, "yield": {"$ref": "#/definitions/yield_list"},
"label": {"type": "string"}, "label": {"type": ["string", "null"]},
"style": {"$ref": "#/definitions/style"} "style": {"$ref": "#/definitions/style"}
}, },
"required": ["yield", "label"], "required": ["yield", "label"],
...@@ -113,7 +115,10 @@ ...@@ -113,7 +115,10 @@
"type": "string", "type": "string",
"enum": ["step", "stepfilled", "points"] "enum": ["step", "stepfilled", "points"]
}, },
"error": {"$ref": "#/definitions/error"} "error": {"$ref": "#/definitions/error"},
"x_errorbar": {"type": "boolean"},
"keep_zero": {"type": "boolean"},
"den_error": {"$ref": "#/definitions/error"}
}, },
"required": ["numerator"], "required": ["numerator"],
"additionalProperties": false "additionalProperties": false
...@@ -164,8 +169,8 @@ ...@@ -164,8 +169,8 @@
"symbol": {"type": "string"}, "symbol": {"type": "string"},
"unit": {"type": "string"}, "unit": {"type": "string"},
"name": {"type": "string"}, "name": {"type": "string"},
"log": {"type": "boolean"} "log": {"type": "boolean"},
}, "unit_in_brackets": {"type": "boolean"} },
"required": ["symbol"], "required": ["symbol"],
"additionalProperties": false "additionalProperties": false
}, },
......
...@@ -205,4 +205,6 @@ STATIC_URL = '/static/' ...@@ -205,4 +205,6 @@ STATIC_URL = '/static/'
DATETIME_INPUT_FORMATS = '%Y-%m-%d %H:%M' DATETIME_INPUT_FORMATS = '%Y-%m-%d %H:%M'
SCHEMA_URL = "https://gitlab.cern.ch/fsauerbu/uhepp/-/raw/master/uhepp.schema.json" SCHEMA_URL_1 = "https://gitlab.cern.ch/fsauerbu/uhepp/-/raw/0.1.6/uhepp.schema.json"
SCHEMA_URL_2 = "https://gitlab.cern.ch/fsauerbu/uhepp/-/raw/v0.2.0/uhepp.schema.json"
SCHEMA_URL_3 = "https://gitlab.cern.ch/fsauerbu/uhepp/-/raw/0cff18263ff936853e65a120cf9da02cb0deee93/uhepp.schema.json"
from django import forms from django import forms
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from . import models
class TokenForm(forms.Form): class TokenForm(forms.Form):
description = forms.CharField(label=_('Description'), max_length=100) description = forms.CharField(label=_('Description'), max_length=100)
...@@ -22,3 +23,9 @@ class CollectionPermForm(forms.BaseForm): ...@@ -22,3 +23,9 @@ class CollectionPermForm(forms.BaseForm):
self.declared_fields = self.base_fields self.declared_fields = self.base_fields
super().__init__(*args, **kwds) super().__init__(*args, **kwds)
class PlotForm(forms.ModelForm):
class Meta:
model = models.Plot
fields = ["comment"]
# Generated by Django 3.1.7 on 2021-04-09 15:16
from django.db import migrations, models
import django.db.models.functions.text
class Migration(migrations.Migration):
dependencies = [
('uhepp_vault', '0008_auto_20210223_1620'),
]
operations = [
migrations.AlterModelOptions(
name='collection',
options={'ordering': ['-activity', django.db.models.functions.text.Lower('title')]},
),
migrations.AddField(
model_name='plot',
name='comment',
field=models.TextField(blank=True, null=True),
),
]
...@@ -64,6 +64,7 @@ class Plot(models.Model): ...@@ -64,6 +64,7 @@ class Plot(models.Model):
api_view_count = models.IntegerField(default=0) api_view_count = models.IntegerField(default=0)
title = models.CharField(max_length=255, null=True, blank=True) title = models.CharField(max_length=255, null=True, blank=True)
uploaded = models.DateTimeField(auto_now_add=True) uploaded = models.DateTimeField(auto_now_add=True)
comment = models.TextField(null=True, blank=True)
collection = models.ForeignKey( collection = models.ForeignKey(
Collection, Collection,
......
{% extends 'uhepp_vault/base.html' %} {% extends 'uhepp_vault/base.html' %}
{% load pygmentify_tags %} {% load pygmentify_tags %}
{% load humanize %} {% load humanize %}
{% load crispy_forms_tags %}
{% block title %}{{ plot.title }} - uhepp hub{% endblock %} {% block title %}{{ plot.title }} - uhepp hub{% endblock %}
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
</a> </a>
</span> </span>
{% endif %}</h1> {% endif %}</h1>
<div class="d-none d-lg-inline text-muted"> <div class="d-none d-lg-inline text-muted">
<i class="fas fa-eye"></i> <i class="fas fa-eye"></i>
{{ plot.view_count }} view{{ plot.view_count|pluralize }}, {{ plot.view_count }} view{{ plot.view_count|pluralize }},
...@@ -38,7 +40,8 @@ ...@@ -38,7 +40,8 @@
</span> </span>
</div> </div>
<div class="d-flex">
<div class="d-flex align-items-center">
<span class="d-none d-md-inline">UUID: {{ plot.uuid }}</span> <span class="d-none d-md-inline">UUID: {{ plot.uuid }}</span>
<div class="ml-auto btn-group btn-group-sm access-menu"> <div class="ml-auto btn-group btn-group-sm access-menu">
<div class="btn-group btn-group-sm dropdown"> <div class="btn-group btn-group-sm dropdown">
...@@ -122,7 +125,6 @@ uhepp push {{ plot.collection.pk }} local_file.json</pre> ...@@ -122,7 +125,6 @@ uhepp push {{ plot.collection.pk }} local_file.json</pre>
</div> </div>
</div> </div>
<div id="app-root"> <div id="app-root">
<div class="d-flex justify-content-center my-5"> <div class="d-flex justify-content-center my-5">
<div class="spinner-border text-primary" role="status"> <div class="spinner-border text-primary" role="status">
......
...@@ -9,7 +9,9 @@ from . import views ...@@ -9,7 +9,9 @@ from . import views
app_name = 'uhepp_vault' app_name = 'uhepp_vault'
urlpatterns = [ urlpatterns = [
path('', views.home, name='home'), path('', views.home, name='home'),
path('uhepp_v0_1.schema.json', RedirectView.as_view(url=settings.SCHEMA_URL)), path('uhepp_v0_1.schema.json', RedirectView.as_view(url=settings.SCHEMA_URL_1)),
path('uhepp_v0_2.schema.json', RedirectView.as_view(url=settings.SCHEMA_URL_2)),
path('uhepp_v0_3.schema.json', RedirectView.as_view(url=settings.SCHEMA_URL_3)),
path('account/', views.AccountEditView.as_view(), name='account-detail'), path('account/', views.AccountEditView.as_view(), name='account-detail'),
path('login/', auth_views.LoginView.as_view()), path('login/', auth_views.LoginView.as_view()),
path('logout/', views.logout, name='logout'), path('logout/', views.logout, name='logout'),
......
...@@ -19,7 +19,7 @@ from uhepp_api.masks import MaskRelatedColletions ...@@ -19,7 +19,7 @@ from uhepp_api.masks import MaskRelatedColletions
from .models import PUBLIC_LEVEL, INTERNAL_LEVEL, PUBLIC_LEVEL, \ from .models import PUBLIC_LEVEL, INTERNAL_LEVEL, PUBLIC_LEVEL, \
Collection, Plot, Profile Collection, Plot, Profile
from .forms import TokenForm from .forms import TokenForm, PlotForm
def quantize(value, sig_digits): def quantize(value, sig_digits):
if value <= 100: if value <= 100:
...@@ -212,10 +212,12 @@ class PlotListView(generic.ListView): ...@@ -212,10 +212,12 @@ class PlotListView(generic.ListView):
) )
return queryset return queryset
class PlotDetail(generic.DetailView): class PlotDetail(generic.UpdateView):
model = Plot model = Plot
slug_field = 'uuid' slug_field = 'uuid'
slug_url_kwarg = 'uuid' slug_url_kwarg = 'uuid'
fields = ["comment"]
template_name = 'uhepp_vault/plot_detail.html'
def get_queryset(self): def get_queryset(self):
if self.request.user.is_anonymous: if self.request.user.is_anonymous:
......