summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-04-10 18:15:03 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-08 17:42:05 +0100
commited26a06a07a75c8039f2a9b251b350331c7474aa (patch)
treeebb2d88d75b51a856322c0a26ab89570a9954276 /bitbake
parent4b59ba1bbb61fe60f500ad742a6515227b22397d (diff)
downloadpoky-ed26a06a07a75c8039f2a9b251b350331c7474aa.tar.gz
bitbake: toaster: Move project context variables to common scope
We have a bunch of context data which are used in multiple pages so it makes more sense to have this in a single place libtoaster.ctx that's accessible from each page rather than request it from every page. (Bitbake rev: 4ef2774a2f683929c700550a9acc7b8f6074195b) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/base.js39
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/importlayer.js12
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/layerdetails.js23
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/libtoaster.js16
-rw-r--r--bitbake/lib/toaster/toastergui/static/js/machines.js12
-rw-r--r--bitbake/lib/toaster/toastergui/templates/base.html17
-rw-r--r--bitbake/lib/toaster/toastergui/templates/importlayer.html4
-rw-r--r--bitbake/lib/toaster/toastergui/templates/layerdetails.html5
-rw-r--r--bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html2
-rw-r--r--bitbake/lib/toaster/toastergui/templates/machines.html5
10 files changed, 63 insertions, 72 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/base.js b/bitbake/lib/toaster/toastergui/static/js/base.js
index 667c5dff6c..c4c96c80e6 100644
--- a/bitbake/lib/toaster/toastergui/static/js/base.js
+++ b/bitbake/lib/toaster/toastergui/static/js/base.js
@@ -6,7 +6,7 @@ function basePageInit (ctx) {
6 /* Hide the button if we're on the project,newproject or importlyaer page 6 /* Hide the button if we're on the project,newproject or importlyaer page
7 * or if there are no projects yet defined 7 * or if there are no projects yet defined
8 */ 8 */
9 if (ctx.numProjects === 0 || ctx.currentUrl.search('newproject|project/\\d/$|importlayer/$') > 0){ 9 if (ctx.numProjects == 0 || ctx.currentUrl.search('newproject|project/\\d/$|importlayer/$') > 0){
10 newBuildButton.hide(); 10 newBuildButton.hide();
11 return; 11 return;
12 } 12 }
@@ -18,17 +18,18 @@ function basePageInit (ctx) {
18 18
19 newBuildButton.show().removeAttr("disabled"); 19 newBuildButton.show().removeAttr("disabled");
20 20
21 _checkProjectBuildable(); 21 _checkProjectBuildable()
22 _setupNewBuildButton(); 22 _setupNewBuildButton();
23 23
24 var currentProjectId = libtoaster.ctx.projectId;
24 25
25 function _checkProjectBuildable(){ 26 function _checkProjectBuildable(){
26 if (ctx.projectId === undefined) 27 if (currentProjectId == undefined)
27 return; 28 return;
28 29
29 libtoaster.getProjectInfo(ctx.projectInfoUrl, ctx.projectId, 30 libtoaster.getProjectInfo(ctx.projectInfoUrl, currentProjectId,
30 function(data){ 31 function(data){
31 if (data.machine.name === undefined || data.layers.length === 0) { 32 if (data.machine.name == undefined || data.layers.length == 0) {
32 /* we can't build anything with out a machine and some layers */ 33 /* we can't build anything with out a machine and some layers */
33 $("#new-build-button #targets-form").hide(); 34 $("#new-build-button #targets-form").hide();
34 $("#new-build-button .alert").show(); 35 $("#new-build-button .alert").show();
@@ -51,18 +52,18 @@ function basePageInit (ctx) {
51 /* If we don't have a current project then present the set project 52 /* If we don't have a current project then present the set project
52 * form. 53 * form.
53 */ 54 */
54 if (ctx.projectId === undefined) { 55 if (currentProjectId == undefined) {
55 $('#change-project-form').show(); 56 $('#change-project-form').show();
56 $('#project .icon-pencil').hide(); 57 $('#project .icon-pencil').hide();
57 } 58 }
58 59
59 libtoaster.makeTypeahead(newBuildTargetInput, ctx.xhrDataTypeaheadUrl, { type : "targets", project_id: ctx.projectId }, function(item){ 60 libtoaster.makeTypeahead(newBuildTargetInput, { type : "targets", project_id: currentProjectId }, function(item){
60 /* successfully selected a target */ 61 /* successfully selected a target */
61 selectedTarget = item; 62 selectedTarget = item;
62 }); 63 });
63 64
64 65
65 libtoaster.makeTypeahead(newBuildProjectInput, ctx.xhrDataTypeaheadUrl, { type : "projects" }, function(item){ 66 libtoaster.makeTypeahead(newBuildProjectInput, { type : "projects" }, function(item){
66 /* successfully selected a project */ 67 /* successfully selected a project */
67 newBuildProjectSaveBtn.removeAttr("disabled"); 68 newBuildProjectSaveBtn.removeAttr("disabled");
68 selectedProject = item; 69 selectedProject = item;
@@ -72,13 +73,13 @@ function basePageInit (ctx) {
72 * the value that has been set by selecting a suggestion from the typeahead 73 * the value that has been set by selecting a suggestion from the typeahead
73 */ 74 */
74 newBuildProjectInput.on('input', function(event) { 75 newBuildProjectInput.on('input', function(event) {
75 if (event.keyCode === 13) 76 if (event.keyCode == 13)
76 return; 77 return;
77 newBuildProjectSaveBtn.attr("disabled", "disabled"); 78 newBuildProjectSaveBtn.attr("disabled", "disabled");
78 }); 79 });
79 80
80 newBuildTargetInput.on('input', function() { 81 newBuildTargetInput.on('input', function() {
81 if ($(this).val().length === 0) 82 if ($(this).val().length == 0)
82 newBuildTargetBuildBtn.attr("disabled", "disabled"); 83 newBuildTargetBuildBtn.attr("disabled", "disabled");
83 else 84 else
84 newBuildTargetBuildBtn.removeAttr("disabled"); 85 newBuildTargetBuildBtn.removeAttr("disabled");
@@ -88,21 +89,22 @@ function basePageInit (ctx) {
88 if (!newBuildTargetInput.val()) 89 if (!newBuildTargetInput.val())
89 return; 90 return;
90 91
91 var selectedTargetName = newBuildTargetInput.val(); 92 if (!selectedTarget)
93 selectedTarget = { name: newBuildTargetInput.val() };
92 /* fire and forget */ 94 /* fire and forget */
93 libtoaster.startABuild(ctx.projectBuildUrl, ctx.projectId, selectedTargetName, null, null); 95 libtoaster.startABuild(ctx.projectBuildUrl, currentProjectId, selectedTarget.name, null, null);
94 window.location.replace(ctx.projectPageUrl+ctx.projectId); 96 window.location.replace(ctx.projectBasePageUrl+currentProjectId);
95 }); 97 });
96 98
97 newBuildProjectSaveBtn.click(function() { 99 newBuildProjectSaveBtn.click(function() {
98 ctx.projectId = selectedProject.id; 100 currentProjectId = selectedProject.id
99 /* Update the typeahead project_id paramater */ 101 /* Update the typeahead project_id paramater */
100 _checkProjectBuildable(); 102 _checkProjectBuildable();
101 newBuildTargetInput.data('typeahead').options.xhrParams.project_id = ctx.projectId; 103 newBuildTargetInput.data('typeahead').options.xhrParams.project_id = currentProjectId;
102 newBuildTargetInput.val(""); 104 newBuildTargetInput.val("");
103 105
104 $("#new-build-button #project a").text(selectedProject.name).attr('href', ctx.projectPageUrl+ctx.projectId); 106 $("#new-build-button #project a").text(selectedProject.name).attr('href', ctx.projectBasePageUrl+currentProjectId);
105 $("#new-build-button .alert a").attr('href', ctx.projectPageUrl+ctx.projectId); 107 $("#new-build-button .alert a").attr('href', ctx.projectBasePageUrl+currentProjectId);
106 108
107 109
108 $("#change-project-form").slideUp({ 'complete' : function() { 110 $("#change-project-form").slideUp({ 'complete' : function() {
@@ -130,5 +132,6 @@ function basePageInit (ctx) {
130 $(".new-build").click (function(event) { 132 $(".new-build").click (function(event) {
131 event.stopPropagation(); 133 event.stopPropagation();
132 }); 134 });
133 } 135 };
136
134} 137}
diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js
index d14a8abcaf..ec1cc19e90 100644
--- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js
+++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js
@@ -18,7 +18,7 @@ function importLayerPageInit (ctx) {
18 18
19 $("#new-project-button").hide(); 19 $("#new-project-button").hide();
20 20
21 libtoaster.makeTypeahead(layerDepInput, ctx.xhrDataTypeaheadUrl, { type : "layers", project_id: ctx.projectId, include_added: "true" }, function(item){ 21 libtoaster.makeTypeahead(layerDepInput, { type : "layers", project_id: libtoaster.ctx.projectId, include_added: "true" }, function(item){
22 currentLayerDepSelection = item; 22 currentLayerDepSelection = item;
23 23
24 layerDepBtn.removeAttr("disabled"); 24 layerDepBtn.removeAttr("disabled");
@@ -28,7 +28,7 @@ function importLayerPageInit (ctx) {
28 /* We automatically add "openembedded-core" layer for convenience as a 28 /* We automatically add "openembedded-core" layer for convenience as a
29 * dependency as pretty much all layers depend on this one 29 * dependency as pretty much all layers depend on this one
30 */ 30 */
31 $.getJSON(ctx.xhrDataTypeaheadUrl, { type : "layers", project_id: ctx.projectId, include_added: "true" , value: "openembedded-core" }, function(layer) { 31 $.getJSON(libtoaster.ctx.xhrDataTypeaheadUrl, { type : "layers", project_id: libtoaster.ctx.projectId, include_added: "true" , value: "openembedded-core" }, function(layer) {
32 if (layer.list.length == 1) { 32 if (layer.list.length == 1) {
33 currentLayerDepSelection = layer.list[0]; 33 currentLayerDepSelection = layer.list[0];
34 layerDepBtn.click(); 34 layerDepBtn.click();
@@ -63,7 +63,7 @@ function importLayerPageInit (ctx) {
63 63
64 $("#layer-deps-list").append(newLayerDep); 64 $("#layer-deps-list").append(newLayerDep);
65 65
66 libtoaster.getLayerDepsForProject(ctx.xhrDataTypeaheadUrl, ctx.projectId, currentLayerDepSelection.id, function (data){ 66 libtoaster.getLayerDepsForProject(libtoaster.ctx.projectId, currentLayerDepSelection.id, function (data){
67 /* These are the dependencies of the layer added as a dependency */ 67 /* These are the dependencies of the layer added as a dependency */
68 if (data.list.length > 0) { 68 if (data.list.length > 0) {
69 currentLayerDepSelection.url = ctx.layerDetailsUrl+currentLayerDepSelection.id; 69 currentLayerDepSelection.url = ctx.layerDetailsUrl+currentLayerDepSelection.id;
@@ -137,7 +137,7 @@ function importLayerPageInit (ctx) {
137 vcs_url: vcsURLInput.val(), 137 vcs_url: vcsURLInput.val(),
138 git_ref: gitRefInput.val(), 138 git_ref: gitRefInput.val(),
139 dir_path: $("#layer-subdir").val(), 139 dir_path: $("#layer-subdir").val(),
140 project_id: ctx.projectId, 140 project_id: libtoaster.ctx.projectId,
141 layer_deps: layerDepsCsv, 141 layer_deps: layerDepsCsv,
142 }; 142 };
143 143
@@ -152,7 +152,7 @@ function importLayerPageInit (ctx) {
152 } else { 152 } else {
153 /* Success layer import now go to the project page */ 153 /* Success layer import now go to the project page */
154 $.cookie('layer-imported-alert', JSON.stringify(data), { path: '/'}); 154 $.cookie('layer-imported-alert', JSON.stringify(data), { path: '/'});
155 window.location.replace(ctx.projectPageUrl+'#/layerimported'); 155 window.location.replace(libtoaster.ctx.projectPageUrl+'#/layerimported');
156 } 156 }
157 }, 157 },
158 error: function (data) { 158 error: function (data) {
@@ -211,7 +211,7 @@ function importLayerPageInit (ctx) {
211 var name = $(this).val(); 211 var name = $(this).val();
212 212
213 /* Check if the layer name exists */ 213 /* Check if the layer name exists */
214 $.getJSON(ctx.xhrDataTypeaheadUrl, { type : "layers", project_id: ctx.projectId, include_added: "true" , value: name }, function(layer) { 214 $.getJSON(libtoaster.ctx.xhrDataTypeaheadUrl, { type : "layers", project_id: libtoaster.ctx.projectId, include_added: "true" , value: name }, function(layer) {
215 if (layer.list.length > 0) { 215 if (layer.list.length > 0) {
216 for (var i in layer.list){ 216 for (var i in layer.list){
217 if (layer.list[i].name == name) { 217 if (layer.list[i].name == name) {
diff --git a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js
index bac60c4512..3b6423f7f4 100644
--- a/bitbake/lib/toaster/toastergui/static/js/layerdetails.js
+++ b/bitbake/lib/toaster/toastergui/static/js/layerdetails.js
@@ -9,7 +9,7 @@ function layerDetailsPageInit (ctx) {
9 var addRmLayerBtn = $("#add-remove-layer-btn"); 9 var addRmLayerBtn = $("#add-remove-layer-btn");
10 10
11 /* setup the dependencies typeahead */ 11 /* setup the dependencies typeahead */
12 libtoaster.makeTypeahead(layerDepInput, ctx.xhrDataTypeaheadUrl, { type : "layers", project_id: ctx.projectId, include_added: "true" }, function(item){ 12 libtoaster.makeTypeahead(layerDepInput, { type : "layers", project_id: libtoaster.ctx.projectId, include_added: "true" }, function(item){
13 currentLayerDepSelection = item; 13 currentLayerDepSelection = item;
14 14
15 layerDepBtn.removeAttr("disabled"); 15 layerDepBtn.removeAttr("disabled");
@@ -125,15 +125,14 @@ function layerDetailsPageInit (ctx) {
125 $(".build-target-btn").click(function(){ 125 $(".build-target-btn").click(function(){
126 /* fire a build */ 126 /* fire a build */
127 var target = $(this).data('target-name'); 127 var target = $(this).data('target-name');
128 libtoaster.startABuild(ctx.projectBuildUrl, ctx.projectId, target, null, null); 128 libtoaster.startABuild(ctx.projectBuildUrl, libtoaster.ctx.projectId, target, null, null);
129 window.location.replace(ctx.projectPageUrl); 129 window.location.replace(libtoaster.ctx.projectPageUrl);
130 }); 130 });
131 131
132 $(".select-machine-btn").click(function(){ 132 $(".select-machine-btn").click(function(){
133 var data = { machineName : $(this).data('machine-name') }; 133 var data = { machineName : $(this).data('machine-name') };
134 libtoaster.editProject(ctx.xhrEditProjectUrl, ctx.projectId, data, 134 libtoaster.editCurrentProject(data, function (){
135 function (){ 135 window.location.replace(libtoaster.ctx.projectPageUrl+"#/machineselected");
136 window.location.replace(ctx.projectPageUrl+"#/machineselected");
137 }, null); 136 }, null);
138 }); 137 });
139 138
@@ -256,8 +255,8 @@ function layerDetailsPageInit (ctx) {
256 } 255 }
257 256
258 alertMsg.children("#layer-affected-name").text(ctx.layerVersion.name); 257 alertMsg.children("#layer-affected-name").text(ctx.layerVersion.name);
259 alertMsg.children("#project-affected-name").text(ctx.projectName); 258 alertMsg.children("#project-affected-name").text(libtoaster.ctx.projectName);
260 alertMsg.children("#project-affected-name").attr("href", ctx.projectPageUrl); 259 alertMsg.children("#project-affected-name").attr("href", libtoaster.ctx.projectPageUrl);
261 $("#alert-area").show(); 260 $("#alert-area").show();
262 } 261 }
263 262
@@ -269,12 +268,11 @@ function layerDetailsPageInit (ctx) {
269 268
270 if (directive == 'add') { 269 if (directive == 'add') {
271 /* If adding get the deps for this layer */ 270 /* If adding get the deps for this layer */
272 libtoaster.getLayerDepsForProject(ctx.xhrDataTypeaheadUrl, ctx.projectId, ctx.layerVersion.id, function (data) { 271 libtoaster.getLayerDepsForProject(libtoaster.ctx.projectId, ctx.layerVersion.id, function (data) {
273 /* got result for dependencies */ 272 /* got result for dependencies */
274 if (data.list.length == 0){ 273 if (data.list.length == 0){
275 var editData = { layerAdd : ctx.layerVersion.id }; 274 var editData = { layerAdd : ctx.layerVersion.id };
276 libtoaster.editProject(ctx.xhrEditProjectUrl, ctx.projectId, editData, 275 libtoaster.editCurrentProject(editData, function() {
277 function() {
278 setLayerInCurrentPrj(true); 276 setLayerInCurrentPrj(true);
279 }); 277 });
280 return; 278 return;
@@ -291,8 +289,7 @@ function layerDetailsPageInit (ctx) {
291 } else if (directive == 'remove') { 289 } else if (directive == 'remove') {
292 var editData = { layerDel : ctx.layerVersion.id }; 290 var editData = { layerDel : ctx.layerVersion.id };
293 291
294 libtoaster.editProject(ctx.xhrEditProjectUrl, ctx.projectId, editData, 292 libtoaster.editCurrentProject(editData, function () {
295 function () {
296 /* Success removed layer */ 293 /* Success removed layer */
297 //window.location.reload(); 294 //window.location.reload();
298 setLayerInCurrentPrj(false); 295 setLayerInCurrentPrj(false);
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
index ae9e4556a1..9257f735db 100644
--- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
+++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js
@@ -14,12 +14,12 @@ var libtoaster = (function (){
14 * selectedCB: function to call once an item has been selected one 14 * selectedCB: function to call once an item has been selected one
15 * arg of the item. 15 * arg of the item.
16 */ 16 */
17 function _makeTypeahead (jQElement, xhrUrl, xhrParams, selectedCB) { 17 function _makeTypeahead (jQElement, xhrParams, selectedCB) {
18 18
19 jQElement.typeahead({ 19 jQElement.typeahead({
20 source: function(query, process){ 20 source: function(query, process){
21 xhrParams.value = query; 21 xhrParams.value = query;
22 $.getJSON(xhrUrl, this.options.xhrParams, function(data){ 22 $.getJSON(libtoaster.ctx.xhrDataTypeaheadUrl, this.options.xhrParams, function(data){
23 if (data.error !== "ok") { 23 if (data.error !== "ok") {
24 console.log("Error getting data from server "+data.error); 24 console.log("Error getting data from server "+data.error);
25 return; 25 return;
@@ -41,7 +41,7 @@ var libtoaster = (function (){
41 return $('<span></span>').text(item.name).get(0); 41 return $('<span></span>').text(item.name).get(0);
42 }, 42 },
43 sorter: function (items) { return items; }, 43 sorter: function (items) { return items; },
44 xhrUrl: xhrUrl, 44 xhrUrl: libtoaster.ctx.xhrDataTypeaheadUrl,
45 xhrParams: xhrParams, 45 xhrParams: xhrParams,
46 }); 46 });
47 47
@@ -147,10 +147,10 @@ var libtoaster = (function (){
147 * projectVersion 147 * projectVersion
148 * machineName 148 * machineName
149 */ 149 */
150 function _editProject(url, projectId, data, onSuccess, onFail){ 150 function _editCurrentProject(data, onSuccess, onFail){
151 $.ajax({ 151 $.ajax({
152 type: "POST", 152 type: "POST",
153 url: url, 153 url: libtoaster.ctx.xhrProjectEditUrl,
154 data: data, 154 data: data,
155 headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, 155 headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
156 success: function (data) { 156 success: function (data) {
@@ -170,9 +170,9 @@ var libtoaster = (function (){
170 }); 170 });
171 } 171 }
172 172
173 function _getLayerDepsForProject(xhrDataTypeaheadUrl, projectId, layerId, onSuccess, onFail){ 173 function _getLayerDepsForProject(projectId, layerId, onSuccess, onFail){
174 /* Check for dependencies not in the current project */ 174 /* Check for dependencies not in the current project */
175 $.getJSON(xhrDataTypeaheadUrl, 175 $.getJSON(libtoaster.ctx.xhrDataTypeaheadUrl,
176 { type: 'layerdeps', 'value': layerId , project_id: projectId }, 176 { type: 'layerdeps', 'value': layerId , project_id: projectId },
177 function(data) { 177 function(data) {
178 if (data.error != "ok") { 178 if (data.error != "ok") {
@@ -227,7 +227,7 @@ var libtoaster = (function (){
227 makeTypeahead : _makeTypeahead, 227 makeTypeahead : _makeTypeahead,
228 getProjectInfo: _getProjectInfo, 228 getProjectInfo: _getProjectInfo,
229 getLayerDepsForProject : _getLayerDepsForProject, 229 getLayerDepsForProject : _getLayerDepsForProject,
230 editProject : _editProject, 230 editCurrentProject : _editCurrentProject,
231 debug: false, 231 debug: false,
232 parseUrlParams : _parseUrlParams, 232 parseUrlParams : _parseUrlParams,
233 dumpsUrlParams : _dumpsUrlParams, 233 dumpsUrlParams : _dumpsUrlParams,
diff --git a/bitbake/lib/toaster/toastergui/static/js/machines.js b/bitbake/lib/toaster/toastergui/static/js/machines.js
index 973a037be7..fbcafc26b5 100644
--- a/bitbake/lib/toaster/toastergui/static/js/machines.js
+++ b/bitbake/lib/toaster/toastergui/static/js/machines.js
@@ -45,7 +45,7 @@ function machinesPageInit (ctx) {
45 45
46 var layerName = addLayerBtn.data('layer-name'); 46 var layerName = addLayerBtn.data('layer-name');
47 alertMsg.children("#layer-affected-name").text(layerName); 47 alertMsg.children("#layer-affected-name").text(layerName);
48 alertMsg.children("#project-affected-name").text(ctx.projectName).attr('href', ctx.projectPageUrl); 48 alertMsg.children("#project-affected-name").text(libtoaster.ctx.projectName).attr('href', libtoaster.ctx.projectPageUrl);
49 49
50 $("#alert-area").show(); 50 $("#alert-area").show();
51 } 51 }
@@ -61,12 +61,11 @@ function machinesPageInit (ctx) {
61 name : $(this).data('layer-name'), 61 name : $(this).data('layer-name'),
62 }; 62 };
63 63
64 libtoaster.getLayerDepsForProject(ctx.xhrDataTypeaheadUrl, ctx.projectId, layer.id, function (data) { 64 libtoaster.getLayerDepsForProject(libtoaster.ctx.projectId, layer.id, function (data) {
65 /* got result for dependencies */ 65 /* got result for dependencies */
66 if (data.list.length == 0){ 66 if (data.list.length == 0){
67 var editData = { layerAdd : layer.id }; 67 var editData = { layerAdd : layer.id };
68 libtoaster.editProject(ctx.xhrEditProjectUrl, ctx.projectId, editData, 68 libtoaster.editCurrentProject(editData, function() {
69 function() {
70 setLayerInCurrentPrj(btn); 69 setLayerInCurrentPrj(btn);
71 }); 70 });
72 return; 71 return;
@@ -84,9 +83,8 @@ function machinesPageInit (ctx) {
84 83
85 $(".select-machine-btn").click(function(){ 84 $(".select-machine-btn").click(function(){
86 var data = { machineName : $(this).data('machine-name') }; 85 var data = { machineName : $(this).data('machine-name') };
87 libtoaster.editProject(ctx.xhrEditProjectUrl, ctx.projectId, data, 86 libtoaster.editCurrentProject(data, function (){
88 function (){ 87 window.location.replace(libtoaster.ctx.projectPageUrl+"#/machineselected");
89 window.location.replace(ctx.projectPageUrl+"#/machineselected");
90 }, null); 88 }, null);
91 }); 89 });
92 90
diff --git a/bitbake/lib/toaster/toastergui/templates/base.html b/bitbake/lib/toaster/toastergui/templates/base.html
index 58392b36f5..25933a1e90 100644
--- a/bitbake/lib/toaster/toastergui/templates/base.html
+++ b/bitbake/lib/toaster/toastergui/templates/base.html
@@ -26,20 +26,27 @@
26 libtoaster.debug = true; 26 libtoaster.debug = true;
27 </script> 27 </script>
28{% endif %} 28{% endif %}
29<script>
30 libtoaster.ctx = {
31 projectId : {{project.id|default:'undefined'}},
32 xhrDataTypeaheadUrl : "{% url 'xhr_datatypeahead' %}",
33 {% if project.id %}
34 xhrProjectEditUrl : "{% url 'xhr_projectedit' project.id %}",
35 projectPageUrl : "{% url 'project' project.id %}",
36 projectName : "{{project.name}}",
37 {% endif %}
38 };
39</script>
29<script src="{% static 'js/base.js' %}"></script> 40<script src="{% static 'js/base.js' %}"></script>
30{%if MANAGED %} 41{%if MANAGED %}
31<script> 42<script>
32 $(document).ready(function () { 43 $(document).ready(function () {
33 /* Vars needed for base.js */ 44 /* Vars needed for base.js */
34 var ctx = {}; 45 var ctx = {};
35 ctx.xhrDataTypeaheadUrl = "{% url 'xhr_datatypeahead' %}";
36 ctx.projectBuildUrl = "{% url 'xhr_build' %}"; 46 ctx.projectBuildUrl = "{% url 'xhr_build' %}";
37 ctx.projectPageUrl = "{% url 'base_project' %}"; 47 ctx.projectBasePageUrl = "{% url 'base_project' %}";
38 ctx.projectInfoUrl = "{% url 'xhr_projectinfo' %}"; 48 ctx.projectInfoUrl = "{% url 'xhr_projectinfo' %}";
39 ctx.numProjects = {{projects|length}}; 49 ctx.numProjects = {{projects|length}};
40 {% if project %}
41 ctx.projectId = {{project.id}};
42 {% endif %}
43 ctx.currentUrl = "{{request.path|escapejs}}"; 50 ctx.currentUrl = "{{request.path|escapejs}}";
44 51
45 basePageInit(ctx); 52 basePageInit(ctx);
diff --git a/bitbake/lib/toaster/toastergui/templates/importlayer.html b/bitbake/lib/toaster/toastergui/templates/importlayer.html
index 5ef8a5786c..c92b5d8b24 100644
--- a/bitbake/lib/toaster/toastergui/templates/importlayer.html
+++ b/bitbake/lib/toaster/toastergui/templates/importlayer.html
@@ -13,12 +13,8 @@
13 <script> 13 <script>
14 $(document).ready(function (){ 14 $(document).ready(function (){
15 var ctx = { 15 var ctx = {
16 xhrDataTypeaheadUrl : "{% url 'xhr_datatypeahead' %}",
17 layerDetailsUrl : "{% url 'base_layerdetails' %}", 16 layerDetailsUrl : "{% url 'base_layerdetails' %}",
18 xhrImportLayerUrl : "{% url 'xhr_importlayer' %}", 17 xhrImportLayerUrl : "{% url 'xhr_importlayer' %}",
19 xhrEditProjectUrl : "{% url 'xhr_projectedit' project.id %}",
20 projectPageUrl : "{% url 'project' project.id %}",
21 projectId : {{project.id}}
22 }; 18 };
23 19
24 try { 20 try {
diff --git a/bitbake/lib/toaster/toastergui/templates/layerdetails.html b/bitbake/lib/toaster/toastergui/templates/layerdetails.html
index 0d3aa15373..435bf04e42 100644
--- a/bitbake/lib/toaster/toastergui/templates/layerdetails.html
+++ b/bitbake/lib/toaster/toastergui/templates/layerdetails.html
@@ -18,12 +18,7 @@
18 var ctx = { 18 var ctx = {
19 projectBuildUrl : "{% url 'xhr_build' %}", 19 projectBuildUrl : "{% url 'xhr_build' %}",
20 layerDetailsUrl : "{% url 'base_layerdetails' %}", 20 layerDetailsUrl : "{% url 'base_layerdetails' %}",
21 projectPageUrl : "{% url 'project' project.id %}",
22 xhrEditProjectUrl : "{% url 'xhr_projectedit' project.id %}",
23 xhrDataTypeaheadUrl : "{% url 'xhr_datatypeahead' %}",
24 xhrUpdateLayerUrl : "{% url 'xhr_updatelayer' %}", 21 xhrUpdateLayerUrl : "{% url 'xhr_updatelayer' %}",
25 projectId : {{project.id}},
26 projectName : "{{project.name}}",
27 numTargets : {{total_targets}}, 22 numTargets : {{total_targets}},
28 numMachines: {{machines|length}}, 23 numMachines: {{machines|length}},
29 layerVersion : { 24 layerVersion : {
diff --git a/bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html b/bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html
index 8222027d4f..ea49af50d8 100644
--- a/bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html
+++ b/bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html
@@ -18,7 +18,7 @@
18 </div> 18 </div>
19 19
20<script> 20<script>
21 /* projectId: current project 21 /*
22 * layer: Object representing the parent layer { id: .. name: ... url } 22 * layer: Object representing the parent layer { id: .. name: ... url }
23 * dependencies: array of dependency layer objects { id: .. name: ..} 23 * dependencies: array of dependency layer objects { id: .. name: ..}
24 * title: optional override for title 24 * title: optional override for title
diff --git a/bitbake/lib/toaster/toastergui/templates/machines.html b/bitbake/lib/toaster/toastergui/templates/machines.html
index 2ac35378e0..64db0f9ca7 100644
--- a/bitbake/lib/toaster/toastergui/templates/machines.html
+++ b/bitbake/lib/toaster/toastergui/templates/machines.html
@@ -12,11 +12,6 @@
12 12
13 $(document).ready(function (){ 13 $(document).ready(function (){
14 var ctx = { 14 var ctx = {
15 projectPageUrl : "{% url 'project' project.id %}",
16 projectName : "{{project.name}}",
17 xhrEditProjectUrl : "{% url 'xhr_projectedit' project.id %}",
18 projectId : {{project.id}},
19 xhrDataTypeaheadUrl : "{% url 'xhr_datatypeahead' %}",
20 }; 15 };
21 16
22 try { 17 try {