feat: add new docs and groups
This commit is contained in:
parent
3fafbcc1d6
commit
595d07bf50
BIN
build/bin/textualize.app/Contents/MacOS/Textualize
Executable file
BIN
build/bin/textualize.app/Contents/MacOS/Textualize
Executable file
Binary file not shown.
23
core/App/app.go
Normal file
23
core/App/app.go
Normal file
@ -0,0 +1,23 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
var instance *App
|
||||
|
||||
func GetInstance() *App {
|
||||
if instance == nil {
|
||||
instance = &App{}
|
||||
}
|
||||
|
||||
return instance
|
||||
}
|
||||
|
||||
func (a *App) Startup(ctx context.Context) {
|
||||
a.Context = ctx
|
||||
}
|
||||
@ -3,9 +3,6 @@ package document
|
||||
func InitizeModule() {
|
||||
GetDocumentCollection()
|
||||
GetDocumentGroupCollection()
|
||||
|
||||
// TODO: remove when UI allows adding docs
|
||||
createTestData()
|
||||
}
|
||||
|
||||
func createTestData() {
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
'use client'
|
||||
|
||||
import React, { Fragment, useEffect, useState } from 'react'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import React, { Fragment, useRef, useState } from 'react'
|
||||
import { Menu, Transition } from '@headlessui/react'
|
||||
import { BellIcon } from '@heroicons/react/24/outline'
|
||||
import { MagnifyingGlassIcon } from '@heroicons/react/20/solid'
|
||||
import { GetDocuments } from '../../wailsjs/wailsjs/go/ipc/Channel'
|
||||
import { MagnifyingGlassIcon, PlusIcon, XMarkIcon } from '@heroicons/react/20/solid'
|
||||
import { GetDocuments, RequestAddDocument, RequestAddDocumentGroup } from '../../wailsjs/wailsjs/go/ipc/Channel'
|
||||
import { LogPrint } from '../../wailsjs/wailsjs/runtime/runtime'
|
||||
import { ipc } from '../../wailsjs/wailsjs/go/models'
|
||||
|
||||
@ -15,74 +14,71 @@ type NavigationItem = {
|
||||
children: { id: string, name: string }[]
|
||||
}
|
||||
|
||||
// const navigation: NavigationItem[] = [
|
||||
// {
|
||||
// id: uuidv4(),
|
||||
// name: 'Chapter One',
|
||||
// children: [
|
||||
// { name: 'Overview', id: uuidv4() },
|
||||
// { name: 'Members', id: uuidv4() },
|
||||
// { name: 'Calendar', id: uuidv4() },
|
||||
// { name: 'Settings', id: uuidv4() },
|
||||
// ],
|
||||
// },
|
||||
// ]
|
||||
|
||||
const userNavigation = [
|
||||
{ name: 'Your Profile' },
|
||||
{ name: 'Settings' },
|
||||
{ name: 'Sign out' },
|
||||
]
|
||||
|
||||
const getNavigationProps = (
|
||||
documents: ipc.Document[],
|
||||
documentGroups: ipc.DocumentGroup[]): NavigationItem[] => {
|
||||
const groupsWithDocuments = documentGroups.map(g => {
|
||||
const childrenDocuments = documents
|
||||
.filter(d => d.groupId === g.id)
|
||||
.map(d => ({ id: d.id, name: d.name }))
|
||||
const getNavigationProps = (documentsAndGroups: ipc.GetDocumentsResponse): NavigationItem[] => {
|
||||
const { documents, documentGroups } = documentsAndGroups
|
||||
|
||||
return {
|
||||
id: g.id,
|
||||
name: g.name,
|
||||
children: childrenDocuments
|
||||
}
|
||||
})
|
||||
|
||||
const documentsWithoutGroup = documents
|
||||
.filter(d => !d.groupId)
|
||||
const groupsWithDocuments = documentGroups.map(g => {
|
||||
const childrenDocuments = documents
|
||||
.filter(d => d.groupId === g.id)
|
||||
.map(d => ({ id: d.id, name: d.name }))
|
||||
|
||||
return [
|
||||
...groupsWithDocuments,
|
||||
{
|
||||
id: 'Uncategorized',
|
||||
name: 'Uncategorized',
|
||||
children: documentsWithoutGroup
|
||||
}
|
||||
]
|
||||
return {
|
||||
id: g.id,
|
||||
name: g.name,
|
||||
children: childrenDocuments
|
||||
}
|
||||
})
|
||||
|
||||
const documentsWithoutGroup = documents
|
||||
.filter(d => !d.groupId || d.groupId === 'Uncategorized')
|
||||
.map(d => ({ id: d.id, name: d.name }))
|
||||
|
||||
return [
|
||||
...groupsWithDocuments,
|
||||
{
|
||||
id: 'Uncategorized',
|
||||
name: 'Uncategorized',
|
||||
children: documentsWithoutGroup
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const initDocumentsAndGroups = new ipc.GetDocumentsResponse({ documents: [], documentGroups: [] })
|
||||
|
||||
function classNames(...classes: any[]) {
|
||||
return classes.filter(Boolean).join(' ')
|
||||
}
|
||||
|
||||
function WorkspaceNavigation () {
|
||||
function WorkspaceNavigation() {
|
||||
const [selectedItemId, setSelectedItemId] = useState('')
|
||||
const [selectedGroupId, setSelectedGroupId] = useState('')
|
||||
const [documents, setDocuments] = useState([] as ipc.Document[])
|
||||
const [documentGroups, setDocumentGroups] = useState([] as ipc.DocumentGroup[])
|
||||
const [navigation, setNavigation] = useState([] as NavigationItem[])
|
||||
const [isAddNewDocumentInputShowing, setIsAddNewDocumentInputShowing] = useState(false)
|
||||
const [isAddNewGroupInputShowing, setIsAddNewGroupInputShowing] = useState(false)
|
||||
const [documentsAndGroups, setDocumentsAndGroups] = useState(initDocumentsAndGroups)
|
||||
const addDocumentTextInput = useRef<HTMLInputElement>(null)
|
||||
const addGroupTextInput = useRef<HTMLInputElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
setNavigation(getNavigationProps(documents, documentGroups))
|
||||
}, [documents, documentGroups])
|
||||
|
||||
GetDocuments().then(response => {
|
||||
LogPrint(JSON.stringify(response, null, 2))
|
||||
if (!documents.length) setDocuments(response.documents)
|
||||
if (!documentGroups.length) setDocumentGroups(response.documentGroups)
|
||||
})
|
||||
const navigation = getNavigationProps(documentsAndGroups)
|
||||
|
||||
const updateDocuments = async () => {
|
||||
GetDocuments().then(response => {
|
||||
LogPrint(JSON.stringify(response, null, 2))
|
||||
setDocumentsAndGroups(response)
|
||||
Promise.resolve(response)
|
||||
})
|
||||
}
|
||||
|
||||
if (!documentsAndGroups.documents.length
|
||||
|| !documentsAndGroups.documentGroups.length) {
|
||||
updateDocuments()
|
||||
}
|
||||
|
||||
|
||||
const getParentGroupIdFromItemId = (itemId: string) => {
|
||||
@ -94,69 +90,180 @@ function WorkspaceNavigation () {
|
||||
return parentGroupId
|
||||
}
|
||||
|
||||
const onAddNewDocumentLineItemClickHandler = (groupId: string) => {
|
||||
setSelectedGroupId(groupId)
|
||||
setIsAddNewDocumentInputShowing(true)
|
||||
setIsAddNewGroupInputShowing(false)
|
||||
}
|
||||
|
||||
const onAddNewGroupLineItemClickHandler = () => {
|
||||
setIsAddNewGroupInputShowing(true)
|
||||
setIsAddNewDocumentInputShowing(false)
|
||||
}
|
||||
|
||||
const onItemClickHandler = (itemId: string) => {
|
||||
setSelectedItemId(itemId)
|
||||
setSelectedGroupId(getParentGroupIdFromItemId(itemId))
|
||||
setIsAddNewDocumentInputShowing(false)
|
||||
setIsAddNewGroupInputShowing(false)
|
||||
}
|
||||
|
||||
const onCancelAddGroupClickHandler = () => {
|
||||
setIsAddNewGroupInputShowing(false)
|
||||
}
|
||||
|
||||
const onCancelAddItemClickHandler = () => {
|
||||
setIsAddNewDocumentInputShowing(false)
|
||||
}
|
||||
|
||||
const onConfirmAddDocumentClickHandler = async (groupId: string) => {
|
||||
const documentName = addDocumentTextInput.current?.value
|
||||
if (!documentName) return
|
||||
|
||||
const response = await RequestAddDocument(groupId, documentName)
|
||||
if (!response.id) return
|
||||
|
||||
let newDocumentsAndGroups = new ipc.GetDocumentsResponse(documentsAndGroups)
|
||||
newDocumentsAndGroups.documents.push(response)
|
||||
setDocumentsAndGroups(newDocumentsAndGroups)
|
||||
setSelectedItemId(response.id)
|
||||
setSelectedGroupId(groupId)
|
||||
setIsAddNewDocumentInputShowing(false)
|
||||
}
|
||||
|
||||
const onConfirmAddGroupClickHandler = async(e: React.MouseEvent) => {
|
||||
const groupName = addGroupTextInput.current?.value
|
||||
if (!groupName) return
|
||||
|
||||
const response = await RequestAddDocumentGroup(groupName)
|
||||
if (!response.id) return
|
||||
|
||||
let newDocumentsAndGroups = new ipc.GetDocumentsResponse(documentsAndGroups)
|
||||
newDocumentsAndGroups.documentGroups.push(response)
|
||||
setDocumentsAndGroups(newDocumentsAndGroups)
|
||||
setSelectedGroupId(response.id)
|
||||
setIsAddNewGroupInputShowing(false)
|
||||
}
|
||||
|
||||
const renderAddGroupInput = () => {
|
||||
return isAddNewGroupInputShowing
|
||||
? <div className="mt-1 flex rounded-md shadow-sm">
|
||||
<div className="relative flex flex-grow items-stretch focus-within:z-10 text-lg">
|
||||
<input
|
||||
type="text"
|
||||
name="groupName"
|
||||
id="groupName"
|
||||
className="text-white placeholder-gray-400 bg-gray-900 bg-opacity-5 block w-full rounded-none rounded-l-md border-late-700 focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
|
||||
placeholder="Add Group"
|
||||
ref={addGroupTextInput}
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onCancelAddGroupClickHandler}
|
||||
className="bg-gray-900 bg-opacity-5 relative -ml-px inline-flex items-center space-x-2 border border-gray-400 px-1 py-0 text-sm font-medium text-gray-100 hover:text-gray-900 hover:bg-gray-100 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500"
|
||||
>
|
||||
<XMarkIcon className="h-4 w-5" aria-hidden="true" />
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={onConfirmAddGroupClickHandler}
|
||||
className="bg-gray-900 bg-opacity-5 relative -ml-px inline-flex items-center space-x-2 border border-gray-400 px-1 py-0 text-sm font-medium text-gray-100 hover:text-gray-900 hover:bg-gray-100 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500"
|
||||
>
|
||||
<PlusIcon className="h-4 w-5" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
: <a
|
||||
role='button'
|
||||
className={classNames(
|
||||
'text-gray-300 hover:bg-gray-700 hover:text-white',
|
||||
' group w-full flex items-center pr-2 py-2 text-left font-medium',
|
||||
'text-sm rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 p-2'
|
||||
)}
|
||||
onClick={onAddNewGroupLineItemClickHandler}
|
||||
>
|
||||
<PlusIcon className="h-5 w-4" aria-hidden="true" />
|
||||
Add Group
|
||||
</a>
|
||||
}
|
||||
|
||||
const renderAddNewDocument = (groupId: string) => {
|
||||
return isAddNewDocumentInputShowing && selectedGroupId === groupId
|
||||
? <div className="flex rounded-md shadow-sm">
|
||||
<div className="relative flex flex-grow items-stretch focus-within:z-10 text-lg">
|
||||
<input
|
||||
type="text"
|
||||
name="documentName"
|
||||
id="documentName"
|
||||
className="text-white placeholder-gray-400 bg-gray-900 bg-opacity-5 block w-full rounded-none rounded-l-md border-late-700 focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
|
||||
placeholder="Add Document"
|
||||
ref={addDocumentTextInput}
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onCancelAddItemClickHandler}
|
||||
className="bg-gray-900 bg-opacity-5 relative -ml-px inline-flex items-center space-x-2 border border-gray-400 px-1 py-0 text-sm font-medium text-gray-100 hover:text-gray-900 hover:bg-gray-100 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500"
|
||||
>
|
||||
<XMarkIcon className="h-4 w-5" aria-hidden="true" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onConfirmAddDocumentClickHandler(groupId)}
|
||||
className="bg-gray-900 bg-opacity-5 relative -ml-px inline-flex items-center space-x-2 rounded-r-md border border-gray-400 px-1 py-0 text-sm font-medium text-gray-100 hover:text-gray-900 hover:bg-gray-100 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500"
|
||||
>
|
||||
<PlusIcon className="h-7 w-5" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
: <a
|
||||
role='button'
|
||||
className={classNames(
|
||||
'text-gray-300 hover:bg-gray-700 hover:text-white',
|
||||
' group w-full flex items-center pr-2 py-2 text-left font-medium',
|
||||
'text-sm rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 p-2'
|
||||
)}
|
||||
onClick={() => onAddNewDocumentLineItemClickHandler(groupId)}
|
||||
>
|
||||
<PlusIcon className="h-3 w-4" aria-hidden="true" />
|
||||
Add Document
|
||||
</a>
|
||||
}
|
||||
|
||||
const renderNavigationItems = () => (
|
||||
<nav className="flex-1 space-y-1 px-2 py-4" aria-label='Sidebar'>
|
||||
<div>
|
||||
<a
|
||||
role='button'
|
||||
onClick={() => console.log('Add Group')}
|
||||
className={classNames(
|
||||
'text-gray-300 hover:bg-gray-700 hover:text-white',
|
||||
'group flex items-center px-2 py-2 text-base font-medium rounded-md'
|
||||
)}
|
||||
>
|
||||
Add New Group
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{renderAddGroupInput()}
|
||||
|
||||
{navigation.map((item) =>
|
||||
<details key={item.name} open={item.id === selectedGroupId}>
|
||||
<summary className={classNames(
|
||||
item.id === selectedGroupId
|
||||
? 'bg-gray-900 text-white'
|
||||
: 'text-gray-300 hover:bg-gray-700 hover:text-white',
|
||||
'group items-center px-2 py-2 text-base font-medium rounded-md'
|
||||
)}>
|
||||
<a role='button'>
|
||||
{item.name}
|
||||
</a>
|
||||
item.id === selectedGroupId
|
||||
? 'bg-gray-900 text-white'
|
||||
: 'text-gray-300 hover:bg-gray-700 hover:text-white',
|
||||
'group items-center px-2 py-2 text-base font-medium rounded-md'
|
||||
)}>
|
||||
<a role='button'>{item.name}</a>
|
||||
</summary>
|
||||
<ul>
|
||||
{item.children.map(child => (
|
||||
<li key={child.id}>
|
||||
<a
|
||||
role='button'
|
||||
className={classNames(
|
||||
child.id === selectedItemId
|
||||
? 'bg-gray-900 text-white'
|
||||
: 'text-gray-300 hover:bg-gray-700 hover:text-white',
|
||||
'group w-full flex items-center pr-2 py-2 text-left font-medium text-sm rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 p-2'
|
||||
)}
|
||||
onClick={() => onItemClickHandler(child.id)}
|
||||
role='button'
|
||||
onClick={() => onItemClickHandler(child.id)}
|
||||
className={classNames(
|
||||
child.id === selectedItemId
|
||||
? 'bg-gray-900 text-white'
|
||||
: 'text-gray-300 hover:bg-gray-700 hover:text-white',
|
||||
'group w-full flex items-center pr-2 py-2 text-left font-medium text-sm rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 p-2'
|
||||
)}
|
||||
>
|
||||
{ child.name }
|
||||
{child.name}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
|
||||
<li>
|
||||
<a
|
||||
role='button'
|
||||
className={classNames(
|
||||
'text-gray-300 hover:bg-gray-700 hover:text-white',
|
||||
' group w-full flex items-center pr-2 py-2 text-left font-medium',
|
||||
'text-sm rounded-md focus:outline-none focus:ring-2 focus:ring-indigo-500 p-2'
|
||||
)}
|
||||
onClick={() => console.log('Add New Item')}
|
||||
>
|
||||
Add New Document
|
||||
</a>
|
||||
</li>
|
||||
{renderAddNewDocument(item.id)}
|
||||
</ul>
|
||||
</details>
|
||||
)}
|
||||
@ -166,7 +273,7 @@ function WorkspaceNavigation () {
|
||||
return (
|
||||
<>
|
||||
<div className="hidden md:fixed md:inset-y-0 md:flex md:w-64 md:flex-col">
|
||||
{/* Sidebar component, swap this element with another sidebar if you like */}
|
||||
{/* Sidebar component */}
|
||||
<div className="flex min-h-0 flex-1 flex-col bg-gray-800 bg-opacity-25">
|
||||
<div className="flex h-16 flex-shrink-0 items-center bg-gray-900 px-4 bg-opacity-25">
|
||||
<img
|
||||
|
||||
4
frontend/wailsjs/wailsjs/go/ipc/Channel.d.ts
vendored
4
frontend/wailsjs/wailsjs/go/ipc/Channel.d.ts
vendored
@ -3,3 +3,7 @@
|
||||
import {ipc} from '../models';
|
||||
|
||||
export function GetDocuments():Promise<ipc.GetDocumentsResponse>;
|
||||
|
||||
export function RequestAddDocument(arg1:string,arg2:string):Promise<ipc.Document>;
|
||||
|
||||
export function RequestAddDocumentGroup(arg1:string):Promise<ipc.DocumentGroup>;
|
||||
|
||||
@ -5,3 +5,11 @@
|
||||
export function GetDocuments() {
|
||||
return window['go']['ipc']['Channel']['GetDocuments']();
|
||||
}
|
||||
|
||||
export function RequestAddDocument(arg1, arg2) {
|
||||
return window['go']['ipc']['Channel']['RequestAddDocument'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function RequestAddDocumentGroup(arg1) {
|
||||
return window['go']['ipc']['Channel']['RequestAddDocumentGroup'](arg1);
|
||||
}
|
||||
|
||||
32
go.mod
32
go.mod
@ -2,33 +2,35 @@ module textualize
|
||||
|
||||
go 1.18
|
||||
|
||||
// replace github.com/wailsapp/wails/v2 v2.0.0-beta.38 => /Users/joshuashoemaker/go/pkg/mod/github.com/wailsapp/wails/v2@v2.0.0-beta.38
|
||||
// replace github.com/wailsapp/wails/v2 v2.0.0-beta.38 => /Users/yeho/go/pkg/mod/github.com/wailsapp/wails/v2@v2.0.0-beta.38
|
||||
|
||||
require github.com/wailsapp/wails/v2 v2.2.0
|
||||
require (
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/wailsapp/wails/v2 v2.2.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bep/debounce v1.2.1 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/google/uuid v1.1.2 // indirect
|
||||
github.com/imdario/mergo v0.3.12 // indirect
|
||||
github.com/imdario/mergo v0.3.13 // indirect
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
|
||||
github.com/labstack/echo/v4 v4.9.0 // indirect
|
||||
github.com/labstack/gommon v0.3.1 // indirect
|
||||
github.com/labstack/gommon v0.4.0 // indirect
|
||||
github.com/leaanthony/go-ansi-parser v1.0.1 // indirect
|
||||
github.com/leaanthony/gosod v1.0.3 // indirect
|
||||
github.com/leaanthony/slicer v1.5.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.11 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 // indirect
|
||||
github.com/leaanthony/slicer v1.6.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/samber/lo v1.27.1 // indirect
|
||||
github.com/samber/lo v1.36.0 // indirect
|
||||
github.com/tkrajina/go-reflector v0.5.5 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.1 // indirect
|
||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
|
||||
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/crypto v0.4.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20221207211629-99ab8fa1c11f // indirect
|
||||
golang.org/x/net v0.4.0 // indirect
|
||||
golang.org/x/sys v0.3.0 // indirect
|
||||
golang.org/x/text v0.5.0 // indirect
|
||||
)
|
||||
|
||||
55
go.sum
55
go.sum
@ -5,41 +5,44 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
|
||||
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
|
||||
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
|
||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
|
||||
github.com/labstack/echo/v4 v4.9.0 h1:wPOF1CE6gvt/kmbMR4dGzWvHMPT+sAEUJOwOTtvITVY=
|
||||
github.com/labstack/echo/v4 v4.9.0/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks=
|
||||
github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o=
|
||||
github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
|
||||
github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8=
|
||||
github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
|
||||
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
|
||||
github.com/leaanthony/debme v1.2.1/go.mod h1:3V+sCm5tYAgQymvSOfYQ5Xx2JCr+OXiD9Jkw3otUjiA=
|
||||
github.com/leaanthony/go-ansi-parser v1.0.1 h1:97v6c5kYppVsbScf4r/VZdXyQ21KQIfeQOk2DgKxGG4=
|
||||
github.com/leaanthony/go-ansi-parser v1.0.1/go.mod h1:7arTzgVI47srICYhvgUV4CGd063sGEeoSlych5yeSPM=
|
||||
github.com/leaanthony/gosod v1.0.3 h1:Fnt+/B6NjQOVuCWOKYRREZnjGyvg+mEhd1nkkA04aTQ=
|
||||
github.com/leaanthony/gosod v1.0.3/go.mod h1:BJ2J+oHsQIyIQpnLPjnqFGTMnOZXDbvWtRCSG7jGxs4=
|
||||
github.com/leaanthony/slicer v1.5.0 h1:aHYTN8xbCCLxJmkNKiLB6tgcMARl4eWmH9/F+S/0HtY=
|
||||
github.com/leaanthony/slicer v1.5.0/go.mod h1:FwrApmf8gOrpzEWM2J/9Lh79tyq8KTX5AzRtwV7m4AY=
|
||||
github.com/leaanthony/slicer v1.6.0 h1:1RFP5uiPJvT93TAHi+ipd3NACobkW53yUiBqZheE/Js=
|
||||
github.com/leaanthony/slicer v1.6.0/go.mod h1:o/Iz29g7LN0GqH3aMjWAe90381nyZlDNquK+mtH2Fj8=
|
||||
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
|
||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
|
||||
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 h1:acNfDZXmm28D2Yg/c3ALnZStzNaZMSagpbr96vY6Zjc=
|
||||
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
|
||||
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/samber/lo v1.27.1 h1:sTXwkRiIFIQG+G0HeAvOEnGjqWeWtI9cg5/n51KrxPg=
|
||||
github.com/samber/lo v1.27.1/go.mod h1:it33p9UtPMS7z72fP4gw/EIfQB2eI8ke7GR2wc6+Rhg=
|
||||
github.com/samber/lo v1.36.0 h1:4LaOxH1mHnbDGhTVE0i1z8v/lWaQW8AIfOD3HU4mSaw=
|
||||
github.com/samber/lo v1.36.0/go.mod h1:HLeWcJRRyLKp3+/XBJvOrerCQn9mhdKMHyd7IRlgeQ8=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M=
|
||||
github.com/tkrajina/go-reflector v0.5.5 h1:gwoQFNye30Kk7NrExj8zm3zFtrGPqOkzFMLuQZg1DtQ=
|
||||
github.com/tkrajina/go-reflector v0.5.5/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4=
|
||||
@ -51,13 +54,13 @@ github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhw
|
||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
github.com/wailsapp/wails/v2 v2.2.0 h1:+zRTNjwqyz1kofT0J2R1FpxXB+m3cZJzW3RjxDgxWNw=
|
||||
github.com/wailsapp/wails/v2 v2.2.0/go.mod h1:zdc9YVrIijjuNNkLOO3UpTU6M12TJe6TlriL+3ttlMM=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM=
|
||||
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
|
||||
golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8=
|
||||
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
|
||||
golang.org/x/exp v0.0.0-20221207211629-99ab8fa1c11f h1:90Jq/vvGVDsqj8QqCynjFw9MCerDguSMODLYII416Y8=
|
||||
golang.org/x/exp v0.0.0-20221207211629-99ab8fa1c11f/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
|
||||
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@ -66,16 +69,16 @@ golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
||||
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
package ipc
|
||||
|
||||
import (
|
||||
app "textualize/core/App"
|
||||
document "textualize/core/Document"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
type GetDocumentsResponse struct {
|
||||
@ -13,7 +17,10 @@ func (c *Channel) GetDocuments() GetDocumentsResponse {
|
||||
documents := document.GetDocumentCollection().Documents
|
||||
documentGroups := document.GetDocumentGroupCollection().DocumentGroups
|
||||
|
||||
var response GetDocumentsResponse
|
||||
response := GetDocumentsResponse{
|
||||
DocumentGroups: make([]DocumentGroup, 0),
|
||||
Documents: make([]Document, 0),
|
||||
}
|
||||
|
||||
for _, d := range documents {
|
||||
jsonDocument := Document{
|
||||
@ -38,3 +45,59 @@ func (c *Channel) GetDocuments() GetDocumentsResponse {
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
func (c *Channel) RequestAddDocument(groupId string, documentName string) Document {
|
||||
filePath, err := runtime.OpenFileDialog(app.GetInstance().Context, runtime.OpenDialogOptions{
|
||||
Title: "Select an Image",
|
||||
Filters: []runtime.FileFilter{
|
||||
{
|
||||
DisplayName: "Image Files (*.jpg, *.png)",
|
||||
Pattern: "*.jpg;*.png",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
runtime.LogError(app.GetInstance().Context, err.Error())
|
||||
return Document{}
|
||||
}
|
||||
|
||||
newDocument := document.Document{
|
||||
Id: uuid.NewString(),
|
||||
Name: documentName,
|
||||
Path: filePath,
|
||||
GroupId: groupId,
|
||||
ProjectId: "something else",
|
||||
}
|
||||
|
||||
document.GetDocumentCollection().AddDocument(newDocument)
|
||||
|
||||
documentResponse := Document{
|
||||
Id: newDocument.Id,
|
||||
Name: newDocument.Name,
|
||||
Path: newDocument.Path,
|
||||
GroupId: newDocument.GroupId,
|
||||
ProjectId: newDocument.ProjectId,
|
||||
}
|
||||
|
||||
return documentResponse
|
||||
}
|
||||
|
||||
func (c *Channel) RequestAddDocumentGroup(name string) DocumentGroup {
|
||||
newDocumentGroup := document.DocumentGroup{
|
||||
Id: uuid.NewString(),
|
||||
Name: name,
|
||||
ProjectId: "something else",
|
||||
}
|
||||
|
||||
document.GetDocumentGroupCollection().AddDocumentGroup(newDocumentGroup)
|
||||
|
||||
response := DocumentGroup{
|
||||
Id: newDocumentGroup.Id,
|
||||
Name: newDocumentGroup.Name,
|
||||
ParentId: newDocumentGroup.ParentId,
|
||||
ProjectId: newDocumentGroup.ProjectId,
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
13
main.go
13
main.go
@ -4,6 +4,7 @@ import (
|
||||
"embed"
|
||||
"log"
|
||||
|
||||
app "textualize/core/App"
|
||||
document "textualize/core/Document"
|
||||
Channel "textualize/ipc"
|
||||
|
||||
@ -22,7 +23,7 @@ var icon []byte
|
||||
|
||||
func main() {
|
||||
// Create an instance of the app structure
|
||||
app := NewApp()
|
||||
app := app.GetInstance()
|
||||
|
||||
document.InitizeModule()
|
||||
ipcChannel := Channel.GetInstance()
|
||||
@ -46,11 +47,11 @@ func main() {
|
||||
Menu: nil,
|
||||
Logger: nil,
|
||||
LogLevel: logger.DEBUG,
|
||||
OnStartup: app.startup,
|
||||
OnDomReady: app.domReady,
|
||||
OnBeforeClose: app.beforeClose,
|
||||
OnShutdown: app.shutdown,
|
||||
WindowStartState: options.Normal,
|
||||
OnStartup: app.Startup,
|
||||
// OnDomReady: app.domReady,
|
||||
// OnBeforeClose: app.beforeClose,
|
||||
// OnShutdown: app.shutdown,
|
||||
WindowStartState: options.Normal,
|
||||
Bind: []interface{}{
|
||||
ipcChannel,
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user