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 {
.alert-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 {
if (!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}`)
}
......
......@@ -694,10 +694,10 @@ const UheppHistPost = ({width, height, uhepp}) => {
const margin = {
top: 10,
bottom: 60,
top: 5,
bottom: 40,
left: 80,
right: 80,
right: 10,
sep: 3,
}
......@@ -1000,6 +1000,7 @@ const UheppHistPost = ({width, height, uhepp}) => {
</Group> }
</svg>
</div>
<div className="container text-right">
<canvas className="d-none" ref={canvasRef} width={canvasWidth} height={canvasHeight}></canvas>
{ !pngDownload &&
......
......@@ -93,4 +93,4 @@ class PlotSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Plot
fields = ["uuid", "collection", "url", "uhepp"]
fields = ["uuid", "collection", "url", "uhepp", "comment"]
{
"$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",
"description": "Universal high-energy physics plots",
"type": "object",
......@@ -41,7 +41,7 @@
"properties": {
"version": {
"type": "string",
"enum": ["0.1"]
"enum": ["0.1", "0.2", "0.3"]
},
"type": {
"type": "string",
......@@ -81,13 +81,15 @@
"enum": ["step", "stepfilled", "points"]
},
"error": {"$ref": "#/definitions/error"},
"x_errorbar": {"type": "boolean"},
"keep_zero": {"type": "boolean"},
"content": {
"type": "array",
"items": {
"type": "object",
"properties": {
"yield": {"$ref": "#/definitions/yield_list"},
"label": {"type": "string"},
"label": {"type": ["string", "null"]},
"style": {"$ref": "#/definitions/style"}
},
"required": ["yield", "label"],
......@@ -113,7 +115,10 @@
"type": "string",
"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"],
"additionalProperties": false
......@@ -164,8 +169,8 @@
"symbol": {"type": "string"},
"unit": {"type": "string"},
"name": {"type": "string"},
"log": {"type": "boolean"}
},
"log": {"type": "boolean"},
"unit_in_brackets": {"type": "boolean"} },
"required": ["symbol"],
"additionalProperties": false
},
......
......@@ -205,4 +205,6 @@ STATIC_URL = '/static/'
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.utils.translation import gettext_lazy as _
from . import models
class TokenForm(forms.Form):
description = forms.CharField(label=_('Description'), max_length=100)
......@@ -22,3 +23,9 @@ class CollectionPermForm(forms.BaseForm):
self.declared_fields = self.base_fields
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):
api_view_count = models.IntegerField(default=0)
title = models.CharField(max_length=255, null=True, blank=True)
uploaded = models.DateTimeField(auto_now_add=True)
comment = models.TextField(null=True, blank=True)
collection = models.ForeignKey(
Collection,
......
{% extends 'uhepp_vault/base.html' %}
{% load pygmentify_tags %}
{% load humanize %}
{% load crispy_forms_tags %}
{% block title %}{{ plot.title }} - uhepp hub{% endblock %}
......@@ -29,6 +30,7 @@
</a>
</span>
{% endif %}</h1>
<div class="d-none d-lg-inline text-muted">
<i class="fas fa-eye"></i>
{{ plot.view_count }} view{{ plot.view_count|pluralize }},
......@@ -38,7 +40,8 @@
</span>
</div>
<div class="d-flex">
<div class="d-flex align-items-center">
<span class="d-none d-md-inline">UUID: {{ plot.uuid }}</span>
<div class="ml-auto btn-group btn-group-sm access-menu">
<div class="btn-group btn-group-sm dropdown">
......@@ -122,7 +125,6 @@ uhepp push {{ plot.collection.pk }} local_file.json</pre>
</div>
</div>
<div id="app-root">
<div class="d-flex justify-content-center my-5">
<div class="spinner-border text-primary" role="status">
......
......@@ -9,7 +9,9 @@ from . import views
app_name = 'uhepp_vault'
urlpatterns = [
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('login/', auth_views.LoginView.as_view()),
path('logout/', views.logout, name='logout'),
......
......@@ -19,7 +19,7 @@ from uhepp_api.masks import MaskRelatedColletions
from .models import PUBLIC_LEVEL, INTERNAL_LEVEL, PUBLIC_LEVEL, \
Collection, Plot, Profile
from .forms import TokenForm
from .forms import TokenForm, PlotForm
def quantize(value, sig_digits):
if value <= 100:
......@@ -212,10 +212,12 @@ class PlotListView(generic.ListView):
)
return queryset
class PlotDetail(generic.DetailView):
class PlotDetail(generic.UpdateView):
model = Plot
slug_field = 'uuid'
slug_url_kwarg = 'uuid'
fields = ["comment"]
template_name = 'uhepp_vault/plot_detail.html'
def get_queryset(self):
if self.request.user.is_anonymous:
......