mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 12:49:01 +02:00

Typo, there has to be a ? in front of the id or otherwise we don't get linked to the right commit. This would have affected recently added layers with a cgit web frontend. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
436 lines
18 KiB
HTML
436 lines
18 KiB
HTML
{% extends "base.html" %}
|
|
{% load i18n %}
|
|
{% load static %}
|
|
|
|
{% comment %}
|
|
|
|
layerindex-web - layer editing form page template
|
|
|
|
Copyright (C) 2013-2018 Intel Corporation
|
|
Licensed under the MIT license, see COPYING.MIT for details
|
|
|
|
{% endcomment %}
|
|
|
|
<!--
|
|
{% block title_append %} - edit layer{% endblock %}
|
|
-->
|
|
|
|
{% block topfunctions %}
|
|
<!-- Remove submit link/tools drop-down added by base.html, otherwise clicking it may lose changes -->
|
|
{% endblock %}
|
|
|
|
|
|
{% block content %}
|
|
{% autoescape on %}
|
|
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
{% block heading %}
|
|
<div class="page-header">
|
|
<h1>Edit layer</h1>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block formtop %}
|
|
{% endblock %}
|
|
<form id="edit_layer_form" method="post">
|
|
{% csrf_token %}
|
|
{% for hidden in form.hidden_fields %}
|
|
{{ hidden }}
|
|
{% endfor %}
|
|
|
|
<div class="formfields">
|
|
{% for field in form.visible_fields %}
|
|
{% if field.name != 'captcha' %}
|
|
{% if field.errors %}
|
|
<div class="form-group alert alert-danger">
|
|
{{ field.errors }}
|
|
{% else %}
|
|
<div class="form-group">
|
|
{% endif %}
|
|
<div class="control-label">
|
|
{{ field.label_tag }}
|
|
</div>
|
|
<div class="controls">
|
|
{% if field.name == 'deps' %}
|
|
<div class="form-group has-feedback has-clear">
|
|
<input type="text" class="form-control" id="layersearchtext" placeholder="search layers">
|
|
<a class="glyphicon glyphicon-remove-sign form-control-feedback form-control-clear" id="layersearchclear" style="pointer-events: auto; text-decoration: none;cursor: pointer;"></a>
|
|
</div>
|
|
<div class="scrolling">
|
|
<table class="layerstable"><tbody>
|
|
{% for deplayer in deplistlayers %}
|
|
{% if deplayer.id in form.checked_deps %}
|
|
<tr>
|
|
<td class="checkboxtd"><input type="checkbox" name="deps" value="{{ deplayer.id }}" id="id_deps_{{forloop.counter}}" checked="checked" /></td>
|
|
{% if deplayer.status == 'N' %}
|
|
<td><label class="text-muted" for="id_deps_{{forloop.counter}}">{{ deplayer.name }} (unpublished)</label></td>
|
|
{% else %}
|
|
<td><label for="id_deps_{{forloop.counter}}">{{ deplayer.name }}</label></td>
|
|
{% endif %}
|
|
</tr>
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% for deplayer in deplistlayers %}
|
|
{% if not deplayer.id in form.checked_deps %}
|
|
<tr>
|
|
<td class="checkboxtd"><input type="checkbox" name="deps" value="{{ deplayer.id }}" id="id_deps_{{forloop.counter}}" /></td>
|
|
{% if deplayer.status == 'N' %}
|
|
<td><label class="text-muted" for="id_deps_{{forloop.counter}}">{{ deplayer.name }} (unpublished)</label></td>
|
|
{% else %}
|
|
<td><label for="id_deps_{{forloop.counter}}">{{ deplayer.name }}</label></td>
|
|
{% endif %}
|
|
</tr>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</tbody></table>
|
|
</div>
|
|
{% else %}
|
|
{{ field }}
|
|
{% endif %}
|
|
<span class="help-block custom-help">
|
|
{{ field.help_text }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% if field.name == 'vcs_web_url' %}
|
|
<div class="control-label">
|
|
Web interface type
|
|
</div>
|
|
<div class="controls">
|
|
<div class="formfield-div">
|
|
<select id="idx_vcs_web_type" class="form-control">
|
|
<option>(custom)</option>
|
|
<option>cgit</option>
|
|
<option>gitweb</option>
|
|
<option>gitlab</option>
|
|
</select>
|
|
</div>
|
|
<span class="help-block custom-help">
|
|
Type of web interface (helps to auto-determine other URL fields)
|
|
</span>
|
|
</div>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
<h3 id="maintainers">Maintainers</h3>
|
|
{{ maintainerformset.non_form_errors }}
|
|
{{ maintainerformset.management_form }}
|
|
{% for maintainerform in maintainerformset %}
|
|
<div class="maintainerform" id="maintainerform-{{forloop.counter0}}">
|
|
<h4>Maintainer {{forloop.counter}}</h4>
|
|
<div class="maintainerformfields">
|
|
{% for hidden in maintainerform.hidden_fields %}
|
|
{{ hidden }}
|
|
{% endfor %}
|
|
|
|
{% for field in maintainerform.visible_fields %}
|
|
{% if field.errors %}
|
|
<div class="form-group alert alert-danger">
|
|
{{ field.errors }}
|
|
{% else %}
|
|
<div class="form-group">
|
|
{% endif %}
|
|
<div class="control-label">
|
|
{{ field.label_tag }}
|
|
</div>
|
|
<div class="controls">
|
|
{{ field }}
|
|
<span class="help-block custom-help">
|
|
{{ field.help_text }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
<p><a href="#" class="btn btn-default btn-sm" id="addanothermaintainer"><i class="glyphicon glyphicon-plus" aria-hidden="true"></i>Add maintainer</a><p>
|
|
|
|
|
|
{% if form.captcha %}
|
|
<div class="captchafield">
|
|
<h3>Verification</h3>
|
|
{% if form.captcha.errors %}
|
|
<div class="form-group alert alert-danger">
|
|
{{ form.captcha.errors }}
|
|
{% else %}
|
|
<div class="form-group">
|
|
{% endif %}
|
|
<div class="controls">
|
|
{{ form.captcha }}
|
|
<span class="help-block custom-help">
|
|
{{ form.captcha.help_text }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="submitbuttons">
|
|
{% block submitbuttons %}
|
|
<input type="submit" value="Save layer" class="btn btn-primary btn-large submitbutton" />
|
|
<a href="{{ return_url }}" class="btn btn-default btn-large">Cancel</a>
|
|
{% endblock %}
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
{% endautoescape %}
|
|
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script>
|
|
if (typeof String.prototype.startsWith != 'function') {
|
|
String.prototype.startsWith = function (str){
|
|
return this.slice(0, str.length) == str;
|
|
};
|
|
}
|
|
|
|
function AutoWebFields(repoval) {
|
|
// Auto-determine web interface URLs from repo URL
|
|
if( repoval[repoval.length-1] == '/' )
|
|
repoval = repoval.slice(0, repoval.length-1)
|
|
|
|
if( repoval.startsWith('git://git.openembedded.org/') ) {
|
|
reponame = repoval.replace(/^.*\//, '')
|
|
this.vcs_web_url = 'http://cgit.openembedded.org/' + reponame
|
|
this.vcs_web_tree_base_url = 'http://cgit.openembedded.org/' + reponame + '/tree/%path%?h=%branch%'
|
|
this.vcs_web_file_base_url = 'http://cgit.openembedded.org/' + reponame + '/tree/%path%?h=%branch%'
|
|
this.vcs_web_commit_url = 'http://cgit.openembedded.org/' + reponame + '/commit/?id=%hash%'
|
|
this.vcs_web_type = 'cgit'
|
|
}
|
|
else if( repoval.startsWith('git://git.yoctoproject.org/') ) {
|
|
reponame = repoval.replace(/^.*\//, '')
|
|
this.vcs_web_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame
|
|
this.vcs_web_tree_base_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%'
|
|
this.vcs_web_file_base_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%'
|
|
this.vcs_web_commit_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/commit/?id=%hash%'
|
|
this.vcs_web_type = 'cgit'
|
|
}
|
|
else if( repoval.startsWith('git://github.com/') ) {
|
|
reponame = repoval.replace(/^.*github.com\//, '')
|
|
reponame = reponame.replace(/.git$/, '')
|
|
this.vcs_web_url = 'http://github.com/' + reponame
|
|
this.vcs_web_tree_base_url = 'http://github.com/' + reponame + '/tree/%branch%/'
|
|
this.vcs_web_file_base_url = 'http://github.com/' + reponame + '/blob/%branch%/'
|
|
this.vcs_web_commit_url = 'http://github.com/' + reponame + '/commit/%hash%/'
|
|
this.vcs_web_type = '(custom)'
|
|
}
|
|
else if( repoval.startsWith('git://gitlab.com/') ) {
|
|
reponame = repoval.replace(/^.*gitlab.com\//, '')
|
|
reponame = reponame.replace(/.git$/, '')
|
|
this.vcs_web_url = 'http://gitlab.com/' + reponame
|
|
this.vcs_web_tree_base_url = 'http://gitlab.com/' + reponame + '/tree/%branch%/'
|
|
this.vcs_web_file_base_url = 'http://gitlab.com/' + reponame + '/blob/%branch%/'
|
|
this.vcs_web_commit_url = 'http://gitlab.com/' + reponame + '/commit/%hash%/'
|
|
this.vcs_web_type = '(custom)'
|
|
}
|
|
else if( repoval.startsWith('git://bitbucket.org/') ) {
|
|
reponame = repoval.replace(/^.*bitbucket.org\//, '')
|
|
reponame = reponame.replace(/.git$/, '')
|
|
this.vcs_web_url = 'http://bitbucket.org/' + reponame
|
|
this.vcs_web_tree_base_url = 'http://bitbucket.org/' + reponame + '/src/%branch%/%path%?at=%branch%'
|
|
this.vcs_web_file_base_url = 'http://bitbucket.org/' + reponame + '/src/%branch%/%path%?at=%branch%'
|
|
this.vcs_web_commit_url = 'http://bitbucket.org/' + reponame + '/commits/%hash%'
|
|
this.vcs_web_type = '(custom)'
|
|
}
|
|
else {
|
|
this.vcs_web_url = ''
|
|
this.vcs_web_tree_base_url = ''
|
|
this.vcs_web_file_base_url = ''
|
|
this.vcs_web_commit_url = ''
|
|
this.vcs_web_type = '(custom)'
|
|
}
|
|
};
|
|
|
|
auto_web_url_field = function (e) {
|
|
// Auto-determine web interface type from URL
|
|
vcs_web_url = $('#id_vcs_web_url').val()
|
|
if ( vcs_web_url.indexOf('/cgit.cgi/') > -1 || vcs_web_url.indexOf('/cgit/') > -1 ) {
|
|
$('#idx_vcs_web_type').val('cgit')
|
|
auto_web_type_field(e)
|
|
}
|
|
else if ( vcs_web_url.indexOf('a=summary') > -1 ) {
|
|
$('#idx_vcs_web_type').val('gitweb')
|
|
auto_web_type_field(e)
|
|
}
|
|
}
|
|
|
|
auto_web_type_field = function (e) {
|
|
// Auto-determine web interface tree/file URLs based on type
|
|
type = $('#idx_vcs_web_type').val()
|
|
if (type == '(custom)') {
|
|
readonly = $('#idx_vcs_web_type').prop('disabled')
|
|
$('#id_vcs_web_tree_base_url').prop('readonly', readonly)
|
|
$('#id_vcs_web_file_base_url').prop('readonly', readonly)
|
|
$('#id_vcs_web_commit_url').prop('readonly', readonly)
|
|
}
|
|
else {
|
|
$('#id_vcs_web_tree_base_url').prop('readonly', true)
|
|
$('#id_vcs_web_file_base_url').prop('readonly', true)
|
|
$('#id_vcs_web_commit_url').prop('readonly', true)
|
|
vcs_web_url = $('#id_vcs_web_url').val()
|
|
if (vcs_web_url) {
|
|
if (vcs_web_url.endsWith('/')) {
|
|
vcs_web_url = vcs_web_url.slice(0, -1)
|
|
}
|
|
if (type == 'cgit') {
|
|
$('#id_vcs_web_tree_base_url').val('readonly', true)
|
|
$('#id_vcs_web_file_base_url').prop('readonly', true)
|
|
$('#id_vcs_web_commit_url').prop('readonly', true)
|
|
if (e) {
|
|
$('#id_vcs_web_tree_base_url').val(vcs_web_url + '/tree/%path%?h=%branch%')
|
|
$('#id_vcs_web_file_base_url').val(vcs_web_url + '/tree/%path%?h=%branch%')
|
|
$('#id_vcs_web_commit_url').val(vcs_web_url + '/commit/?id=%hash%')
|
|
}
|
|
}
|
|
else if (type == 'gitweb') {
|
|
$('#id_vcs_web_tree_base_url').val('readonly', true)
|
|
$('#id_vcs_web_file_base_url').prop('readonly', true)
|
|
$('#id_vcs_web_commit_url').prop('readonly', true)
|
|
if (e) {
|
|
spliturl = vcs_web_url.split('?')
|
|
if (spliturl.length > 1) {
|
|
params = spliturl[1].split(';')
|
|
newparams = []
|
|
for (i = 0; i < params.length; i++) {
|
|
if (!params[i].startsWith('a=')) {
|
|
newparams.push(params[i])
|
|
}
|
|
}
|
|
newparamsstr = newparams.join(';')
|
|
if( newparamsstr ) {
|
|
newparamsstr += ';'
|
|
}
|
|
vcs_web_url = spliturl[0] + '?' + newparamsstr
|
|
}
|
|
else {
|
|
vcs_web_url = spliturl[0] + '?'
|
|
}
|
|
$('#id_vcs_web_tree_base_url').val(vcs_web_url + 'a=tree;f=%path%;hb=refs/heads/%branch%')
|
|
$('#id_vcs_web_file_base_url').val(vcs_web_url + 'a=blob;f=%path%;hb=refs/heads/%branch%')
|
|
$('#id_vcs_web_commit_url').val(vcs_web_url + 'a=commit;h=%hash%')
|
|
}
|
|
}
|
|
else if (type == 'gitlab') {
|
|
$('#id_vcs_web_tree_base_url').val('readonly', true)
|
|
$('#id_vcs_web_file_base_url').prop('readonly', true)
|
|
$('#id_vcs_web_commit_url').prop('readonly', true)
|
|
if (e) {
|
|
$('#id_vcs_web_tree_base_url').val(vcs_web_url + '/tree/%branch%/%path%')
|
|
$('#id_vcs_web_file_base_url').val(vcs_web_url + '/blob/%branch%/%path%')
|
|
$('#id_vcs_web_commit_url').val(vcs_web_url + '/commit/%hash%')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
auto_web_fields = function (e) {
|
|
repoval = $('#id_vcs_url').val()
|
|
awf = new AutoWebFields(repoval)
|
|
if (awf.vcs_web_url) {
|
|
if (e) {
|
|
$('#id_vcs_web_url').val(awf.vcs_web_url)
|
|
$('#id_vcs_web_tree_base_url').val(awf.vcs_web_tree_base_url)
|
|
$('#id_vcs_web_file_base_url').val(awf.vcs_web_file_base_url)
|
|
$('#id_vcs_web_commit_url').val(awf.vcs_web_commit_url)
|
|
$('#idx_vcs_web_type').val(awf.vcs_web_type)
|
|
}
|
|
$('#id_vcs_web_url').prop('readonly', true);
|
|
$('#idx_vcs_web_type').prop('disabled', true);
|
|
}
|
|
else {
|
|
$('#id_vcs_web_url').prop('readonly', false);
|
|
$('#idx_vcs_web_type').prop('disabled', false);
|
|
}
|
|
|
|
auto_web_type_field(e)
|
|
};
|
|
|
|
split_email = function() {
|
|
// Split email name/email address pairs
|
|
name_input = $(this)
|
|
split_regex = /^"?([^"@$<>]+)"? *<([^<> ]+)>[ -]*(.*)?$/
|
|
matches = split_regex.exec(name_input.val())
|
|
if( matches ){
|
|
name_input.val($.trim(matches[1]))
|
|
email_id = name_input.attr('id').replace('-name', '-email')
|
|
$('#' + email_id).val($.trim(matches[2]))
|
|
resp_id = email_id.replace('-email', '-responsibility')
|
|
currval = $('#' + resp_id).val()
|
|
// Set the responsibility with the remainder of the value unless the user has entered a value for
|
|
// responsibility already
|
|
if( currval == window['last_' + resp_id] || currval == "" ) {
|
|
newval = $.trim(matches[3])
|
|
$('#' + resp_id).val(newval)
|
|
window['last_' + resp_id] = newval
|
|
}
|
|
}
|
|
}
|
|
|
|
expand_maintainer = function() {
|
|
for(i=0;i<{{ maintainerformset.total_form_count }};i++) {
|
|
maintbox = $('#maintainerform-' + i)
|
|
if( maintbox.is(':hidden') ) {
|
|
maintbox.slideToggle();
|
|
if( i == {{maintainerformset.total_form_count}} - 1 )
|
|
$('#addanothermaintainer').hide()
|
|
break
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function clearLayerSearch() {
|
|
$("#layersearchtext").val('');
|
|
$(".layerstable > tbody > tr").show();
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
$('.maintainerform').hide()
|
|
|
|
for(i=0;i<{{ maintainerformset.total_form_count }};i++) {
|
|
name_input = $('#id_layermaintainer_set-' + i + '-name')
|
|
name_input.change(split_email)
|
|
resp_id = 'id_layermaintainer_set-' + i + '-responsibility'
|
|
window['last_' + resp_id] = ""
|
|
if( i==0 || name_input.val() )
|
|
$('#maintainerform-' + i).show()
|
|
}
|
|
$('#addanothermaintainer').click(expand_maintainer)
|
|
|
|
$('#id_vcs_url').change(auto_web_fields)
|
|
$('#id_vcs_web_url').change(auto_web_url_field)
|
|
$('#idx_vcs_web_type').change(auto_web_type_field)
|
|
auto_web_fields(null)
|
|
|
|
{% if not allow_base_type %}
|
|
$("#id_layer_type option[value='A']").remove();
|
|
{% endif %}
|
|
|
|
firstfield = $("#edit_layer_form input:text, #edit_layer_form textarea").first();
|
|
if( ! firstfield.val() )
|
|
firstfield.focus()
|
|
});
|
|
|
|
$("#layersearchtext").on("input", function() {
|
|
var value = $(this).val().toLowerCase();
|
|
$(".layerstable > tbody > tr").filter(function() {
|
|
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
|
|
});
|
|
});
|
|
|
|
$("#layersearchclear").click(function(){
|
|
clearLayerSearch();
|
|
$("#layersearchtext").focus();
|
|
});
|
|
|
|
</script>
|
|
{% endblock %}
|