summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/importlayer.js94
-rw-r--r--bitbake/lib/toaster/toastergui/templates/importlayer.html39
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py11
3 files changed, 82 insertions, 62 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js
index 9d54286f4a..d14a8abcaf 100644
--- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js
+++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js
@@ -148,7 +148,6 @@ function importLayerPageInit (ctx) {
148 headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, 148 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
149 success: function (data) { 149 success: function (data) {
150 if (data.error != "ok") { 150 if (data.error != "ok") {
151 show_error_message(data, layerData);
152 console.log(data.error); 151 console.log(data.error);
153 } else { 152 } else {
154 /* Success layer import now go to the project page */ 153 /* Success layer import now go to the project page */
@@ -164,59 +163,7 @@ function importLayerPageInit (ctx) {
164 } 163 }
165 }); 164 });
166 165
167 function show_error_message(error, layerData) { 166 function enable_import_btn(enabled) {
168
169 var errorMsg = $("#import-error").fadeIn();
170 var errorType = error.error;
171 var body = errorMsg.children("p");
172 var title = errorMsg.children("h3");
173 var optionsList = errorMsg.children("ul");
174 var invalidLayerRevision = $("#invalid-layer-revision-hint");
175 var layerRevisionCtrl = $("#layer-revision-ctrl");
176
177 /* remove any existing items */
178 optionsList.children().each(function(){ $(this).remove(); });
179 body.text("");
180 title.text("");
181 invalidLayerRevision.hide();
182 layerNameCtrl.removeClass("error");
183 layerRevisionCtrl.removeClass("error");
184
185 switch (errorType){
186 case 'hint-layer-version-exists':
187 title.text("This layer already exists");
188 body.html("A layer <strong>"+layerData.name+"</strong> already exists with this Git repository URL and this revision. You can:");
189 optionsList.append("<li>Import <strong>"+layerData.name+"</strong> with a different revision </li>");
190 optionsList.append("<li>or <a href=\""+ctx.layerDetailsUrl+error.existing_layer_version+"/\" >change the revision of the existing layer</a></li>");
191
192 layerRevisionCtrl.addClass("error");
193
194 invalidLayerRevision.html("A layer <strong>"+layerData.name+"</strong> already exists with this revision.<br />You can import <strong>"+layerData.name+"</strong> with a different revision");
195 invalidLayerRevision.show();
196 break;
197
198 case 'hint-layer-exists-with-different-url':
199 title.text("This layer already exists");
200 body.html("A layer <strong>"+layerData.name+"</strong> already exists with a different Git repository URL:<p style='margin-top:10px;'><strong>"+error.current_url+"</strong></p><p>You can:</p>");
201 optionsList.append("<li>Import the layer under a different name</li>");
202 optionsList.append("<li>or <a href=\""+ctx.layerDetailsUrl+error.current_id+"/\" >change the Git repository URL of the existing layer</a></li>");
203 duplicatedLayerName.html("A layer <strong>"+layerData.name+"</strong> already exists with a different Git repository URL.<br />To import this layer give it a different name.");
204 duplicatedLayerName.show();
205 layerNameCtrl.addClass("error");
206 break;
207
208 case 'hint-layer-exists':
209 title.text("This layer already exists");
210 body.html("A layer <strong>"+layerData.name+"</strong> already exists. You can:");
211 optionsList.append("<li>Import the layer under a different name</li>");
212 break;
213 default:
214 title.text("Error")
215 body.text(data.error);
216 }
217 }
218
219 function enable_import_btn (enabled) {
220 var importAndAddHint = $("#import-and-add-hint"); 167 var importAndAddHint = $("#import-and-add-hint");
221 168
222 if (enabled) { 169 if (enabled) {
@@ -244,6 +191,38 @@ function importLayerPageInit (ctx) {
244 enable_import_btn(true); 191 enable_import_btn(true);
245 } 192 }
246 193
194 function layerExistsError(layer){
195 var dupLayerInfo = $("#duplicate-layer-info");
196 dupLayerInfo.find(".dup-layer-name").text(layer.name);
197 dupLayerInfo.find(".dup-layer-link").attr("href", layer.layerdetailurl);
198 dupLayerInfo.find("#dup-layer-vcs-url").text(layer.giturl);
199 dupLayerInfo.find("#dup-layer-revision").text(layer.revision);
200
201 $(".fields-apart-from-layer-name").fadeOut(function(){
202
203 dupLayerInfo.fadeIn();
204 });
205 }
206
207 layerNameInput.on('blur', function() {
208 if (!$(this).val()){
209 return;
210 }
211 var name = $(this).val();
212
213 /* Check if the layer name exists */
214 $.getJSON(ctx.xhrDataTypeaheadUrl, { type : "layers", project_id: ctx.projectId, include_added: "true" , value: name }, function(layer) {
215 if (layer.list.length > 0) {
216 for (var i in layer.list){
217 if (layer.list[i].name == name) {
218 console.log(layer.list[i])
219 layerExistsError(layer.list[i]);
220 }
221 }
222 }
223 });
224 });
225
247 vcsURLInput.on('input', function() { 226 vcsURLInput.on('input', function() {
248 check_form(); 227 check_form();
249 }); 228 });
@@ -260,6 +239,13 @@ function importLayerPageInit (ctx) {
260 return; 239 return;
261 } 240 }
262 241
242 if ($("#duplicate-layer-info").css("display") != "None"){
243 $("#duplicate-layer-info").fadeOut(function(){
244 $(".fields-apart-from-layer-name").show();
245 });
246
247 }
248
263 /* Don't remove the error class if we're displaying the error for another 249 /* Don't remove the error class if we're displaying the error for another
264 * reason. 250 * reason.
265 */ 251 */
diff --git a/bitbake/lib/toaster/toastergui/templates/importlayer.html b/bitbake/lib/toaster/toastergui/templates/importlayer.html
index 6b2111a1f4..5ef8a5786c 100644
--- a/bitbake/lib/toaster/toastergui/templates/importlayer.html
+++ b/bitbake/lib/toaster/toastergui/templates/importlayer.html
@@ -51,26 +51,51 @@
51 <div class="control-group" id="layer-name-ctrl"> 51 <div class="control-group" id="layer-name-ctrl">
52 <label class="control-label" for="import-layer-name"> 52 <label class="control-label" for="import-layer-name">
53 Layer name 53 Layer name
54 <span class="icon-question-sign get-help" title="Something like 'meta-mylayer'. Your layer name must be unique and can only include letters, numbers and dashes" /> 54 <span class="icon-question-sign get-help" title="Something like 'meta-mylayer'. Your layer name must be unique and can only include letters, numbers and dashes"></span>
55 </label> 55 </label>
56 <div class="controls"> 56 <div class="controls">
57 <input id="import-layer-name" type="text" required autofocus> 57 <input id="import-layer-name" type="text" required autofocus data-autocomplete="off" data-provide="typeahead">
58 <span class="help-inline" style="display: none;" id="invalid-layer-name-hint">A valid layer name can only include letters, numbers and dashes</span> 58 <span class="help-inline" style="display: none;" id="invalid-layer-name-hint">A valid layer name can only include letters, numbers and dashes</span>
59 <span class="help-inline" style="display: none;" id="duplicated-layer-name-hint"></span> 59 <span class="help-inline" style="display: none;" id="duplicated-layer-name-hint"></span>
60 </div> 60 </div>
61 61
62 </div> 62 </div>
63 <span id="duplicate-layer-info" style="display:none">
64 <div class="alert warning">
65 <h3>A layer called <a href="" class="dup-layer-link"><span class="dup-layer-name"></span></a> already exists</h3>
66 <p>Layer names must be unqiue. Please use a different layer name.</p>
67 </div>
68 <dl>
69 <dt>
70 The <span class="dup-layer-name"></span> repository url is
71 </dt>
72 <dd>
73 <span id="dup-layer-vcs-url"></span>
74 </dd>
75
76 <dt>
77 The <span class="dup-layer-name"></span> revision is
78 </dt>
79 <dd>
80 <span id="dup-layer-revision"></span>
81 </dd>
82 </dl>
83
84 <p><a href="" class="dup-layer-link">View the <span class="dup-layer-name"></span> layer information</a></p>
63 85
86 </span>
87
88 <span class="fields-apart-from-layer-name">
64 <label for="layer-git-repo-url" class="project-form"> 89 <label for="layer-git-repo-url" class="project-form">
65 Git repository URL 90 Git repository URL
66 <span class="icon-question-sign get-help" title="Fetch/clone URL of the repository. Currently, Toaster only supports Git repositories." /> 91 <span class="icon-question-sign get-help" title="Fetch/clone URL of the repository. Currently, Toaster only supports Git repositories." ></span>
67 </label> 92 </label>
68 93
69 <input type="text" id="layer-git-repo-url" class="input-xxlarge" required> 94 <input type="text" id="layer-git-repo-url" class="input-xxlarge" required>
70 <label class="project-form" for="layer-subdir"> 95 <label class="project-form" for="layer-subdir">
71 Repository subdirectory 96 Repository subdirectory
72 <span class="muted">(optional)</span> 97 <span class="muted">(optional)</span>
73 <span class="icon-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)" /> 98 <span class="icon-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>
74 </label> 99 </label>
75 <input type="text" id="layer-subdir"> 100 <input type="text" id="layer-subdir">
76 101
@@ -83,13 +108,16 @@
83 <span class="help-inline" style="diaply:none;" id="invalid-layer-revision-hint"></span> 108 <span class="help-inline" style="diaply:none;" id="invalid-layer-revision-hint"></span>
84 </div> 109 </div>
85 </div> 110 </div>
111 </span>
86 112
87 </fieldset> 113 </fieldset>
114
115 <span class="fields-apart-from-layer-name">
88 <fieldset class="air"> 116 <fieldset class="air">
89 <legend> 117 <legend>
90 Layer dependencies 118 Layer dependencies
91 <span class="muted">(optional)</span> 119 <span class="muted">(optional)</span>
92 <span class="icon-question-sign get-help heading-help" title="Other layers this layer depends upon" /> 120 <span class="icon-question-sign get-help heading-help" title="Other layers this layer depends upon"></span>
93 </legend> 121 </legend>
94 <ul class="unstyled configuration-list" id="layer-deps-list"> 122 <ul class="unstyled configuration-list" id="layer-deps-list">
95 </ul> 123 </ul>
@@ -105,6 +133,7 @@
105 <button class="btn btn-primary btn-large" data-toggle="modal" id="import-and-add-btn" data-target="#dependencies-message" disabled>Import and add to project</button> 133 <button class="btn btn-primary btn-large" data-toggle="modal" id="import-and-add-btn" data-target="#dependencies-message" disabled>Import and add to project</button>
106 <span class="help-inline" id="import-and-add-hint" style="vertical-align: middle;">To import a layer, you need to enter a repository URL, a branch, tag or commit and a layer name</span> 134 <span class="help-inline" id="import-and-add-hint" style="vertical-align: middle;">To import a layer, you need to enter a repository URL, a branch, tag or commit and a layer name</span>
107 </div> 135 </div>
136 </span>
108 </form> 137 </form>
109 138
110{% endblock %} 139{% endblock %}
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 14029813e8..8034cfceaf 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -2279,9 +2279,14 @@ if toastermain.settings.MANAGED:
2279 2279
2280 2280
2281 def _lv_to_dict(x): 2281 def _lv_to_dict(x):
2282 return {"id": x.pk, "name": x.layer.name, "tooltip": x.layer.vcs_url+" | "+x.commit, 2282 return {"id": x.pk,
2283 "detail": "(" + x.layer.vcs_url + (")" if x.up_branch == None else " | "+x.up_branch.name+")"), 2283 "name": x.layer.name,
2284 "giturl": x.layer.vcs_url, "layerdetailurl" : reverse('layerdetails', args=(x.pk,))} 2284 "tooltip": x.layer.vcs_url+" | "+x.get_vcs_reference(),
2285 "detail": "(" + x.layer.vcs_url + (")" if x.up_branch == None else " | "+x.get_vcs_reference()+")"),
2286 "giturl": x.layer.vcs_url,
2287 "layerdetailurl" : reverse('layerdetails', args=(x.pk,)),
2288 "revision" : x.get_vcs_reference(),
2289 }
2285 2290
2286 2291
2287 # returns layers for current project release that are not in the project set, matching the name 2292 # returns layers for current project release that are not in the project set, matching the name