diff --git a/arches/admin.py b/arches/admin.py index 8a1b96bc916..b73521756fe 100644 --- a/arches/admin.py +++ b/arches/admin.py @@ -15,13 +15,27 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . ''' - -from app.models.models import DLanguage, MapLayer, MapSource, TileserverLayer, IIIFManifest, Geocoder, MapMarker, DDataType, Widget, Plugin, UserProfile, GraphModel + +from app.models import models from django.contrib import admin from guardian.admin import GuardedModelAdmin + class PluginAdmin(GuardedModelAdmin): - pass + pass -admin.site.register([DLanguage, MapLayer, MapSource, TileserverLayer, IIIFManifest, Geocoder, MapMarker, DDataType, Widget, UserProfile, GraphModel]) -admin.site.register(Plugin, PluginAdmin) + +admin.site.register([ + models.DLanguage, + models.MapLayer, + models.MapSource, + models.TileserverLayer, + models.Geocoder, + models.MapMarker, + models.DDataType, + models.Widget, + models.UserProfile, + models.GraphModel + ]) + +admin.site.register(models.Plugin, PluginAdmin) diff --git a/arches/app/datatypes/datatypes.py b/arches/app/datatypes/datatypes.py index 0b9b716cc67..36538e04084 100644 --- a/arches/app/datatypes/datatypes.py +++ b/arches/app/datatypes/datatypes.py @@ -1224,64 +1224,6 @@ def process_mobile_data(self, tile, node, db, couch_doc, node_value): pass return node_value -class CSVChartJsonDataType(FileListDataType): - def __init__(self, model=None): - super(CSVChartJsonDataType, self).__init__(model=model) - - def handle_request(self, current_tile, request, node): - try: - previously_saved_tile = models.TileModel.objects.filter(pk=current_tile.tileid) - if previously_saved_tile.count() == 1: - for previously_saved_file in previously_saved_tile[0].data[str(node.pk)]['files']: - previously_saved_file_has_been_removed = True - for incoming_file in current_tile.data[str(node.pk)]['files']: - if previously_saved_file['file_id'] == incoming_file['file_id']: - previously_saved_file_has_been_removed = False - if previously_saved_file_has_been_removed: - deleted_file = models.File.objects.get(pk=previously_saved_file["file_id"]) - deleted_file.delete() - - files = request.FILES.getlist('file-list_' + str(node.pk), []) - for file_data in files: - file_model = models.File() - file_model.path = file_data - file_model.save() - for file_json in current_tile.data[str(node.pk)]['files']: - if file_json["name"] == file_data.name and file_json["url"] is None: - file_json["file_id"] = str(file_model.pk) - file_json["url"] = str(file_model.path.url) - file_json["status"] = 'uploaded' - except Exception as e: - print e - - -class IIIFDrawingDataType(BaseDataType): - def get_strings(self, nodevalue): - string_list = [nodevalue['manifestLabel']] - for feature in nodevalue['features']: - if feature['properties']['name'] != '': - string_list.append(feature['properties']['name']) - return string_list - - def append_to_document(self, document, nodevalue, nodeid, tile, provisional=False): - string_list = self.get_strings(nodevalue) - for string_item in string_list: - document['strings'].append({'string': string_item, 'nodegroup_id': tile.nodegroup_id}) - for feature in nodevalue['features']: - if feature['properties']['type'] is not None: - valueid = feature['properties']['type'] - value = models.Value.objects.get(pk=valueid) - document['domains'].append({'label': value.value, 'conceptid': value.concept_id, 'valueid': valueid, 'nodegroup_id': tile.nodegroup_id, 'provisional': provisional}) - - def get_search_terms(self, nodevalue, nodeid=None): - terms = [] - string_list = self.get_strings(nodevalue) - for string_item in string_list: - if string_item is not None: - if settings.WORDS_PER_SEARCH_TERM == None or (len(string_item.split(' ')) < settings.WORDS_PER_SEARCH_TERM): - terms.append(string_item) - return terms - class BaseDomainDataType(BaseDataType): def get_option_text(self, node, option_id): diff --git a/arches/app/media/css/arches.css b/arches/app/media/css/arches.css index acd2aecb70e..15db7f973ec 100644 --- a/arches/app/media/css/arches.css +++ b/arches/app/media/css/arches.css @@ -7273,7 +7273,7 @@ a.list-group-item:not(.active):hover, .clear-find:hover, div .switch label:hover background: #01113c; border-radius: 50%; border: none; - + } .btn-file-select { @@ -8065,78 +8065,11 @@ h4.report-toolbar-title { color: grey; } -.csv-chart { - height: 300px; - margin-left: -10px; - padding-right: 30px; -} - -.csv-chart-title { - font-size: 15px; - font-weight: 500; -} - -.csv-chart-menubar { - padding-bottom: 15px; - margin-top: 5px; -} - -.csv-chart-menubar-item { - padding: 5px 10px; - border: 1px solid #ddd; -} - -a .csv-chart-menubar-item { - color: #777; - font-weight: 400; -} - -.csv-chart-menubar-item.active { - color: #123; - border-radius: 1px; - background: #f2f2f2; -} - -.csv-chart-widget-input { - width: 100%; - padding: 0px 0px 10px; -} - -.csv-chart-selection-detail-container { - flex-direction: row; - display: flex; - justify-content: center; -} - -.csv-chart-selection-detail { - flex-grow: 1; - flex-shrink: 1; -} - .file-selector { padding-right: 15px; padding-top: 15px; } -.tab-content .csv-chart-panel { - padding-top: 0px; -} - -.pad-ver .csv-chart-panel { - padding-top: 0px; -} - -.csv-chart-container { - margin-top: -15px; - margin-left: -30px; - margin-right: -45px; -} - -.csv-chart-file-selector { - margin-top: 10px; - padding-right: 15px; -} - .map-widget-container { position: absolute; top: 6px; @@ -8572,19 +8505,6 @@ div.row.widget-wrapper.report-header:hover { right: 11px; } -.iiif-wrapper .map-widget-panel { - background-color: rgba(143, 143, 143, 0.2); - border-left: solid rgba(143, 143, 143, 0.6) 1px; -} - -.expanded-iiif .map-widget-panel { - position: fixed; - top: 160px; - width: 298px; - bottom: 0; - height: auto; -} - .map-search-container, .map-search-container div .map-widget-panel { height: calc(100vh - 110px); } @@ -8654,25 +8574,6 @@ div.row.widget-wrapper.report-header:hover { top: 51px; } -.iiif-wrapper { - height: 500px; -} - -.iiif-wrapper.expanded-iiif { - position: fixed; - top: 106px; - right: 0px; - left: 50px; - bottom: 0; - transition-duration: .3s; - z-index: 100; - height: auto; -} - -.leaflet-iiif { - height: 100%; -} - .expanded-resource-menu { margin-left: -275px; transition-duration: .3s; @@ -9345,28 +9246,6 @@ a.clear-geojson-button:hover { border-radius: 2px; } -.iiif-expand-button { - position: absolute; -} - -.iiif-toolbar { - border-left: 1px solid #999; - border-right: 1px solid #999; -} - -.iiif-widget-panel { - height: 430px; - width: 298px; - right: 11px; - border-bottom: 1px solid #999; - border-right: 1px solid #999; -} - -.iiif-widget-panel-title { - width: 297px; -} - - /* Hide "Full Screen" button for map tools widget in card manager */ .widget-preview div div div div span .toggle-map-size { @@ -9681,15 +9560,6 @@ a.clear-geojson-button:hover { flex-direction: column; } -.iiif-widget { - position: relative; -} - -.iiif-widget .hover-feature-info { - margin-left: 25px; - height: 220px; -} - .hover-feature-title-bar { height: 40px; padding: 10px; diff --git a/arches/app/media/js/views/components/widgets/csv-chart.js b/arches/app/media/js/views/components/widgets/csv-chart.js deleted file mode 100644 index 0e18c318efe..00000000000 --- a/arches/app/media/js/views/components/widgets/csv-chart.js +++ /dev/null @@ -1,336 +0,0 @@ -define([ - 'jquery', - 'knockout', - 'knockout-mapping', - 'underscore', - 'dropzone', - 'nvd3', - 'uuid', - 'moment', - 'viewmodels/widget', - 'arches', - 'bindings/dropzone', - 'bindings/nvd3-line', - // 'bindings/datatable', - 'bindings/chosen', -], function($, ko, koMapping, _, Dropzone, nvd3, uuid, moment, WidgetViewModel, arches) { - /** - * registers a file-widget component for use in forms - * @function external:"ko.components".file-widget - * @param {object} params - * @param {string} params.value - the value being managed - * @param {function} params.config - observable containing config object - * @param {string} params.config().acceptedFiles - accept attribute value for file input - * @param {string} params.config().maxFilesize - maximum allowed file size in MB - */ - return ko.components.register('csv-chart-widget', { - viewModel: function(params) { - var self = this; - params.configKeys = ['acceptedFiles', 'maxFilesize']; - - WidgetViewModel.apply(this, [params]); - this.selectedFile = ko.observable(); - this.viewChart = ko.observable(false); - - this.selectionDisplayValues = ko.computed(function() { - if (this.selectedFile()) { - var f = this.selectedFile() - res = { - file_name: ko.unwrap(f.name), - upload_time: moment(ko.unwrap(f.upload_time)).format('YYYY-MM-DD'), - size: ko.unwrap(f.size)/1024 + 'kb', - url: ko.unwrap(f.url), - records: this.chartData().length === 0 ? undefined : this.chartData()[0].values.length - }; - return res; - } else { - return { - upload_time: undefined, - size: undefined, - records: undefined, - file_name: undefined - } - } - - }, this); - - if (this.form) { - this.form.on('after-update', function(req, tile) { - if (tile.isParent === true){ - if (self.dropzone) { - self.dropzone.removeAllFiles(true); - } - } else if ((self.tile === tile || _.contains(tile.tiles, self.tile)) && req.status === 200) { - if (self.filesForUpload().length > 0) { - self.filesForUpload.removeAll(); - } - var data = req.responseJSON.data[self.node.nodeid] || req.responseJSON.tiles[self.node.nodeid][0].data[self.node.nodeid]; - if (Array.isArray(data.files)) { - self.uploadedFiles(data.files) - } - self.dropzone.removeAllFiles(true); - self.formData.delete('file-list_' + self.node.nodeid); - } - }); - this.form.on('tile-reset', function(tile) { - if ((self.tile === tile || _.contains(tile.tiles, self.tile))) { - var value = ko.unwrap(self.value); - if (self.filesForUpload().length > 0) { - self.filesForUpload.removeAll(); - } - if (Array.isArray(value.files)) { - self.uploadedFiles(value.files) - } - self.dropzone.removeAllFiles(true); - self.formData.delete('file-list_' + self.node.nodeid); - } - }); - } - this.acceptedFiles.subscribe(function(val) { - if (self.dropzone) { - self.dropzone.hiddenFileInput.setAttribute("accept", val); - } - }); - this.maxFilesize.subscribe(function(val) { - if (self.dropzone) { - self.dropzone.options.maxFilesize = val; - } - }); - - this.filesForUpload = ko.observableArray(); - this.uploadedFiles = ko.observableArray(); - if (ko.isObservable(self.value)) { - if (self.value()) { - if (Array.isArray(self.value().files)) { - this.uploadedFiles(self.value().files); - } - } - } else { - if (Array.isArray(self.value.files())) { - this.uploadedFiles(self.value.files()); - } - } - - this.removeFile = function(file) { - var filesForUpload = self.filesForUpload(); - var uploadedFiles = self.uploadedFiles(); - if (file.file_id) { - file = _.find(uploadedFiles, function (uploadedFile) { - return file.file_id === ko.unwrap(uploadedFile.file_id); - }); - self.uploadedFiles.remove(file); - } else { - file = filesForUpload[file.index]; - self.filesForUpload.remove(file); - } - } - - this.formatSize = function (file) { - var bytes = ko.unwrap(file.size); - if(bytes == 0) return '0 Byte'; - var k = 1024; - var dm = 2; - var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - var i = Math.floor(Math.log(bytes) / Math.log(k)); - return '' + parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; - }; - - this.selectedUrl = ko.observable('') - this.selectedFiles = ko.observableArray([]); - - this.indicateDataTableRowSelection = function(row) { - this.selectedFiles.removeAll(); - this.selectedFiles.push(ko.unwrap(row.url)) - } - - if (!ko.isObservable(this.value)) { - this.datasetName = this.value.name; - this.datasetDescription = this.value.description; - this.datasetDevice = this.value.device; - } else { - this.datasetName = ko.observable(''); - this.datasetDescription = ko.observable(''); - this.datasetDevice = ko.observable(''); - }; - - [this.datasetName, this.datasetDescription, this.datasetDevice].forEach(function(obs){ - var self = this; - obs.subscribe(function(val){ - if (ko.isObservable(self.value)){ - this.value({'files':this.filesJSON(), 'name':this.datasetName(), 'description':this.datasetDescription(), 'device':this.datasetDevice()}) - } - }, self) - }, this); - - this.filesJSON = ko.computed(function() { - var filesForUpload = self.filesForUpload(); - var uploadedFiles = self.uploadedFiles(); - return ko.toJS(uploadedFiles.concat( - _.map(filesForUpload, function(file, i) { - return { - name: file.name, - accepted: file.accepted, - height: file.height, - lastModified: file.lastModified, - size: file.size, - status: file.status, - type: file.type, - width: file.width, - url: null, - file_id: null, - index: i, - content: URL.createObjectURL(file), - error: file.error, - upload_time: Date.now() - }; - }) - )); - }).extend({throttle: 100}); - - this.filesJSON.subscribe(function(value) { - if (_.contains(self.formData.keys(), 'file-list_' + self.node.nodeid)) { - self.formData.delete('file-list_' + self.node.nodeid); - } - _.each(self.filesForUpload(), function(file) { - if (file.accepted) { - self.formData.append('file-list_' + self.node.nodeid, file, file.name); - } - }); - - if (ko.unwrap(self.value) !== null || self.filesForUpload().length !== 0 || self.uploadedFiles().length !== 0) { - if (ko.isObservable(self.value)){ - self.value( - {'files':value.filter(function(file) { - return file.accepted; - }), - 'name':self.datasetName(), - 'description':self.datasetDescription(), - 'device':self.datasetDevice() - }) - } else { - self.value.files(value.filter(function(file) { - return file.accepted; - })); - } - } - - }); - - this.chartData = ko.observable([]) - this.resize = function(){ - var self = this; - var reloadChart = function() { - self.getFileData(self.uploadedFiles()[0]) - window.dispatchEvent(new Event('resize')) - } - window.setTimeout(reloadChart, 50) - } - - - - this.getFileData = function(f) { - var self = this; - var url = ko.unwrap(f.url); - var filename = ko.unwrap(f.name); - var basename = filename.substr(0, filename.lastIndexOf('.')) || filename; - if (url.endsWith('.csv')) { - d3.csv(url, function(d) { - return { - x: +d.x, - y: +d.y, - }; - }, function(error, rows) { - var data = _.sortBy(rows, function(a){return a['x']}); - self.chartData(data) - }); - } else { - d3.text(url, function(text) { - var rows = d3.tsv.parseRows(text).map(function(row) { - return { - x: +row[0], - y: +row[1] - } - }) - var data = _.sortBy(rows, function(a){return a['x']}); - var series = [{values: data, key: basename, color: '#ff7f0e'}] - - self.chartData(series); - self.selectedFile(f); - }); - } - } - - this.selectedUrl.subscribe(function(val){ - var url = val; - if (this.uploadedFiles().length > 0 && url) { - var selected = _.filter(this.uploadedFiles(), function(f){return ko.unwrap(f.url) === url})[0] - this.selectedFile(url); - this.getFileData(selected); - } - - // this.indicateDataTableRowSelection(selected) //Only needed if we keep table - }, this) - - this.unique_id = uuid.generate(); - this.uniqueidClass = ko.computed(function () { - return "unique_id_" + self.unique_id; - }); - - this.dropzoneOptions = { - url: "arches.urls.root", - dictDefaultMessage: '', - autoProcessQueue: false, - previewTemplate: $("template#file-widget-dz-preview").html(), - autoQueue: false, - previewsContainer: ".dz-previews." + this.uniqueidClass(), - clickable: ".fileinput-button." + this.uniqueidClass(), - acceptedFiles: this.acceptedFiles(), - maxFilesize: this.maxFilesize(), - init: function() { - self.dropzone = this; - - this.on("addedfile", function(file) { - self.filesForUpload.push(file); - }); - - this.on("error", function(file, error) { - file.error = error; - self.filesForUpload.valueHasMutated() - }); - - this.on("removedfile", function(file) { - self.filesForUpload.remove(file); - }); - } - }; - - this.reset = function() { - if (self.dropzone) { - self.dropzone.removeAllFiles(true); - self.uploadedFiles.removeAll(); - self.filesForUpload.removeAll(); - } - }; - - this.displayValue = ko.computed(function() { - return self.uploadedFiles().length; - }); - - this.reportFiles = ko.computed(function() { - return self.uploadedFiles().filter(function(file) { - return ko.unwrap(file.type).indexOf('image') < 0; - }); - }); - - this.reportImages = ko.computed(function() { - return self.uploadedFiles().filter(function(file) { - return ko.unwrap(file.type).indexOf('image') >= 0; - }); - }); - - }, - template: { - require: 'text!widget-templates/csv-chart' - } - }); -}); diff --git a/arches/app/media/js/views/components/widgets/iiif.js b/arches/app/media/js/views/components/widgets/iiif.js deleted file mode 100644 index f0ceca56d5a..00000000000 --- a/arches/app/media/js/views/components/widgets/iiif.js +++ /dev/null @@ -1,389 +0,0 @@ -define([ - 'knockout', - 'underscore', - 'viewmodels/widget', - 'leaflet', - 'knockout-mapping', - 'uuid', - 'arches', - 'leaflet-iiif', - 'leaflet-draw', - 'leaflet-draw-local', - 'bindings/leaflet' -], function(ko, _, WidgetViewModel, L, koMapping, uuid, arches) { - return ko.components.register('iiif-widget', { - viewModel: function(params) { - var self = this; - var canvasLayer = null; - params.configKeys = ['nameLabel', 'placeholder', 'typeLabel']; - WidgetViewModel.apply(this, [params]); - - this.displayValue = ko.computed(function() { - var val = ko.unwrap(self.value); - if (!val) { - return val; - } - return val.manifestLabel; - }); - - var features = self.value.features ? koMapping.toJS(self.value.features) : []; - var ignoreFeatureClick = false; - this.hoverData = ko.observable(null); - this.clickData = ko.observable(null); - this.clickName = ko.pureComputed({ - read: function() { - return self.clickData() ? self.clickData().name : ''; - }, - write: function(val) { - if (self.clickData()) { - self.clickData().name = val; - updateFeatures(); - } - }, - owner: this - }); - this.clickType = ko.pureComputed({ - read: function() { - return self.clickData() ? self.clickData().type : null; - }, - write: function(val) { - if (self.clickData()) { - self.clickData().type = val; - updateFeatures(); - } - }, - owner: this - }); - this.hoverType = ko.pureComputed(function() { - return self.hoverData() ? self.hoverData().type : null; - }); - this.popupData = ko.computed(function() { - var hoverData = self.hoverData(); - return hoverData ? hoverData : self.clickData(); - }); - - var highlightedFeature; - var highlightedFeatureStyle; - var largeIcon = new L.Icon.Default(); - largeIcon.options.iconSize = [33, 54] - largeIcon.options.iconAnchor = [16, 54] - largeIcon.options.shadowSize = [54, 54]; - var highlightFeature = function(layer) { - highlightedFeatureStyle = _.clone(layer.options); - if (highlightedFeatureStyle.icon) { - layer.setIcon(largeIcon); - } else { - layer.setStyle({ - weight: 7, - color: '#2a3fff', - fillOpacity: 0.7 - }); - - if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) { - layer.bringToFront(); - } - } - - highlightedFeature = layer; - }; - - this.clickData.subscribe(function(clickData) { - if (highlightedFeature) { - if (highlightedFeatureStyle.icon) { - highlightedFeature.setIcon(highlightedFeatureStyle.icon); - } else { - highlightedFeature.setStyle(highlightedFeatureStyle); - } - highlightedFeature = null; - highlightedFeatureStyle = null; - } - }); - - var addLayerListeners = function(layer) { - layer.on({ - mouseover: function(e) { - self.hoverData(layer.feature.properties); - }, - mouseout: function(e) { - self.hoverData(null); - }, - click: function(e) { - if (!ignoreFeatureClick) { - self.clickData(layer.feature.properties); - highlightFeature(layer); - } - } - }); - } - var drawnItems = new L.geoJson({ - type: 'FeatureCollection', - features: features - }, { - onEachFeature: function(feature, layer) { - addLayerListeners(layer) - } - }); - var drawControl = new L.Control.Draw({ - edit: { - featureGroup: drawnItems - }, - draw: { - circle: false - } - }); - - this.expandControls = ko.observable(false); - - var manifestId; - var canvasId; - if (self.value.manifestId !== undefined) { - manifestId = ko.unwrap(self.value.manifestId); - } - if (self.value.canvasId !== undefined) { - canvasId = ko.unwrap(self.value.canvasId); - } - this.selectedManifest = ko.observable(null); - this.selectedCanvas = ko.observable(null); - var updateSelections = function(manifest) { - var selectedCanvas; - var selectedManifest; - if (manifest.data()['@id'] === manifestId) { - selectedManifest = manifest; - _.find(manifest.data().sequences, function(sequence) { - var canvas = _.find(sequence.canvases, function(canvas) { - return canvas['@id'] === canvasId; - }); - if (canvas) { - selectedCanvas = canvas; - } - return canvas; - }); - } - if (selectedManifest) { - self.selectedManifest(selectedManifest); - } - if (selectedCanvas) { - self.selectedCanvas(selectedCanvas); - } - } - _.each(arches.iiifManifests, function(manifest) { - if (!manifest.data) { - manifest.data = ko.observable(null); - $.get(manifest.url, function(data) { - manifest.data(data); - }); - } - if (manifest.data()) { - updateSelections(manifest); - } else { - manifest.data.subscribe(function() { - updateSelections(manifest); - }) - } - }); - this.manifests = ko.observableArray(arches.iiifManifests); - - var updateFeatures = function() { - var features = drawnItems.toGeoJSON().features; - if (self.value.features !== undefined) { - self.value.features(features); - } else { - var value = self.value(); - if (!value) { - value = { - canvasId: null, - canvasLabel: null, - manifestId: null, - manifestLabel: null, - attribution: null, - url: null - }; - } - value.features = features; - self.value(value) - } - } - this.map = null; - this.mapConfig = { - center: [0, 0], - crs: L.CRS.Simple, - zoom: 0, - afterRender: function(map) { - var url; - var attribution; - if (self.value.url !== undefined) { - url = ko.unwrap(self.value.url); - } - if (self.value.attribution !== undefined) { - attribution = ko.unwrap(self.value.manifestLabel) + ', ' + - ko.unwrap(self.value.canvasLabel) + ', ' + - ko.unwrap(self.value.attribution); - } - self.map = map; - self.map.addLayer(drawnItems); - map.on('preclick', function(e) { - self.clickData(null); - }); - - if (url) { - canvasLayer = L.tileLayer.iiif( - url, { - attribution: attribution - } - ).addTo(self.map); - } - - if (self.state !== 'report') { - self.map.addControl(drawControl); - map.on('draw:deletestart', function(e) { - ignoreFeatureClick = true; - }); - map.on('draw:deletestop', function(e) { - ignoreFeatureClick = false; - }) - } else { - self.map.addLayer(drawnItems); - } - - self.map.on(L.Draw.Event.CREATED, function(e) { - var type = e.layerType - var layer = e.layer; - layer.feature = { - type: "Feature", - properties: { - id: uuid.generate(), - name: '', - type: null - } - }; - - addLayerListeners(layer); - - drawnItems.addLayer(layer); - - updateFeatures() - }); - self.map.on(L.Draw.Event.EDITED, updateFeatures); - self.map.on(L.Draw.Event.DELETED, updateFeatures); - - self.expanded.subscribe(function () { - _.defer(function () { - self.map.invalidateSize(); - }, 500); - }); - } - }; - - this.selectedCanvas.subscribe(function(canvas) { - var url; - var manifest = self.selectedManifest() ? self.selectedManifest().data() : { - '@id': null, - 'label': null, - 'attribution': null - }; - if (self.map && canvasLayer && self.map.hasLayer(canvasLayer)) { - self.map.removeLayer(canvasLayer); - canvasLayer = null; - } - if (canvas) { - if (canvas.images.length > 0) { - url = canvas.images[0].resource.service['@id'] + '/info.json'; - } - if (self.map) { - self.map.removeLayer(drawnItems); - if (canvas.images.length > 0) { - canvasLayer = L.tileLayer.iiif( - canvas.images[0].resource.service['@id'] + '/info.json', { - attribution: manifest['label'] + ', ' + canvas['label'] + ', ' + manifest['attribution'] - } - ).addTo(self.map); - } - self.map.addLayer(drawnItems); - } - } else { - canvas = { - '@id': null, - 'label': null - }; - url = null; - } - if (self.value.canvasId !== undefined) { - self.value.canvasId(canvas['@id']); - self.value.canvasLabel(canvas['label']); - self.value.manifestId(manifest['@id']); - self.value.manifestLabel(manifest['label']); - self.value.attribution(manifest['attribution']); - self.value.url(url); - self.value.features(drawnItems.toGeoJSON().features); - } else { - var value = self.value(); - if (canvas['@id']) { - if (!value) { - value = {}; - } - value.canvasId = canvas['@id']; - value.canvasLabel = canvas['label']; - value.manifestId = manifest['@id']; - value.manifestLabel = manifest['label']; - value.attribution = manifest['attribution']; - value.url = url; - value.features = drawnItems.toGeoJSON().features; - } - self.value(value) - } - }); - - if (this.form) { - this.form.on('after-update', function(req, tile) { - self.clickData(null); - if (!ko.unwrap(self.value)) { - drawnItems.clearLayers(); - self.selectedManifest(null); - self.selectedCanvas(null); - } - }); - this.form.on('tile-reset', function(tile) { - self.clickData(null); - drawnItems.clearLayers(); - var features = self.value.features ? koMapping.toJS(self.value.features) : []; - drawnItems.addData({ - type: 'FeatureCollection', - features: features - }); - var manifestId; - var canvasId; - if (self.value.manifestId !== undefined) { - manifestId = ko.unwrap(self.value.manifestId); - } - if (self.value.canvasId !== undefined) { - canvasId = ko.unwrap(self.value.canvasId); - } - var selectedManifest = _.find(self.manifests(), function(manifest) { - return manifest.data()['@id'] === manifestId - }); - var selectedCanvas = null; - if (selectedManifest) { - _.find(selectedManifest.data().sequences, function(sequence) { - var canvas = _.find(sequence.canvases, function(canvas) { - return canvas['@id'] === canvasId; - }); - if (canvas) { - selectedCanvas = canvas; - } - return canvas; - }); - } - var currentCanvasId = self.selectedCanvas() ? self.selectedCanvas()['@id'] : null; - var selectedCanvasId = selectedCanvas ? selectedCanvas['@id'] : null; - if (currentCanvasId !== selectedCanvasId) { - self.selectedCanvas(selectedCanvas); - } - self.selectedManifest(selectedManifest); - }); - } - }, - template: { - require: 'text!widget-templates/iiif' - } - }); -}); diff --git a/arches/app/models/migrations/4665_remove_disco_widgets.py b/arches/app/models/migrations/4665_remove_disco_widgets.py new file mode 100644 index 00000000000..1cd766813b4 --- /dev/null +++ b/arches/app/models/migrations/4665_remove_disco_widgets.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.15 on 2019-023-05 14:40 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import uuid + + +class Migration(migrations.Migration): + + dependencies = [ + ('models', '4695_delete_resource_instance_bug'), + ] + + operations = [ + migrations.RunSQL( + """ + DELETE FROM d_data_types WHERE datatype IN ('iiif-drawing', 'csv-chart-json') + """, + """ + INSERT INTO d_data_types(datatype, + iconclass, + modulename, + classname, + defaultconfig, + configcomponent, + configname, + isgeometric, + defaultwidget) + VALUES ('csv-chart-json', + 'fa fa-line-chart', + 'datatypes.py', + 'CSVChartJsonDataType', + null, + null, + null, + FALSE, + '10000000-0000-0000-0000-000000000020' + ); + INSERT INTO d_data_types(datatype, + iconclass, + modulename, + classname, + defaultconfig, + configcomponent, + configname, + isgeometric, + defaultwidget) + VALUES ('iiif-drawing', + 'fa fa-file-code-o', + 'datatypes.py', + 'IIIFDrawingDataType', + '{"rdmCollection": null}', + 'views/components/datatypes/concept', + 'concept-datatype-config', + FALSE, + '10000000-0000-0000-0000-000000000022'); + """) + ] diff --git a/arches/app/models/models.py b/arches/app/models/models.py index 1ae657581a3..32021498a46 100644 --- a/arches/app/models/models.py +++ b/arches/app/models/models.py @@ -892,18 +892,6 @@ class Meta: db_table = 'graphs_x_mapping_file' -class IIIFManifest(models.Model): - id = models.UUIDField(primary_key=True, default=uuid.uuid1) - url = models.TextField() - - def __unicode__(self): - return self.url - - class Meta: - managed = True - db_table = 'iiif_manifests' - - class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) phone = models.CharField(max_length=16, blank=True) diff --git a/arches/app/templates/javascript.htm b/arches/app/templates/javascript.htm index e4bf8b09405..781f0d09b6a 100644 --- a/arches/app/templates/javascript.htm +++ b/arches/app/templates/javascript.htm @@ -312,11 +312,6 @@ 'addtomap': {{ resource_map_layer.addtomap|lower }}, 'is_resource_layer': true },{% endfor %}{% endautoescape %}], - iiifManifests: [{% autoescape off %}{% for manifest in iiif_manifests %}{ - 'id': '{{ manifest.id }}', - 'url': '{{ manifest.url }}', - 'icon': '{{ manifest.icon }}' - },{% endfor %}{% endautoescape %}], conceptCollections: [{% autoescape off %}{% for concept_collection in concept_collections %}{ 'label': '{{ concept_collection.label | escapejs }}', 'id': '{{ concept_collection.id }}', diff --git a/arches/app/templates/views/components/widgets/csv-chart.htm b/arches/app/templates/views/components/widgets/csv-chart.htm deleted file mode 100644 index ac065c98553..00000000000 --- a/arches/app/templates/views/components/widgets/csv-chart.htm +++ /dev/null @@ -1,205 +0,0 @@ -{% extends "views/components/widgets/base.htm" %} {% load i18n %} {% block form %} -
-
- - - - -
- - -
- -
- - -
-
-
-
- - - {% trans "Add files" %}... - - -
- -
-
- -
- -
-
-
-
- - - -
-
-

- - - -

-
-
-
-
- -
-
- -
-
-
-
- - -
-
-
-
-

-
-
- - -
-
- -
- -
-
- - -
- - -
-
- - -
-
- - - - - - - - - -
-
- -
-
- -
-
- -
-
-
-
-
-
- -
- -
-
-
- -
-
- - -{% endblock form %} - -{% block config_form %} -
- {% trans "Accepted Files" %} -
-
- -
- -
- {% trans "Max File Size (mb)" %} -
-
- -
-{% endblock config_form %} {% block report %} -
- - -
{% trans "None" %}
- - - -
- - - - -
- - - -
-
- -
- - - -
- -
-
- -{% endblock report %} -{% block display_value %} -Test -{% endblock display_value %} diff --git a/arches/app/templates/views/components/widgets/iiif.htm b/arches/app/templates/views/components/widgets/iiif.htm deleted file mode 100644 index 8a734874c14..00000000000 --- a/arches/app/templates/views/components/widgets/iiif.htm +++ /dev/null @@ -1,247 +0,0 @@ -{% extends "views/components/widgets/base.htm" %} -{% load i18n %} - -{% block form %} -
- - - - -
-
- -
- -
- - - - -
- - - - - -
-
- -
-
- -
-
- - - - - -
- - - -

{% trans "Select an image:" %}

-
- - -
-
- -
-
- -
-
- - - - - -
-
- - -
-
-
- {% trans "Drawing Details" %} -
- -
-
-
- - - - - - - -
-
- - -
- - -
- -
-
- {% trans "(Click to edit details)" %} -
-
-
- - -
-
-
-{% endblock form %} - -{% block config_form %} -
-
- {% trans "Name Label" %} -
-
- -
-
-
-
- {% trans "Type Label" %} -
-
- -
-
-{% endblock config_form %} - -{% block report %} -
-
- -
-
-
- {% trans "Drawing Details" %} -
- -
-
-
- - - - - - - -
-
- - -
- - -
- -
-
-
- -
-
-{% endblock report %} diff --git a/arches/app/views/base.py b/arches/app/views/base.py index 576c13691d3..ae0f2a088d7 100644 --- a/arches/app/views/base.py +++ b/arches/app/views/base.py @@ -65,7 +65,6 @@ def get_context_data(self, **kwargs): } context['user_is_reviewer'] = self.request.user.groups.filter(name='Resource Reviewer').exists() context['app_name'] = settings.APP_NAME - context['iiif_manifests'] = models.IIIFManifest.objects.all() return context diff --git a/arches/management/commands/packages.py b/arches/management/commands/packages.py index f096a213494..ca285295ee3 100644 --- a/arches/management/commands/packages.py +++ b/arches/management/commands/packages.py @@ -17,6 +17,7 @@ ''' """This module contains commands for building Arches.""" + import os, sys, subprocess, shutil, csv, json, unicodecsv import urllib, uuid, glob from datetime import datetime @@ -381,23 +382,27 @@ def load_system_settings(package_dir): else: update_system_settings = False - if update_system_settings == True: + if update_system_settings is True: if len(glob.glob(os.path.join(package_dir, 'system_settings', 'System_Settings.json'))) > 0: - system_settings = glob.glob(os.path.join(package_dir, 'system_settings', 'System_Settings.json'))[0] + system_settings = os.path.join(package_dir, 'system_settings', 'System_Settings.json') shutil.copy(system_settings, settings.SYSTEM_SETTINGS_LOCAL_PATH) self.import_business_data(settings.SYSTEM_SETTINGS_LOCAL_PATH, overwrite=True) def load_package_settings(package_dir): - if os.path.exists(os.path.join(package_dir, 'package_settings.py')): + if os.path.exists(os.path.join(package_dir, 'package_settings.py')) is True: update_package_settings = True if os.path.exists(os.path.join(settings.APP_ROOT, 'package_settings.py')): - if yes == False: + if yes is False: response = raw_input('Overwrite current packages_settings.py? (Y/N): ') if response.lower() not in ('t', 'true', 'y', 'yes'): update_package_settings = False - if update_package_settings == True: - package_settings = glob.glob(os.path.join(package_dir, 'package_settings.py'))[0] + if update_package_settings is True \ + and os.path.exists(os.path.join(package_dir, 'package_settings.py')): + package_settings = os.path.join(package_dir, 'package_settings.py') shutil.copy(package_settings, settings.APP_ROOT) + elif os.path.exists(os.path.join(package_dir, 'package_settings.py')): + package_settings = os.path.join(package_dir, 'package_settings.py') + shutil.copy(package_settings, settings.APP_ROOT) def load_resource_to_resource_constraints(package_dir): config_paths = glob.glob(os.path.join(package_dir, 'package_config.json')) @@ -577,6 +582,14 @@ def load_reports(package_dir): def load_functions(package_dir): load_extensions(package_dir, 'functions', 'fn') + def load_apps(package_dir): + package_apps = glob.glob(os.path.join(package_dir, 'apps', '*')) + for app in package_apps: + try: + app_name = os.path.basename(app) + management.call_command('startapp', '--template', app, app_name) + except CommandError as e: + print e def handle_source(source): if os.path.isdir(source): @@ -654,6 +667,7 @@ def handle_source(source): css_files = glob.glob(os.path.join(css_source, '*.css')) for css_file in css_files: shutil.copy(css_file, css_dest) + load_apps(package_location) def update_project_templates(self): @@ -670,105 +684,6 @@ def update_project_templates(self): for f in files: shutil.copyfile(f['src'], f['dst']) - settings_whitelist = [ - 'APP_NAME', - 'APP_TITLE', - 'COPYRIGHT_TEXT', - 'COPYRIGHT_YEAR', - 'MODE', - 'CACHES', - 'DATABASES', - 'DEBUG', - 'RESOURCE_IMPORT_LOG', - 'INTERNAL_IPS', - 'ANONYMOUS_USER_NAME', - 'ELASTICSEARCH_HTTP_PORT', - 'SEARCH_BACKEND', - 'ELASTICSEARCH_HOSTS', - 'ELASTICSEARCH_CONNECTION_OPTIONS', - 'ROOT_DIR', - 'ONTOLOGY_PATH', - 'ONTOLOGY_BASE', - 'ONTOLOGY_BASE_VERSION', - 'ONTOLOGY_BASE_NAME', - 'ONTOLOGY_BASE_ID', - 'ONTOLOGY_EXT', - 'ADMINS', - 'MANAGERS', - 'POSTGIS_VERSION', - 'USE_I18N', - 'TIME_ZONE', - 'USE_TZ', - 'LANGUAGE_CODE', - 'LOCALE_PATHS', - 'USE_L10N', - 'MEDIA_URL', - 'MEDIA_ROOT', - 'DATATYPE_LOCATIONS', - 'STATIC_ROOT', - 'STATIC_URL', - 'TILE_CACHE_CONFIG', - 'ADMIN_MEDIA_PREFIX', - 'STATICFILES_DIRS', - 'STATICFILES_FINDERS', - 'TEMPLATES', - 'AUTHENTICATION_BACKENDS', - 'INSTALLED_APPS', - 'MIDDLEWARE_CLASSES', - 'ROOT_URLCONF', - 'WSGI_APPLICATION', - 'LOGGING', - 'LOGIN_URL', - 'SYSTEM_SETTINGS_LOCAL_PATH', - 'AUTH_PASSWORD_VALIDATORS', - 'EMAIL_BACKEND', - 'EMAIL_USE_TLS', - 'EMAIL_HOST', - 'EMAIL_HOST_USER', - 'EMAIL_HOST_PASSWORD', - 'EMAIL_PORT', - 'DATE_IMPORT_EXPORT_FORMAT', - 'ANALYSIS_COORDINATE_SYSTEM_SRID', - 'CACHE_BY_USER' - ] - - with open('arches/install/arches-templates/project_name/settings_local.py-tpl', 'w') as f: - for setting_key in dir(settings): - if setting_key in settings_whitelist: - setting_value = getattr(settings, setting_key) - if type(setting_value) == dict or type(setting_value) == list: - val = "\n{0} = {1}\n\n\n".format(setting_key, JSONSerializer().serialize(setting_value, indent=4)) - val = val.replace(' false', ' False').replace(' true', ' True').replace(' null', ' None') - elif type(setting_value) == tuple: - braces = ('(',')') - val = "\n{0} = {1}\n".format(setting_key, braces[0]) - for value in setting_value: - val = val + " " + str(value) + ',\n' - val = val + "{0}\n\n\n".format(braces[1]) - else: - try: - setting_value.upper() - val = "{0} = '{1}'\n\n".format(setting_key, setting_value) - except: - val = "{0} = {1}\n\n".format(setting_key, setting_value) - - f.write(val) - - lines = None - with open('arches/install/arches-templates/project_name/settings_local.py-tpl', 'r') as f: - lines = f.readlines() - - with open('arches/install/arches-templates/project_name/settings_local.py-tpl', 'w') as f: - f.write('import os\n') - cwd = os.getcwd() - - for line in lines: - line = line.replace(cwd, '') - if len(line) > 1: - f.write('#' + line) - else: - f.write(line) - def setup(self, package_name, es_install_location=None): """ diff --git a/yarn.lock b/yarn.lock index 3ac7dc861e9..f4d4696780c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1690,7 +1690,12 @@ knockout-mapping@~2.6.0: resolved "https://registry.yarnpkg.com/knockout-mapping/-/knockout-mapping-2.6.0.tgz#052759d01ecf30d4947e8ebe64ad2c82933f06ff" integrity sha1-BSdZ0B7PMNSUfo6+ZK0sgpM/Bv8= -knockout@3.4.0, knockout@>=2.3.0: +knockout@3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/knockout/-/knockout-3.5.0.tgz#6d3e19bf53b1dc4d8de81c97a5ba9672443dc292" + integrity sha512-vBUF/IsBDzaejHkNpiquKdc5uPrImXuQ4Mb9lEfNNJ5cyHGI8ThDupR+h3eMFZhfmPE/brfwcIAn/fm0yOvJUg== + +knockout@>=2.3.0: version "3.4.0" resolved "https://registry.yarnpkg.com/knockout/-/knockout-3.4.0.tgz#59d7261815a11eb7c1a3f3c7077ca898a44caadb" integrity sha1-WdcmGBWhHrfBo/PHB3yomKRMqts=