All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit d650d27d authored by Jonathon Duerig's avatar Jonathon Duerig

Various fixes when merging in with Leigh's code. Jacks Editor now works in Apt.

parent bcf15f18
......@@ -395,3 +395,7 @@ blockquote #selected_profile_description {
left: 0;
right: 0;
}
.jacks #canvasContainer, .jacks #topoButtons {
background-color: #fff;
}
define(['underscore', 'js/lib/text!template/edit-modal.html'],
function (_, editModalString)
{
'use strict';
function JacksEditor (root)
{
this.root = root;
this.instance = null;
this.input = null;
this.output = null;
this.xml = null;
this.render();
}
JacksEditor.prototype = {
render: function ()
{
this.root.html(editModalString);
this.root.find('#quickvm_editmodal').on('shown.bs.modal', _.bind(this.handleShown, this));
this.root.find('#edit-save').click(_.bind(this.fetchXml, this));
this.instance = new window.Jacks({
mode: 'editor',
source: 'rspec',
root: '#edit_nopicker',
nodeSelect: true,
readyCallback: _.bind(this.jacksReady, this),
show: {
rspec: false,
tour: false,
version: false,
menu: true,
selectInfo: true
},
canvasOptions: {
"defaults": [
{
"name": "Add VM",
"image": "urn:publicid:IDN+utahddc.geniracks.net+image+emulab-ops:UBUNTU12-64-STD",
"type": "emulab-xen"
}
],
"images": [
/*
{
"id": "urn:publicid:IDN+utahddc.geniracks.net+image+emulab-ops:FBSD100-64-STD",
"name": "FreeBSD 10.0 64-bit version"
},
*/
{
"id": "urn:publicid:IDN+utahddc.geniracks.net+image+emulab-ops:UBUNTU12-64-STD",
"name": "Ubuntu 12.04 LTS 64-bit"
}/*,
{
"id": "urn:publicid:IDN+utahddc.geniracks.net+image+emulab-ops:UBUNTU14-64-STD",
"name": "Ubuntu 14.04 LTS 64-bit"
}*/
],
"types": [
{
"id": "emulab-xen",
"name": "Emulab Xen VM"
}
]
}
});
},
// Show a modal that lets the user edit their rspec. Callback
// is called with a new rspec if they click ok.
show: function (newXml, callback)
{
this.xml = newXml;
this.callback = callback;
if (this.input)
{
this.root.find('#quickvm_editmodal').modal('show');
}
},
// Hide the modal.
hide: function ()
{
this.xml = null;
this.root.find('#quickvm_editmodal').modal('hide');
},
handleShown: function ()
{
var expression = /^\s*$/;
if (this.xml && ! expression.exec(this.xml))
{
var rspec = $.parseXML(this.xml);
convertNamespace(rspec.documentElement);
this.input.trigger('change-topology',
[{ rspec: rspec.documentElement.outerHTML }]);
}
else
{
this.input.trigger('change-topology', [{
rspec:
'<rspec '+
'xmlns="http://www.geni.net/resources/rspec/3" '+
'xmlns:emulab="http://www.protogeni.net/resources/rspec/ext/emulab/1"'+
'xmlns:tour="http://www.protogeni.net/resources/rspec/ext/apt-tour/1"'+
'xmlns:jacks="http://www.protogeni.net/resources/rspec/ext/jacks/1"'+
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'+
'xsi:schemaLocation="http://www.geni.net/resources/rspec/3 http://www.geni.net/resources/rspec/3/request.xsd">'+
'</rspec>'
}]);
}
},
jacksReady: function (input, output)
{
this.input = input;
this.output = output;
if (this.xml)
{
this.show(this.xml);
}
},
fetchXml: function ()
{
var that = this;
var fetchDone = function (topology) {
that.output.off('fetch-topology', fetchDone);
that.callback(topology[0].rspec);
that.hide();
};
this.output.on('fetch-topology', fetchDone);
this.input.trigger('fetch-topology');
}
};
var v2ns = 'http://www.protogeni.net/resources/rspec/2';
var v3ns = 'http://www.geni.net/resources/rspec/3';
function convertNamespace(el)
{
if (el.namespaceURI === v2ns)
{
el.setAttribute('xmlns', v3ns);
}
_.each(el.children, convertNamespace);
}
return JacksEditor;
});
......@@ -135,7 +135,7 @@ function (_, sup, filesize, JacksEditor, ShowImagingModal,
$('#profile_description').prop("disabled", false);
// Show the hidden buttons (in new profile mode)
$('#showtopo_modal_button').removeClass("invisible");
$('#edit_topo_modal_button').removeClass("invisible");
$('#show_rspec_modal_button').removeClass("invisible");
//
......@@ -150,15 +150,6 @@ function (_, sup, filesize, JacksEditor, ShowImagingModal,
reader.readAsText(this.files[0]);
});
// The Show topology button.
// $('#showtopo_modal_button').click(function (event) {
// $.fn.animateBackgroundHighlight = function(highlightColor, duration) {
// var highlightBg = highlightColor || "#FFFF9C";
// var animateMs = duration || 1500;
// var originalBg = this.css("backgroundColor");
// console.log(originalBg);
// };
function changeRspec(newRspec)
{
$('#profile_rspec_textarea').val(newRspec);
......@@ -173,7 +164,7 @@ function (_, sup, filesize, JacksEditor, ShowImagingModal,
SyncSteps();
ProfileModified();
}
$('#edit_rspec_button').click(function (event) {
$('#edit_topo_modal_button').click(function (event) {
event.preventDefault();
editor.show($('#profile_rspec_textarea').val(), changeRspec);
});
......@@ -502,9 +493,11 @@ function (_, sup, filesize, JacksEditor, ShowImagingModal,
function SyncSteps()
{
var rspec = $('#profile_rspec_textarea').val();
if (rspec === "") {
var expression = /^\s*$/;
if (expression.exec(rspec)) {
return;
}
console.log('"' + rspec + '"');
var xmlDoc = $.parseXML(rspec);
var xml = $(xmlDoc);
......
<!-- This is the topology edit modal -->
<div id='quickvm_editmodal' class='modal fade'>
<div class='modal-dialog' id='edit_dialog'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'
aria-hidden='true'>
&times;</button>
<h3>Topology Editor</h3>
</div>
<div class='modal-body'>
<!-- This topo diagram goes inside this div -->
<div class='panel panel-default'
id='edit_container'>
<div class='panel-body'>
<div id='edit_nopicker' class='jacks'></div>
<div class='edit_buttons'>
<button id='edit-save' class='btn btn-primary'>Accept</button>
<button type='button' class='btn btn-default' data-dismiss='modal'>Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
......@@ -181,19 +181,16 @@
data-input='false'
style='margin-right: 10px;'
data-buttonText='Choose file'>
<!--
<button class='btn btn-primary btn-xs
<% if (! gotrspec) { %>invisible<% } %>'
type='button'
style='margin-right: 10px; margin-left: 10px;'
id='showtopo_modal_button'>
Show</button>
-->
id='edit_topo_modal_button'>
Topology</button>
<button class='btn btn-primary btn-xs'
type='button'
style='margin-right: 10px;'
id='show_rspec_modal_button'>
Edit</button>
XML Source</button>
</div>
</div>
<textarea name="formfields[profile_rspec]"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment