Skip to content

Commit

Permalink
Merge pull request #73 from FDA/origin/Sep2022
Browse files Browse the repository at this point in the history
Origin/sep2022
  • Loading branch information
lorenbuhle authored Sep 7, 2022
2 parents 92c9088 + 3379f28 commit 0f4204b
Show file tree
Hide file tree
Showing 394 changed files with 9,301 additions and 4,762 deletions.
4 changes: 3 additions & 1 deletion app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
1 change: 1 addition & 0 deletions app/assets/csvs/treasure_hunt_warm_up_results.csv

Large diffs are not rendered by default.

Empty file added app/assets/images/.keep
Empty file.
Binary file added app/assets/images/apps/AppIconBlue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/apps/AppIconGreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/apps/AppIconYellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/beta-release.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/navbar/NavbarBackground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions app/assets/images/navbar/gsrs-logo-round-bw.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/running_workstation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions app/assets/javascripts/_precision/precision.app.editor.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
class AppEditorModel
constructor: (app, ubuntuReleases, @mode = 'edit') ->
constructor: (app, ubuntuReleases, @availableInstances, @mode = 'edit') ->
@isNewApp = @mode != 'edit'
@saving = ko.observable(false)
@loadingAssets = ko.observable(false)
@errorMessage = ko.observable()

