Commit fae79a27 authored by Samuel GAIST's avatar Samuel GAIST Committed by Samuel GAIST
Browse files

[toolchains][templates] Removed edition related code

parent a2905619
Pipeline #43873 passed with stage
in 17 minutes and 2 seconds
{% extends "base.html" %}
{% comment %}
* Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/
* Contact: beat.support@idiap.ch
*
* This file is part of the beat.web module of the BEAT platform.
*
* Commercial License Usage
* Licensees holding valid commercial BEAT licenses may use this file in
* accordance with the terms contained in a written agreement between you
* and Idiap. For further information contact tto@idiap.ch
*
* Alternatively, this file may be used under the terms of the GNU Affero
* Public License version 3 as published by the Free Software and appearing
* in the file LICENSE.AGPL included in the packaging of this file.
* The BEAT platform is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero Public License along
* with the BEAT platform. If not, see http://www.gnu.org/licenses/.
{% endcomment %}
{% load toolchain_tags %}
{% load ui_tags %}
{% load fingerprint %}
{% load static %}
{% block title %}
{% if not edition %}
{{ block.super }} - Create a new toolchain{% if toolchain_version > 1 %} version {% endif %}
{% else %}
{{ block.super }} - Edition of the toolchain {{ toolchain_author }}/{{ toolchain_name }}/{{ toolchain_version }}
{% endif %}
{% endblock %}
{% block stylesheets %}
{{ block.super }}
<link rel="stylesheet" href="{% fingerprint "toolchains/css/editor.css" %}" type="text/css" media="screen" />
<link rel="stylesheet" href="{% fingerprint "ui/css/list-selector.css" %}" type="text/css" media="screen" />
<link rel="stylesheet" href="{% fingerprint "ui/css/smart-selector.css" %}" type="text/css" media="screen" />
<link rel="stylesheet" href="{% fingerprint "spectrum/spectrum.css" %}" type="text/css" media="screen" />
<link rel="stylesheet" href="{% fingerprint "jquery-ui/themes/base/minified/jquery-ui.min.css" %}" type="text/css" media="screen" />
{% endblock %}
{% block scripts %}
{{ block.super }}
{% csrf_token %}
<script src="{% fingerprint "toolchains/js/models.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "toolchains/js/common.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "jquery-ui/ui/minified/jquery.ui.core.min.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "jquery-ui/ui/minified/jquery.ui.position.min.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "jquery-ui/ui/minified/jquery.ui.widget.min.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "jquery-ui/ui/minified/jquery.ui.button.min.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "jquery-ui/ui/minified/jquery.ui.dialog.min.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "toolchains/js/dialogs.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "toolchains/js/editor.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "toolchains/js/utils.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "databases/js/utils.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "ui/js/listselector.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "ui/js/smartselector.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "spectrum/spectrum.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "mousetrap/mousetrap.min.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "mousetrap/plugins/pause/mousetrap-pause.min.js" %}" type="text/javascript" charset="utf-8"></script>
<script src="{% fingerprint "underscore/underscore-min.js" %}" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
function updateValidity(errors)
{
var target = $('#validation_errors')[0];
$(target).empty();
if ((errors !== null) && (errors.length > 0))
{
$('#editor_error_icon').show();
if (errors[0] == '"')
errors = JSON.parse(errors);
target.innerHTML = errors.replace(/\n/g, '<br />');
$('html, body').animate({
scrollTop: $(target).offset().top
}, 1000);
}
else
{
$('#editor_error_icon').hide();
}
}
function setupEditor(databases, toolchains)
{
{% if not edition and toolchain_version == 1 %}
$('#name_editor').show();
{% endif %}
$('.toolchain_editor').show();
// Setup the editor
var list_selector = new beat.ui.ListSelector('list_selector');
var smart_selector = new beat.ui.SmartSelector('smart_selector');
var import_settings_dialog = new beat.toolchains.dialogs.ImportSettings('import_settings', '{% url 'api_toolchains:all' %}');
var toolchain_editor = new beat.toolchains.editor.ToolchainEditor('editor', '{% static "ui/images/icons" %}',
list_selector, smart_selector,
import_settings_dialog);
var declaration = {{ declaration|safe }};
var toolchain = new beat.toolchains.models.Toolchain(declaration);
toolchain_editor.setToolchain(toolchain);
toolchain_editor.setDatabaseTemplates(databases);
toolchain_editor.setImportableToolchains(toolchains);
updateValidity('{{ errors }}');
{% if not edition %}
{% if toolchain_version == 1 %}
$('#toolchain_name').keyup(function() {
if ($('#toolchain_name')[0].value.trim().length > 0)
toolchain_editor.toolbar.enableSaveButton();
});
{% else %}
toolchain_editor.toolbar.enableSaveButton();
{% endif %}
{% endif %}
// Callbacks of the toolchain editor
toolchain_editor.callbacks.onSave = function(declaration) {
updateValidity('');
{% if not edition %}
{% if toolchain_version == 1 %}
if ($('#toolchain_name')[0].value.trim() == '')
{
updateValidity('Invalid toolchain name');
return false;
}
{% endif %}
{% endif %}
$.ajax({
{% if not edition %}
type: "POST",
url: '{% url 'api_toolchains:list_create' toolchain_author %}',
{% else %}
type: "PUT",
url: '{% url 'api_toolchains:object' toolchain_author toolchain_name toolchain_version %}?fields=errors',
{% endif %}
data: JSON.stringify({
{% if not edition %}
{% if toolchain_version > 1 %}
name: '{{ toolchain_name }}',
version: '{{ toolchain_version }}',
previous_version: '{{ toolchain_author }}/{{ toolchain_name }}/{{ toolchain_version|add:-1 }}',
{% else %}
name: $('#toolchain_name')[0].value.trim(),
{% endif %}
{% if fork_of %}
fork_of: '{{ fork_of.fullname }}',
{% endif %}
short_description: '{{ short_description|escapejs }}',
description: '{{ description|escapejs }}',
{% endif %}
declaration: declaration,
strict: false,
}),
contentType: "application/json; charset=utf-8",
success: function(data) {
if (data.errors)
updateValidity(data.errors.split('\n'));
{% if not edition and toolchain_version == 1 %}
else
window.location = '{% url "toolchains:edit" toolchain_author "__-__" toolchain_version %}'.replace("__-__", data.name);
{% endif %}
},
error: function(jqXHR, textStatus, errorThrown) {
if (jqXHR.status == 404)
{
alert('Error: Toolchain not found');
}
else if (jqXHR.status == 403)
{
alert('Error: Unauthorized access');
}
else if (jqXHR.responseText.length > 0)
{
updateValidity(jqXHR.responseText);
}
else
{
alert('Error: ' + errorThrown);
}
},
});
};
toolchain_editor.callbacks.onClose = function(declaration) {
{% if not edition %}
window.location = '{% url "toolchains:list" toolchain_author %}';
{% else %}
window.location = '{% url "toolchains:view" toolchain_author toolchain_name toolchain_version %}';
{% endif %}
};
}
</script>
{% endblock %}
{% block content %}
<div id="title" class="row">
<div class="col-sm-12">
<h3>
<ol class="breadcrumb">
{% if edition %}
<li>Edit</li>
<li><a data-toggle="tooltip" data-placement="bottom" title="View all your toolchains" href="{% url 'toolchains:list' request.user.username %}">toolchains</a></li>
<li><a data-toggle="tooltip" data-placement="bottom" title="View all {{ toolchain_author }}'s toolchains" href="{% url 'toolchains:list' toolchain_author %}">{{ toolchain_author }}</a></li>
<li><a data-toggle="tooltip" data-placement="bottom" title="View the latest version of this toolchain" href="{% url 'toolchains:view-latest' toolchain_author toolchain_name %}">{{ toolchain_name }}</a></li>
<li>{{ toolchain_version }}{# to be ended after endif #}
{% elif fork_of %}
<li>Fork</li>
<li><a data-toggle="tooltip" data-placement="bottom" title="View all your toolchains" href="{% url 'toolchains:list' request.user.username %}">toolchains</a></li>
<li><a data-toggle="tooltip" data-placement="bottom" title="View all {{ toolchain_author }}'s toolchains" href="{% url 'toolchains:list' fork_of.author.username %}">{{ fork_of.author.username }}</a></li>
<li><a data-toggle="tooltip" data-placement="bottom" title="View the latest version of this toolchain" href="{% url 'toolchains:view-latest' fork_of.author.username fork_of.name %}">{{ fork_of.name }}</a></li>
<li><a data-toggle="tooltip" data-placement="bottom" title="View the toolchain you're forking" href="{% url 'toolchains:view' fork_of.author.username fork_of.name fork_of.version %}">{{ fork_of.version }}</a>{# to be ended after endif #}
{% elif toolchain_version > 1 %}
<li>Create</li>
<li><a data-toggle="tooltip" data-placement="bottom" title="View all your toolchains" href="{% url 'toolchains:list' request.user.username %}">toolchains</a></li>
<li><a data-toggle="tooltip" data-placement="bottom" title="View all {{ toolchain_author }}'s toolchains" href="{% url 'toolchains:list' toolchain_author %}">{{ toolchain_author }}</a></li>
<li><a data-toggle="tooltip" data-placement="bottom" title="View the latest version of this toolchain" href="{% url 'toolchains:view-latest' toolchain_author toolchain_name %}">{{ toolchain_name }}</a></li>
<li>{{ toolchain_version }}{# to be ended after endif #}
{% else %}
<li>New toolchain
{% endif %}
<i id="editor_error_icon" class="fa fa-warning fa-lg" title="This toolchain can't be used in an experiment due to the errors indicated at the bottom of the page" style="display:none;"></i>
</li>
</ol>
</h3>
</div>
</div>
<div class="row">
<div class="col-sm-12 progress">
<i class="fa fa-refresh fa-spin fa-lg"></i>
</div>
</div>
{% if not edition and toolchain_version == 1 %}
<div class="row">
<div id="name_editor" class="col-sm-8 contribution_editor" style="display: none;">
<div class="form-inline">
<div class="form-group">
<label class="control-label" for="toolchain_name">Name:</label>
<input id="toolchain_name" class="form-control contribution_name" type="text" size="100%" />
<p class="help">The name for this toolchain (space-like characters will be automatically replaced by dashes)</p>
</div>
</div>
</div>
</div>
{% endif %}
<div class="row margin_bottom_15">
<div class="col-sm-12">
{% toolchain_editor "editor" %}
</div>
</div>
<div class="row margin_bottom_15">
<div id="validation_errors" class="col-sm-12">
</div>
</div>
{% list_selector "list_selector" %}
{% smart_selector "smart_selector" %}
{% toolchain_import_settings "import_settings" %}
<script type="text/javascript">
jQuery(document).ready(function() {
$.ajaxSetup({
beforeSend: function(xhr, settings) {
xhr.setRequestHeader('X-CSRFToken', $.cookie('csrftoken'));
}
});
var database_templates = null;
var toolchains = null;
function _update()
{
if ((database_templates !== null) && (toolchains !== null))
{
$('.progress').hide();
setupEditor(database_templates, toolchains);
}
}
beat.databases.utils.getTemplates('{{ URL_PREFIX }}', function(data) {
if (typeof(data) == 'object')
{
database_templates = data;
_update();
}
else
{
alert(data);
}
});
$.get('{% url 'api_toolchains:all' %}?fields=name,short_description', function(data) {
toolchains = data;
_update();
});
});
</script>
{% endblock %}
......@@ -41,14 +41,6 @@
<a class="btn btn-default btn-delete" onclick="modal_delete('toolchain', '{{ object.fullname }}', '{% url 'api_toolchains:all' %}', '{% url 'toolchains:list' request.user.username %}');" data-toggle="tooltip" data-placement="bottom" title="Delete"><i class="fa fa-times fa-lg"></i></a>
{% endif %}
<!-- New version, needs to be the owner -->
<a class="btn btn-default btn-new-version" href="{% url 'toolchains:new-version' object.name %}" data-toggle="tooltip" data-placement="bottom" title="New version"><i class="fa fa-copy fa-lg"></i></a>
<!-- Edit, needs to be modifiable -->
{% if object.modifiable %}
<a class="btn btn-default btn-edit" href="{% url 'toolchains:edit' object.author.username object.name object.version %}" data-toggle="tooltip" data-placement="bottom" title="Edit"><i class="fa fa-edit fa-lg"></i></a>
{% endif %}
{% endifequal %}
<!-- Edit, needs to be modifiable -->
......@@ -56,16 +48,6 @@
<a class="btn btn-default btn-edit" href="{% url 'admin:toolchains_toolchain_change' object.id %}" data-toggle="tooltip" data-placement="bottom" title="Edit as admin"><i class="fa fa-cogs fa-lg"></i></a>
{% endif %}
{% if not request.user.is_anonymous %}
<!-- New experiment button, needs to be logged in -->
<a class="btn btn-default btn-new-experiment" href="{% url 'experiments:new-from-toolchain' object.author.username object.name object.version %}" data-toggle="tooltip" data-placement="bottom" title="New experiment"><i class="fa fa-cog fa-lg"></i></a>
<!-- Fork button, needs to be logged in -->
<a class="btn btn-default btn-fork" href="{% url 'toolchains:fork' object.author.username object.name object.version %}" data-toggle="tooltip" data-placement="bottom" title="Fork"><i class="fa fa-code-fork fa-lg"></i></a>
{% endif %}
<!-- Search, works for logged-in and anonymous users -->
<a class="btn btn-default btn-search" href="{% url 'search:search' %}?query=type:results%20tc:{{ object.fullname }}" data-toggle="tooltip" data-placement="bottom" title="Search experiments"><i class="fa fa-search fa-lg"></i></a>
......
{% comment %}
* Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/
* Contact: beat.support@idiap.ch
*
* This file is part of the beat.web module of the BEAT platform.
*
* Commercial License Usage
* Licensees holding valid commercial BEAT licenses may use this file in
* accordance with the terms contained in a written agreement between you
* and Idiap. For further information contact tto@idiap.ch
*
* Alternatively, this file may be used under the terms of the GNU Affero
* Public License version 3 as published by the Free Software and appearing
* in the file LICENSE.AGPL included in the packaging of this file.
* The BEAT platform is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero Public License along
* with the BEAT platform. If not, see http://www.gnu.org/licenses/.
{% endcomment %}
{% load ui_tags %}
<div id="{{ editor_id }}" class="toolchain_editor progress">
<div class="toolbar" style="display:none">
<span id="close" class="btn btn-default btn-sm" title="Close the editor and go back to the toolchain page">
<i class="fa fa-arrow-circle-o-left fa-lg"></i>
</span>
<span id="save" class="btn btn-default btn-sm disabled" title="Save the toolchain">
<i class="fa fa-floppy-o fa-lg"></i>
</span>
<span id="undo" class="btn btn-default btn-sm disabled" title="Undo">
<i class="fa fa-undo fa-lg"></i>
</span>
<span id="redo" class="btn btn-default btn-sm disabled" title="Redo">
<i class="fa fa-repeat fa-lg"></i>
</span>
<span id="zoom-out" class="btn btn-default btn-sm" title="Zoom out">
<i class="fa fa-search-minus fa-lg"></i>
</span>
<span id="zoom-in" class="btn btn-default btn-sm" title="Zoom in">
<i class="fa fa-search-plus fa-lg"></i>
</span>
<span id="center-view" class="btn btn-default btn-sm" title="Center the view on the toolchain">
<i class="fa fa-arrows-alt fa-lg"></i>
</span>
</div>
<div class="components_bar" style="display:none">
<div id="protocol" class="button creation" title="Add a database">
<div class="image"></div>
<span class="text">Database</span>
</div>
<div id="dataset" class="button creation" title="Add a dataset">
<div class="image"></div>
<span class="text">Dataset</span>
</div>
<div id="block" class="button creation" title="Add a block">
<div class="image"></div>
<span class="text">Block</span>
</div>
<div id="analyzer" class="button creation" title="Add an analyzer">
<div class="image"></div>
<span class="text">Analyzer</span>
</div>
<div id="toolchain" class="button creation" title="Import another toolchain">
<div class="image"></div>
<span class="text">Import toolchain</span>
</div>
</div>
<canvas class="grid">
To edit a toolchain, please use a modern browser (Mozilla Firefox 3.0+,
Google Chrome 1+, Apple Safari 3+, Opera 9.5+, Microsoft Internet Explorer 9+)
</canvas>
<div class="infobar"></div>
<div class="color_picker_anchor" style="width: 1px; height: 1px;"></div>
{% list_selector "channel_selector" %}
<input type="text" class="textbox" style="display:none" />
</div>
......@@ -50,12 +50,6 @@
{% endif %}
<!-- Notice there can be no div space if vertical-center is used -->
</div><div class="col-sm-2 vertical-center">
{% if owner %}
<a class="btn btn-success btn-sm pull-right" href="{% url 'toolchains:new' %}"><i class="fa fa-plus fa-lg"></i> New</a>
{% endif %}
</div><!-- col -->
</div><!-- row -->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment