Fix merging errors

This commit is contained in:
CasVT
2024-03-11 22:34:32 +01:00
11 changed files with 6 additions and 1002 deletions

View File

@@ -174,158 +174,6 @@ def get_apprise_services() -> List[Dict[str, Union[str, Dict[str, list]]]]:
return apprise_services
def _sort_tokens(t: dict) -> int:
result = [
int(not t['required'])
]
if t['type'] == 'choice':
result.append(0)
elif t['type'] != 'list':
result.append(1)
else:
result.append(2)
return result
def get_apprise_services() -> List[Dict[str, Union[str, Dict[str, list]]]]:
apprise_services = []
raw = Apprise().details()
for entry in raw['schemas']:
entry: Dict[str, Union[str, dict]]
result: Dict[str, Union[str, Dict[str, list]]] = {
'name': str(entry['service_name']),
'doc_url': entry['setup_url'],
'details': {
'templates': entry['details']['templates'],
'tokens': [],
'args': []
}
}
schema = entry['details']['tokens']['schema']
result['details']['tokens'].append({
'name': schema['name'],
'map_to': 'schema',
'required': schema['required'],
'type': 'choice',
'options': schema['values'],
'default': schema.get('default')
})
handled_tokens = {'schema'}
result['details']['tokens'] += [
{
'name': v['name'],
'map_to': k,
'required': v['required'],
'type': 'list',
'delim': v['delim'][0],
'content': [
{
'name': content['name'],
'required': content['required'],
'type': content['type'],
'prefix': content.get('prefix'),
'regex': content.get('regex')
}
for content, _ in ((entry['details']['tokens'][e], handled_tokens.add(e)) for e in v['group'])
]
}
for k, v in
filter(
lambda t: t[1]['type'].startswith('list:'),
entry['details']['tokens'].items()
)
]
handled_tokens.update(
set(map(lambda e: e[0],
filter(lambda e: e[1]['type'].startswith('list:'),
entry['details']['tokens'].items())
))
)
result['details']['tokens'] += [
{
'name': v['name'],
'map_to': k,
'required': v['required'],
'type': v['type'].split(':')[0],
**({
'options': v.get('values'),
'default': v.get('default')
} if v['type'].startswith('choice') else {
'prefix': v.get('prefix'),
'min': v.get('min'),
'max': v.get('max'),
'regex': v.get('regex')
})
}
for k, v in
filter(
lambda t: not t[0] in handled_tokens,
entry['details']['tokens'].items()
)
]
result['details']['tokens'].sort(key=_sort_tokens)
result['details']['args'] += [
{
'name': v.get('name', k),
'map_to': k,
'required': v.get('required', False),
'type': v['type'].split(':')[0],
**({
'delim': v['delim'][0],
'content': []
} if v['type'].startswith('list') else {
'options': v['values'],
'default': v.get('default')
} if v['type'].startswith('choice') else {
'default': v['default']
} if v['type'] == 'bool' else {
'min': v.get('min'),
'max': v.get('max'),
'regex': v.get('regex')
})
}
for k, v in
filter(
lambda a: (
a[1].get('alias_of') is None
and not a[0] in ('cto', 'format', 'overflow', 'rto', 'verify')
),
entry['details']['args'].items()
)
]
result['details']['args'].sort(key=_sort_tokens)
apprise_services.append(result)
apprise_services.sort(key=lambda s: s['name'].lower())
apprise_services.insert(0, {
'name': 'Custom URL',
'doc_url': 'https://github.com/caronc/apprise#supported-notifications',
'details': {
'templates': ['{url}'],
'tokens': [{
'name': 'Apprise URL',
'map_to': 'url',
'required': True,
'type': 'string',
'prefix': None,
'min': None,
'max': None,
'regex': None
}],
'args': []
}
})
return apprise_services
class NotificationService:
def __init__(self, user_id: int, notification_service_id: int) -> None:
self.id = notification_service_id

View File

@@ -229,9 +229,6 @@ class Reminder:
Either repeat_quantity and repeat_interval are given, weekdays is
given or neither, but not both.
Note about args:
Either repeat_quantity and repeat_interval are given, weekdays is given or neither, but not both.
Raises:
NotificationServiceNotFound: One of the notification services was not found.
InvalidKeyValue: The value of one of the keys is not valid or
@@ -513,9 +510,6 @@ class Reminders:
Either repeat_quantity and repeat_interval are given,
weekdays is given or neither, but not both.
Note about args:
Either repeat_quantity and repeat_interval are given, weekdays is given or neither, but not both.
Raises:
NotificationServiceNotFound: One of the notification services was not found.
InvalidKeyValue: The value of one of the keys is not valid

View File