@ubuntuReleases = ko.observableArray(ubuntuReleases)
@dxid = app?.dxid
@entityType = app?.entity_type
@name = ko.observable(app?.name)
@name.cache = ko.computed(
read: () =>
Expand Down Expand Up @@ -67,7 +68,6 @@ class AppEditorModel

@internetAccess = ko.observable(app?.spec?.internet_access ? false)

@availableInstances = Precision.INSTANCES
@defaultInstanceType = app?.spec?.instance_type ? "baseline-8"
@instanceType = ko.observable(@defaultInstanceType)

Expand Down Expand Up @@ -205,6 +205,7 @@ class AppEditorModel
ordered_assets: @getAssetsForSave()
packages: @packages.peek()
code: @code.peek() ? ""
entity_type: @entityType

Precision.api('/api/apps', params)
.done((data) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ class AppInputModel
data.toString()
)
when 'float'
value = _.map(value, (data) =>
value = _.map(value.split(','), (data) =>
data = $.trim(data)
parseFloat(data, 10)
)
Expand Down
30 changes: 20 additions & 10 deletions app/assets/javascripts/_precision/precision.autocomplete.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ class AutocompleteModel
EVENTS = {
CHANGE_EVENT: "#{PREFIX}.change",
KEYUP: "#{PREFIX}.keyup",
SETVALUE: "#{PREFIX}.setvalue"
SETVALUE: "#{PREFIX}.setvalue",
OPTION_CLICK: "#{PREFIX}.optionClick"
}

createEvents = () -> {
CHANGE_EVENT: new Event(EVENTS.CHANGE_EVENT),
KEYUP: new Event(EVENTS.KEYUP),
SETVALUE: new Event(EVENTS.SETVALUE)
SETVALUE: new Event(EVENTS.SETVALUE),
OPTION_CLICK: new Event(EVENTS.OPTION_CLICK)
}

dispatchEvent = (el, e, eName) ->
el.dispatchEvent(e)
$(el).trigger(eName)
dispatchEvent = (el, e, eName, data) ->
el.dispatchEvent(e, [data])
$(el).trigger(eName, [data])

convertOptionValues = (options = []) ->
simpleTypes = ['string', 'number', 'boolean']
Expand Down Expand Up @@ -62,13 +64,14 @@ class AutocompleteModel

renderInputGroup = () ->
inputGroup = document.createElement('div')
inputGroup.classList.add('#{PREFIX}--input-group')
inputGroup.classList.add("#{PREFIX}--input-group")
return inputGroup

renderRootNode = () ->
renderRootNode = (inputNode) ->
rootNode = document.createElement('div')
rootNode.classList.add("#{PREFIX}")
rootNode.classList.add("#{PREFIX}--wrapper")
rootNode.classList.add("#{PREFIX}--lg") if inputNode.classList.contains('input-lg')
return rootNode

renderHiddenInput = (hiddenInput) ->
Expand Down Expand Up @@ -127,6 +130,7 @@ class AutocompleteModel
@value = e.target.getAttribute('data-value')
@nodes.hiddenInput.value = @value
@dispatchInputEvent('SETVALUE')
@dispatchInputEvent('OPTION_CLICK', @value)

onKeyUp: (e) =>
@dispatchInputEvent('KEYUP')
Expand Down Expand Up @@ -161,8 +165,8 @@ class AutocompleteModel
if notAutocomplete and notHidden
@nodes.optionsContainer.classList.add('hidden')

dispatchInputEvent: (event) ->
dispatchEvent(@nodes.inputNode, @events[event], @eventNames[event])
dispatchInputEvent: (event, data) ->
dispatchEvent(@nodes.inputNode, @events[event], @eventNames[event], data)

disabled: (disabled) ->
if disabled
Expand All @@ -175,7 +179,7 @@ class AutocompleteModel
@eventNames = EVENTS

@nodes = {}
@nodes.rootNode = renderRootNode()
@nodes.rootNode = renderRootNode(@params.inputNode)
@nodes.inputNode = renderInputNode(@params.inputNode)
@nodes.hiddenInput = renderHiddenInput(@params.inputNode)
@nodes.inputGroup = renderInputGroup()
Expand Down Expand Up @@ -224,3 +228,9 @@ class AutocompleteModel

window.Precision ||= {}
window.Precision.autocomplete = AutocompleteModel

### PARAMS ###
# @params.inputNode - input type text (DOM Node, not JQuery) [DOM Node] [REQUIRED]
# @params.getOptionsAsync - Promise to get options with api [function -> promise]
# @params.disabled - disable input node [boolean]
# @params.options - default options [Array[int|string|boolean]] | [Array[Object{value, label}]]
18 changes: 0 additions & 18 deletions app/assets/javascripts/_precision/precision.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,6 @@ window.Precision.CK_CONFIG =
autoGrow_minHeight: 400
autoGrow_onStartup: true

window.Precision.INSTANCES = [
{value: "baseline-2", label: "Baseline 2"}
{value: "baseline-4", label: "Baseline 4"}
{value: "baseline-8", label: "Baseline 8"}
{value: "baseline-16", label: "Baseline 16"}
{value: "baseline-36", label: "Baseline 36"}
{value: "himem-2", label: "High Mem 2"}
{value: "himem-4", label: "High Mem 4"}
{value: "himem-8", label: "High Mem 8"}
{value: "himem-16", label: "High Mem 16"}
{value: "himem-32", label: "High Mem 32"}
{value: "hidisk-2", label: "High Disk 2"}
{value: "hidisk-4", label: "High Disk 4"}
{value: "hidisk-8", label: "High Disk 8"}
{value: "hidisk-16", label: "High Disk 16"}
{value: "hidisk-36", label: "High Disk 36"}
]

window.Precision.carousel =
# Source: http://jsfiddle.net/technotarek/gXN2u/
setHeight: (id) ->
Expand Down
7 changes: 7 additions & 0 deletions app/assets/javascripts/_precision/precision.dataTable.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DataTable = $.fn.dataTable
dom = "<'row'<'col-sm-4'l><'col-sm-12'f>><'row'<'col-sm-24'tr>><'row'<'col-sm-10'i><'col-sm-14'p>>"

$.extend( true, DataTable.defaults, {
dom: dom,
renderer: 'bootstrap'
})
84 changes: 84 additions & 0 deletions app/assets/javascripts/_precision/precision.nav.dropdown.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
TABLE_CONFIG = [
{
resource: 'Compute',
usage: (stats) -> stats.computeCharges,
bold: false,
},
{
resource: 'Storage',
usage: (stats) -> stats.storageCharges,
bold: false,
},
{
resource: 'Data Egress',
usage: (stats) -> stats.dataEgressCharges,
bold: false,
},
{
resource: 'Total',
usage: (stats) -> stats.totalCharges,
bold: true,
},
{
resource: 'Usage Limit',
usage: (stats) -> stats.usageLimit,
bold: false,
},
{
resource: 'Usage Available',
usage: (stats) -> stats.usageAvailable,
bold: true,
},
{
resource: 'Job Limit',
usage: (stats) -> stats.jobLimit,
bold: true,
},
]

createCloudResourceSpendingsTable = (data) ->
TABLE_CONFIG.map((row) -> {
resource: row.resource,
usage: "$#{row.usage(data).toFixed(2)}",
bold: row.bold
})
class NavBarDropdownModel
getCloudResourcesModalElement: () ->
$('#cloud_resources_modal')
# First and foremost apologies my sincerest apologies to knockoutJS gods, this is not creation as it was originally intended
# these params are passed, because this fn is invoked with "afterRender" template workaround
# No idea what is happening
loadStats: (isLoadingObservable, resourceTableObservable) ->
error = false
isLoadingObservable(true)
$.ajax('/api/user/cloud_resources', {
method: 'GET',
contentType: 'application/json',
dataType: 'json',
jsonp: false,
success: (data) ->
data
error: (xhr, status, err) ->
Precision.alert.showAboveAll('Something went wrong while loading cloud user spendings')
error = true
}).done((data) =>
table = createCloudResourceSpendingsTable(data)
resourceTableObservable(table)
).always(=>
isLoadingObservable(false)
)
showCloudResourcesModal: () ->
# Need to reinitialize element, because template rendering most likely occurs between constructor and "loadStats" call, that invalidates the ref
@cloudResourcesModal = @getCloudResourcesModalElement() if @cloudResourcesModal.length == 0
@cloudResourcesModal.modal('show')
constructor: (tableConfig) ->
@cloudResourcesModal = @getCloudResourcesModalElement()
@resourceTable = ko.observable()
@isLoading = ko.observable(false)


$(document).ready(() =>
$headerContainer = $("body header")
viewModel = new NavBarDropdownModel()
ko.applyBindings(viewModel, $headerContainer[0])
)
Loading

0 comments on commit 0f4204b

Please sign in to comment.