Skip to content

Commit

Permalink
Public photo sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbrendel committed Aug 27, 2024
1 parent 7391a48 commit 5a7e2e5
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 8 deletions.
5 changes: 4 additions & 1 deletion app/controller/share.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ public function share_photo($request)
$asset = $request->params()->query('asset', null);
$title = $request->params()->query('title', null);
$type = $request->params()->query('type', null);
$public = $request->params()->query('public', null);
$description = $request->params()->query('description', null);
$keywords = $request->params()->query('keywords', null);

$result = ApiModule::sharePhoto($asset, $title, $type);
$result = ApiModule::sharePhoto($asset, $title, $type, $public, $description, $keywords);

if ($result->code != 200) {
throw new \Exception($result->msg);
Expand Down
5 changes: 4 additions & 1 deletion app/lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,5 +420,8 @@
'backup_settings_stored' => 'Backup cronjob settings were saved succesfully',
'auto_backup_not_active' => 'The auto-backup feature has not been activated yet',
'shared_photos' => 'Shared Photos',
'confirm_remove_shared_photo' => 'Do you really want to remove this item?'
'confirm_remove_shared_photo' => 'Do you really want to remove this item?',
'share_photo_public' => 'Share this photo publicly',
'share_photo_description' => 'Description',
'share_photo_keywords' => 'Keywords'
];
10 changes: 8 additions & 2 deletions app/modules/ApiModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ class ApiModule {
* @param $asset
* @param $title
* @param $type
* @param $public
* @param $description
* @param $keywords
* @return mixed
* @throws \Exception
*/
public static function sharePhoto($asset, $title, $type)
public static function sharePhoto($asset, $title, $type, $public, $description, $keywords)
{
try {
$file = null;
Expand All @@ -31,7 +34,10 @@ public static function sharePhoto($asset, $title, $type)
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'title' => $title,
'workspace' => app('workspace'),
'hortusfox_photo' => curl_file_create($file)
'hortusfox_photo' => curl_file_create($file),
'public' => $public,
'description' => $description,
'keywords' => $keywords
]);

$response = curl_exec($ch);
Expand Down
4 changes: 2 additions & 2 deletions app/resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,11 +940,11 @@ window.vue = new Vue({
window.vue.bShowSharePhoto = true;
},

performPhotoShare: function(asset, title, type, result, button, error) {
performPhotoShare: function(asset, title, _public, description, keywords, type, result, button, error) {
let origButtonHtml = button.innerHTML;
button.innerHTML = '<i class=\'fas fa-spinner fa-spin\'></i>&nbsp;' + window.vue.loadingPleaseWait;

window.vue.ajaxRequest('post', window.location.origin + '/share/photo/post', { asset: asset, title: title, type: type }, function(response) {
window.vue.ajaxRequest('post', window.location.origin + '/share/photo/post', { asset: asset, title: title, public: _public, description: description, keywords: keywords, type: type }, function(response) {
button.innerHTML = origButtonHtml;

if (response.code == 200) {
Expand Down
24 changes: 23 additions & 1 deletion app/views/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,28 @@
</div>
</div>
<div class="field">
<div class="control">
<input type="checkbox" class="checkbox" id="share-photo-public" value="0" onclick="if (this.checked) { document.getElementById('share-photo-public-data').classList.remove('is-hidden'); } else { document.getElementById('share-photo-public-data').classList.add('is-hidden'); }">&nbsp;<span>{{ __('app.share_photo_public') }}</span>
</div>
</div>
<div id="share-photo-public-data" class="is-hidden">
<div class="field">
<label class="label">{{ __('app.share_photo_description') }}</label>
<div class="control">
<input type="text" class="input" id="share-photo-description">
</div>
</div>
<div class="field">
<label class="label">{{ __('app.share_photo_keywords') }}</label>
<div class="control">
<input type="text" class="input" id="share-photo-keywords">
</div>
</div>
</div>
<div class="field">
<p class="is-color-error is-hidden" id="share-photo-error"></p>
</div>
Expand All @@ -1109,7 +1131,7 @@
</div>
</section>
<footer class="modal-card-foot is-stretched">
<button id="share-photo-submit-action" class="button is-success" onclick="window.vue.performPhotoShare(document.getElementById('share-photo-id').value, document.getElementById('share-photo-title').value, document.getElementById('share-photo-type').value, document.getElementById('share-photo-link'), this, document.getElementById('share-photo-error'));">{{ __('app.share') }}</button>
<button id="share-photo-submit-action" class="button is-success" onclick="window.vue.performPhotoShare(document.getElementById('share-photo-id').value, document.getElementById('share-photo-title').value, document.getElementById('share-photo-public').checked, document.getElementById('share-photo-description').value, document.getElementById('share-photo-keywords').value, document.getElementById('share-photo-type').value, document.getElementById('share-photo-link'), this, document.getElementById('share-photo-error'));">{{ __('app.share') }}</button>
</footer>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

0 comments on commit 5a7e2e5

Please sign in to comment.