Skip to content

Commit

Permalink
Merge 35a17f1 into d4fe818
Browse files Browse the repository at this point in the history
  • Loading branch information
jsavell committed Nov 16, 2018
2 parents d4fe818 + 35a17f1 commit a3cdeea
Show file tree
Hide file tree
Showing 78 changed files with 559 additions and 219 deletions.
5 changes: 4 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ module.exports = function (grunt) {
'node_modules/weaver-ui-core/app/controllers/registrationController.js',
'node_modules/weaver-ui-core/app/controllers/userController.js',
'node_modules/weaver-ui-core/app/controllers/errorPageController.js',

'node_modules/openseadragon/build/openseadragon/openseadragon.min.js',
'node_modules/ng-openseadragon/dist/ng-openseadragon.min.js'
],
dest: '<%= build.app %>/resources/scripts/core_concat.js'
},
Expand Down Expand Up @@ -206,4 +209,4 @@ module.exports = function (grunt) {

grunt.registerTask('deploy', ['jshint', 'useminPrepare', 'concat', 'uglify', 'usemin', 'sass']);

};
};
3 changes: 2 additions & 1 deletion app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var metadataTool = angular.module('metadataTool', [
'ngTable',
'ngSanitize',
'ngCsv',
'ngFileUpload'
'ngFileUpload',
'ui.openseadragon'
]);

