v1.0.41 - fix routes.xml, use API for config

This commit is contained in:
2026-04-16 20:51:06 +02:00
parent 3065ff13cc
commit 11118bbf8b
3 changed files with 43 additions and 22 deletions

View File

@@ -4,7 +4,7 @@
<name>Minimal Profile</name> <name>Minimal Profile</name>
<summary>Hides profile fields to create a minimal user profile</summary> <summary>Hides profile fields to create a minimal user profile</summary>
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description> <description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
<version>1.0.35</version> <version>1.0.41</version>
<licence>AGPL</licence> <licence>AGPL</licence>
<author>Your Name</author> <author>Your Name</author>
<namespace>MinimalProfile</namespace> <namespace>MinimalProfile</namespace>

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<routes> <routes>
<route url="/apps/minimalprofile/api/v1/hidden-fields" method="GET" controller="OCA\MinimalProfile\Controller\ApiController:getHiddenFields"/> <route url="/apps/minimalprofile/api/v1/hidden-fields" method="GET" controller="OCA\MinimalProfile\Controller\ApiController" action="getHiddenFields"/>
</routes> </routes>

View File

@@ -1,5 +1,5 @@
/** /**
* Minimal Profile v40 - NEW SCRIPT * MinimalProfile v41 - API-based config
*/ */
(function() { (function() {
'use strict'; 'use strict';
@@ -8,14 +8,7 @@
return; return;
} }
console.log('MinimalProfile v40: HERE'); console.log('MinimalProfile v41: Starting');
var storageKey = 'minimalprofile_hidden';
var stored = localStorage.getItem(storageKey);
var hidden = stored ? JSON.parse(stored) : [];
var urlParam = new URLSearchParams(window.location.search).get('hide');
if (urlParam) hidden = urlParam.split(',');
if (!hidden.length) return;
var map = { var map = {
'pronouns': '#account-property-pronouns', 'pronouns': '#account-property-pronouns',
@@ -23,6 +16,9 @@
'headline': '#account-property-headline' 'headline': '#account-property-headline'
}; };
function hideFields(hidden) {
if (!hidden || !hidden.length) return;
var css = ''; var css = '';
hidden.forEach(function(f) { hidden.forEach(function(f) {
if (map[f]) { if (map[f]) {
@@ -36,4 +32,29 @@
s.textContent = css; s.textContent = css;
document.head.appendChild(s); document.head.appendChild(s);
} }
}
function loadConfig() {
var xhr = new XMLHttpRequest();
xhr.open('GET', '/apps/minimalprofile/api/v1/hidden-fields', true);
xhr.onload = function() {
if (xhr.status === 200) {
try {
var data = JSON.parse(xhr.responseText);
console.log('MinimalProfile v41: API returned', data.hiddenFields);
hideFields(data.hiddenFields);
} catch(e) {
console.error('MinimalProfile v41: JSON parse error', e);
}
} else {
console.error('MinimalProfile v41: API failed', xhr.status);
}
};
xhr.onerror = function() {
console.error('MinimalProfile v41: Network error');
};
xhr.send();
}
loadConfig();
})(); })();