mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 14:42:19 +02:00
add the ability to ask for multiple instances from JS page
This commit is contained in:
parent
0e19d9a53a
commit
76df707e31
5 changed files with 39 additions and 10 deletions
|
@ -36,11 +36,22 @@ body {
|
|||
}
|
||||
#deploy-button {
|
||||
background-color: #0DFFBB;
|
||||
right: 0px;
|
||||
right: 85px;
|
||||
}
|
||||
#deploy-button:hover {
|
||||
background-color: #28FF57;
|
||||
}
|
||||
|
||||
#instance-field {
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
top: 40px;
|
||||
}
|
||||
|
||||
#instance-field input {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
#stop-button {
|
||||
background-color: #CC1F00;
|
||||
right: 0px;
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
Run
|
||||
</a>
|
||||
</div>
|
||||
<div class='big-field' id='instance-field'>
|
||||
<input type='text' name='instances' placeholder='# of instances'>
|
||||
</div>
|
||||
<!-- %div#stop-button.big-button -->
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -20,6 +20,11 @@ $(document).ready(function(){
|
|||
// add the script
|
||||
+ script + '\r\n'
|
||||
+ '--' + boundary + '--';
|
||||
|
||||
var headers = {};
|
||||
if ($('#instance-field input').val()) {
|
||||
headers['ASSIGNMENT-INSTANCES'] = $('#instance-field input').val();
|
||||
}
|
||||
|
||||
// post form to assignment in order to create an assignment
|
||||
$.ajax({
|
||||
|
@ -27,6 +32,7 @@ $(document).ready(function(){
|
|||
data: body,
|
||||
type: "POST",
|
||||
url: "/assignment",
|
||||
headers: headers,
|
||||
success: function (data, status) {
|
||||
console.log(data);
|
||||
console.log(status);
|
||||
|
|
|
@ -313,17 +313,18 @@ int main(int argc, const char* argv[]) {
|
|||
broadcastPacket,
|
||||
numHeaderBytes + numAssignmentBytes);
|
||||
|
||||
// remove the assignment from the queue
|
||||
::assignmentQueue.erase(assignment);
|
||||
|
||||
if ((*assignment)->getType() == Assignment::AgentType) {
|
||||
// if this is a script assignment we need to delete it to avoid a memory leak
|
||||
// or if there is more than one instance to send out, simpy decrease the number of instances
|
||||
if ((*assignment)->getNumberOfInstances() > 1) {
|
||||
(*assignment)->decrementNumberOfInstances();
|
||||
} else {
|
||||
::assignmentQueue.erase(assignment);
|
||||
delete *assignment;
|
||||
}
|
||||
} else {
|
||||
// remove the assignment from the queue
|
||||
::assignmentQueue.erase(assignment);
|
||||
}
|
||||
|
||||
// stop looping, we've handed out an assignment
|
||||
|
@ -351,12 +352,18 @@ int main(int argc, const char* argv[]) {
|
|||
|
||||
nodeList->sendAssignment(*(*assignment));
|
||||
|
||||
// remove the assignment from the queue
|
||||
::assignmentQueue.erase(assignment);
|
||||
|
||||
if ((*assignment)->getType() == Assignment::AgentType) {
|
||||
// if this is a script assignment we need to delete it to avoid a memory leak
|
||||
delete *assignment;
|
||||
// or if there is more than one instance to send out, simpy decrease the number of instances
|
||||
if ((*assignment)->getNumberOfInstances() > 1) {
|
||||
(*assignment)->decrementNumberOfInstances();
|
||||
} else {
|
||||
::assignmentQueue.erase(assignment);
|
||||
delete *assignment;
|
||||
}
|
||||
} else {
|
||||
// remove the assignment from the queue
|
||||
::assignmentQueue.erase(assignment);
|
||||
}
|
||||
|
||||
// stop looping, we've handed out an assignment
|
||||
|
|
|
@ -21,7 +21,8 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, Assig
|
|||
_type(type),
|
||||
_location(location),
|
||||
_attachedPublicSocket(NULL),
|
||||
_attachedLocalSocket(NULL)
|
||||
_attachedLocalSocket(NULL),
|
||||
_numberOfInstances(1)
|
||||
{
|
||||
// set the create time on this assignment
|
||||
gettimeofday(&_time, NULL);
|
||||
|
@ -35,7 +36,8 @@ Assignment::Assignment(Assignment::Command command, Assignment::Type type, Assig
|
|||
Assignment::Assignment(const unsigned char* dataBuffer, int numBytes) :
|
||||
_location(GlobalLocation),
|
||||
_attachedPublicSocket(NULL),
|
||||
_attachedLocalSocket(NULL)
|
||||
_attachedLocalSocket(NULL),
|
||||
_numberOfInstances(1)
|
||||
{
|
||||
// set the create time on this assignment
|
||||
gettimeofday(&_time, NULL);
|
||||
|
|
Loading…
Reference in a new issue