Nextcloud rename Ajax to Fetch and added Nextcloud theme for #96

This commit is contained in:
the-djmaze 2022-10-11 14:49:22 +02:00
parent 63ef2cc724
commit 47c1071f3f
7 changed files with 84 additions and 57 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

View file

@ -0,0 +1,51 @@
:root {
/* MAIN */
--main-color: #333;
--main-bg-color: transparent;
--main-bg-image: none;
/* LOADING */
--loading-color: #000;
/* LOGIN */
--login-color: #eee;
--login-bg-color: rgba(0,0,0,0.5);
--login-box-shadow: none;
--login-border: none;
--login-border-radius: 7px;
/* MENU */
--dropdown-menu-color: #333;
--dropdown-menu-bg-color: #fff;
--dropdown-menu-hover-bg-color: #757575;
--dropdown-menu-hover-color: #eee;
--dropdown-menu-disable-color: #999;
/* FOLDERS */
--folders-color: #333;
--folders-disabled-color: #999;
--folders-selected-color: #eee;
--folders-selected-bg-color: rgba(0,0,0,0.5);
--folders-focused-color: #eee;
--folders-focused-bg-color: rgba(0,0,0,0.7);
--folders-hover-color: #eee;
--folders-hover-bg-color: rgba(0,0,0,0.5);
--folders-drop-color: #eee;
--folders-drop-bg-color: rgba(0,0,0,0.5);
/* SETTINGS */
--settings-menu-color: #333;
--settings-menu-selected-color: #eee;
--settings-menu-selected-bg-color: rgba(0,0,0,0.5);
--settings-menu-hover-color: #eee;
--settings-menu-hover-bg-color: rgba(0,0,0,0.5);
/* MESSAGE LIST */
--message-list-toolbar-bg-color: #eee;
}
.thm-message-list-top-toolbar, .thm-message-list-bottom-toolbar {
background-image: linear-gradient(to bottom, #f4f4f4, #dfdfdf) !important;
background-repeat: repeat-x !important;
}

View file

@ -18,13 +18,13 @@ return [
'verb' => 'POST'
],
[
'name' => 'ajax#setPersonal',
'url' => '/ajax/personal.php',
'name' => 'fetch#setPersonal',
'url' => '/fetch/personal.php',
'verb' => 'POST'
],
[
'name' => 'ajax#setAdmin',
'url' => '/ajax/admin.php',
'name' => 'fetch#setAdmin',
'url' => '/fetch/admin.php',
'verb' => 'POST'
]
]

View file

@ -7,11 +7,9 @@
*/
// Do the following things once the document is fully loaded.
document.onreadystatechange = function () {
if (document.readyState === 'complete') {
watchIFrameTitle();
}
}
document.onreadystatechange = () => {
(document.readyState === 'complete') && watchIFrameTitle();
};
// The SnappyMail application is already configured to modify the <title> element
// of its root document with the number of unread messages in the inbox.
@ -31,7 +29,7 @@ function watchIFrameTitle() {
childList: true,
subtree: true
};
let observer = new MutationObserver(function(mutations) {
let observer = new MutationObserver(mutations => {
let title = mutations[0].target.innerText;
if (title) {
let matches = title.match(/\(([0-9]+)\)/);
@ -45,7 +43,7 @@ function watchIFrameTitle() {
observer.observe(target, config);
}
function SnappyMailFormHelper(sID, sAjaxFile, fCallback)
function SnappyMailFormHelper(sID, sFetchFile, fCallback)
{
try
{
@ -56,49 +54,33 @@ function SnappyMailFormHelper(sID, sAjaxFile, fCallback)
oDesc = oForm.querySelector('.snappymail-result-desc')
;
oForm.addEventListener('submit', (...args) => {
console.dir({args:args});
return false
});
oSubmit.onclick = oEvent => {
oForm.addEventListener('submit', oEvent => {
oEvent.preventDefault();
oForm.classList.add('snappymail-ajax')
oForm.classList.add('snappymail-fetch')
oForm.classList.remove('snappymail-error')
oForm.classList.remove('snappymail-success')
oDesc.textContent = '';
oSubmit.textContent = '...';
fetch(OC.filePath('snappymail', 'ajax', sAjaxFile), {
fetch(OC.filePath('snappymail', 'fetch', sFetchFile), {
mode: 'same-origin',
cache: 'no-cache',
redirect: 'error',
referrerPolicy: 'no-referrer',
credentials: 'same-origin',
method: 'POST',
/*
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
'snappymail-email': document.getElementById('snappymail-email').value,
'snappymail-password': document.getElementById('snappymail-password').value
})
*/
headers: {},
body: new FormData(oForm)
})
.then(response => response.json())
.then(oData => {
let bResult = false;
oForm.classList.remove('snappymail-ajax');
let bResult = 'success' === oData?.status;
oForm.classList.remove('snappymail-fetch');
oSubmit.textContent = sSubmitValue;
if (oData) {
bResult = 'success' === oData.status;
if (oData.Message) {
oDesc.textContent = t('snappymail', oData.Message);
}
if (oData?.Message) {
oDesc.textContent = t('snappymail', oData.Message);
}
if (bResult) {
oForm.classList.add('snappymail-success');
@ -108,13 +90,11 @@ function SnappyMailFormHelper(sID, sAjaxFile, fCallback)
oDesc.textContent = t('snappymail', 'Error');
}
}
if (fCallback) {
fCallback(bResult, oData);
}
fCallback?.(bResult, oData);
});
return false;
};
});
}
catch(e) {
console.error(e);

View file

@ -3,7 +3,7 @@
namespace OCA\SnappyMail\AppInfo;
use OCA\SnappyMail\Util\SnappyMailHelper;
use OCA\SnappyMail\Controller\AjaxController;
use OCA\SnappyMail\Controller\FetchController;
use OCA\SnappyMail\Controller\PageController;
use OCP\AppFramework\App;
@ -47,8 +47,8 @@ class Application extends App implements IBootstrap
);
$container->registerService(
'AjaxController', function($c) {
return new AjaxController(
'FetchController', function($c) {
return new FetchController(
$c->query('AppName'),
$c->query('Request'),
$c->getServer()->getAppManager(),

View file

@ -11,7 +11,7 @@ use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
class AjaxController extends Controller {
class FetchController extends Controller {
private $config;
private $appManager;

View file

@ -9,32 +9,28 @@ class PersonalSettings implements ISettings
{
private $config;
public function __construct(IConfig $config) {
public function __construct(IConfig $config)
{
$this->config = $config;
}
public function getForm() {
public function getForm()
{
$uid = \OC::$server->getUserSession()->getUser()->getUID();
$keys = [
'snappymail-email',
'snappymail-password'
$parameters = [
'snappymail-email' => $this->config->getUserValue($uid, 'snappymail', 'snappymail-email'),
'snappymail-password' => $this->config->getUserValue($uid, 'snappymail', 'snappymail-password') ? '******' : ''
];
$parameters = [];
foreach ($keys as $k) {
$v = $this->config->getUserValue($uid, 'snappymail', $k);
$parameters[$k] = $v;
}
return new TemplateResponse('snappymail', 'personal_settings', $parameters, '');
}
public function getSection() {
public function getSection()
{
return 'additional';
}
public function getPriority() {
public function getPriority()
{
return 50;
}