Skip to content

Commit

Permalink
updates chemical analysis images workflow #1134
Browse files Browse the repository at this point in the history
  • Loading branch information
chrabyrd committed Oct 30, 2023
1 parent 6791369 commit ec25f17
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 67 deletions.
3 changes: 1 addition & 2 deletions arches_for_science/media/css/project.css
Original file line number Diff line number Diff line change
Expand Up @@ -729,8 +729,7 @@

.afs-image-service-list-item {
display: inline-flex;
flex-direction: column;
align-items: baseline;
align-items: center;
padding-left: 5px;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ define([

SummaryStep.apply(this, [params]);

this.resourceData.subscribe(function(val){
self.loading(true);

this.resourceData.subscribe(async function(val){
this.displayName = val['displayname'] || 'unnamed';
this.reportVals = {
projectName: {'name': 'Project', 'value': params.relatedProjectData.projectName, 'resourceid': params.relatedProjectData.project},
observationName: {'name': 'Observation', 'value': params.relatedProjectData.observationName, 'resourceid': params.relatedProjectData.observation},
};

await getWorkflowDigitalResources();
await getWorkflowManifestResource();

this.loading(false);
}, this);

Expand All @@ -33,16 +39,15 @@ define([
return await response.json()
};

(async (val) => {
async function getWorkflowDigitalResources() {
self.workflowDigitalResources(await Promise.all(self.digitalResourcesIds.map( async function(resourceid){
return await self.getWorkflowResourceData(resourceid);
})));
})();
};

(async (val) => {
async function getWorkflowManifestResource() {
self.workflowManifestResource(await self.getWorkflowResourceData(self.manifestResourceId))
})()

};
}

ko.components.register('add-chemical-analysis-images-final-step', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,51 @@ define([
}
};

this.savePhysicalThingDigitalReferenceTile = function(data) {
var digitalReferenceTile = self.physicalThingDigitalReferenceTile();
var digitalSourceNodeId = 'a298ee52-8d59-11eb-a9c4-faffc265b501'; // Digital Source (E73) (physical thing)

var digitalResourceInstanceId = data.resourceinstance_id

digitalReferenceTile.data[digitalSourceNodeId] = [{
"resourceId": digitalResourceInstanceId,
"ontologyProperty": "http://www.cidoc-crm.org/cidoc-crm/P67i_is_referred_to_by",
"inverseOntologyProperty": "http://www.cidoc-crm.org/cidoc-crm/P67_refers_to"
}];

var digitalReferenceTypeNodeId = 'f11e4d60-8d59-11eb-a9c4-faffc265b501'; // Digital Reference Type (E55) (physical thing)
digitalReferenceTile.data[digitalReferenceTypeNodeId] = '1497d15a-1c3b-4ee9-a259-846bbab012ed'; // Preferred Manifest concept value

digitalReferenceTile.transactionId = params.form.workflowId;
return digitalReferenceTile.save();
}

this.saveObservationDigitalReferenceTile = function(data) {
if (self.observationDigitalReferenceTile()) {
self.observationResourceInstanceId(self.observationDigitalReferenceTile().resourceinstance_id);
var digitalReferenceTile = self.observationDigitalReferenceTile();
var digitalSourceNodeId = '0ae14d2a-8e30-11eb-a9c4-faffc265b501'; // Digital Source (E73) (observation)

var digitalResourceInstanceId = data.resourceinstance_id

digitalReferenceTile.data[digitalSourceNodeId] = [{
"resourceId": digitalResourceInstanceId,
"ontologyProperty": "http://www.cidoc-crm.org/cidoc-crm/P67i_is_referred_to_by",
"inverseOntologyProperty": "http://www.cidoc-crm.org/cidoc-crm/P67_refers_to"
}];

var digitalReferenceTypeNodeId = '0ae14c58-8e30-11eb-a9c4-faffc265b501'; // Digital Reference Type (E55) (observation)
digitalReferenceTile.data[digitalReferenceTypeNodeId] = '1497d15a-1c3b-4ee9-a259-846bbab012ed'; // Preferred Manifest concept value

digitalReferenceTile.transactionId = params.form.workflowId;
return digitalReferenceTile.save();
}
};

this.save = function() {
params.form.complete(false);
params.form.saving(true);
params.pageVm.loading(true);

params.form.lockExternalStep("select-project", true);
if (self.manifestData() && self.manifestData()['label'] === self.selectedPhysicalThingImageServiceName()) {
Expand All @@ -240,43 +282,9 @@ define([
self.digitalResourceServiceIdentifierTile.save().then(async function(data) {
params.form.savedData(data);

var digitalReferenceTile = self.physicalThingDigitalReferenceTile();
var digitalSourceNodeId = 'a298ee52-8d59-11eb-a9c4-faffc265b501'; // Digital Source (E73) (physical thing)

var digitalResourceInstanceId = data.resourceinstance_id
self.savePhysicalThingDigitalReferenceTile(data);
self.saveObservationDigitalReferenceTile(data);

digitalReferenceTile.data[digitalSourceNodeId] = [{
"resourceId": digitalResourceInstanceId,
"ontologyProperty": "http://www.cidoc-crm.org/cidoc-crm/P67i_is_referred_to_by",
"inverseOntologyProperty": "http://www.cidoc-crm.org/cidoc-crm/P67_refers_to"
}];

var digitalReferenceTypeNodeId = 'f11e4d60-8d59-11eb-a9c4-faffc265b501'; // Digital Reference Type (E55) (physical thing)
digitalReferenceTile.data[digitalReferenceTypeNodeId] = '1497d15a-1c3b-4ee9-a259-846bbab012ed'; // Preferred Manifest concept value

digitalReferenceTile.transactionId = params.form.workflowId;
await digitalReferenceTile.save()

// Do the save again for observation
if (self.observationDigitalReferenceTile()) {
self.observationResourceInstanceId(self.observationDigitalReferenceTile().resourceinstance_id);
var digitalReferenceTile = self.observationDigitalReferenceTile();
var digitalSourceNodeId = '0ae14d2a-8e30-11eb-a9c4-faffc265b501'; // Digital Source (E73) (observation)

digitalReferenceTile.data[digitalSourceNodeId] = [{
"resourceId": digitalResourceInstanceId,
"ontologyProperty": "http://www.cidoc-crm.org/cidoc-crm/P67i_is_referred_to_by",
"inverseOntologyProperty": "http://www.cidoc-crm.org/cidoc-crm/P67_refers_to"
}];

var digitalReferenceTypeNodeId = '0ae14c58-8e30-11eb-a9c4-faffc265b501'; // Digital Reference Type (E55) (observation)
digitalReferenceTile.data[digitalReferenceTypeNodeId] = '1497d15a-1c3b-4ee9-a259-846bbab012ed'; // Preferred Manifest concept value

digitalReferenceTile.transactionId = params.form.workflowId;
await digitalReferenceTile.save()
}


self.formData.append("transaction_id", params.form.workflowId);
self.formData.append("observation_id", self.observationResourceInstanceId());

Expand All @@ -301,6 +309,7 @@ define([

params.form.complete(true);
params.form.saving(false);
params.pageVm.loading(false);
})
});
});
Expand All @@ -319,10 +328,41 @@ define([
return tile.nodegroup_id === digitalResourceServiceIdentifierNodegroupId;
});

params.form.savedData(matchingTile);
self.saveObservationDigitalReferenceTile(matchingTile);

self.formData.append("transaction_id", params.form.workflowId);
self.formData.append("observation_id", self.observationResourceInstanceId());

fetch(arches.urls.add_chemical_analysis_images_file_upload, {
method: 'POST',
credentials: 'include',
body: self.formData,
headers: {
"X-CSRFToken": Cookies.get('csrftoken')
}
}).then(resp => {
return resp.json();
}).then(respJSON => {
respJSON.digitalResourceInstanceIds.forEach(function(d){
self.digitalResourcesInstanceIds.push(d);
});

matchingTile.digitalResourceInstancesIds = [];
matchingTile.digitalResourceInstancesIds = self.digitalResourcesInstanceIds();
matchingTile.ManifestResourceId = matchingTile.resourceinstance_id;
params.form.savedData(matchingTile);
params.form.value(matchingTile);

params.form.complete(true);
params.form.saving(false);
params.pageVm.loading(false);
});
}
else {
params.form.complete(true);
params.form.saving(false);
params.pageVm.loading(false);
}
params.form.complete(true);
params.form.saving(false);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,19 @@ <h5 class="summary-value">{% trans 'Related Manifest' %}</h5>
<h5 class="summary-value">{% trans 'Related Digital Files' %}</h5>
<div class="afs-final-step-block">
<div style="display: flex; flex-direction: column;">
<!-- ko foreach: {data: workflowDigitalResources, as: 'digitalResource'} -->
<div style="display: inline-flex;">
<a data-bind="attr: { href: $parent.urls.resource + '/' + digitalResource.resourceinstanceid}" target="_blank">
<div class="summary-value"
data-bind = "text: digitalResource.displayname">
</div>
</a>
</div>
<!-- ko if: workflowDigitalResources().length -->
<!-- ko foreach: {data: workflowDigitalResources, as: 'digitalResource'} -->
<div style="display: inline-flex;">
<a data-bind="attr: { href: $parent.urls.resource + '/' + digitalResource.resourceinstanceid}" target="_blank">
<div class="summary-value"
data-bind = "text: digitalResource.displayname">
</div>
</a>
</div>
<!-- /ko -->
<!-- /ko -->
<!-- ko ifnot: workflowDigitalResources().length -->
<div>{% trans 'None' %}</div>
<!-- /ko -->
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{% load i18n %}

<div class="afs-image-service-instructions" style="padding-bottom: 8px;">
<p>
{% blocktrans %}
Select an existing image service for your object that you can use to draw the locations of your observations.
Or upload image(s) to create a new service.
{% endblocktrans %}
</p>

<!-- ko foreach: [...physicalThingDigitalReferencePreferredManifestResourceData(), ...physicalThingDigitalReferenceAlternateManifestResourceData()] -->
<div class="afs-image-service-list-item">
<div class="afs-image-service-list-item" style="margin-right: 40px;">
<input
type="radio"
data-bind="{
Expand All @@ -31,7 +34,7 @@
<button class="btn btn-success" style="margin-left: 28px;" data-bind="click: openManifestManager, disable: $parent.locked">
<i class="ion-android-cloud-done"></i>
<span>
Create new Image Service
{% trans "Create new Image Service" %}
</span>
</button>

Expand Down Expand Up @@ -67,14 +70,17 @@
data-bind="
style: {
transform: !isManifestManagerHidden() ? 'translate(0,0)' : 'translate(0,-100vh)'
}">
<button
class="btn btn-labeled btn-primary return-to-workflow-button"
data-bind="
style: {
transform: !isManifestManagerHidden() ? 'translate(0,0)' : 'translate(0,-100vh)'
},
click: handleExitFromManifestManager
"
>Return to Workflow</button>
}"
>
<button
class="btn btn-labeled btn-primary return-to-workflow-button"
data-bind="
style: {
transform: !isManifestManagerHidden() ? 'translate(0,0)' : 'translate(0,-100vh)'
},
click: handleExitFromManifestManager
"
>
{% trans "Return to Workflow" %}
</button>
</div>

0 comments on commit ec25f17

Please sign in to comment.