blob: 7e1ebb382abfe84d653737e11b52073bee3da8a7 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001{% extends "base.html" %}
2{% load projecttags %}
3{% load humanize %}
Patrick Williamsf1e5d692016-03-30 15:21:19 -05004
5{% block title %} Create a new project - Toaster {% endblock %}
6
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007{% block pagecontent %}
Patrick Williamsc0f7c042017-02-23 20:41:17 -06008<div class="row">
9 <div class="col-md-12">
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010 <div class="page-header">
11 <h1>Create a new project</h1>
12 </div>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013 {% if alert %}
Patrick Williamsc0f7c042017-02-23 20:41:17 -060014 <div class="alert alert-danger" role="alert">{{alert}}</div>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015 {% endif %}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017 <form method="POST">{% csrf_token %}
Patrick Williamsc0f7c042017-02-23 20:41:17 -060018 <div class="form-group" id="validate-project-name">
19 <label class="control-label">Project name <span class="text-muted">(required)</span></label>
20 <input type="text" class="form-control" required id="new-project-name" name="projectname">
21 </div>
22 <p class="help-block text-danger" style="display: none;" id="hint-error-project-name">A project with this name exists. Project names must be unique.</p>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024 <label class="project-form">Project type:</label>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025 {% if releases.count > 0 %}
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080026 <label class="project-form radio" style="padding-left: 35px;"><input id='type-new' type="radio" name="ptype" value="new"/> New project</label>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027 {% endif %}
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028 <label class="project-form radio" style="padding-left: 35px;"><input id='type-import' type="radio" name="ptype" value="import"/> Import command line project</label>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029
30 {% if releases.count > 0 %}
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080031 <div class="release form-group">
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032 {% if releases.count > 1 %}
Patrick Williamsc0f7c042017-02-23 20:41:17 -060033 <label class="control-label">
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 Release
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080035 <span class="glyphicon glyphicon-question-sign get-help" title="The version of the build system you want to use for this project"></span>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036 </label>
Patrick Williamsc0f7c042017-02-23 20:41:17 -060037 <select name="projectversion" id="projectversion" class="form-control">
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038 {% for release in releases %}
39 <option value="{{release.id}}"
40 {%if defaultbranch == release.name %}
41 selected
42 {%endif%}
43 >{{release.description}}</option>
44 {% endfor %}
45 </select>
Patrick Williamsc0f7c042017-02-23 20:41:17 -060046 <div class="row">
47 <div class="col-md-4">
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 {% for release in releases %}
Patrick Williamsc0f7c042017-02-23 20:41:17 -060049 <div class="helptext" id="description-{{release.id}}" style="display: none">
50 <span class="help-block">{{release.helptext|safe}}</span>
51 </div>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052 {% endfor %}
Brad Bishop5dd7cbb2018-09-05 22:26:40 -070053 </div>
54 </div>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055 {% else %}
56 <input type="hidden" name="projectversion" value="{{releases.0.id}}"/>
57 {% endif %}
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080058
59 <input type="checkbox" class="checkbox-mergeattr" name="mergeattr" value="mergeattr"> Merged Toaster settings (Command line user compatibility)
60 <span class="glyphicon glyphicon-question-sign get-help" title="Place the Toaster settings into the standard 'local.conf' and 'bblayers.conf' instead of 'toaster_bblayers.conf' and 'toaster.conf'"></span>
61
62 </div>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063 {% endif %}
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080064
65 <div class="build-import form-group" id="import-project">
66 <label class="control-label">Import existing project directory
67 <span class="glyphicon glyphicon-question-sign get-help" title="Enter a path to an existing build directory, import the existing settings, and create a Toaster Project for it."></span>
68 </label>
69 <input style="width: 33%;"type="text" class="form-control" required id="import-project-dir" name="importdir">
70 </div>
71
Patrick Williamsc0f7c042017-02-23 20:41:17 -060072 <div class="top-air">
73 <input type="submit" id="create-project-button" class="btn btn-primary btn-lg" value="Create project"/>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 <span class="help-inline" style="vertical-align:middle;">To create a project, you need to enter a project name</span>
75 </div>
Patrick Williamsc0f7c042017-02-23 20:41:17 -060076
Patrick Williamsc124f4f2015-09-15 14:41:29 -050077 </form>
Patrick Williamsc0f7c042017-02-23 20:41:17 -060078 </div>
Patrick Williamsc124f4f2015-09-15 14:41:29 -050079 </div>
80
81 <script type="text/javascript">
82 $(document).ready(function () {
83 // hide the new project button
84 $("#new-project-button").hide();
85 $('.btn-primary').attr('disabled', 'disabled');
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080086 $('#type-new').attr('checked', 'checked');
Patrick Williamsc124f4f2015-09-15 14:41:29 -050087
88 // enable submit button when all required fields are populated
89 $("input#new-project-name").on('input', function() {
90 if ($("input#new-project-name").val().length > 0 ){
91 $('.btn-primary').removeAttr('disabled');
92 $(".help-inline").css('visibility','hidden');
93 }
94 else {
95 $('.btn-primary').attr('disabled', 'disabled');
96 $(".help-inline").css('visibility','visible');
97 }
98 });
99
100 // show relevant help text for the selected release
101 var selected_release = $('select').val();
102 $("#description-" + selected_release).show();
103
104
105 $('select').change(function(){
106 var new_release = $('select').val();
107 $(".helptext").hide();
108 $('#description-' + new_release).fadeIn();
109 });
110
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600111 libtoaster.makeProjectNameValidation($("#new-project-name"),
112 $("#hint-error-project-name"), $("#validate-project-name"),
113 $(".btn-primary"));
114
115
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800116 // Hide the project release when you select an analysis project
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117 function projectType() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800118 if ($("input[type='radio']:checked").val() == 'new') {
119 $('.build-import').fadeOut();
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500120 $('.release').fadeIn();
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800121 $('#import-project-dir').removeAttr('required');
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500122 }
123 else {
124 $('.release').fadeOut();
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800125 $('.build-import').fadeIn();
126 $('#import-project-dir').attr('required', 'required');
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500127 }
128 }
129 projectType();
130
131 $('input:radio').change(function(){
132 projectType();
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800133 });
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500134 });
135 </script>
136
137{% endblock %}