pull/721/head
nchamo 2019-08-29 00:10:26 -03:00
rodzic 909b9f1e5f
commit abb597299d
3 zmienionych plików z 65 dodań i 18 usunięć

Wyświetl plik

@ -0,0 +1,43 @@
<h1 align="center">Cloud Import </h1>
Welcome to Cloud Import!
Cloud Import is a WebODM add-on that enables you to import your files from external sources. Instead of downloading the files to your computer and then upload them back to WebODM, you can simply import them to create a new task!
## Current Support
Currently, we support these kinds of sources:
#### Cloud Platforms
A **cloud platform** is an online platform that can store files, like [Dropbox](https://www.dropbox.com/ "Dropbox") or [Google Drive](https://www.google.com/drive/ "Google Drive"). Platforms have the concept of a folder or album, where files are stored. By entering the folder's URL, we will use each platform's API to retrieve all the images in those folders, and import them into WebODM.
Current platforms supported:
*None so far*
#### Cloud Libraries
A **cloud library** is an extension of a cloud platform that has images organized in a folders or albums. It differs from a cloud platform, in the way that it can also list all folders it contains, so that a user can choose to import a specific folder from a list, instead of a URL.
Cloud libraries can be used as cloud platorms, but if you happen to configure a server URL, then a list of all the folders in the server will be presented when trying to import to a new task.
Current platforms supported:
* [Piwigo](http://piwigo.com/ "Piwigo")
## Setup
Some of the platforms described above might need some configuration. For example, you might set a server URL or a authentication token. When that is the case, you can go to the *"Cloud Import"* tab on the left menu, and do all the configuring you need.
## Contribute
If you would like to add support for new platforms, please don't hesitate to do so! Here are a few simple guidelines that might help you in your quest.
#### New Platforms
If you simply need to add a new platform, then add your new Python script on `WebODM/plugins/cloudimport/platforms`. You can copy an already existing platform file, or you can check the file `WebODM/plugins/cloudimport/cloud_platform.py` to see what you need to implement.
#### New Extensions
Now, if you want to add some more complex logic that requieres user configuration or something like that, you might need to write a **platform extension**. You will need to add your extension to `WebODM/plugins/cloudimport/extensions`. You can copy an already existing extension, or you can check the file `WebODM/plugins/cloudimport/platform_extension.py` to see what you need to implement.
#### Known Gaps
Now, there are a few known gaps to the system that you might encounter or that you might enjoy closing.
1. **Allow image resizing**:
Currently, when importing a folder, image resizing is not allowed. This might be a problem for users without a lot of disk space, so it might make sense to fix this.
1. **Allow potential pagination when calling APIs**
Currently, the workflow doesn't support calling APIs that requiere pagination.
1. **Make platform extension have their own js, like WebODM plugins**
Currently, each platform extension that might require their own Javascript code will need to add it manually to the already existing code. It would be much easier if this was handed automatically, like the other parts of the add-on.

Wyświetl plik

@ -1,9 +0,0 @@
BEFORE MERGING TO MASTER
* Add validation to the configuration for each platform extension
* Fix error message popup
* Allow image resizing
* Allow potential pagination when calling APIs
* Make platform extension have their own js somewhere, like WebODM plugins

Wyświetl plik

@ -14,56 +14,69 @@ from rest_framework import status
from .platform_helper import get_all_platforms, get_platform_by_name
platforms = None
class ImportFolderTaskView(TaskView):
def post(self, request, project_pk=None, pk=None):
task = self.get_and_check_task(request, pk)
# Read form data
folder_url = request.data.get('selectedFolderUrl', None)
platform_name = request.data.get('platform', None)
# Make sure both values are set
if folder_url == None or platform_name == None:
return Response({'error': 'Folder URL and platform name must be set.'}, status=status.HTTP_400_BAD_REQUEST)
# Fetch the platform by name
platform = get_platform_by_name(platform_name)
# Make sure that the platform actually exists
if platform == None:
return Response({'error': 'Failed to find a platform with the name \'{}\''.format(platform_name)}, status=status.HTTP_400_BAD_REQUEST)
# Verify that the folder url is valid
if platform.verify_folder_url(folder_url) == None:
return Response({'error': 'Invalid URL'}, status=status.HTTP_400_BAD_REQUEST)
# Get the files from the folder
files = platform.import_from_folder(folder_url)
task.console_output += "Importing images...\n"
# Update the task with the new information
task.console_output += "Importing {} images...\n".format(len(files))
task.images_count = len(files)
task.pending_action=pending_actions.IMPORT
task.pending_action = pending_actions.IMPORT
task.save()
# Start importing the files in the background
serialized = [file.serialize() for file in files]
logger.error(serialized)
import_files.delay(task.id, serialized)
return Response({}, status=status.HTTP_200_OK)
class PlatformsVerifyTaskView(TaskView):
def get(self, request, platform_name):
# Read the form data
folder_url = request.GET.get('folderUrl', None)
# Fetch the platform by name
platform = get_platform_by_name(platform_name)
# Make sure that the platform actually exists
if platform == None:
return Response({'error': 'Failed to find a platform with the name \'{}\''.format(platform_name)}, status=status.HTTP_400_BAD_REQUEST)
folder = platform.verify_folder_url(folder_url)
# Verify that the folder url is valid
folder = platform.verify_folder_url(folder_url)
if folder == None:
return Response({'error': 'Invalid URL'}, status=status.HTTP_400_BAD_REQUEST)
# Return the folder
return Response({'folder': folder.serialize()}, status=status.HTTP_200_OK)
class PlatformsTaskView(TaskView):
def get(self, request):
# Fetch and return all platforms
platforms = get_all_platforms()
return Response({'platforms': [platform.serialize(user = request.user) for platform in platforms]}, status=status.HTTP_200_OK)