Skip to content

Commit

Permalink
Show endpoint URL instead of server address input for WebDAV
Browse files Browse the repository at this point in the history
since the whole URL is required, not only the IP or hostname. Merge with S3 endpoint URL setting and extend the tooltip to show examples for both upload services.
  • Loading branch information
MichaIng committed May 1, 2022
1 parent 43cd07d commit e4d907e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
24 changes: 12 additions & 12 deletions motioneye/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
</td>
<td><span class="help-mark" title="{{ _("elektu servon, al kiu la mediadosieroj estu alŝutitaj") }}">?</span></td>
</tr>
<tr class="settings-item" required="true" depends="uploadEnabled uploadService=(ftp|sftp|http|https|webdav)">
<tr class="settings-item" required="true" depends="uploadEnabled uploadService=(ftp|sftp|http|https)">
<td class="settings-item-label"><span class="settings-item-label">{{ _("Servila Adreso") }}</span></td>
<td class="settings-item-value"><input type="text" class="styled storage camera-config" id="uploadServerEntry"></td>
<td><span class="help-mark" title="{{ _("la domajna nomo IP-adreso de la servilo (ekz. ftp.example.com 192.168.1.3)") }}">?</span></td>
Expand All @@ -479,6 +479,13 @@
</td>
<td><span class="help-mark" title="{{ _("la HTTP-metodo uzi por alŝuti dosierojn") }}">?</span></td>
</tr>
<tr class="settings-item" depends="uploadEnabled uploadService=(s3|webdav)">
<td class="settings-item-label"><span class="settings-item-label">{{ _("Endpoint URL") }}</span></td>
<td class="settings-item-value"><input type="text" class="styled storage camera-config" id="uploadEndpointUrlEntry"></td>
<td><span class="help-mark" title="{{ _("The complete URL to the upload server endpoint:") }}
{{ _("For S3: E.g. http://my.minio:9000. Leave it empty for AWS!") }}
{{ _("For WebDAV: E.g. https://my.cloud/remote.php/dav/files/Me/") }}">?</span></td>
</tr>
<tr class="settings-item" required="true" depends="uploadEnabled uploadService!=(s3)">
<td class="settings-item-label"><span class="settings-item-label">{{ _("Loko") }}</span></td>
<td class="settings-item-value"><input type="text" class="styled storage camera-config" id="uploadLocationEntry"></td>
Expand Down Expand Up @@ -518,11 +525,6 @@
</td>
<td><span class="help-mark" title="{{ _("alklaku ĉi tie por akiri la ŝlosilan rajtigan servon") }}">?</span></td>
</tr>
<tr class="settings-item" depends="uploadEnabled uploadService=(s3)">
<td class="settings-item-label"><span class="settings-item-label">{{ _("Endpoint URL") }}</span></td>
<td class="settings-item-value"><input type="text" class="styled storage camera-config" id="uploadEndpointUrlEntry"></td>
<td><span class="help-mark" title="{{ _("The complete URL to the S3 server endpoint, e.g. http://my.minio:9000. Leave this empty for AWS!") }}">?</span></td>
</tr>
<tr class="settings-item" depends="uploadEnabled uploadService=(s3)">
<td class="settings-item-label"><span class="settings-item-label">{{ _("Access Key") }}</span></td>
<td class="settings-item-value"><input type="password" autocomplete="new-password" class="styled storage camera-config" id="uploadAccessKeyEntry"></td>
Expand Down Expand Up @@ -1108,8 +1110,8 @@
<td><span class="help-mark" title="{{ _("difinas la bildan serĉtempan intervalon por krei telegramajn aldonojn (pli altaj valoroj generas pli da bildoj koste de pliigita sciiga prokrasto); agordi al 0 por malebligi bildajn aldonaĵojn; vi devas ankaŭ ebligi Senmovajn Bildojn por ke ĉi tio funkciu; vi volos ludi per ĉi tiu numero ĝis bildo estos sendita. Bona komenca numero estas 30 se vi agordas senmovajn bildojn al unu bildmoviĝo ekigita. Por norma movado ekigita, starigu ĉi tion multe pli malalte.") }}">?</span></td>
</tr>
<tr class="settings-item" required="true" depends="telegramNotificationsEnabled motionDetectionEnabled" strip="true">
<td class="settings-item-label"><a href="https://core.telegram.org/bots#6-botfather" target="_blank"><div class="button normal-button test-button" id="apiInstructionButton" style="opacity: 1; display: inline-block;">{{ _("API-Informoj") }}</div></a></td>
<td class="settings-item-label"><div class="button normal-button test-button" id="telegramTestButton" style="opacity: 1; display: inline-block;">{{ _("Testo") }}</div></td>
<td class="settings-item-label"><a href="https://core.telegram.org/bots#6-botfather" target="_blank"><div class="button normal-button test-button" id="apiInstructionButton" style="opacity: 1; display: inline-block;">{{ _("API-Informoj") }}</div></a></td>
<td class="settings-item-label"><div class="button normal-button test-button" id="telegramTestButton" style="opacity: 1; display: inline-block;">{{ _("Testo") }}</div></td>
</tr>
<tr class="settings-item" depends="motionDetectionEnabled">
<td colspan="100"><div class="settings-item-separator"></div></td>
Expand Down Expand Up @@ -1301,7 +1303,6 @@
</table>
{% endif %}
{% endfor %}

