Skip to content

Commit

Permalink
Added form.js and updated changelog for release
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan Rodgers committed Aug 15, 2019
1 parent 1cbd64c commit a353d69
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## 0.1.0 - 2019-08-15
### Added
- Added `form.js` to keep node type and num_cores in sync

## 0.0.1 - 2019-08-15
### Added
- Initial release!

[Unreleased]: https://github.com/OSC/bc_osc_stata/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/OSC/bc_osc_stata/compare/v0.0.1...v0.1.0
61 changes: 61 additions & 0 deletions form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'use strict'

/**
* Fix num cores, allowing blanks to remain
*/
function fix_num_cores() {
let node_type_input = $('#batch_connect_session_context_node_type');
let node_type = node_type_input.val();
let num_cores_input = $('#num_cores');

if(num_cores_input.val() === '') {
return;
}

if(node_type === ':hugemem') {
set_ppn_owens_hugemem(num_cores_input);
} else {
set_ppn_owens_regular(num_cores_input);
}
}

/**
* Sets the PPN limits available for Owens hugemem nodes.
*
* hugemem reservations are always assigned the full node
*
* @param {element} num_cores_input The input for num_cores
*/
function set_ppn_owens_hugemem(num_cores_input) {
const NUM_CORES = 48;
num_cores_input.attr('max', NUM_CORES);
num_cores_input.attr('min', NUM_CORES);
num_cores_input.val(NUM_CORES);
}

/**
* Sets the PPN limits available for non hugemem Owens nodes.
*
* @param {element} num_cores_input The input for num_cores
*/
function set_ppn_owens_regular(num_cores_input) {
const NUM_CORES = 28;
num_cores_input.attr('max', NUM_CORES);
num_cores_input.attr('min', 1);
num_cores_input.val(Math.min(NUM_CORES, num_cores_input.val()));
}


/**
* Change the maximum number of cores selected.
*/
function set_node_type_change_handler() {
let node_type_input = $('#batch_connect_session_context_node_type');
node_type_input.change(node_type_input, fix_num_cores);
}

$(document).ready(function() {
// Set the max value to be what was set in the last session
fix_num_cores();
set_node_type_change_handler();
});

0 comments on commit a353d69

Please sign in to comment.