mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Initial resources kit.
This commit is contained in:
31
resources/assets/v4/api/preferences/index.js
Normal file
31
resources/assets/v4/api/preferences/index.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* basic.js
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {api} from "boot/axios";
|
||||
|
||||
export default class Preferences {
|
||||
getByName(name) {
|
||||
return api.get('/api/v1/preferences/' + name);
|
||||
}
|
||||
|
||||
postByName(name, value) {
|
||||
return api.post('/api/v1/preferences', {name: name, data: value});
|
||||
}
|
||||
}
|
||||
15
resources/assets/v4/app.js
Normal file
15
resources/assets/v4/app.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import './bootstrap';
|
||||
//import {onDOMContentLoaded} from "./util/index.js";
|
||||
|
||||
|
||||
|
||||
|
||||
//alert('hallo');
|
||||
|
||||
|
||||
// onDOMContentLoaded(() => {
|
||||
// //alert('OK dan!');
|
||||
// })
|
||||
|
||||
|
||||
//alert('OK dan 2!');
|
||||
45
resources/assets/v4/bootstrap.js
vendored
Normal file
45
resources/assets/v4/bootstrap.js
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* We'll load the axios HTTP library which allows us to easily issue requests
|
||||
* to our Laravel back-end. This library automatically handles sending the
|
||||
* CSRF token as a header based on the value of the "XSRF" token cookie.
|
||||
*/
|
||||
|
||||
import axios from 'axios';
|
||||
import Alpine from 'alpinejs';
|
||||
import BasicStore from './store/Basic';
|
||||
|
||||
window.axios = axios;
|
||||
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||
|
||||
/**
|
||||
* Echo exposes an expressive API for subscribing to channels and listening
|
||||
* for events that are broadcast by Laravel. Echo and event broadcasting
|
||||
* allows your team to easily build robust real-time web applications.
|
||||
*/
|
||||
|
||||
// import Echo from 'laravel-echo';
|
||||
|
||||
// import Pusher from 'pusher-js';
|
||||
// window.Pusher = Pusher;
|
||||
|
||||
// window.Echo = new Echo({
|
||||
// broadcaster: 'pusher',
|
||||
// key: import.meta.env.VITE_PUSHER_APP_KEY,
|
||||
// cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1',
|
||||
// wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`,
|
||||
// wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
|
||||
// wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
|
||||
// forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
|
||||
// enabledTransports: ['ws', 'wss'],
|
||||
// });
|
||||
|
||||
|
||||
|
||||
window.Alpine = Alpine
|
||||
|
||||
Alpine.start()
|
||||
|
||||
|
||||
window.BasicStore = new BasicStore;
|
||||
|
||||
window.BasicStore.init();
|
||||
42
resources/assets/v4/store/Basic.js
Normal file
42
resources/assets/v4/store/Basic.js
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
|
||||
// basic store for preferred date range and some other vars.
|
||||
// used in layout.
|
||||
class Basic {
|
||||
viewRange = '1M';
|
||||
darkMode = 'browser';
|
||||
listPageSize = 10;
|
||||
locale = 'en-US';
|
||||
range = {
|
||||
start: null, end: null
|
||||
};
|
||||
currencyCode = 'AAA';
|
||||
currencyId = '0';
|
||||
constructor() {
|
||||
}
|
||||
|
||||
init() {
|
||||
console.log('init');
|
||||
// load variables from window if present
|
||||
this.loadVariable('viewRange')
|
||||
}
|
||||
|
||||
loadVariable(name) {
|
||||
console.log('loadVariable(' + name + ')');
|
||||
if(window.hasOwnProperty(name)) {
|
||||
console.log('from windows');
|
||||
this[name] = window[name];
|
||||
return;
|
||||
}
|
||||
// load from local storage
|
||||
if(window.Alpine.store(name)) {
|
||||
console.log('from alpine');
|
||||
this[name] = window.Alpine.store(name);
|
||||
return;
|
||||
}
|
||||
// grab using axios
|
||||
console.log('axios');
|
||||
}
|
||||
}
|
||||
|
||||
export default Basic;
|
||||
22
resources/assets/v4/support/daterange.js
Normal file
22
resources/assets/v4/support/daterange.js
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
|
||||
|
||||
|
||||
class DateRange {
|
||||
start=null;
|
||||
end = null;
|
||||
constructor() {
|
||||
this.start = null
|
||||
this.end = null
|
||||
}
|
||||
|
||||
setStart(start) {
|
||||
this.start = start
|
||||
}
|
||||
|
||||
setEnd(end) {
|
||||
this.end = end
|
||||
}
|
||||
}
|
||||
|
||||
export default DateRange
|
||||
24
resources/assets/v4/util/index.js
Normal file
24
resources/assets/v4/util/index.js
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
const domContentLoadedCallbacks = [];
|
||||
// from admin LTE
|
||||
const onDOMContentLoaded = (callback) => {
|
||||
if (document.readyState === 'loading') {
|
||||
// add listener on the first call when the document is in loading state
|
||||
if (!domContentLoadedCallbacks.length) {
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
for (const callback of domContentLoadedCallbacks) {
|
||||
callback()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
domContentLoadedCallbacks.push(callback)
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export {
|
||||
onDOMContentLoaded,
|
||||
}
|
||||
Reference in New Issue
Block a user