<div class="settings-progress"></div>
</form>
</div>
Expand All @@ -1314,9 +1315,8 @@
</div>
{% else %}
<div class="camera-frame" id="camera{{camera_id}}"
streaming_framerate="{{camera_config['stream_maxrate']}}" streaming_server_resize="{{camera_config['@webcam_server_resize']|string|lower}}"
proto="{{camera_config['@proto']}}" url="{{camera_config['@url']}}">

streaming_framerate="{{camera_config['stream_maxrate']}}" streaming_server_resize="{{camera_config['@webcam_server_resize']|string|lower}}"
proto="{{camera_config['@proto']}}" url="{{camera_config['@url']}}">
<div class="camera-container">
<div class="camera-placeholder"><img class="no-camera" src="{{static_path}}img/no-camera.svg"></div>
<img class="camera">
Expand Down
14 changes: 7 additions & 7 deletions motioneye/uploadservices.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ class Webdav(UploadService):
NAME = 'webdav'

def __init__(self, camera_id):
self._server = None
self._endpoint_url = None
self._username = None
self._password = None
self._location = None
Expand Down Expand Up @@ -914,7 +914,7 @@ def _request(self, url, method, body=None):
raise e

def _make_dirs(self, path):
dir_url = self._server.rstrip('/') + '/'
dir_url = self._endpoint_url.rstrip('/') + '/'
for folder in path.split('/'):
dir_url = dir_url + folder + '/'
self._request(dir_url, 'MKCOL')
Expand All @@ -923,7 +923,7 @@ def test_access(self):
try:
path = self._location.strip('/') + '/' + str(time.time())
self._make_dirs(path)
self._request(self._server.rstrip('/') + '/' + path, 'DELETE')
self._request(self._endpoint_url.rstrip('/') + '/' + path, 'DELETE')
return True
except Exception as e:
self.error(str(e), exc_info=True)
Expand All @@ -935,23 +935,23 @@ def upload_data(self, filename, mime_type, data, ctime, camera_name):
self._make_dirs(path)
self.debug(f'uploading {filename} of {len(data)} bytes')
self._request(
self._server.rstrip('/') + '/' + path + '/' + filename,
self._endpoint_url.rstrip('/') + '/' + path + '/' + filename,
'PUT',
bytearray(data),
)
self.debug('upload done')

def dump(self):
return {
'server': self._server,
'endpoint_url': self._endpoint_url,
'username': self._username,
'password': self._password,
'location': self._location,
}

def load(self, data):
if data.get('server') is not None:
self._server = data['server']
if data.get('endpoint_url') is not None:
self._endpoint_url = data['endpoint_url']
if data.get('username') is not None:
self._username = data['username']
if data.get('password') is not None:
Expand Down

0 comments on commit e4d907e

Please sign in to comment.