Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add imaginary as option #1026

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,12 @@ updates:
labels:
- 3. to review
- dependencies
- package-ecosystem: "docker"
directory: "/Containers/imaginary"
schedule:
interval: "daily"
time: "12:00"
open-pull-requests-limit: 10
labels:
- 3. to review
- dependencies
2 changes: 2 additions & 0 deletions Containers/imaginary/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# From https://github.com/h2non/imaginary/blob/master/Dockerfile
FROM nextcloud/imaginary:20220819
11 changes: 11 additions & 0 deletions Containers/nextcloud/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -407,5 +407,16 @@ else
fi
fi

# Imaginary
if version_greater "24.0.0.0" "$installed_version"; then
if [ "$IMAGINARY_ENABLED" = 'yes' ]; then
php /var/www/html/occ config:system:set enabledPreviewProviders 0 --value="OC\\Preview\\Imaginary"
php /var/www/html/occ config:system:set preview_imaginary_url --value="http://$IMAGINARY_HOST:9000"
else
php /var/www/html/occ config:system:delete enabledPreviewProviders 0
php /var/www/html/occ config:system:delete preview_imaginary_url
fi
fi

# Remove the update skip file always
rm -f /mnt/ncdata/skip.update
24 changes: 22 additions & 2 deletions php/containers.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
"identifier": "nextcloud-aio-nextcloud",
"dependsOn": [
"nextcloud-aio-database",
"nextcloud-aio-redis"
"nextcloud-aio-redis",
"nextcloud-aio-imaginary"
],
"displayName": "Nextcloud",
"containerName": "nextcloud/aio-nextcloud",
Expand Down Expand Up @@ -140,7 +141,9 @@
"ONLYOFFICE_HOST=nextcloud-aio-onlyoffice",
"UPDATE_NEXTCLOUD_APPS=%UPDATE_NEXTCLOUD_APPS%",
"TZ=%TIMEZONE%",
"TALK_PORT=%TALK_PORT%"
"TALK_PORT=%TALK_PORT%",
"IMAGINARY_ENABLED=%IMAGINARY_ENABLED%",
"IMAGINARY_HOST=nextcloud-aio-imaginary"
],
"maxShutdownTime": 10,
"restartPolicy": "unless-stopped"
Expand Down Expand Up @@ -367,6 +370,23 @@
],
"maxShutdownTime": 10,
"restartPolicy": "unless-stopped"
},
{
"identifier": "nextcloud-aio-imaginary",
"dependsOn": [],
"displayName": "Imaginary",
"containerName": "nextcloud/aio-imaginary",
"ports": [],
"internalPorts": [
"9000"
],
"environmentVariables": [
"TZ=%TIMEZONE%"
],
"volumes": [],
"secrets": [],
"maxShutdownTime": 10,
"restartPolicy": "unless-stopped"
}
]
}
5 changes: 5 additions & 0 deletions php/public/disable-imaginary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
document.addEventListener("DOMContentLoaded", function(event) {
// Imaginary
var imaginary = document.getElementById("imaginary");
imaginary.disabled = true;
});
1 change: 1 addition & 0 deletions php/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
'collabora_dictionaries' => $configurationManager->GetCollaboraDictionaries(),
'automatic_updates' => $configurationManager->areAutomaticUpdatesEnabled(),
'is_backup_section_enabled' => $configurationManager->isBackupSectionEnabled(),
'is_imaginary_enabled' => $configurationManager->isImaginaryEnabled(),
]);
})->setName('profile');
$app->get('/login', function ($request, $response, $args) use ($container) {
Expand Down
4 changes: 4 additions & 0 deletions php/public/options-form-submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ document.addEventListener("DOMContentLoaded", function(event) {
// Talk
var talk = document.getElementById("talk");
talk.addEventListener('change', makeOptionsFormSubmitVisible);

// Imaginary
var imaginary = document.getElementById("imaginary");
imaginary.addEventListener('change', makeOptionsFormSubmitVisible);
});
8 changes: 8 additions & 0 deletions php/src/ContainerDefinitionFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ private function GetDefinition(bool $latest): array
if (!$this->configurationManager->isTalkEnabled()) {
continue;
}
} elseif ($entry['identifier'] === 'nextcloud-aio-imaginary') {
if (!$this->configurationManager->isImaginaryEnabled()) {
continue;
}
}

$ports = new ContainerPorts();
Expand Down Expand Up @@ -146,6 +150,10 @@ private function GetDefinition(bool $latest): array
if (!$this->configurationManager->isTalkEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-imaginary') {
if (!$this->configurationManager->isImaginaryEnabled()) {
continue;
}
}
$dependsOn[] = $value;
}
Expand Down
5 changes: 5 additions & 0 deletions php/src/Controller/ConfigurationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public function SetConfig(Request $request, Response $response, $args) : Respons
} else {
$this->configurationManager->SetTalkEnabledState(0);
}
if (isset($request->getParsedBody()['imaginary'])) {
$this->configurationManager->SetImaginaryEnabledState(1);
} else {
$this->configurationManager->SetImaginaryEnabledState(0);
}
}

