-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1622d10
commit b998472
Showing
20 changed files
with
559 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,9 @@ node_modules | |
pnpm-lock.yaml | ||
package-lock.json | ||
yarn.lock | ||
|
||
# Custom: | ||
/src-tauri | ||
/src/old_routes | ||
/old/ | ||
/.github/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,39 @@ | ||
import { DashboardDefinition, UrlAction } from '@orbitale/svelte-admin'; | ||
import Home from 'carbon-icons-svelte/lib/Home.svelte'; | ||
import PiggyBank from "carbon-icons-svelte/lib/PiggyBank.svelte"; | ||
import ChartLogisticRegression from "carbon-icons-svelte/lib/ChartLogisticRegression.svelte"; | ||
import ListBoxes from "carbon-icons-svelte/lib/ListBoxes.svelte"; | ||
import Tag from "carbon-icons-svelte/lib/Tag.svelte"; | ||
import TagGroup from "carbon-icons-svelte/lib/TagGroup.svelte"; | ||
import FetchUpload from "carbon-icons-svelte/lib/FetchUpload.svelte"; | ||
import ListCheckedMirror from "carbon-icons-svelte/lib/ListCheckedMirror.svelte"; | ||
import PiggyBank from 'carbon-icons-svelte/lib/PiggyBank.svelte'; | ||
import ChartLogisticRegression from 'carbon-icons-svelte/lib/ChartLogisticRegression.svelte'; | ||
import ListBoxes from 'carbon-icons-svelte/lib/ListBoxes.svelte'; | ||
import Tag from 'carbon-icons-svelte/lib/Tag.svelte'; | ||
import TagGroup from 'carbon-icons-svelte/lib/TagGroup.svelte'; | ||
import FetchUpload from 'carbon-icons-svelte/lib/FetchUpload.svelte'; | ||
import ListCheckedMirror from 'carbon-icons-svelte/lib/ListCheckedMirror.svelte'; | ||
|
||
import OperationCrud from '$lib/crud/cruds/OperationCrud'; | ||
import BankAccountsCrud from "$lib/crud/cruds/BankAccountsCrud"; | ||
import TagRulesCrud from "$lib/crud/cruds/TagRulesCrud"; | ||
import TagsCrud from "$lib/crud/cruds/TagsCrud"; | ||
import TriageCrud from "$lib/crud/cruds/TriageCrud"; | ||
import BankAccountsCrud from '$lib/crud/cruds/BankAccountsCrud'; | ||
import TagRulesCrud from '$lib/crud/cruds/TagRulesCrud'; | ||
import TagsCrud from '$lib/crud/cruds/TagsCrud'; | ||
import TriageCrud from '$lib/crud/cruds/TriageCrud'; | ||
|
||
export const dashboard = new DashboardDefinition({ | ||
adminConfig: { | ||
defaultLocale: 'en', | ||
rootUrl: '/crud/', | ||
head: { | ||
brandName: 'Compotes', | ||
appName: '' | ||
} | ||
}, | ||
adminConfig: { | ||
defaultLocale: 'en', | ||
rootUrl: '/crud/', | ||
head: { | ||
brandName: 'Compotes', | ||
appName: '' | ||
} | ||
}, | ||
|
||
sideMenu: [ | ||
new UrlAction('Homepage', '/', Home), | ||
// new UrlAction('Analytics', '/analytics', ChartLogisticRegression), | ||
new UrlAction('Operations', '/crud/operations/list', ListBoxes), | ||
new UrlAction('Tags', '/crud/tags/list', Tag), | ||
new UrlAction('Tag rules', '/crud/tag-rules/list', TagGroup), | ||
new UrlAction('Triage', '/crud/triage/list', ListCheckedMirror), | ||
new UrlAction('Bank accounts', '/crud/bank-accounts/list', PiggyBank), | ||
new UrlAction('Import', '/import', FetchUpload), | ||
], | ||
sideMenu: [ | ||
new UrlAction('Homepage', '/', Home), | ||
// new UrlAction('Analytics', '/analytics', ChartLogisticRegression), | ||
new UrlAction('Operations', '/crud/operations/list', ListBoxes), | ||
new UrlAction('Tags', '/crud/tags/list', Tag), | ||
new UrlAction('Tag rules', '/crud/tag-rules/list', TagGroup), | ||
new UrlAction('Triage', '/crud/triage/list', ListCheckedMirror), | ||
new UrlAction('Bank accounts', '/crud/bank-accounts/list', PiggyBank), | ||
new UrlAction('Import', '/import', FetchUpload) | ||
], | ||
|
||
cruds: [ | ||
OperationCrud, | ||
BankAccountsCrud, | ||
TagRulesCrud, | ||
TagsCrud, | ||
TriageCrud, | ||
] | ||
cruds: [OperationCrud, BankAccountsCrud, TagRulesCrud, TagsCrud, TriageCrud] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,95 @@ | ||
import { | ||
CallbackStateProcessor, | ||
CallbackStateProvider, | ||
CrudDefinition, Edit, | ||
List, | ||
TextField, | ||
UrlAction, | ||
type RequestParameters, | ||
type CrudOperation, | ||
type StateProcessorInput, | ||
} from "@orbitale/svelte-admin"; | ||
CallbackStateProcessor, | ||
CallbackStateProvider, | ||
CrudDefinition, | ||
Edit, | ||
List, | ||
TextField, | ||
UrlAction, | ||
type RequestParameters, | ||
type CrudOperation, | ||
type StateProcessorInput | ||
} from '@orbitale/svelte-admin'; | ||
|
||
import {createBankAccount, getBankAccountById, getBankAccounts, updateBankAccount} from "$lib/db/bank_accounts"; | ||
import type BankAccount from "$lib/entities/BankAccount"; | ||
import {goto} from "$app/navigation"; | ||
import {success} from "$lib/utils/message"; | ||
import { | ||
createBankAccount, | ||
getBankAccountById, | ||
getBankAccounts, | ||
updateBankAccount | ||
} from '$lib/db/bank_accounts'; | ||
import type BankAccount from '$lib/entities/BankAccount'; | ||
import { goto } from '$app/navigation'; | ||
import { success } from '$lib/utils/message'; | ||
|
||
const baseFields = [ | ||
new TextField('name', 'Name'), | ||
new TextField('slug', 'Identifier', {disabled: true}), | ||
new TextField('currency', 'Currency'), | ||
new TextField('name', 'Name'), | ||
new TextField('slug', 'Identifier', { disabled: true }), | ||
new TextField('currency', 'Currency') | ||
]; | ||
|
||
export default new CrudDefinition<BankAccount>({ | ||
name: 'bank-accounts', | ||
defaultOperationName: "list", | ||
label: {plural: "BankAccounts", singular: "BankAccount"}, | ||
// minStateLoadingTimeMs: 0, | ||
name: 'bank-accounts', | ||
defaultOperationName: 'list', | ||
label: { plural: 'BankAccounts', singular: 'BankAccount' }, | ||
// minStateLoadingTimeMs: 0, | ||
|
||
operations: [ | ||
new List([...baseFields], [new UrlAction('Edit', '/crud/bank-accounts/edit')]), | ||
new Edit(baseFields) | ||
], | ||
|
||
stateProvider: new CallbackStateProvider<BankAccount>( | ||
async (operation: CrudOperation, requestParameters: RequestParameters) => { | ||
if (typeof window === 'undefined') { | ||
// SSR, can't call Tauri API then. | ||
return Promise.resolve([]); | ||
} | ||
|
||
operations: [ | ||
new List([...baseFields], | ||
[ | ||
new UrlAction('Edit', '/crud/bank-accounts/edit'), | ||
]), | ||
new Edit(baseFields), | ||
], | ||
if (operation.name === 'list') { | ||
return getBankAccounts(); | ||
} | ||
|
||
stateProvider: new CallbackStateProvider<BankAccount>(async (operation: CrudOperation, requestParameters: RequestParameters) => { | ||
if (typeof window === 'undefined') { | ||
// SSR, can't call Tauri API then. | ||
return Promise.resolve([]); | ||
} | ||
if (operation.name === 'view' || operation.name === 'edit') { | ||
return getBankAccountById(Number(requestParameters.id)); | ||
} | ||
|
||
if (operation.name === 'list') { | ||
return getBankAccounts(); | ||
} | ||
return Promise.resolve(null); | ||
} | ||
), | ||
|
||
if (operation.name === 'view' || operation.name === 'edit') { | ||
return getBankAccountById(Number(requestParameters.id)); | ||
} | ||
stateProcessor: new CallbackStateProcessor<BankAccount>( | ||
async ( | ||
data: StateProcessorInput<BankAccount>, | ||
operation: CrudOperation, | ||
requestParameters: RequestParameters | ||
) => { | ||
if (operation.name === 'new') { | ||
if (!data) { | ||
throw new Error('Cannot create new object: empty data.'); | ||
} | ||
if (Array.isArray(data)) { | ||
throw new Error('Cannot update data as array for this action.'); | ||
} | ||
|
||
return Promise.resolve(null); | ||
}), | ||
return createBankAccount(data); | ||
} | ||
|
||
stateProcessor: new CallbackStateProcessor<BankAccount>(async (data: StateProcessorInput<BankAccount>, operation: CrudOperation, requestParameters: RequestParameters) => { | ||
if (operation.name === 'new') { | ||
return createBankAccount(data); | ||
} | ||
if (operation.name === 'edit') { | ||
if (!data) { | ||
throw new Error('Cannot create new object: empty data.'); | ||
} | ||
if (Array.isArray(data)) { | ||
throw new Error('Cannot update data as array for this action.'); | ||
} | ||
|
||
if (operation.name === 'edit') { | ||
data.id = Number(requestParameters.id); | ||
data.id = Number(requestParameters.id); | ||
|
||
await updateBankAccount(data); | ||
success('Success!'); | ||
await goto('/crud/bank-accounts/list'); | ||
await updateBankAccount(data); | ||
success('Success!'); | ||
await goto('/crud/bank-accounts/list'); | ||
|
||
return; | ||
} | ||
}) | ||
return; | ||
} | ||
} | ||
) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,91 @@ | ||
import { | ||
CallbackStateProcessor, | ||
CallbackStateProvider, | ||
CheckboxField, | ||
CrudDefinition, | ||
DateField, | ||
List, | ||
NumberField, | ||
PaginatedResults, | ||
TextField, | ||
UrlAction, | ||
View, | ||
type RequestParameters, | ||
type CrudOperation, | ||
type ListOperationOptions, | ||
KeyValueObjectField | ||
} from "@orbitale/svelte-admin"; | ||
CallbackStateProcessor, | ||
CallbackStateProvider, | ||
CheckboxField, | ||
CrudDefinition, | ||
DateField, | ||
List, | ||
NumberField, | ||
PaginatedResults, | ||
TextField, | ||
UrlAction, | ||
View, | ||
type RequestParameters, | ||
type CrudOperation, | ||
type ListOperationOptions, | ||
KeyValueObjectField | ||
} from '@orbitale/svelte-admin'; | ||
|
||
import {getOperationById, getOperations, getOperationsCount} from "$lib/db/operations"; | ||
import type Operation from "$lib/entities/Operation"; | ||
import { getOperationById, getOperations, getOperationsCount } from '$lib/db/operations'; | ||
import type Operation from '$lib/entities/Operation'; | ||
|
||
export default new CrudDefinition<Operation>({ | ||
name: 'operations', | ||
defaultOperationName: "list", | ||
label: {plural: "Operations", singular: "Operation"}, | ||
// minStateLoadingTimeMs: 0, | ||
name: 'operations', | ||
defaultOperationName: 'list', | ||
label: { plural: 'Operations', singular: 'Operation' }, | ||
// minStateLoadingTimeMs: 0, | ||
|
||
operations: [ | ||
new List( | ||
[ | ||
new DateField('operation_date', 'Date'), | ||
new TextField('op_type', 'Type 1'), | ||
new TextField('type_display', 'Type 2'), | ||
new TextField('details', 'Details'), | ||
new TextField('tags', 'Tags'), | ||
new NumberField('amount_display', 'Montant'), | ||
], | ||
[ | ||
new UrlAction('View', '/crud/operations/view'), | ||
], | ||
{ | ||
pagination: { | ||
enabled: true, | ||
itemsPerPage: 20, | ||
} | ||
}), | ||
new View([ | ||
new TextField('id', 'ID'), | ||
new DateField('operation_date', 'Date'), | ||
new TextField('op_type', 'Type 1'), | ||
new TextField('type_display', 'Type 2'), | ||
new TextField('details', 'Details'), | ||
new NumberField('amount_in_cents', 'Montant (in cents)'), | ||
new NumberField('amount', 'Montant'), | ||
new NumberField('hash', 'Hash'), | ||
new TextField('state', 'State'), | ||
new KeyValueObjectField('bank_account', 'Bank account', 'name'), | ||
new TextField('tags', 'Tags'), | ||
new CheckboxField('ignored_from_charts', 'Is ignored from charts'), | ||
]), | ||
], | ||
operations: [ | ||
new List( | ||
[ | ||
new DateField('operation_date', 'Date'), | ||
new TextField('op_type', 'Type 1'), | ||
new TextField('type_display', 'Type 2'), | ||
new TextField('details', 'Details'), | ||
new TextField('tags', 'Tags'), | ||
new NumberField('amount_display', 'Montant') | ||
], | ||
[new UrlAction('View', '/crud/operations/view')], | ||
{ | ||
pagination: { | ||
enabled: true, | ||
itemsPerPage: 20 | ||
} | ||
} | ||
), | ||
new View([ | ||
new TextField('id', 'ID'), | ||
new DateField('operation_date', 'Date'), | ||
new TextField('op_type', 'Type 1'), | ||
new TextField('type_display', 'Type 2'), | ||
new TextField('details', 'Details'), | ||
new NumberField('amount_in_cents', 'Montant (in cents)'), | ||
new NumberField('amount', 'Montant'), | ||
new NumberField('hash', 'Hash'), | ||
new TextField('state', 'State'), | ||
new KeyValueObjectField('bank_account', 'Bank account', 'name'), | ||
new TextField('tags', 'Tags'), | ||
new CheckboxField('ignored_from_charts', 'Is ignored from charts') | ||
]) | ||
], | ||
|
||
stateProvider: new CallbackStateProvider<Operation>(async (operation: CrudOperation, requestParameters: RequestParameters) => { | ||
if (typeof window === 'undefined') { | ||
// SSR, can't call Tauri API then. | ||
return Promise.resolve([]); | ||
} | ||
stateProvider: new CallbackStateProvider<Operation>( | ||
async (operation: CrudOperation, requestParameters: RequestParameters) => { | ||
if (typeof window === 'undefined') { | ||
// SSR, can't call Tauri API then. | ||
return Promise.resolve([]); | ||
} | ||
|
||
if (operation.name === 'list') { | ||
const options: ListOperationOptions = operation.options; | ||
const results = await getOperations(Number(requestParameters.page)||1); | ||
const numberOfItems = await getOperationsCount(null); | ||
return Promise.resolve(new PaginatedResults(Number(requestParameters.page), numberOfItems / Number(options.pagination?.itemsPerPage||10), numberOfItems, results)); | ||
} | ||
if (operation.name === 'list') { | ||
const options: ListOperationOptions = operation.options; | ||
const results = await getOperations(Number(requestParameters.page) || 1); | ||
const numberOfItems = await getOperationsCount(null); | ||
return Promise.resolve( | ||
new PaginatedResults( | ||
Number(requestParameters.page), | ||
numberOfItems / Number(options.pagination?.itemsPerPage || 10), | ||
numberOfItems, | ||
results | ||
) | ||
); | ||
} | ||
|
||
if (operation.name === 'view' || operation.name === 'edit') { | ||
return getOperationById(Number(requestParameters.id)); | ||
} | ||
if (operation.name === 'view' || operation.name === 'edit') { | ||
return getOperationById(Number(requestParameters.id)); | ||
} | ||
|
||
return Promise.resolve(null); | ||
}), | ||
stateProcessor: new CallbackStateProcessor<Operation>(() => {}) | ||
return Promise.resolve(null); | ||
} | ||
), | ||
stateProcessor: new CallbackStateProcessor<Operation>(() => {}) | ||
}); |
Oops, something went wrong.