Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Import snapshot to current case #727

Merged
merged 15 commits into from
May 16, 2023
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
42 changes: 41 additions & 1 deletion app/assets/javascripts/components/import_ratings/_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,46 @@ <h2>CSV</h2>
</div>
</div>
</uib-tab>
<uib-tab index="2" heading="Snapshots" select="ctrl.clearSelection()">
<p>
Importing snapshots is fun! Any missing queries will be created. The Case ID provided in the uploaded CSV file will be replaced so that all rows will be imported into the current case.
</p>
<div class="form-group">
<input type="radio" id="snapshots" name="importSelection" value="snapshots"
ng-model="ctrl.options.which">
<label for="snapshots">Snapshot CSV</label>

<span class="help-block">
The CSV file should have the headers: <code>Snapshot Name,Snapshot Time,Case ID,Query Text,Doc ID,Doc Position</code> and lines similar to:
<pre>
Snapshot: testsnap1,2023-05-12T18:22:22.245Z,6,test,527641,1
Snapshot: testsnap1,2023-05-12T18:22:22.245Z,6,test,9426,2
Snapshot: testsnap1,2023-05-12T18:22:22.245Z,6,test,1921,3
</pre>
</span>
<p>Select Snapshot CSV file to import:</p>

<ng-csv-import
class="import"
content="ctrl.snapshots.content"
header="ctrl.snapshots.header"
header-visible="true"
separator="ctrl.snapshots.separator"
separator-visible="ctrl.snapshots.separatorVisible"
result="ctrl.snapshots.result">
</ng-csv-import>

<div ng-if="ctrl.snapshots.content" class="block left">
<h2>CSV</h2>
<div ng-show="ctrl.snapshots.import.alert" class="text-danger bg-danger import-content"
ng-bind-html="ctrl.snapshots.import.alert">
</div>
<div class="content import-content">
<pre>{{ ctrl.snapshots.content }}</pre>
</div>
</div>
</div>
</uib-tab>
</uib-tabset>

</div>
Expand All @@ -130,7 +170,7 @@ <h2>CSV</h2>
<span ng-show="ctrl.ratingsTypePicked()">
This operation WILL override your existing ratings. Proceed with caution!
</span>
<span ng-show="!ctrl.ratingsTypePicked()">
<span ng-show="ctrl.informationNeedsTypePicked()">
This operation WILL override your existing information needs. Proceed with caution!
</span>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,50 @@ angular.module('QuepidApp')
'flash',
'caseSvc',
'queriesSvc',
function($scope, $uibModal, flash, caseSvc, queriesSvc) {
'querySnapshotSvc',
function ($scope, $uibModal, flash, caseSvc, queriesSvc, querySnapshotSvc) {
var ctrl = this;

// Functions
ctrl.create = create;

function create () {
function create() {
var modalInstance = $uibModal.open({
templateUrl: 'import_ratings/_modal.html',
controller: 'ImportRatingsModalInstanceCtrl',
templateUrl: 'import_ratings/_modal.html',
controller: 'ImportRatingsModalInstanceCtrl',
controllerAs: 'ctrl',
size: 'lg',
resolve: {
theCase: function() {
resolve: {
theCase: function () {
return ctrl.acase;
},
querySnapshotSvc: function () {
return querySnapshotSvc;
},
flash: function () {
return flash;
},
queriesSvc: function () {
return flash;
}
}
});

modalInstance.result.then(
function(error) {
if ( !error ) {
function (response) {
if (!response.error) {
queriesSvc.reset();
queriesSvc.bootstrapQueries(ctrl.acase.caseNo)
.then(function() {
.then(function () {
queriesSvc.searchAll();
});

flash.success = 'Ratings imported successfully!';
flash.success = response.message;
} else {
flash.error = error;
flash.error = response.message;
}
}, function() { }
}, function () {
}
);
}
}
Expand Down
Loading