Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit 47c1071

Browse files
author
the-djmaze
committed
Nextcloud rename Ajax to Fetch and added Nextcloud theme for #96
1 parent 63ef2cc commit 47c1071

File tree

7 files changed

+84
-57
lines changed

7 files changed

+84
-57
lines changed
160 Bytes
Loading
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
:root {
3+
/* MAIN */
4+
--main-color: #333;
5+
--main-bg-color: transparent;
6+
--main-bg-image: none;
7+
8+
/* LOADING */
9+
--loading-color: #000;
10+
11+
/* LOGIN */
12+
--login-color: #eee;
13+
--login-bg-color: rgba(0,0,0,0.5);
14+
--login-box-shadow: none;
15+
--login-border: none;
16+
--login-border-radius: 7px;
17+
18+
/* MENU */
19+
--dropdown-menu-color: #333;
20+
--dropdown-menu-bg-color: #fff;
21+
--dropdown-menu-hover-bg-color: #757575;
22+
--dropdown-menu-hover-color: #eee;
23+
--dropdown-menu-disable-color: #999;
24+
25+
/* FOLDERS */
26+
--folders-color: #333;
27+
--folders-disabled-color: #999;
28+
--folders-selected-color: #eee;
29+
--folders-selected-bg-color: rgba(0,0,0,0.5);
30+
--folders-focused-color: #eee;
31+
--folders-focused-bg-color: rgba(0,0,0,0.7);
32+
--folders-hover-color: #eee;
33+
--folders-hover-bg-color: rgba(0,0,0,0.5);
34+
--folders-drop-color: #eee;
35+
--folders-drop-bg-color: rgba(0,0,0,0.5);
36+
37+
/* SETTINGS */
38+
--settings-menu-color: #333;
39+
--settings-menu-selected-color: #eee;
40+
--settings-menu-selected-bg-color: rgba(0,0,0,0.5);
41+
--settings-menu-hover-color: #eee;
42+
--settings-menu-hover-bg-color: rgba(0,0,0,0.5);
43+
44+
/* MESSAGE LIST */
45+
--message-list-toolbar-bg-color: #eee;
46+
}
47+
48+
.thm-message-list-top-toolbar, .thm-message-list-bottom-toolbar {
49+
background-image: linear-gradient(to bottom, #f4f4f4, #dfdfdf) !important;
50+
background-repeat: repeat-x !important;
51+
}

integrations/nextcloud/snappymail/appinfo/routes.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
'verb' => 'POST'
1919
],
2020
[
21-
'name' => 'ajax#setPersonal',
22-
'url' => '/ajax/personal.php',
21+
'name' => 'fetch#setPersonal',
22+
'url' => '/fetch/personal.php',
2323
'verb' => 'POST'
2424
],
2525
[
26-
'name' => 'ajax#setAdmin',
27-
'url' => '/ajax/admin.php',
26+
'name' => 'fetch#setAdmin',
27+
'url' => '/fetch/admin.php',
2828
'verb' => 'POST'
2929
]
3030
]

integrations/nextcloud/snappymail/js/snappymail.js

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
*/
88

99
// Do the following things once the document is fully loaded.
10-
document.onreadystatechange = function () {
11-
if (document.readyState === 'complete') {
12-
watchIFrameTitle();
13-
}
14-
}
10+
document.onreadystatechange = () => {
11+
(document.readyState === 'complete') && watchIFrameTitle();
12+
};
1513

