Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
jrtcppv committed Aug 8, 2021
2 parents e91e89c + 467f91a commit aab6af9
Show file tree
Hide file tree
Showing 24 changed files with 1,136 additions and 262 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ FILES = \
components/filter-data.js \
components/removable-pill.js \
components/user-data.js \
components/text-calendar-button.js \
registration/registration-page.js \
password-reset/password-reset-request-page.js \
password-reset/password-reset-page.js \
Expand Down Expand Up @@ -335,6 +336,7 @@ FILES = \
components/inline-warning.js \
project-settings/single-upload.js \
project-settings/data-media-list.js \
project-settings/data-version-list.js \
project-settings/data-project-types.js \
project-settings/data-attributes-clone.js \
project-settings/data-memberships.js \
Expand All @@ -350,6 +352,7 @@ FILES = \
project-settings/leaf-type-edit.js \
project-settings/state-type-edit.js \
project-settings/membership-edit.js \
project-settings/version-edit.js \
project-settings/project-settings.js \
annotation/annotation-breadcrumbs.js \
annotation/lock-button.js \
Expand Down
23 changes: 21 additions & 2 deletions main/schema/components/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'show_empty': {
'type': 'boolean',
'description': 'Whether to show this version on media for which no annotations exist.',
'default': True,
'default': True
},
'bases': {
'type': 'array',
Expand All @@ -29,7 +29,26 @@

version_update = {
'type': 'object',
'properties': version_properties,
'properties': {
'name': {
'description': 'Name of the version.',
'type': 'string',
},
'description': {
'description': 'Description of the version.',
'type': 'string',
},
'show_empty': {
'type': 'boolean',
'description': 'Whether to show this version on media for which no annotations exist.',
},
'bases': {
'type': 'array',
'description': 'Array of other version IDs that are dependencies of this version.',
'items': {'type': 'integer'},
'minimum': 0,
},
}
}

version = {
Expand Down
1 change: 1 addition & 0 deletions main/static/css/tator/components/_form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -415,4 +415,5 @@ input[type="datetime-local"] {

::-webkit-calendar-picker-indicator {
filter: invert(1);
margin-left: 2px;
}
2 changes: 1 addition & 1 deletion main/static/js/annotation/frame-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FramePanel extends TatorElement {
this._typeId = val.id;
this._method = val.interpolation;
this._attributes.dataType = val;
this._attributes.addEventListener("input", () => {
this._attributes.addEventListener("change", () => {
if (this._blockingWrites) {
return;
}
Expand Down
5 changes: 5 additions & 0 deletions main/static/js/annotation/video-settings-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class VideoSettingsDialog extends ModalDialog {
safeModeOption.setAttribute("on-text", "On");
safeModeOption.setValue(true);
safeModeGridDiv.appendChild(safeModeOption);
this._safeModeOption = safeModeOption;

const apply = document.createElement("button");
apply.setAttribute("class", "btn btn-clear");
Expand Down Expand Up @@ -252,6 +253,10 @@ class VideoSettingsDialog extends ModalDialog {
}

let mainVideo = this._medias[0];
if (mainVideo['fps'] < 20)
{
this._safeModeOption.setValue(false);
}
let sourceList = [];
for (let mediaFile of mainVideo.media_files["streaming"])
{
Expand Down
5 changes: 5 additions & 0 deletions main/static/js/annotator/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,11 @@ class VideoCanvas extends AnnotationCanvas {
var promise = this._videoElement[this._scrub_idx].loadedDataPromise(this);

this.startDownload(streaming_files, offsite_config);
if (fps < 20)
{
console.info("Disable safe mode for low FPS");
this.allowSafeMode = false;
}
if (fps > guiFPS)
{
this._playbackRate=guiFPS/fps;
Expand Down
1 change: 1 addition & 0 deletions main/static/js/components/inputs/checkbox-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class CheckboxInput extends TatorElement {
}

setValue(val) {
console.log(val.id);
this._input.value = val.id;
this._checked = val.checked;
if (val.data) {
Expand Down
100 changes: 83 additions & 17 deletions main/static/js/components/inputs/datetime-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,33 @@ class DateTimeInput extends TatorElement {
this._input.setAttribute("class", "form-control input-sm col-12");
this._input.setAttribute("type", "datetime-local");
this._input.setAttribute("step", ".1");
this._input.hidden = false;
this.label.appendChild(this._input);

this._textInput = document.createElement("input");
this._textInput.setAttribute("class", "form-control input-sm col-8");
this._textInput.setAttribute("type", "text");
this._textInput.hidden = true;
this.label.appendChild(this._textInput);

this._toggle = document.createElement("text-calendar-button");
this.label.appendChild(this._toggle);

this._toggle.addEventListener("click", () => {
if (this._toggle.current_state == "text") {
this._input.hidden = true;
this._textInput.hidden = false;
}
else {
this._input.hidden = false;
this._textInput.hidden = true;
}
});

this._input.addEventListener("change", () => {

this._setTextFromCalendar(); // this.getValue() utilizes the text field

if (this.getValue() === null) {
this._input.classList.add("has-border");
this._input.classList.add("is-invalid");
Expand All @@ -38,6 +62,25 @@ class DateTimeInput extends TatorElement {
this._input.addEventListener("blur", () => {
document.body.classList.remove("shortcuts-disabled");
});

this._textInput.addEventListener("change", () => {
if (this.getValue() === null) {
this._textInput.classList.add("has-border");
this._textInput.classList.add("is-invalid");
} else {
this._textInput.classList.remove("has-border");
this._textInput.classList.remove("is-invalid");
}
this.dispatchEvent(new Event("change"));
});

this._textInput.addEventListener("focus", () => {
document.body.classList.add("shortcuts-disabled");
});

this._textInput.addEventListener("blur", () => {
document.body.classList.remove("shortcuts-disabled");
});
}

static get observedAttributes() {
Expand All @@ -56,10 +99,14 @@ class DateTimeInput extends TatorElement {
set permission(val) {
if (hasPermission(val, "Can Edit")) {
this._input.removeAttribute("readonly");
this._textInput.removeAttribute("readonly");
this._input.classList.remove("disabled");
this._textInput.classList.remove("disabled");
} else {
this._input.setAttribute("readonly", "");
this._textInput.setAttribute("readonly", "");
this._input.classList.add("disabled");
this._textInput.classList.add("disabled");
}
}

Expand All @@ -83,66 +130,85 @@ class DateTimeInput extends TatorElement {
}

getValue() {
let val = this._input.value;
let val = new Date(this._textInput.value);
if (isNaN(val.getTime())) {
val = null;
} else {
val = val.toISOString();
}
return val;
}

_setTextFromCalendar() {
let val = this._input.value;
if (val === null || val === "" || isNaN(new Date(val).getTime())) {
val = null;
} else {
let utcString = val + 'Z';
let date = new Date(utcString);

val = date.toISOString();
}
return val;

this._textInput.value = val;
}

setValue(val) {
// assume any incoming value (not null, or "") is in ISO format
// datetime-local requires this format: YYYY-MM-DDThh:mm:ss.ms
// the text-field will utilize the ISO format: YYYY-MM-DDTHH:mm:ss.sssZ
// Even though it says local, let's assume UTC
if (val === null || val === "" || isNaN(new Date(val).getTime())) {
val = null;
} else {
let date = new Date(val);
let minuteWithOffset = (date.getMinutes() + date.getTimezoneOffset());
date.setMinutes(minuteWithOffset);
//console.log(date.toString());

let year = date.getFullYear();
let month = (Number(date.getMonth()) + 1).toLocaleString('en-US', {
minimumIntegerDigits: 2,
useGrouping: false
useGrouping: false,
timeZone: 'UTC'
});
let day = date.getDate().toLocaleString('en-US', {
minimumIntegerDigits: 2,
useGrouping: false
useGrouping: false,
timeZone: 'UTC'
});
let hours = date.getHours().toLocaleString('en-US', {
minimumIntegerDigits: 2,
useGrouping: false
useGrouping: false,
timeZone: 'UTC'
});
let minutes = date.getMinutes().toLocaleString('en-US', {
minimumIntegerDigits: 2,
useGrouping: false
useGrouping: false,
timeZone: 'UTC'
});
let seconds = date.getSeconds().toLocaleString('en-US', {
minimumIntegerDigits: 2,
useGrouping: false
useGrouping: false,
timeZone: 'UTC'
});
let milliseconds = date.getMilliseconds().toLocaleString('en-US', {
minimumIntegerDigits: 3,
useGrouping: false
useGrouping: false,
timeZone: 'UTC'
});

let dateToString = `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${milliseconds}`;

val = dateToString;
}
//console.log(val);
this._input.value = val;
}

// set autocomplete(config) {
// TatorAutoComplete.enable(this._input, config);
// }
if (val != null) {
this._input.value = val;
this._textInput.value = val + "Z";
}
else {
this._input.value = null;
this._textInput.value = null;
}
}
}

customElements.define("datetime-input", DateTimeInput);
45 changes: 43 additions & 2 deletions main/static/js/components/inputs/feature/checkbox-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class CheckboxSet extends TatorElement {
}

_newInput(item){
console.log(item.id);
console.log(item.name);
let checkbox = document.createElement("checkbox-input");
checkbox.setAttribute("name", `${item.name}`);
if (this.type != undefined) {
Expand Down Expand Up @@ -115,9 +117,48 @@ class CheckboxSet extends TatorElement {
return this._inputs.filter(input => input.getChecked()).map(checked => checked.getData());
}

changed(){
return this.getValue() !== this._default;
changed() {
const currentValue = this.getValue();
const originalValue = this._default

if (currentValue && originalValue) {
if (originalValue.length !== currentValue.length) {
return true;
} else {
// if they are the same lenght they should have the same values
for (let val of originalValue) {
if(!currentValue.includes(val)) return true
}
}
}

return false;
}

relabelInput({ value, newLabel }) {
for (let checkbox of this._inputs) {
if(Number(checkbox._input.value) === Number(value)) return checkbox.setAttribute("name", newLabel);
}
return console.log("No matching input found");
}

removeInput({ value }) {
for (let checkbox of this._inputs) {
if (Number(checkbox._input.value) === Number(value)) {
checkbox.setValue(false);

let idx = this._inputs.indexOf(checkbox);
this._inputs.splice(idx, 1);
checkbox.remove()
const inputWrapper = this._inputDiv.children[idx];
console.log(inputWrapper);
this._inputDiv.removeChild(inputWrapper);

return true;
}
}
return console.log("No matching input found");
}

}

Expand Down
Loading

0 comments on commit aab6af9

Please sign in to comment.