metadataTool.model = core.model;
Expand Down
18 changes: 14 additions & 4 deletions app/config/apiMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ var apiMapping = {
remove: {
'endpoint': '/private/queue',
'controller': 'project',
'method': 'delete'
'method': 'remove'
},
ingestTypes: {
'endpoint': '/private/queue',
Expand All @@ -143,6 +143,11 @@ var apiMapping = {
'endpoint': '/private/queue',
'controller': 'project',
'method': 'get-field-profile-labels'
},
syncDocuments: {
'endpoint': '/private/queue',
'controller': 'project',
'method': 'sync'
}
},
ProjectRepository: {
Expand All @@ -165,7 +170,7 @@ var apiMapping = {
remove: {
'endpoint': '/private/queue',
'controller': 'project-repository',
'method': 'delete'
'method': 'remove'
},
types: {
'endpoint': '/private/queue',
Expand Down Expand Up @@ -193,12 +198,17 @@ var apiMapping = {
remove: {
'endpoint': '/private/queue',
'controller': 'project-authority',
'method': 'delete'
'method': 'remove'
},
types: {
'endpoint': '/private/queue',
'controller': 'project-authority',
'method': 'types'
},
uploadCsv: {
'endpoint': '/private/queue',
'controller': 'project-authority',
'method': 'upload-csv'
}
},
ProjectSuggestor: {
Expand All @@ -221,7 +231,7 @@ var apiMapping = {
remove: {
'endpoint': '/private/queue',
'controller': 'project-suggestor',
'method': 'delete'
'method': 'remove'
},
types: {
'endpoint': '/private/queue',
Expand Down
9 changes: 7 additions & 2 deletions app/config/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ var appConfig = {
// Set this to the webService if mocking AuthService

'authService': 'http://labs.library.tamu.edu/auth3',
'webService': 'http://localhost:9001',

'webService': 'http://localhost:9000',
'iiifService': 'http://localhost:9003',
//If cantaloupeService is null, a simple image viewer will be used instead of the OpenSeaDragon viewer
'cantaloupeService': 'http://localhost:8182/iiif/2/',

'basePath': '/metadatatool',

'storageType': 'session',

Expand All @@ -31,6 +34,8 @@ var appConfig = {
*/
'sockJsConnectionType': ['websocket', 'iframe-eventsource', 'iframe-htmlfile', 'jsonp-polling'],

'contentMap': {"image": ["image/jpeg", "image/jpg", "image/png", "image/gif", "image/svg", "image/bmp", "image/jp2", "image/jpx", "image/tif", "image/tiff"],"pdf": ["application/pdf"], "text": ["text/plain"]},

// Set this to 'admin' or 'user' if using mock AuthService
// otherwise set to null or false

Expand Down
10 changes: 0 additions & 10 deletions app/controllers/adminController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,4 @@ metadataTool.controller('AdminController', function ($controller, $injector, $ro
$scope: $scope
}));

$scope.sync = function () {
WsApi.fetch({
endpoint: '/private/queue',
controller: 'admin',
method: 'sync'
}).then(function (data) {
logger.log(data);
});
};

});
85 changes: 27 additions & 58 deletions app/controllers/annotateController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
metadataTool.controller('AnnotateController', function ($controller, $http, $location, $routeParams, $q, $scope, $timeout, AlertService, ControlledVocabularyRepo, DocumentRepo, ResourceRepo, StorageService, UserService) {
metadataTool.controller('AnnotateController', function ($controller, $http, $location, $routeParams, $q, $scope, $timeout, AlertService, ControlledVocabularyRepo, DocumentRepo, ResourceRepo, StorageService, UserService, ProjectRepositoryRepo) {

angular.extend(this, $controller('AbstractController', {
$scope: $scope
Expand All @@ -12,11 +12,15 @@ metadataTool.controller('AnnotateController', function ($controller, $http, $loc

$scope.cv = ControlledVocabularyRepo.getAll();

$scope.repositories = ProjectRepositoryRepo.getAll();

$scope.action = $routeParams.action;

$scope.loadingText = "Loading...";

$q.all([documentPromise, resourcesPromise, ControlledVocabularyRepo.ready()]).then(function (args) {
var types = appConfig.contentMap;

$q.all([documentPromise, resourcesPromise, ControlledVocabularyRepo.ready(), ProjectRepositoryRepo.ready()]).then(function (args) {
$scope.document = args[0];

$scope.resources = args[1];
Expand All @@ -40,29 +44,6 @@ metadataTool.controller('AnnotateController', function ($controller, $http, $loc
$scope.suggestions = payload["ArrayList<Suggestion>"] !== undefined ? payload["ArrayList<Suggestion>"] : payload.ArrayList;
});

var types = {
text: ['text/plain'],
pdf: ['application/pdf'],
image: ['image/jpeg', 'image/jpg', 'image/jp2', 'image/jpx', 'image/svg', 'image/bmp', 'image/gif', 'image/png', 'image/tif', 'image/tiff']
};

var selected = {
text: 0,
pdf: 0,
image: 0
};

var transition = function () {
$scope.loading = true;
$scope.switching = true;
$timeout(function () {
$scope.loading = false;
}, 1000);
$timeout(function () {
$scope.switching = false;
}, 250);
};

$scope.hasFileType = function (type) {
for (var k in $scope.resources) {
var resource = $scope.resources[k];
Expand All @@ -73,39 +54,15 @@ metadataTool.controller('AnnotateController', function ($controller, $http, $loc
return false;
};

$scope.active = $scope.hasFileType('text') ? 'text' : $scope.hasFileType('pdf') ? 'pdf' : $scope.hasFileType('image') ? 'image' : undefined;

$scope.select = function (type) {
$scope.active = type;
};

$scope.getFiles = function () {
$scope.getFilesOfType = function (type) {
if ($scope.resources === undefined) {
return [];
}
return $scope.resources.filter(function (resource) {
return types[$scope.active].indexOf(resource.mimeType) >= 0;
return types[type].indexOf(resource.mimeType) >= 0;
});
};

$scope.selected = function () {
return selected[$scope.active];
};

$scope.next = function () {
if ($scope.selected() < $scope.getFiles().length - 1) {
transition();
selected[$scope.active]++;
}
};

$scope.previous = function () {
if ($scope.selected() > 0) {
transition();
selected[$scope.active]--;
}
};

$scope.removeMetadataField = function (field, index) {
$scope.document.dirty(true);
field.values.splice(index, 1);
Expand Down Expand Up @@ -232,17 +189,18 @@ metadataTool.controller('AnnotateController', function ($controller, $http, $loc
var urls = [];
for (var i in $scope.document.publishedLocations) {
var publishedLocation = $scope.document.publishedLocations[i];
if (publishedLocation.repository.type === 'FEDORA_PCDM') {
var fedoraUrl = getSetting(publishedLocation.repository.settings, 'repoUrl').values[0];
var fedoraRestPath = getSetting(publishedLocation.repository.settings, 'restPath').values[0];
var publishedRepository = $scope.getRepositoryById(publishedLocation.repository);
if (publishedRepository.type === 'FEDORA_PCDM') {
var fedoraUrl = getSetting(publishedRepository.settings, 'repoUrl').values[0];
var fedoraRestPath = getSetting(publishedRepository.settings, 'restPath').values[0];
var fedoraRestBaseUrl = fedoraUrl + '/' + fedoraRestPath + '/';
var containerContextPath = publishedLocation.url.replace(fedoraRestBaseUrl, '');
urls.push(appConfig.iiifService + '/fedora/presentation?context=' + containerContextPath);
urls.push(appConfig.iiifService + '/fedora/collection?context=' + containerContextPath.substring(0, containerContextPath.lastIndexOf('/')).replace('_objects', ''));
}
if (publishedLocation.repository.type === 'DSPACE') {
var dspaceUrl = getSetting(publishedLocation.repository.settings, 'repoUrl').values[0];
var dspaceXmluiPath = getSetting(publishedLocation.repository.settings, 'repoContextPath').values[0];
if (publishedRepository.type === 'DSPACE') {
var dspaceUrl = getSetting(publishedRepository.settings, 'repoUrl').values[0];
var dspaceXmluiPath = getSetting(publishedRepository.settings, 'repoContextPath').values[0];
var dspaceXmluiBaseUrl = dspaceUrl + '/' + dspaceXmluiPath + '/';
var handlePath = publishedLocation.url.replace(dspaceXmluiBaseUrl, '');
urls.push(appConfig.iiifService + '/dspace/presentation?context=' + handlePath);
Expand All @@ -251,6 +209,17 @@ metadataTool.controller('AnnotateController', function ($controller, $http, $loc
}
return urls;
};

$scope.getRepositoryById = function(repositoryId) {
var respository = null;
for (var i in $scope.repositories) {
if (repositoryId == $scope.repositories[i].id) {
repository = $scope.repositories[i];
break;
}
}
return repository;
};
});

});
Expand All @@ -272,4 +241,4 @@ metadataTool.filter('selected', function () {
}
return output;
};
});
});
36 changes: 33 additions & 3 deletions app/controllers/projectAuthorityController.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
metadataTool.controller('ProjectAuthorityController', function ($controller, $scope, UserService, ProjectAuthorityRepo) {
metadataTool.controller('ProjectAuthorityController', function ($controller, $scope, UserService, ProjectAuthorityRepo, ProjectRepo) {

angular.extend(this, $controller('AbstractController', {$scope: $scope}));

$scope.user = UserService.getCurrentUser();

$scope.projectAuthorities = [];

$scope.projects = [];

$scope.types = [];

$scope.newAuthority = {};
Expand All @@ -20,12 +22,41 @@ metadataTool.controller('ProjectAuthorityController', function ($controller, $sc
$scope.types = serviceTypes;
});

$scope.projects = ProjectRepo.getAll();

$scope.delete = function(authority) {
manageAuthority('delete',authority);
};

$scope.update = function(authority) {
repository.dirty(true);
manageRepository('save',authority);
};

$scope.create = function(newAuthority,newAuthoritySettings) {
$scope.create = function(newAuthority,newAuthoritySettings,file) {
if (typeof file !== 'undefined') {
ProjectAuthorityRepo.uploadCsv(file).then(function(data) {
var body = angular.fromJson(data.body);
newAuthoritySettings.paths = {"value":body.payload.String};
create(newAuthority,newAuthoritySettings);
});
} else {
create(newAuthority,newAuthoritySettings);
}
};

$scope.getProjectById = function(projectId) {
var project = null;
for (var i in $scope.projects) {
if (projectId == $scope.projects[i].id) {
project = $scope.projects[i];
break;
}
}
return project;
};

var create = function(newAuthority,newAuthoritySettings) {
var settings = [];
angular.forEach(newAuthoritySettings, function(valueObj,key) {
this.push({"key":key,"values": [valueObj.value]});
Expand All @@ -35,7 +66,6 @@ metadataTool.controller('ProjectAuthorityController', function ($controller, $sc
$scope.newAuthority = {};
$scope.newAuthoritySettings = {};
});

};

var manageAuthority = function(method,authority) {
Expand Down
19 changes: 18 additions & 1 deletion app/controllers/projectController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
metadataTool.controller('ProjectController', function ($controller, $scope, UserService, ProjectRepo, ProjectRepositoryRepo, ProjectAuthorityRepo, ProjectSuggestorRepo, MetadataRepo) {
metadataTool.controller('ProjectController', function ($controller, $scope, AlertService, UserService, ProjectRepo, ProjectRepositoryRepo, ProjectAuthorityRepo, ProjectSuggestorRepo, MetadataRepo) {

angular.extend(this, $controller('AbstractController', {$scope: $scope}));

Expand All @@ -17,6 +17,7 @@ metadataTool.controller('ProjectController', function ($controller, $scope, User
$scope.inputTypes = [];

$scope.isEditing = false;
$scope.isSyncing = false;

$scope.displayResponse = {"status":null,"message":null};

Expand Down Expand Up @@ -56,6 +57,10 @@ metadataTool.controller('ProjectController', function ($controller, $scope, User

$scope.projects = ProjectRepo.getAll();

$scope.delete = function(project) {
manageProject('delete', project);
};

$scope.update = function(project) {
angular.forEach($scope.updateableProjectServices, function(serviceIndexes, serviceType) {
project[serviceType] = [];
Expand Down Expand Up @@ -156,6 +161,18 @@ metadataTool.controller('ProjectController', function ($controller, $scope, User
}
return result;
};

$scope.syncDocuments = function (project) {
$scope.isSyncing = true;
ProjectRepo.syncDocuments(project.id).then(function (rawResponse) {
var response = angular.fromJson(rawResponse.body);
if (response.meta.status === "SUCCESS") {
AlertService.add(response.meta, "app/projects");
}
$scope.closeModal();
$scope.isSyncing = false;
});
};
}
});

Expand Down

0 comments on commit a3cdeea

Please sign in to comment.