1614
// The SnappyMail application is already configured to modify the <title> element
1715
// of its root document with the number of unread messages in the inbox.
@@ -31,7 +29,7 @@ function watchIFrameTitle() {
3129
childList: true,
3230
subtree: true
3331
};
34-
let observer = new MutationObserver(function(mutations) {
32+
let observer = new MutationObserver(mutations => {
3533
let title = mutations[0].target.innerText;
3634
if (title) {
3735
let matches = title.match(/\(([0-9]+)\)/);
@@ -45,7 +43,7 @@ function watchIFrameTitle() {
4543
observer.observe(target, config);
4644
}
4745

48-
function SnappyMailFormHelper(sID, sAjaxFile, fCallback)
46+
function SnappyMailFormHelper(sID, sFetchFile, fCallback)
4947
{
5048
try
5149
{
@@ -56,49 +54,33 @@ function SnappyMailFormHelper(sID, sAjaxFile, fCallback)
5654
oDesc = oForm.querySelector('.snappymail-result-desc')
5755
;
5856

59-
oForm.addEventListener('submit', (...args) => {
60-
console.dir({args:args});
61-
return false
62-
});
63-
64-
oSubmit.onclick = oEvent => {
65-
57+
oForm.addEventListener('submit', oEvent => {
6658
oEvent.preventDefault();
6759

68-
oForm.classList.add('snappymail-ajax')
60+
oForm.classList.add('snappymail-fetch')
6961
oForm.classList.remove('snappymail-error')
7062
oForm.classList.remove('snappymail-success')
7163

7264
oDesc.textContent = '';
7365
oSubmit.textContent = '...';
7466

75-
fetch(OC.filePath('snappymail', 'ajax', sAjaxFile), {
67+
fetch(OC.filePath('snappymail', 'fetch', sFetchFile), {
7668
mode: 'same-origin',
7769
cache: 'no-cache',
7870
redirect: 'error',
7971
referrerPolicy: 'no-referrer',
8072
credentials: 'same-origin',
8173
method: 'POST',
82-
/*
83-
headers: { 'Content-Type': 'application/json' },
84-
body: JSON.stringify({
85-
'snappymail-email': document.getElementById('snappymail-email').value,
86-
'snappymail-password': document.getElementById('snappymail-password').value
87-
})
88-
*/
8974
headers: {},
9075
body: new FormData(oForm)
9176
})
9277
.then(response => response.json())
9378
.then(oData => {
94-
let bResult = false;
95-
oForm.classList.remove('snappymail-ajax');
79+
let bResult = 'success' === oData?.status;
80+
oForm.classList.remove('snappymail-fetch');
9681
oSubmit.textContent = sSubmitValue;
97-
if (oData) {
98-
bResult = 'success' === oData.status;
99-
if (oData.Message) {
100-
oDesc.textContent = t('snappymail', oData.Message);
101-
}
82+
if (oData?.Message) {
83+
oDesc.textContent = t('snappymail', oData.Message);
10284
}
10385
if (bResult) {
10486
oForm.classList.add('snappymail-success');
@@ -108,13 +90,11 @@ function SnappyMailFormHelper(sID, sAjaxFile, fCallback)
10890
oDesc.textContent = t('snappymail', 'Error');
10991
}
11092
}
111-
if (fCallback) {
112-
fCallback(bResult, oData);
113-
}
93+
fCallback?.(bResult, oData);
11494
});
11595

11696
return false;
117-
};
97+
});
11898
}
11999
catch(e) {
120100
console.error(e);

integrations/nextcloud/snappymail/lib/AppInfo/Application.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace OCA\SnappyMail\AppInfo;
44

55
use OCA\SnappyMail\Util\SnappyMailHelper;
6-
use OCA\SnappyMail\Controller\AjaxController;
6+
use OCA\SnappyMail\Controller\FetchController;
77
use OCA\SnappyMail\Controller\PageController;
88

99
use OCP\AppFramework\App;
@@ -47,8 +47,8 @@ public function __construct(array $urlParams = [])
4747
);
4848

4949
$container->registerService(
50-
'AjaxController', function($c) {
51-
return new AjaxController(
50+
'FetchController', function($c) {
51+
return new FetchController(
5252
$c->query('AppName'),
5353
$c->query('Request'),
5454
$c->getServer()->getAppManager(),

integrations/nextcloud/snappymail/lib/Controller/AjaxController.php renamed to integrations/nextcloud/snappymail/lib/Controller/FetchController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use OCP\IL10N;
1212
use OCP\IRequest;
1313

14-
class AjaxController extends Controller {
14+
class FetchController extends Controller {
1515
private $config;
1616
private $appManager;
1717

integrations/nextcloud/snappymail/lib/Settings/PersonalSettings.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,28 @@ class PersonalSettings implements ISettings
99
{
1010
private $config;
1111

12-
public function __construct(IConfig $config) {
12+
public function __construct(IConfig $config)
13+
{
1314
$this->config = $config;
1415
}
1516

16-
public function getForm() {
17+
public function getForm()
18+
{
1719
$uid = \OC::$server->getUserSession()->getUser()->getUID();
18-
19-
$keys = [
20-
'snappymail-email',
21-
'snappymail-password'
20+
$parameters = [
21+
'snappymail-email' => $this->config->getUserValue($uid, 'snappymail', 'snappymail-email'),
22+
'snappymail-password' => $this->config->getUserValue($uid, 'snappymail', 'snappymail-password') ? '******' : ''
2223
];
23-
24-
$parameters = [];
25-
foreach ($keys as $k) {
26-
$v = $this->config->getUserValue($uid, 'snappymail', $k);
27-
$parameters[$k] = $v;
28-
}
29-
3024
return new TemplateResponse('snappymail', 'personal_settings', $parameters, '');
3125
}
3226

33-
public function getSection() {
27+
public function getSection()
28+
{
3429
return 'additional';
3530
}
3631

37-
public function getPriority() {
32+
public function getPriority()
33+
{
3834
return 50;
3935
}
4036

0 commit comments

Comments
 (0)