Skip to content

Commit

Permalink
Add option to limit maximum icon size.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazhoon committed Apr 3, 2023
1 parent 7b98f8e commit d90e264
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ SPDX-License-Identifier: CC0-1.0
-->

# External Portal changelog
## [1.1.0] - TBA
## [1.1.0] - 2023-04-03
### Added
- Option to limit icon maximum size to avoid overly stretched pixmap icons
- Bump supported Nextcloud versions.
### Fixed
- Update dependencies to fix some security issues.
Expand Down
3 changes: 2 additions & 1 deletion lib/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ public function setAdminConfig(array $values): DataResponse {
public function getConfig(): DataResponse {

$extraWide = $this->config->getAppValue(Application::APP_ID, 'extraWide', false);
$maxSize = $this->config->getAppValue(Application::APP_ID, 'maxSize', false);
$showFiles = $this->config->getAppValue(Application::APP_ID, 'showFiles', false);
return new DataResponse(['extraWide' => $extraWide, 'showFiles' => $showFiles]);
return new DataResponse(['extraWide' => $extraWide, 'showFiles' => $showFiles, 'maxSize' => $maxSize]);
}

}
2 changes: 2 additions & 0 deletions lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ public function __construct(IConfig $config,
public function getForm(): TemplateResponse {
$widgetTitle = $this->config->getAppValue(Application::APP_ID, 'widgetTitle', '');
$extraWide = $this->config->getAppValue(Application::APP_ID, 'extraWide', false);
$maxSize = $this->config->getAppValue(Application::APP_ID, 'maxSize', false);
$showFiles = $this->config->getAppValue(Application::APP_ID, 'showFiles', false);

$adminConfig = [
'widgetTitle' => $widgetTitle,
'extraWide' => $extraWide,
'maxSize' => $maxSize,
'showFiles' => $showFiles,
];
$this->initialStateService->provideInitialState('admin-config', $adminConfig);
Expand Down
4 changes: 4 additions & 0 deletions src/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<label for="extraWide">Make the widget wider when there are many links</label>
<input v-model="state.extraWide" type="checkbox" name="extraWide">
<br>
<label for="maxSize">Limit maximum icon size to to avoid over-stretching 32x32 pixmap icons</label>
<input v-model="state.maxSize" type="checkbox" name="maxSize">
<br>
<label for="showFiles">Show Files link for everyone</label>
<input v-model="state.showFiles" type="checkbox" name="showFiles">
<br>
Expand Down Expand Up @@ -68,6 +71,7 @@ export default {
this.saving = true
const values = {
widgetTitle: this.state.widgetTitle,
maxSize: this.state.maxSize,
extraWide: this.state.extraWide,
showFiles: this.state.showFiles,
}
Expand Down
9 changes: 8 additions & 1 deletion src/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<span v-else-if="number > 0">
<div v-for="item in content"
:key="item.id"
:class="{ smaller: content.length>4 && content.length < 7, smallest: content.length>6}">
:class="{ smaller: content.length>4 && content.length < 7, smallest: content.length>6, maxsized: maxSize}">
<a v-bind="{ target: item.sameWindow ? '' : '_blank' }" :href="item.url">
<img class="linkitem"
preserveAspectRatio="xMinYMin meet"
Expand All @@ -47,6 +47,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later

import axios from '@nextcloud/axios'
import { generateOcsUrl, generateUrl } from '@nextcloud/router'
import { translate as t } from '@nextcloud/l10n'

export default {
name: 'Dashboard',
Expand All @@ -64,6 +65,7 @@ export default {
number: 0,
content: [],
extraWide: false,
maxSize: false,
showFiles: false,
}
},
Expand All @@ -80,6 +82,7 @@ export default {
const url = generateUrl('/apps/externalportal/config')
axios.get(url).then((response) => {
this.extraWide = response.data.extraWide
this.maxSize = response.data.maxSize
this.showFiles = response.data.showFiles
console.debug('"' + JSON.stringify(response.data) + '"')
}).catch((error) => {
Expand Down Expand Up @@ -153,6 +156,10 @@ div.smaller {
div.smallest {
width: 30%;
}
div.maxsized {
max-width: 64px;
margin: 0.5rem;
}
.linkitem {
width: 95%;
height: 95%;
Expand Down

0 comments on commit d90e264

Please sign in to comment.