mirror of
https://github.com/mue/mue.git
synced 2026-07-17 14:04:09 +02:00
feat: finish weather, add week number back, improve widget order and quick links
This commit is contained in:
@@ -3,7 +3,6 @@ import React from 'react';
|
||||
import DragHandleIcon from '@material-ui/icons/DragIndicator';
|
||||
|
||||
import { sortableContainer, sortableElement } from 'react-sortable-hoc';
|
||||
import arrayMove from 'array-move';
|
||||
import { toast } from 'react-toastify';
|
||||
|
||||
const SortableItem = sortableElement(({value}) => (
|
||||
@@ -26,9 +25,29 @@ export default class OrderSettings extends React.PureComponent {
|
||||
this.language = window.language.modals.main.settings;
|
||||
}
|
||||
|
||||
// based on https://stackoverflow.com/a/48301905
|
||||
arrayMove(array, oldIndex, newIndex) {
|
||||
if (oldIndex === newIndex) {
|
||||
return array;
|
||||
}
|
||||
|
||||
const newArray = [...array];
|
||||
|
||||
const target = newArray[oldIndex];
|
||||
const inc = newIndex < oldIndex ? -1 : 1;
|
||||
|
||||
for (let i = oldIndex; i !== newIndex; i += inc) {
|
||||
newArray[i] = newArray[i + inc];
|
||||
}
|
||||
|
||||
newArray[newIndex] = target;
|
||||
|
||||
return newArray;
|
||||
}
|
||||
|
||||
onSortEnd = ({oldIndex, newIndex}) => {
|
||||
this.setState(({items}) => ({
|
||||
items: arrayMove(items, oldIndex, newIndex)
|
||||
items: this.arrayMove(items, oldIndex, newIndex)
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ export default function QuickLinks() {
|
||||
<Switch name='quicklinksenabled' text={window.language.modals.main.settings.enabled} />
|
||||
<Checkbox name='quicklinksnewtab' text={language.open_new} />
|
||||
<Checkbox name='quicklinkstooltip' text={language.tooltip} />
|
||||
<Checkbox name='quicklinksnewtab' text={language.chrome_apps} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ export default class TimeSettings extends React.PureComponent {
|
||||
<option value='short'>{time.date.type.short}</option>
|
||||
</Dropdown>
|
||||
<br/>
|
||||
<Checkbox name='weeknumber' text={time.date.week_number}/>
|
||||
{dateSettings}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -13,12 +13,6 @@ export default class TimeSettings extends React.PureComponent {
|
||||
this.language = window.language.modals.main.settings;
|
||||
}
|
||||
|
||||
getLocation() {
|
||||
if (window.navigator.geolocation) {
|
||||
window.navigator.geolocation.getCurrentPosition(console.log, console.log);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
localStorage.setItem('location', this.state.location);
|
||||
}
|
||||
@@ -46,7 +40,7 @@ export default class TimeSettings extends React.PureComponent {
|
||||
<h2>{language.title}</h2>
|
||||
<Switch name='weatherEnabled' text={this.language.enabled} />
|
||||
<ul>
|
||||
<p>{language.location} <span className='modalLink' onClick={() => this.getLocation()}>{language.auto}</span></p>
|
||||
<p>{language.location}</p>
|
||||
<input type='text' value={this.state.location} onChange={(e) => this.setState({ location: e.target.value })}></input>
|
||||
</ul>
|
||||
<br/>
|
||||
|
||||
Reference in New Issue
Block a user