1{% extends project_specific|yesno:"baseprojectspecificpage.html,base.html" %}
2{% load projecttags %}
3{% load humanize %}
4{% load static %}
5{% block title %} Import layer - {{project.name}} - Toaster {% endblock %}
6{% block pagecontent %}
7
8<div class="row">
9  {% include project_specific|yesno:"project_specific_topbar.html,projecttopbar.html" %}
10  {% if project and project.release %}
11  <script src="{% static 'js/layerDepsModal.js' %}"></script>
12  <script src="{% static 'js/importlayer.js' %}"></script>
13  <script>
14  $(document).ready(function (){
15    var ctx = {
16      xhrLayerUrl : "{% url 'xhr_layer' project.id %}",
17      xhrGitRevTypeAheadUrl : "{% url 'xhr_gitrevtypeahead' %}",
18    };
19
20    try {
21      importLayerPageInit(ctx);
22    } catch (e) {
23      document.write("Sorry, An error has occurred loading this page");
24      console.warn(e);
25    }
26  });
27  </script>
28
29  <form class="col-md-11">
30    <span class="help-block">The layer you are importing must be compatible with <strong>{{project.release.description}}</strong>, which is the release you are using in this project.</span>
31    <div class="alert alert-error" id="import-error" style="display:none">
32      <button type="button" class="close" data-dismiss="alert">&times;</button>
33      <h3>&nbsp;</h3>
34      <p></p>
35      <ul></ul>
36    </div>
37    <fieldset>
38      <div class="form-group" id="layer-name-ctrl">
39        <label class="control-label" for="import-layer-name">
40          Layer name
41          <span class="glyphicon glyphicon-question-sign get-help" title="Something like 'meta-mylayer'. Your layer name must be unique and can only include letters, numbers and dashes"></span>
42        </label>
43        <input class="form-control" id="import-layer-name" type="text" required autofocus data-autocomplete="off" data-provide="typeahead">
44        <span class="help-block" style="display: none;" id="invalid-layer-name-hint">A valid layer name can only include letters, numbers and dashes</span>
45        <span class="help-inline" style="display: none;" id="duplicated-layer-name-hint"></span>
46      </div>
47    </fieldset>
48    <div id="duplicate-layer-info" style="display:none">
49      <div class="alert alert-warning">
50        <h3>A layer called <a href="" class="dup-layer-link"><span class="dup-layer-name"></span></a> already exists</h3>
51        <p>Layer names must be unqiue. Please use a different layer name.</p>
52        <dl id="git-layer-dup" style="display:none;">
53          <dt>
54          The <span class="dup-layer-name"></span> repository url is
55          </dt>
56          <dd>
57          <span id="dup-layer-vcs-url"></span>
58          </dd>
59          <dt>
60          The <span class="dup-layer-name"></span> revision is
61          </dt>
62          <dd>
63          <span id="dup-layer-revision"></span>
64          </dd>
65        </dl>
66	<dl id="local-layer-dup" style="display:none;">
67	  <dt>
68	    The <span class="dup-layer-name"></span> directory is
69	  </dt>
70	  <dd>
71	    <span id="dup-local-source-dir-name"></span>
72	  </dd>
73	</dl>
74        <p><a href="" class="dup-layer-link">View the <span class="dup-layer-name"></span> layer information</a></p>
75      </div>
76    </div>
77    <fieldset class="fields-apart-from-layer-name" id="repo-select">
78      <legend class="radioLegend">Where is the layer source code?</legend>
79      <div class="radio">
80	<label>
81          <input type="radio" id="git-repo-radio" name="repo" value="git" checked="checked">
82	  In a <strong>Git repository</strong>
83	</label>
84	<p class="help-block radio-help">To build the layer Toaster must be able to access the Git repository, otherwise builds will fail. Toaster will fetch and checkout your chosen Git revision every time you start a build.</p>
85      </div>
86      <div class="radio">
87	<label>
88          <input type="radio" id="local-dir-radio" name="repo" value="local">
89	  In a <strong>directory</strong>
90	</label>
91	<p class="help-block radio-help">Use this option for quick layer development, by simply providing the path to the layer source code.</p>
92      </div>
93    </fieldset>
94    <fieldset class="fields-apart-from-layer-name" id="git-repo">
95      <legend>Git repository information</legend>
96      <div class="form-group">
97        <label for="layer-git-repo-url">
98          Git repository URL
99          <span class="glyphicon glyphicon-question-sign get-help" title="Fetch/clone URL of the repository. Currently, Toaster only supports Git repositories." ></span>
100        </label>
101        <input type="text" id="layer-git-repo-url" class="form-control" required>
102      </div>
103      <div class="form-group">
104        <label for="layer-subdir">
105          Repository subdirectory
106          <span class="text-muted">(optional)</span>
107          <span class="glyphicon glyphicon-question-sign get-help" title="Subdirectory within the repository where the layer is located, if not in the root (usually only used if the repository contains more than one layer)"></span>
108        </label>
109        <input type="text" class="form-control" id="layer-subdir">
110      </div>
111      <div class="form-group" id="layer-revision-ctrl">
112        <label for="layer-git-ref">
113          Git revision
114          <span class="glyphicon glyphicon-question-sign get-help" title="You can provide a Git branch, a tag or a commit SHA as the revision"></span>
115        </label>
116        <span style="display: block">
117        <input type="text" class="form-control" id="layer-git-ref" autocomplete="off" data-minLength="1" data-autocomplete="off" data-provide="typeahead" required>
118        </span>
119        <span class="help-block has-error" style="display:none;" id="invalid-layer-revision-hint">The "HEAD" branch is reserved (only allowed for the "Local Yocto Project" layers)</span>
120      </div>
121    </fieldset>
122
123    <fieldset class="fields-apart-from-layer-name" id="local-dir" style="display:none;">
124      <legend>Layer directory information</legend>
125      <div class="form-group">
126        <label for="local-dir-path" class="control-label">Enter the absolute path to the layer directory</label>
127        <input type="text" class="form-control" id="local-dir-path" required/>
128        <p class="help-block" id="hintError-dir-path-starts-with-slash" style="display:none;">The absolute path must start with "/".</p>
129        <p class="help-block" id="hintError-dir-path" style="display:none;">The directory path cannot include spaces or any of these characters: \ ? % * : | " " &lt; &gt;</p>
130      </div>
131    </fieldset>
132
133    <fieldset class="fields-apart-from-layer-name">
134      <legend>
135        Layer dependencies
136        <small class="text-muted">(optional)</small>
137        <span class="glyphicon glyphicon-question-sign get-help heading-help" title="Other layers this layer depends upon"></span>
138      </legend>
139      <ul class="list-unstyled lead" id="layer-deps-list">
140      </ul>
141      <div class="form-inline">
142        <div class="form-group">
143          <input type="text" autocomplete="off" data-minLength="1" data-autocomplete="off" data-provide="typeahead" placeholder="Type a layer name" id="layer-dependency" class="form-control">
144        </div>
145        <button class="btn btn-default" id="add-layer-dependency-btn">
146          Add layer
147        </button>
148        <span class="help-inline">You can only add layers Toaster knows about</span>
149    </fieldset>
150    <div class="top-air fields-apart-from-layer-name" id="form-actions">
151      <button class="btn btn-primary btn-lg" data-toggle="modal" id="import-and-add-btn" data-target="#dependencies-message" disabled>Import and add to project</button>
152      <span class="help-inline" id="import-git-layer-and-add-hint" style="vertical-align: middle;">To import a layer you need to enter a layer name, a Git repository URL and a Git revision (branch, tag or commit)</span>
153      <span class="help-inline" id="import-local-dir-and-add-hint" style="vertical-align: middle;display:none;">To import a layer you need to enter a layer name and the absolute path to the layer directory</span>
154    </div>
155  </div>
156</form>
157
158  {% else %} {#project and project release#}
159  <div class="page-header">
160    <h1>Import layer</h1>
161  </div>
162  <div class="alert alert-info" id="import-error" >
163    <h3>Unsupported project type</h3>
164    <p>This project does not support importing layers.</p>
165    <ul></ul>
166  </div>
167
168  {% endif %}
169</div>
170{% endblock %}
171