@@ -117,10 +117,7 @@
.form-container > form .repeat-options > button {
width: calc((100% / 3) - (var(--gap) / 1.5));
min-width: min-content;
<<<<<<< HEAD
=======
padding: 1rem 0rem;
>>>>>>> Development
}
.repeat-bar {
@@ -227,10 +224,7 @@ div.options > button {
.sub-inputs > input,
.sub-inputs > select,
.sub-inputs > button,
<<<<<<< HEAD
=======
.sub-inputs > label,
>>>>>>> Development
.form-container > form .repeat-options > button {
width: 100%;
}

View File

@@ -249,173 +249,24 @@ tr:has(input:read-only) button[data-type="save"] {
display: none;
}
<<<<<<< HEAD
/* */
/* Add service */
/* */
#add-service-container {
display: none;
}
.overflow-container.show-add #add-service-container {
display: block;
}
.overflow-container.show-add > table {
display: none;
}
#service-list {
display: flex;
gap: 1rem;
flex-wrap: wrap;
justify-content: center;
}
#service-list button {
width: max(30%, 10rem);
height: 6rem;
display: flex;
justify-content: center;
align-items: center;
padding: .75rem;
border-radius: 4px;
border: 2px solid var(--color-gray);
text-align: center;
font-size: 1.1rem;
}
#add-service-container.show-add-window #add-service-window {
display: flex;
}
#add-service-container.show-add-window #service-list {
display: none;
}
/* */
/* Add service form */
/* */
#add-service-window {
max-width: 30rem;
margin: auto;
display: none;
flex-direction: column;
justify-content: center;
gap: 1rem;
text-align: center;
}
#add-service-window > h3 {
font-size: 1.75rem;
}
#add-service-window > p {
margin-bottom: calc((1rem + 2px) * -1);
border: 2px solid var(--color-gray);
border-top-left-radius: 4px;
border-top-right-radius: 4px;
padding: .75rem 1rem;
color: var(--color-gray);
text-align: left;
box-shadow: var(--default-shadow);
}
#add-service-window > button {
border-radius: 4px;
border: 2px solid var(--color-gray);
padding: .75rem;
}
#add-service-window > a,
#add-service-window > p > a {
color: var(--color-light);
}
#add-service-window > div[data-map],
#add-service-window > div[data-map] > .entries-list {
display: flex;
flex-direction: column;
gap: inherit;
}
#add-service-window > div[data-map] {
padding: .5rem;
border: 2px solid var(--color-gray);
border-radius: 4px;
box-shadow: var(--default-shadow);
}
#add-service-window > div[data-map] > p {
color: var(--color-gray);
font-size: 1.1rem;
}
.entries-list {
min-height: 5rem;
max-height: 15rem;
overflow-y: auto;
align-items: center;
background-color: var(--color-dark);
color: var(--color-light);
border: 2px solid var(--color-gray);
border-radius: 4px;
padding: .75rem;
box-shadow: var(--default-shadow);
font-size: 1rem;
}
.entries-list > p:first-child {
color: var(--color-gray);
font-size: 1.1rem;
}
.input-entries:not(:has(div)) {
display: none;
}
.add-row {
height: 2rem;
width: 80%;
display: flex;
=======
.add-row {
width: min(100%, 21rem);
display: flex;
justify-content: center;
flex-wrap: wrap;
>>>>>>> Development
gap: 1rem;
}
.add-row input {
flex-grow: 1;
<<<<<<< HEAD
=======
height: 2rem;
min-width: 0rem;
>>>>>>> Development
font-size: .8rem;
}
.add-row button {
<<<<<<< HEAD
=======
height: 2rem;
>>>>>>> Development
padding: .35rem .75rem;
background-color: var(--color-gray);
border-radius: 4px;
@@ -440,12 +291,9 @@ tr:has(input:read-only) button[data-type="save"] {
height: inherit;
fill: var(--color-dark);
}
<<<<<<< HEAD
=======
@media (max-width: 543px) {
#service-list button {
flex-grow: 1;
}
}
>>>>>>> Development

View File

@@ -62,14 +62,10 @@ function logout() {
const default_values = {
'api_key': null,
'locale': 'en-GB',
<<<<<<< HEAD
'default_service': null
=======
'default_service': null,
'sorting_reminders': 'time',
'sorting_static': 'title',
'sorting_templates': 'title'
>>>>>>> Development
};
function setupLocalStorage() {
@@ -125,4 +121,4 @@ const url_prefix = document.getElementById('url_prefix').dataset.value;
const api_key = getLocalStorage('api_key')['api_key'];
if (api_key === null) {
window.location.href = `${url_prefix}/`;
};
};

View File

@@ -57,19 +57,6 @@ function getActiveTab() {
//
// Filling library
//
function getWeekDays(locale)
{
let baseDate = new Date(Date.UTC(2017, 0, 2)); // just a Monday
let weekDays = [];
for(i = 0; i < 7; i++)
{
weekDays.push(baseDate.toLocaleDateString(locale, { weekday: 'short' }));
baseDate.setDate(baseDate.getDate() + 1);
}
return weekDays;
};
const week_days = getWeekDays(getLocalStorage('locale')['locale']);
function fillTable(table, results) {
table.querySelectorAll('button.entry:not(.add-entry)').forEach(
e => e.remove()
@@ -103,11 +90,7 @@ function fillTable(table, results) {
formatted_date += interval_text;
} else if (r.weekdays !== null)
<<<<<<< HEAD
formatted_date += ` (each ${r.weekdays.split(',').map(d => week_days[parseInt(d)]).join(', ')})`;
=======
formatted_date += ` (each ${r.weekdays.map(d => week_days[d]).join(', ')})`;
>>>>>>> Development
time.innerText = formatted_date;
entry.appendChild(time);
@@ -198,4 +181,4 @@ LibEls.tab_selector.querySelectorAll('input').forEach(r => r.onchange = e => {
evaluateSizing();
LibEls.search_bar.input.value = '';
LibEls.search_bar.sort.value = getSorting(getActiveTab());
});
});

View File

@@ -110,123 +110,9 @@ function fillNotificationServices() {
return response.json();
})
.then(json => {
<<<<<<< HEAD
if (json.result.length) {
document.getElementById('add-reminder').classList.remove('error', 'error-icon');
const default_select = document.querySelector('#default-service-input');
default_select.innerHTML = '';
let default_service = getLocalStorage('default_service')['default_service'];
json.result.forEach(service => {
const entry = document.createElement('option');
entry.value = service.id;
entry.innerText = service.title;
if (default_service === service.id)
entry.setAttribute('selected', '');
default_select.appendChild(entry);
});
if (!document.querySelector(`#default-service-input > option[value="${default_service}"]`))
setLocalStorage({'default_service':
parseInt(document.querySelector('#default-service-input > option')?.value)
|| null
});
default_service = getLocalStorage('default_service')['default_service'];
inputs.notification_service.innerHTML = '';
json.result.forEach(service => {
const entry = document.createElement('div');
const select = document.createElement('input');
select.dataset.id = service.id;
select.type = 'checkbox';
entry.appendChild(select);
const title = document.createElement('p');
title.innerText = service.title;
entry.appendChild(title);
inputs.notification_service.appendChild(entry);
});
inputs.notification_service.querySelector(':first-child input').checked = true;
const table = document.getElementById('services-list');
table.innerHTML = '';
json.result.forEach(service => {
const entry = document.createElement('tr');
entry.dataset.id = service.id;
const title_container = document.createElement('td');
title_container.classList.add('title-column');
const title = document.createElement('input');
title.setAttribute('readonly', '');
title.setAttribute('type', 'text');
title.value = service.title;
title_container.appendChild(title);
entry.appendChild(title_container);
const url_container = document.createElement('td');
url_container.classList.add('url-column');
const url = document.createElement('input');
url.setAttribute('readonly', '');
url.setAttribute('type', 'text');
url.value = service.url;
url.addEventListener('keydown', e => {
if (e.key === 'Enter')
saveService(service.id);
});
url_container.appendChild(url);
entry.appendChild(url_container);
const actions = document.createElement('td');
actions.classList.add('action-column');
entry.appendChild(actions);
const edit_button = document.createElement('button');
edit_button.dataset.type = 'edit';
edit_button.addEventListener('click', e => editService(service.id));
edit_button.title = 'Edit';
edit_button.setAttribute('aria-label', 'Edit');
edit_button.innerHTML = icons.edit;
actions.appendChild(edit_button);
const save_button = document.createElement('button');
save_button.dataset.type = 'save';
save_button.addEventListener('click', e => saveService(service.id));
save_button.title = 'Save Edits';
save_button.setAttribute('aria-label', 'Save Edits');
save_button.innerHTML = icons.save;
actions.appendChild(save_button);
const delete_button = document.createElement('button');
delete_button.dataset.type = 'delete';
delete_button.addEventListener('click', e => deleteService(service.id));
delete_button.title = 'Delete';
delete_button.setAttribute('aria-label', 'Delete');
delete_button.innerHTML = icons.delete;
actions.appendChild(delete_button);
table.appendChild(entry);
});
} else {
document.getElementById('add-reminder').classList.add('error', 'error-icon');
inputs.notification_service.innerHTML = '';
const default_select = document.querySelector('#default-service-input');
default_select.innerHTML = '';
const default_service = getLocalStorage('default_service')['default_service'];
if (!document.querySelector(`#default-service-input > option[value="${default_service}"]`))
setLocalStorage({'default_service':
parseInt(document.querySelector('#default-service-input > option')?.value)
|| null
});
};
=======
fillNotificationTable(json);
fillNotificationSelection(json);
setNoNotificationServiceMsg(json);
>>>>>>> Development
})
.catch(e => {
if (e === 401)
@@ -277,18 +163,12 @@ function deleteService(id, delete_reminders_using=false) {
if (json.error !== null) return Promise.reject(json);
row.remove();
<<<<<<< HEAD
fillNotificationSelection();
if (document.querySelectorAll('#services-list > tr').length === 0)
document.getElementById('add-reminder').classList.add('error', 'error-icon');
=======
fillNotificationServices();
if (delete_reminders_using) {
fillLibrary(Types.reminder);
fillLibrary(Types.static_reminder);
fillLibrary(Types.template);
};
>>>>>>> Development
})
.catch(e => {
if (e.error === 'ApiKeyExpired' || e.error === 'ApiKeyInvalid')
@@ -308,80 +188,6 @@ function deleteService(id, delete_reminders_using=false) {
});
};
<<<<<<< HEAD
function testService() {
const test_button = document.querySelector('#test-service');
// Check regexes for input's
[...document.querySelectorAll('#add-service-window > input:not([data-regex=""])[data-regex]')]
.forEach(el => el.classList.remove('error-input'));
const faulty_inputs =
[...document.querySelectorAll('#add-service-window > input:not([data-regex=""])[data-regex]')]
.filter(el => !new RegExp
(
el.dataset.regex.split('').reverse().join('').split(',').slice(1).join(',').split('').reverse().join(''),
el.dataset.regex.split('').reverse().join('').split(',')[0]
).test(el.value)
);
if (faulty_inputs.length > 0) {
faulty_inputs.forEach(el => el.classList.add('error-input'));
return;
};
const data = {
'url': buildAppriseURL()
};
if (!data.url) {
test_button.classList.add('error-input');
test_button.title = 'Required field missing';
return;
};
fetch(`${url_prefix}/api/notificationservices/test?api_key=${api_key}`, {
'method': 'POST',
'headers': {'Content-Type': 'application/json'},
'body': JSON.stringify(data)
})
.then(response => {
if (!response.ok) return Promise.reject(response.status);
test_button.classList.remove('error-input');
test_button.title = '';
test_button.classList.add('show-sent');
})
.catch(e => {
if (e === 401)
window.location.href = `${url_prefix}/`;
else if (e === 400) {
test_button.classList.add('error-input');
test_button.title = 'Invalid Apprise URL';
} else
console.log(e);
});
};
function toggleAddService() {
const cont = document.querySelector('.overflow-container');
if (cont.classList.contains('show-add')) {
// Hide add
cont.classList.remove('show-add');
hideAddServiceWindow();
} else {
// Show add
if (notification_services === null) {
fetch(`${url_prefix}/api/notificationservices/available?api_key=${api_key}`)
.then(response => response.json())
.then(json => {
notification_services = json.result;
const table = document.querySelector('#service-list');
json.result.forEach((result, index) => {
const entry = document.createElement('button');
entry.innerText = result.name;
entry.addEventListener('click', e => showAddServiceWindow(index));
table.appendChild(entry);
});
});
=======
//
// Adding a service
//
@@ -504,7 +310,6 @@ function createEntriesList(token) {
e.preventDefault();
e.stopImmediatePropagation();
addEntry(entries_list);
>>>>>>> Development
};
};
add_row.appendChild(add_input);
@@ -543,137 +348,6 @@ function addEntry(entries_list) {
toggleAddRow(entries_list.querySelector('.add-row'));
};
function createTitle() {
const service_title = document.createElement('input');
service_title.id = 'service-title';
service_title.type = 'text';
service_title.placeholder = 'Service Title';
service_title.required = true;
return service_title;
};
function createChoice(token) {
const choice = document.createElement('select');
choice.dataset.map = token.map_to || '';
choice.dataset.prefix = '';
choice.placeholder = token.name;
choice.required = token.required;
token.options.forEach(option => {
const entry = document.createElement('option');
entry.value = option;
entry.innerText = option;
choice.appendChild(entry);
});
if (token.default)
choice.querySelector(`option[value="${token.default}"]`).setAttribute('selected', '');
return choice;
};
function createString(token) {
const str_input = document.createElement('input');
str_input.dataset.map = token.map_to || '';
str_input.dataset.prefix = token.prefix || '';
str_input.dataset.regex = token.regex || '';
str_input.type = 'text';
str_input.placeholder = `${token.name}${!token.required ? ' (Optional)' : ''}`;
str_input.required = token.required;
return str_input;
};
function createInt(token) {
const int_input = document.createElement('input');
int_input.dataset.map = token.map_to || '';
int_input.dataset.prefix = token.prefix || '';
int_input.type = 'number';
int_input.placeholder = `${token.name}${!token.required ? ' (Optional)' : ''}`;
int_input.required = token.required;
if (token.min !== null)
int_input.min = token.min;
if (token.max !== null)
int_input.max = token.max;
return int_input;
};
function createBool(token) {
const bool_input = document.createElement('select');
bool_input.dataset.map = token.map_to || '';
bool_input.dataset.prefix = '';
bool_input.placeholder = token.name;
bool_input.required = token.required;
[['Yes', 'true'], ['No', 'false']].forEach(option => {
const entry = document.createElement('option');
entry.value = option[1];
entry.innerText = option[0];
bool_input.appendChild(entry);
});
bool_input.querySelector(`option[value="${token.default}"]`).setAttribute('selected', '');
return bool_input;
};
function createEntriesList(token) {
const entries_list = document.createElement('div');
entries_list.classList.add('entries-list');
entries_list.dataset.map = token.map_to || '';
entries_list.dataset.delim = token.delim || '';
entries_list.dataset.prefix = token.prefix || '';
const entries_desc = document.createElement('p');
entries_desc.innerText = token.name;
entries_list.appendChild(entries_desc);
const entries = document.createElement('div');
entries.classList.add('input-entries');
entries_list.appendChild(entries);
const add_row = document.createElement('div');
add_row.classList.add('add-row', 'hidden');
const add_input = document.createElement('input');
add_input.type = 'text';
add_input.addEventListener('keydown', e => {
if (e.key === "Enter") {
e.preventDefault();
e.stopImmediatePropagation();
addEntry(entries_list);
};
});
add_row.appendChild(add_input);
const add_entry_button = document.createElement('button');
add_entry_button.type = 'button';
add_entry_button.innerText = 'Add';
add_entry_button.addEventListener('click', e => addEntry(entries_list));
add_row.appendChild(add_entry_button);
entries_list.appendChild(add_row);
const add_button = document.createElement('button');
add_button.type = 'button';
add_button.innerHTML = icons.add;
add_button.addEventListener('click', e => toggleAddRow(add_row));
entries_list.appendChild(add_button);
return entries_list;
};
function toggleAddRow(row) {
if (row.classList.contains('hidden')) {
// Show row
row.querySelector('input').value = '';
row.classList.remove('hidden');
} else {
// Hide row
row.classList.add('hidden');
};
};
function addEntry(entries_list) {
const value = entries_list.querySelector('.add-row > input').value;
const entry = document.createElement('div');
entry.innerText = value;
entries_list.querySelector('.input-entries').appendChild(entry);
toggleAddRow(entries_list.querySelector('.add-row'));
};
function showAddServiceWindow(index) {
const window = NotiEls.add_service_window;
window.innerHTML = '';
@@ -685,30 +359,6 @@ function showAddServiceWindow(index) {
const title = document.createElement('h3');
title.innerText = data.name;
window.appendChild(title);
<<<<<<< HEAD
const docs = document.createElement('a');
docs.href = data.doc_url;
docs.target = '_blank';
docs.innerText = 'Documentation';
window.appendChild(docs);
window.appendChild(createTitle());
[[data.details.tokens, 'tokens'], [data.details.args, 'args']].forEach(vars => {
if (vars[1] === 'args' && vars[0].length > 0) {
// The args are hidden behind a "Show Advanced Settings" button
const show_args = document.createElement('button');
show_args.type = 'button';
show_args.innerText = 'Show Advanced Settings';
show_args.addEventListener('click', e => {
window.querySelectorAll('[data-is_arg="true"]').forEach(el => el.classList.toggle('hidden'));
show_args.innerText = show_args.innerText === 'Show Advanced Settings' ? 'Hide Advanced Settings' : 'Show Advanced Settings';
});
window.appendChild(show_args);
};
=======
const docs = document.createElement('a');
docs.href = data.doc_url;
@@ -731,7 +381,6 @@ function showAddServiceWindow(index) {
window.appendChild(show_args);
};
>>>>>>> Development
vars[0].forEach(token => {
let result = null;
if (token.type === 'choice') {
@@ -776,13 +425,9 @@ function showAddServiceWindow(index) {
});
if (vars[1] === 'args' && vars[0].length > 0)
<<<<<<< HEAD
window.querySelectorAll('[data-is_arg="true"]').forEach(el => el.classList.toggle('hidden'));
=======
window.querySelectorAll('[data-is_arg="true"]').forEach(
el => el.classList.toggle('hidden')
);
>>>>>>> Development
})
// Bottom options
@@ -798,11 +443,7 @@ function showAddServiceWindow(index) {
const test = document.createElement('button');
test.id = 'test-service';
test.type = 'button';
<<<<<<< HEAD
test.addEventListener('click', e => testService());
=======
test.onclick = e => testService();
>>>>>>> Development
options.appendChild(test);
const test_text = document.createElement('div');
test_text.innerText = 'Test';
@@ -821,13 +462,8 @@ function showAddServiceWindow(index) {
};
function buildAppriseURL() {
<<<<<<< HEAD
const data = notification_services[document.querySelector('#add-service-window').dataset.index];
const inputs = document.querySelectorAll('#add-service-window > [data-map][data-is_arg="false"]');
=======
const data = notification_services[NotiEls.add_service_window.dataset.index];
const inputs = NotiEls.add_service_window.querySelectorAll('[data-map][data-is_arg="false"]');
>>>>>>> Development
const values = {};
// Gather all values and format
@@ -868,15 +504,9 @@ function buildAppriseURL() {
template = template.replace(`{${key}}`, value);
// Add args
<<<<<<< HEAD
const args = [...document.querySelectorAll('#add-service-window > [data-map][data-is_arg="true"]')]
.map(el => {
if (['INPUT', 'SELECT'].includes(el.nodeName) && el.value)
=======
const args = [...NotiEls.add_service_window.querySelectorAll('[data-map][data-is_arg="true"]')]
.map(el => {
if (['INPUT', 'SELECT'].includes(el.nodeName) && el.value && el.value !== el.dataset.default)
>>>>>>> Development
return `${el.dataset.map}=${el.value}`;
else if (el.nodeName == 'DIV') {
let value =
@@ -904,24 +534,6 @@ function buildAppriseURL() {
console.debug(template);
return template;
<<<<<<< HEAD
};
function addService() {
const add_button = document.querySelector('#add-service-window > .options > button[type="submit"]');
// Check regexes for input's
[...document.querySelectorAll('#add-service-window > input:not([data-regex=""])[data-regex]')]
.forEach(el => el.classList.remove('error-input'));
const faulty_inputs =
[...document.querySelectorAll('#add-service-window > input:not([data-regex=""])[data-regex]')]
.filter(el => !new RegExp
(
el.dataset.regex.split('').reverse().join('').split(',').slice(1).join(',').split('').reverse().join(''),
el.dataset.regex.split('').reverse().join('').split(',')[0]
).test(el.value)
=======
};
function testService() {
@@ -993,7 +605,6 @@ function addService() {
el.dataset.regex.split(',')[el.dataset.regex.split(',').length-1]
).test(el.value)
)
>>>>>>> Development
);
if (faulty_inputs.length > 0) {
faulty_inputs.forEach(el => el.classList.add('error-input'));
@@ -1041,10 +652,5 @@ fillNotificationServices();
let notification_services = null;
<<<<<<< HEAD
document.getElementById('add-service-button').addEventListener('click', e => toggleAddService());
document.getElementById('add-service-window').setAttribute('action', 'javascript:addService();');
=======
NotiEls.triggers.service_list.onchange = showServiceList;
NotiEls.add_service_window.action = 'javascript:addService();';
>>>>>>> Development
NotiEls.add_service_window.action = 'javascript:addService();';

View File

@@ -6,30 +6,19 @@ const SettingsEls = {
};
function loadSettings() {
<<<<<<< HEAD
document.getElementById('locale-input').value = getLocalStorage('locale')['locale'];
=======
// Default Service is handled by notification.fillNotificationSelection()
document.getElementById('locale-input').value =
getLocalStorage('locale')['locale'];
>>>>>>> Development
};
function updateLocale(e) {
setLocalStorage({'locale': e.target.value});
<<<<<<< HEAD
window.location.reload();
=======
fillLibrary(Types.reminder);
>>>>>>> Development
};
function updateDefaultService(e) {
setLocalStorage({'default_service': parseInt(e.target.value)});
<<<<<<< HEAD
=======
// Add window is handled by show.showAdd()
>>>>>>> Development
};
function changePassword() {
@@ -66,14 +55,7 @@ function deleteAccount() {
loadSettings();
<<<<<<< HEAD
document.getElementById('locale-input').addEventListener('change', updateLocale);
document.querySelector('#default-service-input').addEventListener('change', updateDefaultService);
document.getElementById('change-password-form').setAttribute('action', 'javascript:changePassword()');
document.getElementById('delete-account-button').addEventListener('click', e => deleteAccount());
=======
SettingsEls.locale_input.onchange = updateLocale;
SettingsEls.default_service_input.onchange = updateDefaultService;
SettingsEls.change_password_form.action = 'javascript:changePassword();';
SettingsEls.delete_account_button.onclick = e => deleteAccount();
>>>>>>> Development
SettingsEls.delete_account_button.onclick = e => deleteAccount();

View File

@@ -4,11 +4,6 @@ function showAdd(type) {
inputs.title.value = '';
inputs.text.value = '';
inputs.time.value = '';
<<<<<<< HEAD
inputs.notification_service.querySelectorAll('input[type="checkbox"]').forEach(c => c.checked = false);
inputs.notification_service.querySelector(`input[type="checkbox"][data-id="${default_service}"]`).checked = true;
document.querySelectorAll('.weekday-bar > input[type="checkbox"]').forEach(el => el.checked = false);
=======
inputs.notification_service.querySelectorAll('input[type="checkbox"]')
.forEach(c => c.checked = false);
inputs.notification_service.querySelector(
@@ -16,7 +11,6 @@ function showAdd(type) {
).checked = true;
document.querySelectorAll('.weekday-bar > input[type="checkbox"]')
.forEach(el => el.checked = false);
>>>>>>> Development
toggleNormal();
selectColor(colors[0]);
inputs.color_toggle.checked = false;
@@ -90,11 +84,7 @@ function showEdit(id, type) {
c => c.checked = json.result.notification_services.includes(parseInt(c.dataset.id))
);
<<<<<<< HEAD
if (type == types.reminder) {
=======
if (type == Types.reminder) {
>>>>>>> Development
if (json.result.repeat_interval !== null) {
toggleRepeated();
type_buttons.repeat_interval.value = json.result.repeat_interval;
@@ -141,4 +131,4 @@ function showEdit(id, type) {
test_text.innerText = 'Trigger';
} else
return;
};
};

View File

@@ -12,15 +12,6 @@ const inputs = {
};
const type_buttons = {
<<<<<<< HEAD
'normal_button': document.getElementById('normal-button'),
'repeat_button': document.getElementById('repeat-button'),
'weekday_button': document.getElementById('weekday-button'),
'repeat_bar': document.querySelector('.repeat-bar'),
'repeat_interval': document.getElementById('repeat-interval'),
'repeat_quantity': document.getElementById('repeat-quantity'),
=======
'normal_button': document.querySelector('#normal-button'),
'repeat_button': document.querySelector('#repeat-button'),
'weekday_button': document.querySelector('#weekday-button'),
@@ -28,7 +19,6 @@ const type_buttons = {
'repeat_bar': document.querySelector('.repeat-bar'),
'repeat_interval': document.querySelector('#repeat-interval'),
'repeat_quantity': document.querySelector('#repeat-quantity'),
>>>>>>> Development
'weekday_bar': document.querySelector('.weekday-bar')
};
@@ -71,12 +61,8 @@ function toggleNormal() {
type_buttons.repeat_interval.value = '';
type_buttons.weekday_bar.classList.add('hidden');
<<<<<<< HEAD
type_buttons.weekday_bar.querySelectorAll('input[type="checkbox"]').forEach(el => el.checked = false);
=======
type_buttons.weekday_bar.querySelectorAll('input[type="checkbox"]')
.forEach(el => el.checked = false);
>>>>>>> Development
};
function toggleRepeated() {
@@ -88,12 +74,8 @@ function toggleRepeated() {
type_buttons.repeat_interval.setAttribute('required', '');
type_buttons.weekday_bar.classList.add('hidden');
<<<<<<< HEAD
type_buttons.weekday_bar.querySelectorAll('input[type="checkbox"]').forEach(el => el.checked = false);
=======
type_buttons.weekday_bar.querySelectorAll('input[type="checkbox"]')
.forEach(el => el.checked = false);
>>>>>>> Development
};
function toggleWeekDay() {
@@ -347,20 +329,6 @@ function submitInfo() {
// code run on load
<<<<<<< HEAD
loadColor();
document.getElementById('template-selection').addEventListener('change', e => applyTemplate());
document.getElementById('color-toggle').addEventListener('click', e => toggleColor());
document.getElementById('toggle-notification-service-list').addEventListener('click', e => toggleNotificationService());
document.getElementById('normal-button').addEventListener('click', e => toggleNormal());
document.getElementById('repeat-button').addEventListener('click', e => toggleRepeated());
document.getElementById('weekday-button').addEventListener('click', e => toggleWeekDay());
document.getElementById('close-info').addEventListener('click', e => hideWindow());
document.getElementById('delete-info').addEventListener('click', e => deleteInfo());
document.getElementById('test-reminder').addEventListener('click', e => testReminder());
document.getElementById('info-form').setAttribute('action', 'javascript:submitInfo();');
=======
fillColors();
document.querySelector('#template-selection').onchange = e => applyTemplate();
@@ -370,5 +338,4 @@ document.querySelector('#weekday-button').onclick = e => toggleWeekDay();
document.querySelector('#close-info').onclick = e => showWindow("home");
document.querySelector('#delete-info').onclick = e => deleteInfo();
document.querySelector('#test-reminder').onclick = e => testReminder();
document.querySelector('#info-form').action = 'javascript:submitInfo();';
>>>>>>> Development
document.querySelector('#info-form').action = 'javascript:submitInfo();';

View File

@@ -217,90 +217,6 @@
</div>
</div>
<<<<<<< HEAD
<div id="info">
<h2></h2>
<div class="form-container">
<form id="info-form">
<div class="sub-inputs">
<select id="template-selection">
<option value="0" selected>No template</option>
</select>
<button type="button" id="color-toggle">Color</button>
</div>
<div class="color-list hidden"></div>
<input type="text" id="title-input" placeholder="Title" required>
<div class="sub-inputs">
<input type="datetime-local" id="time-input" required>
<button type="button" id="toggle-notification-service-list">Notification Services</button>
</div>
<div class="notification-service-list hidden"></div>
<div class="repeat-options sub-inputs">
<button type="button" id="normal-button" data-selected="true">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="256" height="256" x="0" y="0" viewBox="0 0 507.506 507.506" style="enable-background:new 0 0 512 512" xml:space="preserve">
<g>
<path d="M163.865 436.934a54.228 54.228 0 0 1-38.4-15.915L9.369 304.966c-12.492-12.496-12.492-32.752 0-45.248 12.496-12.492 32.752-12.492 45.248 0l109.248 109.248L452.889 79.942c12.496-12.492 32.752-12.492 45.248 0 12.492 12.496 12.492 32.752 0 45.248L202.265 421.019a54.228 54.228 0 0 1-38.4 15.915z"></path>
</g>
</svg>
Normal
</button>
<button type="button" id="repeat-button" data-selected="false">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="256" height="256" x="0" y="0" viewBox="0 0 507.506 507.506" style="enable-background:new 0 0 512 512" xml:space="preserve">
<g>
<path d="M163.865 436.934a54.228 54.228 0 0 1-38.4-15.915L9.369 304.966c-12.492-12.496-12.492-32.752 0-45.248 12.496-12.492 32.752-12.492 45.248 0l109.248 109.248L452.889 79.942c12.496-12.492 32.752-12.492 45.248 0 12.492 12.496 12.492 32.752 0 45.248L202.265 421.019a54.228 54.228 0 0 1-38.4 15.915z"></path>
</g>
</svg>
Repeated
</button>
<button type="button" id="weekday-button" data-selected="false">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="256" height="256" x="0" y="0" viewBox="0 0 507.506 507.506" style="enable-background:new 0 0 512 512" xml:space="preserve">
<g>
<path d="M163.865 436.934a54.228 54.228 0 0 1-38.4-15.915L9.369 304.966c-12.492-12.496-12.492-32.752 0-45.248 12.496-12.492 32.752-12.492 45.248 0l109.248 109.248L452.889 79.942c12.496-12.492 32.752-12.492 45.248 0 12.492 12.496 12.492 32.752 0 45.248L202.265 421.019a54.228 54.228 0 0 1-38.4 15.915z"></path>
</g>
</svg>
Week Days
</button>
</div>
<div class="repeat-bar hidden">
<p>Repeat every </p>
<input type="number" id="repeat-interval" placeholder="interval" min="1" step="1" oninput="validity.valid || (value='');">
<select id="repeat-quantity">
<option value="minutes">Minute(s)</option>
<option value="hours">Hour(s)</option>
<option value="days" selected>Day(s)</option>
<option value="weeks">Week(s)</option>
<option value="months">Month(s)</option>
<option value="years">Year(s)</option>
</select>
</div>
<div class="weekday-bar hidden">
<p>Mo</p>
<input type="checkbox">
<p>Tu</p>
<input type="checkbox">
<p>We</p>
<input type="checkbox">
<p>Tu</p>
<input type="checkbox">
<p>Fr</p>
<input type="checkbox">
<p>Sa</p>
<input type="checkbox">
<p>Su</p>
<input type="checkbox">
</div>
<textarea id="text-input" cols="30" rows="10" placeholder="Text (optional)"></textarea>
<div class="options">
<button type="button" id="close-info">Cancel</button>
<button type="button" id="test-reminder">
<div>Test</div>
<div>Sent</div>
</button>
<button type="button" id="delete-info">Delete</button>
<button type="submit">Add</button>
</div>
</form>
=======
<div class="extra-window-container">
<div id="info">
<h2></h2>
@@ -387,19 +303,9 @@
</div>
</form>
</div>
>>>>>>> Development
</div>
<<<<<<< HEAD
<div id="notification">
<h2>Notification Services</h2>
<p>Setup your notification providers here</p>
<div class="table-container">
<button id="add-service-button" title="Add notification service" aria-label="Add notification service">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="256" height="256" x="0" y="0" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512" xml:space="preserve">
<g>
=======
<div id="notification">
<h2>Notification Services</h2>
<p>Setup your notification providers here</p>
@@ -410,39 +316,11 @@
for="service-list-toggle"
>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="256" height="256" x="0" y="0" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512" xml:space="preserve">
>>>>>>> Development
<g>
<g>
<path d="M480,224H288V32c0-17.673-14.327-32-32-32s-32,14.327-32,32v192H32c-17.673,0-32,14.327-32,32s14.327,32,32,32h192v192 c0,17.673,14.327,32,32,32s32-14.327,32-32V288h192c17.673,0,32-14.327,32-32S497.673,224,480,224z"></path>
</g>
</g>
<<<<<<< HEAD
</g>
</svg>
</button>
<div class="overflow-container">
<table>
<thead>
<tr>
<th class="title-column">Title</th>
<th class="url-column">Apprise URL</th>
<th title="Actions" aria-label="Actions" class="action-column">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="256" height="256" x="0" y="0" viewBox="0 0 24 24" style="enable-background:new 0 0 512 512" xml:space="preserve">
<g>
<path d="M11.24,24a2.262,2.262,0,0,1-.948-.212,2.18,2.18,0,0,1-1.2-2.622L10.653,16H6.975A3,3,0,0,1,4.1,12.131l3.024-10A2.983,2.983,0,0,1,10,0h3.693a2.6,2.6,0,0,1,2.433,3.511L14.443,8H17a3,3,0,0,1,2.483,4.684l-6.4,10.3A2.2,2.2,0,0,1,11.24,24ZM10,2a1,1,0,0,0-.958.71l-3.024,10A1,1,0,0,0,6.975,14H12a1,1,0,0,1,.957,1.29L11.01,21.732a.183.183,0,0,0,.121.241A.188.188,0,0,0,11.4,21.9l6.4-10.3a1,1,0,0,0,.078-1.063A.979.979,0,0,0,17,10H13a1,1,0,0,1-.937-1.351l2.19-5.84A.6.6,0,0,0,13.693,2Z"></path>
</g>
</svg>
</th>
</tr>
</thead>
<tbody id="services-list">
</tbody>
</table>
<div id="add-service-container">
<div id="service-list">
</div>
<form id="add-service-window"></form>
=======
</svg>
</label>
<div class="overflow-container">
@@ -470,92 +348,11 @@
</div>
<form id="add-service-window"></form>
</div>
>>>>>>> Development
</div>
</div>
</div>
<<<<<<< HEAD
<div id="settings">
<h2>Settings</h2>
<div class="settings-container">
<h3>Locale</h3>
<select id="locale-input">
<option value="ar-SA">ar-SA</option>
<option value="bn-BD">bn-BD</option>
<option value="bn-IN">bn-IN</option>
<option value="cs-CZ">cs-CZ</option>
<option value="da-DK">da-DK</option>
<option value="de-AT">de-AT</option>
<option value="de-CH">de-CH</option>
<option value="de-DE">de-DE</option>
<option value="el-GR">el-GR</option>
<option value="en-AU">en-AU</option>
<option value="en-CA">en-CA</option>
<option value="en-GB" selected>en-GB</option>
<option value="en-IE">en-IE</option>
<option value="en-IN">en-IN</option>
<option value="en-NZ">en-NZ</option>
<option value="en-US">en-US</option>
<option value="en-ZA">en-ZA</option>
<option value="es-AR">es-AR</option>
<option value="es-CL">es-CL</option>
<option value="es-CO">es-CO</option>
<option value="es-ES">es-ES</option>
<option value="es-MX">es-MX</option>
<option value="es-US">es-US</option>
<option value="fi-FI">fi-FI</option>
<option value="fr-BE">fr-BE</option>
<option value="fr-CA">fr-CA</option>
<option value="fr-CH">fr-CH</option>
<option value="fr-FR">fr-FR</option>
<option value="he-IL">he-IL</option>
<option value="hi-IN">hi-IN</option>
<option value="hu-HU">hu-HU</option>
<option value="id-ID">id-ID</option>
<option value="it-CH">it-CH</option>
<option value="it-IT">it-IT</option>
<option value="ja-JP">ja-JP</option>
<option value="ko-KR">ko-KR</option>
<option value="nl-BE">nl-BE</option>
<option value="nl-NL">nl-NL</option>
<option value="no-NO">no-NO</option>
<option value="pl-PL">pl-PL</option>
<option value="pt-BR">pt-BR</option>
<option value="pt-PT">pt-PT</option>
<option value="ro-RO">ro-RO</option>
<option value="ru-RU">ru-RU</option>
<option value="sk-SK">sk-SK</option>
<option value="sv-SE">sv-SE</option>
<option value="ta-IN">ta-IN</option>
<option value="ta-LK">ta-LK</option>
<option value="th-TH">th-TH</option>
<option value="tr-TR">tr-TR</option>
<option value="zh-CN">zh-CN</option>
<option value="zh-HK">zh-HK</option>
<option value="zh-TW">zh-TW</option>
</select>
<h3>Default Notification Service</h3>
<select id="default-service-input"></select>
<h3>Change Password</h3>
<form id="change-password-form">
<input type="password" id="password-input" autocomplete="new-password" required>
<button type="submit">Change</button>
</form>
<h3>Delete Account</h3>
<button id="delete-account-button">Delete Account</button>
</div>
<h2>Contact and Donation</h2>
<div class="contact-list">
<a href="https://ko-fi.com/casvt">Donate to MIND</a>
<a href="https://casvt.github.io/MIND/">Documentation</a>
<a href="https://github.com/Casvt/MIND/issues">Report an issue</a>
<a href="https://discord.gg/nMNdgG7vsE">Discord server</a>
=======
<div id="settings">
<h2>Settings</h2>
<table id="settings-table">
@@ -644,7 +441,6 @@
<a href="https://github.com/Casvt/MIND/issues">Report an issue</a>
<a href="https://discord.gg/nMNdgG7vsE">Discord server</a>
</div>
>>>>>>> Development
</div>
</div>
</main>