Skip to content

Commit

Permalink
Merge b0f4d32 into ef13db5
Browse files Browse the repository at this point in the history
  • Loading branch information
eheinrich committed Jun 20, 2019
2 parents ef13db5 + b0f4d32 commit 00a44d5
Show file tree
Hide file tree
Showing 28 changed files with 234 additions and 222 deletions.
10 changes: 6 additions & 4 deletions observation_portal/common/configdb.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from typing import Union
from collections import namedtuple
from collections import namedtuple, defaultdict

import requests
from django.core.cache import caches
Expand Down Expand Up @@ -334,13 +334,15 @@ def get_optical_elements(self, instrument_type: str) -> dict:
Returns:
Available optical elements
"""
optical_elements = {}
optical_elements = defaultdict(list)
optical_elements_tracker = defaultdict(set)
for instrument in self.get_instruments(exclude_states=['DISABLED', ]):
if instrument_type.upper() == instrument['science_camera']['camera_type']['code'].upper():
for optical_element_group in instrument['science_camera']['optical_element_groups']:
optical_elements[optical_element_group['type']] = []
for element in optical_element_group['optical_elements']:
optical_elements[optical_element_group['type']].append(element)
if element['code'] not in optical_elements_tracker[optical_element_group['type']]:
optical_elements_tracker[optical_element_group['type']].add(element['code'])
optical_elements[optical_element_group['type']].append(element)
return optical_elements

def get_modes_by_type(self, instrument_type: str, mode_type: str = '') -> dict:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% extends 'base.html' %}
{% load bootstrap4 %}
{% bootstrap_javascript jquery='full' %}
{% block title %} Proposal List {% endblock %}
{% block content %}
<div class="row">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{% load i18n request_extras humanize %}
{% load static bootstrap4 %}
{% bootstrap_javascript jquery='full' %}
<div class="row requestgroup requestgroup-{{ request.state|state_to_bs }}" data-request='{{ request.id }}'>
<div class="col-md-10">
<div class="row">
Expand All @@ -10,7 +8,7 @@
{% else %}
<span class="requestgroup-title"># {{ request.id }}</span>
{% endif %}
<p><i class="far fa-clock" ></i> <span class="tt" title="Total exposure time + observing overhead"> Duration: {{ request.duration }} seconds</span></p>
<p><i class="far fa-clock" ></i> <span title="Total exposure time + observing overhead"> Duration: {{ request.duration }} seconds</span></p>
<p><i class="fa fa-camera"></i> Instrument: {{ request.configurations.all.0.instrument_type|instrument_type_to_full_name }}</p>
</div>
<div class="col-md-4 requestgroup-block border-right">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% load i18n bootstrap4 request_extras %}
{% bootstrap_javascript jquery='full' %}
{% load i18n request_extras %}
<div class="row">
<div class="col-md-12 ">
<h2>{{ requestgroup.name }} <br/><small>RequestGroup # {{ requestgroup.id }}</small></h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% block title %}Create New Request {% endblock %}
{% block content %}
<div id="app"></div>
{% endblock %}
{% block extra_javascript %}
{% render_bundle 'compose' %}
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div id="request-detail" data-requestid="{{ object.id }}">
<div id="app"></div>
</div>
{% endblock %}
{% block extra_javascript %}
{% render_bundle 'request_detail' %}
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{% if requests.paginator.num_pages > 1 %}
{% bootstrap_pagination requests extra=request.GET.urlencode %}
{% endif %}
{% endblock %}
{% block extra_javascript %}
{% render_bundle 'requestgroup_detail' %}
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% extends 'index.html' %}
{% load render_bundle from webpack_loader %}
{% load i18n bootstrap4 request_extras humanize static %}
{% bootstrap_javascript jquery='full' %}
{% block title %}Submitted Requests{% endblock %}
{% block extra_css %}
<link rel="stylesheet" href="{% static 'css/requestgroup_list.css' %}">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"babel-polyfill": "^6.26.0",
"bootstrap": "^4.3.1",
"bootstrap-table": "^1.12.1",
"bootstrap-table": "^1.14.2",
"bootstrap-vue": "^2.0.0-rc.19",
"chart.js": "^2.8.0",
"chartjs-plugin-annotation": "^0.5.7",
Expand Down
113 changes: 64 additions & 49 deletions static/js/components/configuration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,26 @@
:options="spectraConfigurationOptions"
@input="update"
/>
<div v-if="configuration.type === 'SPECTRUM' || configuration.type === 'NRES_SPECTRUM'">
<customselect
v-model="configuration.acquisition_config.mode"
label="Acquire Mode"
desc="The method for positioning the slit. If Brightest Object is selected, the slit is placed
on the brightest object near the target coordinates."
:errors="{}"
:options="acquireModeOptions"
@input="update"
/>
<customfield
v-for="field in requiredAcquireModeFields"
:key="field"
v-model="configuration.acquisition_config.extra_params[field]"
:label="field | formatField"
:errors="null"
:desc="field | getFieldDescription"
@input="updateAcquisitionConfigExtraParam($event, field)"
/>
</div>
</div>
<div v-if="acquireModeOptions.length > 1 && !simple_interface && configuration.type !== 'LAMP_FLAT' && configuration.type !== 'ARC'">
<customselect
v-model="configuration.acquisition_config.mode"
label="Acquire Mode"
desc="The method for positioning the slit or pinhole. If Brightest Object is selected, the slit/pinhole is placed
on the brightest object near the target coordinates."
:errors="{}"
:options="acquireModeOptions"
@input="update"
/>
<customfield
v-for="field in requiredAcquireModeFields"
:key="field"
v-model="configuration.acquisition_config.extra_params[field]"
:label="field | formatField"
:errors="null"
:desc="field | getFieldDescription"
@input="updateAcquisitionConfigExtraParam($event, field)"
/>
</div>
</b-form>
</b-col>
Expand Down Expand Up @@ -206,22 +206,24 @@
},
acquireModeOptions: function() {
let options = [];
let requiredModeFields = [];
let modes = this.available_instruments[this.selectedinstrument].modes.acquisition.modes;
for (let i in modes) {
requiredModeFields = [];
if ('required_fields' in modes[i].params) {
for (let j in modes[i].params.required_fields) {
requiredModeFields.push(
modes[i].params.required_fields[j]
)
}
}
options.push({
value: modes[i].code,
text: modes[i].name,
requiredFields: requiredModeFields
});
if (this.available_instruments[this.selectedinstrument]) {
let requiredModeFields = [];
let modes = this.available_instruments[this.selectedinstrument].modes.acquisition.modes;
for (let i in modes) {
requiredModeFields = [];
if ('required_fields' in modes[i].params) {
for (let j in modes[i].params.required_fields) {
requiredModeFields.push(
modes[i].params.required_fields[j]
)
}
}
options.push({
value: modes[i].code,
text: modes[i].name,
requiredFields: requiredModeFields
});
}
}
return options;
},
Expand Down Expand Up @@ -276,10 +278,20 @@
console.log('instrumentconfigUpdated');
this.update();
},
acquisitionModeIsAvailable: function(acquisitionMode) {
acquisitionModeIsAvailable: function(acquisitionMode, acquisitionExtraParams) {
// In order for a mode to be available, its code as well as any extra params must match
let modeMatches;
for (let amo in this.acquireModeOptions) {
if (acquisitionMode === this.acquireModeOptions[amo].value) {
return true;
modeMatches = true;
for (let aep in acquisitionExtraParams) {
if (this.acquireModeOptions[amo].requiredFields.indexOf(aep) < 0) {
modeMatches = false;
}
}
if (modeMatches) {
return true;
}
}
}
return false;
Expand All @@ -291,11 +303,19 @@
}
},
setAcquireFields: function() {
if (this.acquisitionModeIsAvailable(this.configuration.acquisition_config.mode)) {
if (this.acquisitionModeIsAvailable(this.configuration.acquisition_config.mode, this.configuration.acquisition_config.extra_params)) {
// The mode that is already set works!
return;
}
if (this.acquireModeOptions.length < 1 || this.simple_interface) {
// This case would happen for i.e. imagers that do not have any acquisition modes. Also
// turn off acquisition for the simple interface since that interface only displays imager,
// and should not be complicated.
this.turnOffAcquisition();
return;
}
}
let defaultMode = this.available_instruments[this.selectedinstrument].modes.acquisition.default;
if (this.acquisitionModeIsAvailable(this.acquireHistory.mode)) {
if (this.acquisitionModeIsAvailable(this.acquireHistory.mode, this.acquireHistory.extra_params)) {
this.configuration.acquisition_config.mode = this.acquireHistory.mode;
this.configuration.acquisition_config.extra_params = this.acquireHistory.extra_params;
} else if (defaultMode) {
Expand All @@ -312,12 +332,6 @@
}
this.update();
},
unsetAcquireFields: function() {
this.saveAcquireFields();
this.configuration.acquisition_config.mode = '';
this.configuration.acquisition_config.extra_params = {};
this.update();
},
turnOffAcquisition: function() {
this.saveAcquireFields();
this.configuration.acquisition_config.mode = 'OFF';
Expand Down Expand Up @@ -346,10 +360,10 @@
this.setAcquireFields();
} else if (configurationType == 'LAMP_FLAT' || configurationType == 'ARC') {
this.setGuidingFields('OPTIONAL');
this.turnOffAcquisition();
this.turnOffAcquisition();
} else if (configurationType == 'EXPOSE') {
this.setGuidingFields(this.selectedImagerGuidingOption);
this.turnOffAcquisition();
this.setAcquireFields();
}
}
},
Expand Down Expand Up @@ -380,6 +394,7 @@
// The selected instrument is set in the request level in the UI, it is actually updated
// in the request json here
this.configuration.instrument_type = value;
this.setupAcquireAndGuideFieldsForType(this.configuration.type);
this.update();
}
},
Expand Down
20 changes: 12 additions & 8 deletions static/js/components/instrumentconfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,25 @@ export default {
this.opticalElementUpdates += 1;
this.update();
},
instrumentConfigurationfillWindow: function() {
this.$emit('instrumentconfigurationfillwindow', this.index);
}
},
watch: {
'instrumentconfig.mode': function(value) {
updateBinning: function() {
for (let mode in this.readoutModeOptions) {
if (value === this.readoutModeOptions[mode].value) {
if (this.instrumentconfig.mode === this.readoutModeOptions[mode].value) {
this.instrumentconfig.bin_x = this.readoutModeOptions[mode].binning;
this.instrumentconfig.bin_y = this.readoutModeOptions[mode].binning;
this.update();
return;
}
}
},
rotatorModeOptions: function(newValue) {
instrumentConfigurationfillWindow: function() {
this.$emit('instrumentconfigurationfillwindow', this.index);
}
},
watch: {
'instrumentconfig.mode': function() {
this.updateBinning();
},
rotatorModeOptions: function() {
if (this.instrumentHasRotatorModes) {
this.instrumentconfig.rotator_mode = this.available_instruments[this.selectedinstrument].modes.rotator.default;
} else {
Expand All @@ -327,6 +330,7 @@ export default {
readoutModeOptions: function() {
// TODO: Implement history
this.instrumentconfig.mode = this.available_instruments[this.selectedinstrument].modes.readout.default;
this.updateBinning();
this.update();
},
availableOpticalElementGroups: function(value) {
Expand Down
3 changes: 2 additions & 1 deletion static/js/components/pressure.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
{value: 'lsc', text: 'Cerro Tololo, Chile (lsc)'},
{value: 'ogg', text: 'Maui, Hawaii (ogg)'},
{value: 'sor', text: 'Cerro Pachón, Chile (sor)'},
{value: 'tfn', text: 'Tenerife, Canary Islands (tfn)'}
{value: 'tfn', text: 'Tenerife, Canary Islands (tfn)'},
{value: 'tlv', text: 'Wise, Israel (tlv)'}
],
data: {
datasets: [],
Expand Down
Loading

0 comments on commit 00a44d5

Please sign in to comment.