if (isset($request->getParsedBody()['delete_collabora_dictionaries'])) {
Expand Down
15 changes: 15 additions & 0 deletions php/src/Data/ConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ public function SetClamavEnabledState(int $value) : void {
$this->WriteConfig($config);
}

public function isImaginaryEnabled() : bool {
$config = $this->GetConfig();
if (isset($config['isImaginaryEnabled']) && $config['isImaginaryEnabled'] === 1) {
return true;
} else {
return false;
}
}

public function SetImaginaryEnabledState(int $value) : void {
$config = $this->GetConfig();
$config['isImaginaryEnabled'] = $value;
$this->WriteConfig($config);
}

public function isOnlyofficeEnabled() : bool {
$config = $this->GetConfig();
if (isset($config['isOnlyofficeEnabled']) && $config['isOnlyofficeEnabled'] === 1) {
Expand Down
6 changes: 6 additions & 0 deletions php/src/Docker/DockerActionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ public function CreateContainer(Container $container) : void {
} else {
$replacements[1] = $this->configurationManager->GetCollaboraDictionaries();
}
} elseif ($out[1] === 'IMAGINARY_ENABLED') {
if ($this->configurationManager->isImaginaryEnabled()) {
$replacements[1] = 'yes';
} else {
$replacements[1] = '';
}
} else {
$replacements[1] = $this->configurationManager->GetSecret($out[1]);
}
Expand Down
6 changes: 6 additions & 0 deletions php/templates/containers.twig
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@
{% else %}
<input type="checkbox" id="collabora" name="collabora"><label for="collabora">Collabora (Nextcloud Office)</label><br>
{% endif %}
{% if is_imaginary_enabled == true %}
<input type="checkbox" id="imaginary" name="imaginary" checked="checked"><label for="imaginary">Imaginary</label><br>
{% else %}
<input type="checkbox" id="imaginary" name="imaginary"><label for="imaginary">Imaginary</label><br>
{% endif %}
{% if is_talk_enabled == true %}
<input type="checkbox" id="talk" name="talk" checked="checked"><label for="talk">Nextcloud Talk (needs ports {{ talk_port }}/TCP and {{ talk_port }}/UDP open in your firewall/router)</label><br><br>
{% else %}
Expand All @@ -472,6 +477,7 @@
{% if isAnyRunning == true %}
<script type="text/javascript" src="disable-talk.js"></script>
<script type="text/javascript" src="disable-collabora.js"></script>
<script type="text/javascript" src="disable-imaginary.js"></script>
{% endif %}

{% if is_collabora_enabled == true and isAnyRunning == false and was_start_button_clicked == true %}
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Included are:
- High performance backend for Nextcloud Files
- High performance backend for Nextcloud Talk
- Backup solution (based on [BorgBackup](https://github.com/borgbackup/borg#what-is-borgbackup))
- Imaginary
- ClamAV

## How to use this?
Expand Down