ticCoreReq.end();
});
+/**
+ * Get ks file path from tic-core via RESTful API
+ * @URI /exports
+ * @TYPE POST
+ */
+app.post('/exports', function(req, res) {
+ var postData = JSON.stringify(req.body);
+ var addr = server.address();
+
+ var options = {
+ host: addr.address,
+ port: Config.TIC_CORE.PORT || addr.port + 1,
+ method: 'POST',
+ path: '/exports',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Content-Length': Buffer.byteLength(postData)
+ }
+ };
+
+ var data = '';
+ var ticCoreReq = http.request(options, function (ticCoreRes) {
+ ticCoreRes.setEncoding('utf8');
+ ticCoreRes.on('data', function (chunk) {
+ data += chunk;
+ });
+ ticCoreRes.on('end', function () {
+ res.send(data);
+ });
+ });
+
+ ticCoreReq.write(postData);
+ ticCoreReq.end();
+});
/**
var checkedPackagesList;
// template for the URL
- var URL_EXPORTS = '<%= protocol %>//<%= hostname %>:<%= port %>/exports';
+ var URL_EXPORTS = '<%= url %>/exports';
// the path for ks
var PATH_TIC_KS = '/tmp/tic/ks/';
};
tableDomElem = $('#tic-image-new-log');
+ tableDomElem.empty();
client.emit('ws/fs/image/add/from', msgData);
var elem = document.createElement('p');
elem.innerText = data;
tableDomElem.append(elem);
+
$('#tic-image-new').animate({ scrollTop : $('#tic-image-new').height() }, 'slow');
});
// button enabled
$('#tic-image-create').prop('disabled', false);
- // the logs are removed
- $('#tic-image-new-log').empty();
-
- // creation was hidden when finished.
- $('#tic-image-new-container').hide();
-
// upate the list of images
updateList(null);
});
function getExportsUrl() {
return _.template(URL_EXPORTS)({
- protocol: location.protocol,
- hostname: location.hostname,
- port: parseInt(location.port) + 1
+ url: location.origin
});
}
output: PATH_TIC_KS
};
- // creation is shown when creation started.
- $('#tic-image-new-container').show();
-
$.ajax({
type: 'POST',
- contentType: 'text/plain',
- data: JSON.stringify(msgData),
+ contentType: 'application/json; charset=UTF-8',
dataType: 'json',
+ data: JSON.stringify(msgData),
+ processData: false,
url: getExportsUrl(),
success: function (res) {
resolve(res.data);
}
// confirm
- Util.showConfirmDialog('Are you sure?')
+ Util.showConfirmDialog('Are you sure want to create the image?')
.then(function () {
getKickstartRecipeFile()
.then(createImage)
// button
$('#tic-image-create').prop('disabled', true);
$('#tic-image-create').click(confirmCreateImage);
-
- // creation was hidden when started.
- $('#tic-image-new-container').hide();
}
function init() {