Initial resources kit.

This commit is contained in:
James Cole
2023-07-11 11:45:55 +02:00
parent 27037c2fbb
commit b9cf8b3ef2
62 changed files with 32671 additions and 5563 deletions

View 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});
}
}

View 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
View 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();

View 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;

View 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

View 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,
}