Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update case.notes.js to allow auto image upload from copy and paste #465

Merged
merged 5 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ git checkout v2.4.7
cp .env.model .env

# Build the dockers
docker-compose build
docker compose build

# Run IRIS
docker-compose up
docker compose up
```

Iris shall be available on the host interface, port 443, protocol HTTPS - ``https://<your_instance_ip>``.
Expand Down
43 changes: 43 additions & 0 deletions source/app/static/assets/js/iris/case.notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const preventFormDefaultBehaviourOnSubmit = (event) => {
return false;
};

var editor = ace.edit("editor_detail",
whikernel marked this conversation as resolved.
Show resolved Hide resolved
{autoScrollEditorIntoView: true,
minLines: 4
});

function Collaborator( session_id, n_id ) {
this.collaboration_socket = collaborator_socket;
Expand Down Expand Up @@ -358,6 +362,45 @@ async function note_detail(id) {
});
}

function handle_ed_paste(event) {
filename = null;
const { items } = event.originalEvent.clipboardData;
for (let i = 0; i < items.length; i += 1) {
const item = items[i];

if (item.kind === 'string') {
item.getAsString(function (s){
filename = $.trim(s.replace(/\t|\n|\r/g, '')).substring(0, 40);
});
}

if (item.kind === 'file') {
const blob = item.getAsFile();

if (blob !== null) {
const reader = new FileReader();
reader.onload = (e) => {
notify_success('The file is uploading in background. Don\'t leave the page');

if (filename === null) {
filename = random_filename(25);
}

upload_interactive_data(e.target.result, filename, function(data){
url = data.data.file_url + case_param();
event.preventDefault();
note_editor.insertSnippet(`\n![${filename}](${url} =100%x40%)\n`);
});
};
reader.readAsDataURL(blob);
} else {
notify_error('Unsupported direct paste of this item. Use datastore to upload.');
}
}
}
}


function refresh_ppl_list() {
$('#ppl_list_viewing').empty();
for (let [key, value] of ppl_viewing) {
Expand Down