Compare commits
No commits in common. "1ac7c8f69a090107378d5becde21bd2c0a66374a" and "2d10b81650b9ae193932ecb93045484b7bc01bc5" have entirely different histories.
1ac7c8f69a
...
2d10b81650
@ -20,7 +20,7 @@ Currently supported pride flags:
|
|||||||
- Lesbian pride flag
|
- Lesbian pride flag
|
||||||
|
|
||||||
more flags to follow soon!</description>
|
more flags to follow soon!</description>
|
||||||
<version>1.1.0</version>
|
<version>1.0.0</version>
|
||||||
<licence>gpl3</licence>
|
<licence>gpl3</licence>
|
||||||
<author mail="transcaffeine@finally.coffee" homepage="https://github.com/finally-coffee-nextcloud-pride-flags">transcaffeine</author>
|
<author mail="transcaffeine@finally.coffee" homepage="https://github.com/finally-coffee-nextcloud-pride-flags">transcaffeine</author>
|
||||||
<namespace>PrideFlags</namespace>
|
<namespace>PrideFlags</namespace>
|
||||||
@ -31,8 +31,6 @@ more flags to follow soon!</description>
|
|||||||
<nextcloud min-version="26" max-version="29"/>
|
<nextcloud min-version="26" max-version="29"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<settings>
|
<settings>
|
||||||
<admin-section>OCA\PrideFlags\Settings\AdminSection</admin-section>
|
|
||||||
<admin>OCA\PrideFlags\Settings\AdminSettings</admin>
|
|
||||||
<personal-section>OCA\PrideFlags\Settings\PersonalSection</personal-section>
|
<personal-section>OCA\PrideFlags\Settings\PersonalSection</personal-section>
|
||||||
<personal>OCA\PrideFlags\Settings\PersonalSettings</personal>
|
<personal>OCA\PrideFlags\Settings\PersonalSettings</personal>
|
||||||
</settings>
|
</settings>
|
||||||
|
@ -4,7 +4,5 @@ return [
|
|||||||
'routes' => [
|
'routes' => [
|
||||||
['name' => 'settings#get', 'url' => '/settings', 'verb' => 'GET'],
|
['name' => 'settings#get', 'url' => '/settings', 'verb' => 'GET'],
|
||||||
['name' => 'settings#set', 'url' => '/settings', 'verb' => 'POST'],
|
['name' => 'settings#set', 'url' => '/settings', 'verb' => 'POST'],
|
||||||
['name' => 'settings#getGlobal', 'url' => '/settings/global', 'verb' => 'GET'],
|
|
||||||
['name' => 'settings#setGlobal', 'url' => '/settings/global', 'verb' => 'POST'],
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
(function(window) {
|
|
||||||
const folder_selector = document.querySelectorAll('.pride_flags_server_settings .server-settings.folder-flavour select')[0];
|
|
||||||
const button_selector = document.querySelectorAll('.pride_flags_server_settings .server-settings.button-flavour select')[0];
|
|
||||||
const submit_button = document.querySelectorAll('.pride_flags_server_settings .settings-pride-submit');
|
|
||||||
const container = document.querySelector('.pride_flags_server_settings .settings-section');
|
|
||||||
|
|
||||||
function load() {
|
|
||||||
fetch(OC.generateUrl('/apps/pride_flags/settings/global'))
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(({folderVariant, buttonVariant}) => {
|
|
||||||
folder_selector.value = folderVariant;
|
|
||||||
button_selector.value = buttonVariant;
|
|
||||||
container.classList.remove('hidden');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function save() {
|
|
||||||
const payload = {
|
|
||||||
folderVariant: folder_selector.value,
|
|
||||||
buttonVariant: button_selector.value,
|
|
||||||
}
|
|
||||||
fetch(OC.generateUrl('/apps/pride_flags/settings/global'), {
|
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify(payload),
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"requesttoken": OC.requestToken,
|
|
||||||
}
|
|
||||||
}).then(response => {
|
|
||||||
if (response.ok) {
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
submit_button.forEach(node => node.addEventListener('click', e => save()));
|
|
||||||
|
|
||||||
load();
|
|
||||||
})(window);
|
|
@ -1,38 +1,36 @@
|
|||||||
(function(window) {
|
|
||||||
const folder_selector = document.querySelectorAll('.pride_flags_user_settings .user-settings.folder-flavour select')[0];
|
|
||||||
const button_selector = document.querySelectorAll('.pride_flags_user_settings .user-settings.button-flavour select')[0];
|
|
||||||
const submit_button = document.querySelectorAll('.pride_flags_user_settings .settings-pride-submit');
|
|
||||||
const container = document.querySelector('.pride_flags_user_settings .settings-section');
|
|
||||||
|
|
||||||
function load() {
|
|
||||||
fetch(OC.generateUrl('/apps/pride_flags/settings'))
|
const folder_selector = document.querySelectorAll('.pride_flags_user_settings .user-settings.folder-flavour select')[0];
|
||||||
.then(res => res.json())
|
const button_selector = document.querySelectorAll('.pride_flags_user_settings .user-settings.button-flavour select')[0];
|
||||||
.then(({folderVariant, buttonVariant}) => {
|
const submit_button = document.querySelectorAll('.pride_flags_user_settings .settings-pride-submit');
|
||||||
folder_selector.value = folderVariant;
|
|
||||||
button_selector.value = buttonVariant;
|
function load() {
|
||||||
container.classList.remove('hidden');
|
fetch(OC.generateUrl('/apps/pride_flags/settings'))
|
||||||
});
|
.then(res => res.json())
|
||||||
|
.then(({folderVariant, buttonVariant}) => {
|
||||||
|
folder_selector.value = folderVariant;
|
||||||
|
button_selector.value = buttonVariant;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function save() {
|
||||||
|
const payload = {
|
||||||
|
folderVariant: folder_selector.value,
|
||||||
|
buttonVariant: button_selector.value,
|
||||||
}
|
}
|
||||||
|
fetch(OC.generateUrl('/apps/pride_flags/settings'), {
|
||||||
function save() {
|
method: 'POST',
|
||||||
const payload = {
|
body: JSON.stringify(payload),
|
||||||
folderVariant: folder_selector.value,
|
headers: {
|
||||||
buttonVariant: button_selector.value,
|
"Content-Type": "application/json",
|
||||||
|
"requesttoken": OC.requestToken,
|
||||||
}
|
}
|
||||||
fetch(OC.generateUrl('/apps/pride_flags/settings'), {
|
}).then(response => {
|
||||||
method: 'POST',
|
if (response.ok) {
|
||||||
body: JSON.stringify(payload),
|
window.location.reload();
|
||||||
headers: {
|
}
|
||||||
"Content-Type": "application/json",
|
})
|
||||||
"requesttoken": OC.requestToken,
|
}
|
||||||
}
|
submit_button.forEach(node => node.addEventListener('click', e => save()));
|
||||||
}).then(response => {
|
|
||||||
if (response.ok) {
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
submit_button.forEach(node => node.addEventListener('click', e => save()));
|
|
||||||
|
|
||||||
load();
|
load();
|
||||||
})(window);
|
|
||||||
|
@ -14,7 +14,6 @@ use OCP\AppFramework\Http;
|
|||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||||
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
|
|
||||||
|
|
||||||
class SettingsController extends Controller {
|
class SettingsController extends Controller {
|
||||||
|
|
||||||
@ -34,17 +33,6 @@ class SettingsController extends Controller {
|
|||||||
return $this->makeJSONResponse(fn () => $this->appSettings->getAll($this->userId));
|
return $this->makeJSONResponse(fn () => $this->appSettings->getAll($this->userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[AuthorizedAdminSetting]
|
|
||||||
public function setGlobal(string $folderVariant, string $buttonVariant): JSONResponse {
|
|
||||||
$this->appSettings->setGlobal($folderVariant, $buttonVariant);
|
|
||||||
return $this->makeJSONResponse(fn () => $this->appSettings->getGlobal());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[NoCSRFRequired]
|
|
||||||
public function getGlobal(): JSONResponse {
|
|
||||||
return $this->makeJSONResponse(fn () => $this->appSettings->getGlobal());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function makeJSONResponse(Closure $closure): JSONResponse {
|
protected function makeJSONResponse(Closure $closure): JSONResponse {
|
||||||
try {
|
try {
|
||||||
return new JSONResponse($closure(), HTTP::STATUS_OK);
|
return new JSONResponse($closure(), HTTP::STATUS_OK);
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace OCA\PrideFlags\Settings;
|
|
||||||
|
|
||||||
use OCA\PrideFlags\AppConstants;
|
|
||||||
use OCP\IL10N;
|
|
||||||
use OCP\IURLGenerator;
|
|
||||||
use OCP\Settings\IIConSection;
|
|
||||||
|
|
||||||
class AdminSection implements IIconSection {
|
|
||||||
public function __construct(private IL10N $l10n, private IURLGenerator $urlGenerator) {}
|
|
||||||
|
|
||||||
public function getID(): string {
|
|
||||||
return AppConstants::APP_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getName(): string {
|
|
||||||
return 'Pride Flags';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPriority(): int {
|
|
||||||
return 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIcon(): string {
|
|
||||||
return $this->urlGenerator->imagePath('core', 'actions/settings-dark.svg');
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace OCA\PrideFlags\Settings;
|
|
||||||
|
|
||||||
use OCA\PrideFlags\AppConstants;
|
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
|
||||||
use OCP\Settings\ISettings;
|
|
||||||
use OCP\Util;
|
|
||||||
|
|
||||||
class AdminSettings implements ISettings {
|
|
||||||
public function getForm(): TemplateResponse {
|
|
||||||
Util::addScript(AppConstants::APP_ID, 'pride-settings-global');
|
|
||||||
return new TemplateResponse(AppConstants::APP_ID, 'server-settings', []);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSection(): string {
|
|
||||||
return AppConstants::APP_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPriority(): int {
|
|
||||||
return 50;
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,18 +13,13 @@ class AppSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getStringSetting($userId, string $key, string $default = ''): string {
|
public function getStringSetting($userId, string $key, string $default = ''): string {
|
||||||
return $this->config->getUserValue(AppConstants::APP_ID, $userId, $key)
|
return $this->config->getUserValue(AppConstants::APP_ID, $userId, $key) ?: $default;
|
||||||
?: ($this->config->getAppValue(AppConstants::APP_ID, $userId, $key) ?: $default);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setStringSetting($userId, string $key, string $value): void {
|
public function setStringSetting($userId, string $key, string $value): void {
|
||||||
$this->config->setUserValue(AppConstants::APP_ID, $userId, $key, $value);
|
$this->config->setUserValue(AppConstants::APP_ID, $userId, $key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAppStringSetting(string $key, string $value): void {
|
|
||||||
$this->config->setAppValue(AppConstants::APP_ID, $key, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAll($userId): array {
|
public function getAll($userId): array {
|
||||||
return [
|
return [
|
||||||
AppSettings::FOLDER_VARIANT => $this->getStringSetting($userId, AppSettings::FOLDER_VARIANT, 'pride'),
|
AppSettings::FOLDER_VARIANT => $this->getStringSetting($userId, AppSettings::FOLDER_VARIANT, 'pride'),
|
||||||
@ -32,20 +27,8 @@ class AppSettings {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGlobal(): array {
|
|
||||||
return [
|
|
||||||
AppSettings::FOLDER_VARIANT => $this->config->getAppValue(AppConstants::APP_ID, AppSettings::FOLDER_VARIANT, 'pride'),
|
|
||||||
AppSettings::BUTTON_VARIANT => $this->config->getAppValue(AppConstants::APP_ID, AppSettings::BUTTON_VARIANT, 'trans'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function set($userId, $folder, $button): void {
|
public function set($userId, $folder, $button): void {
|
||||||
$this->setStringSetting($userId, AppSettings::FOLDER_VARIANT, $folder);
|
$this->setStringSetting($userId, AppSettings::FOLDER_VARIANT, $folder);
|
||||||
$this->setStringSetting($userId, AppSettings::BUTTON_VARIANT, $button);
|
$this->setStringSetting($userId, AppSettings::BUTTON_VARIANT, $button);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setGlobal($folder, $button): void {
|
|
||||||
$this->setAppStringSetting(AppSettings::FOLDER_VARIANT, $folder);
|
|
||||||
$this->setAppStringSetting(AppSettings::BUTTON_VARIANT, $button);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pride_flags",
|
"name": "pride_flags",
|
||||||
"version": "1.1.0",
|
"version": "1.0.0",
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20.0.0",
|
"node": "^20.0.0",
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
<div class="pride_flags_server_settings">
|
|
||||||
<div class="settings-section section hidden">
|
|
||||||
<h2 class="settings_section__name">Server-wide preferences</h2>
|
|
||||||
<div class="server-settings folder-flavour" style="margin-left: 40px; display: flex;">
|
|
||||||
<label for="server-settings-folder-flavour-select" style="display: flex; width: 100px;">Folders</label>
|
|
||||||
<select id="server-settings-folder-flavour-select" style="display: flex; width: 200px;">
|
|
||||||
<option value='pride'>Pride</option>
|
|
||||||
<option value='trans'>Trans Pride</option>
|
|
||||||
<option value='pan'>Pansexual Pride</option>
|
|
||||||
<option value='nonbinary'>Non-binary Pride</option>
|
|
||||||
<option value='bi'>Bisexual Pride</option>
|
|
||||||
<option value='asexual'>Asexual Pride</option>
|
|
||||||
<option value='lesbian'>Lesbian Pride</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="server-settings button-flavour" style="margin-left: 40px; display: flex;">
|
|
||||||
<label for="server-settings-button-flavour-select" style="display: flex; width: 100px;">Buttons</label>
|
|
||||||
<select id="server-settings-button-flavour-select" style="display: flex; width: 200px;">
|
|
||||||
<option value='pride'>Pride</option>
|
|
||||||
<option value='trans'>Trans Pride</option>
|
|
||||||
<option value='pan'>Pansexual Pride</option>
|
|
||||||
<option value='nonbinary'>Non-binary Pride</option>
|
|
||||||
<option value='bi'>Bisexual Pride</option>
|
|
||||||
<option value='asexual'>Asexual Pride</option>
|
|
||||||
<option value='lesbian'>Lesbian Pride</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<button class="settings-pride-submit button primary" style="margin-left: 40px; display: flex; width: 80px; text-align: center;">Save</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="pride_flags_user_settings">
|
<div class="pride_flags_user_settings">
|
||||||
<div class="settings-section section hidden">
|
<div class="settings-section section">
|
||||||
<h2 class="settings_section__name">Personal preferences</h2>
|
<h2 class="settings_section__name">Personal preferences</h2>
|
||||||
<div class="user-settings folder-flavour" style="margin-left: 40px; display: flex;">
|
<div class="user-settings folder-flavour" style="margin-left: 40px; display: flex;">
|
||||||
<label for="user-settings-folder-flavour-select" style="display: flex; width: 100px;">Folders</label>
|
<label for="user-settings-folder-flavour-select" style="display: flex; width: 100px;">Folders</label>
|
||||||
|
Loading…
Reference in New Issue
Block a user