Skip to content

Commit

Permalink
new asset
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardoOliveira committed Sep 8, 2024
1 parent 5b97149 commit ff7b76c
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 423 deletions.
25 changes: 0 additions & 25 deletions frontend/public/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -919,13 +919,6 @@ html {
padding: 0px;
}

.btn-circle {
height: 3rem;
width: 3rem;
border-radius: 9999px;
padding: 0px;
}

:where(.btn:is(input[type="checkbox"])),
:where(.btn:is(input[type="radio"])) {
width: auto;
Expand Down Expand Up @@ -2595,20 +2588,6 @@ input.tab:checked + .tab-content,
padding: 0px;
}

.btn-circle:where(.btn-md) {
height: 3rem;
width: 3rem;
border-radius: 9999px;
padding: 0px;
}

.btn-circle:where(.btn-lg) {
height: 4rem;
width: 4rem;
border-radius: 9999px;
padding: 0px;
}

.join.join-vertical {
flex-direction: column;
}
Expand Down Expand Up @@ -3290,10 +3269,6 @@ input.tab:checked + .tab-content,
padding-bottom: 0.5rem;
}

.pr-1 {
padding-right: 0.25rem;
}

.pt-1 {
padding-top: 0.25rem;
}
Expand Down
9 changes: 0 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ require (
github.com/bodgit/plumbing v1.3.0 // indirect
github.com/bodgit/sevenzip v1.5.1 // indirect
github.com/bodgit/windows v1.0.1 // indirect
github.com/connesc/cipherio v0.2.1 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fogleman/simplify v0.0.0-20170216171241-d32f302d5046 // indirect
Expand All @@ -47,8 +46,6 @@ require (
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/pgzip v1.2.6 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
github.com/leaanthony/gosod v1.0.4 // indirect
github.com/leaanthony/slicer v1.6.0 // indirect
Expand All @@ -58,7 +55,6 @@ require (
github.com/morkid/gocache v1.0.0 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/nwaples/rardecode/v2 v2.0.0-beta.2 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
Expand All @@ -72,7 +68,6 @@ require (
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/therootcompany/xz v1.0.1 // indirect
Expand All @@ -85,15 +80,11 @@ require (
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.57.0 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/sqlite v1.31.1 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
)

require (
Expand Down
347 changes: 14 additions & 333 deletions go.sum

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions v2/library/repo/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"math"
"strings"

"github.com/eduardooliveira/stLib/v2/database"
"github.com/eduardooliveira/stLib/v2/library/entities"
Expand Down Expand Up @@ -104,9 +103,9 @@ func (r AssetRepo) UpdateAsset(a *entities.Asset) error {
func (r AssetRepo) SearchAsset(label string, tags string) ([]*entities.Asset, error) {
var assets []*entities.Asset
q := database.DB.Debug().Model(&entities.Asset{}).Where("label LIKE ?", fmt.Sprintf("%%%s%%", label))
for i, t := range strings.Split(tags, ",") {
q.Joins(fmt.Sprintf("LEFT JOIN project_tags as project_tags%d on project_tags%d.project_uuid = projects.uuid", i, i)).
Where(fmt.Sprintf("project_tags%d.tag_value = ?", i), t)
}
/*for i, t := range strings.Split(tags, ",") {
q.Joins(fmt.Sprintf("LEFT JOIN tags as tags%d on tags%d.asset_id = assets.id", i, i)).
Where(fmt.Sprintf("tags%d.value = ?", i), t)
}*/
return assets, q.Find(&assets).Error
}
2 changes: 1 addition & 1 deletion v2/library/web/comp/details.templ
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/eduardooliveira/stLib/v2/utils"

templ Details(m *DetailsModel) {
<div
class="flex flex-col w-96"
class="flex flex-col w-96 bg-base-200 rounded-box p-2"
:class="tab == 'details' ? '' : 'hidden'"
hx-get="/lib/details"
hx-trigger="tab-details from:body"
Expand Down
2 changes: 1 addition & 1 deletion v2/library/web/comp/edit.templ
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/eduardooliveira/stLib/v2/utils"

templ Edit(m *EditModel) {
<div
class="flex flex-col w-96"
class="flex flex-col w-96 bg-base-200 rounded-box p-2"
:class="tab == 'edit' ? '' : 'hidden'"
hx-get="/lib/edit"
hx-trigger="tab-edit from:body"
Expand Down
23 changes: 2 additions & 21 deletions v2/library/web/comp/index.templ
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package comp

import (
"github.com/eduardooliveira/stLib/v2/library/entities"
"github.com/eduardooliveira/stLib/v2/utils"
)
import "github.com/eduardooliveira/stLib/v2/utils"

templ Index(model IndexModel) {
<div class="flex-auto flex flex-col p-1 asset-view">
Expand All @@ -16,7 +13,7 @@ templ Index(model IndexModel) {
@Pagination(model.Pagination)
<div class="flex-none">
<div class="dropdown dropdown-end">
<div tabindex="0" role="button" class="btn btn-ghost btn-circle">
<div tabindex="0" role="button" class="btn btn-ghost btn-square">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
Expand All @@ -32,22 +29,6 @@ templ Index(model IndexModel) {
</div>
</div>
</div>
<button
class="btn btn-square btn-ghost"
hx-get="/lib/new"
hx-include="#asset-id"
hx-target="#asset-sidebar"
if utils.VoZ(model.Asset.NodeKind) == entities.NodeKindBundle || model.Asset.ID== "" {
disabled
}
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
class="inline-block h-5 w-5 stroke-current"
><title>note-plus</title><path d="M19 13C19.7 13 20.37 13.13 21 13.35V9L15 3H5C3.89 3 3 3.89 3 5V19C3 20.11 3.9 21 5 21H13.35C13.13 20.37 13 19.7 13 19C13 15.69 15.69 13 19 13M14 4.5L19.5 10H14V4.5M23 18V20H20V23H18V20H15V18H18V15H20V18H23Z"></path></svg>
</button>
</div>
</div>
</div>
Expand Down
40 changes: 23 additions & 17 deletions v2/library/web/comp/new.templ
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@ package comp

templ New(m *NewModel) {
<div
class="w-96 p-2"
class="flex flex-col w-96 bg-base-200 rounded-box p-2"
:class="tab == 'new' ? '' : 'hidden'"
hx-get="/lib/new"
hx-trigger="tab-new from:body"
hx-vals="js:{assetID:event.detail.assetID}"
>
<form hx-post="/lib/new" hx-target="#asset-sidebar">
<h1>Import</h1>
<input name="mode" type="hidden" value="import"/>
<input name="parentID" type="hidden" value={ m.ParentID }/>
<textarea name="urls" class="block w-full px-4 py-2 mt-2 text-gray-700 bg-white border border-gray-200 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring" rows="5"></textarea>
<button class="btn btn-sm">Import</button>
</form>
<form hx-post="/lib/new" hx-target="#asset-sidebar" enctype="multipart/form-data">
<h1>New</h1>
<input name="mode" type="hidden" value="upload"/>
<input name="parentID" type="hidden" value={ m.ParentID }/>
<input name="folder" type="text" class="block w-full px-4 py-2 mt-2 text-gray-700 bg-white border border-gray-200 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring"/>
<input type="file" name="files" multiple class="block w-full px-4 py-2 mt-2 text-gray-700 bg-white border border-gray-200 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring"/>
<button class="btn btn-sm">Save</button>
</form>
/*<form hx-post="/lib/new" hx-target="#asset-sidebar">
if m!=nil {
<form hx-post="/lib/new" hx-vals="unset">
<h1>Import</h1>
<input name="mode" type="hidden" value="import"/>
<input name="parentID" type="hidden" value={ m.ParentID }/>
<textarea name="urls" class="block w-full px-4 py-2 mt-2 text-gray-700 bg-white border border-gray-200 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring" rows="5"></textarea>
<button class="btn btn-sm">Import</button>
</form>
<form hx-post="/lib/new" hx-vals="unset" enctype="multipart/form-data">
<h1>New</h1>
<input name="mode" type="hidden" value="upload"/>
<input name="parentID" type="hidden" value={ m.ParentID }/>
<input name="folder" type="text" class="block w-full px-4 py-2 mt-2 text-gray-700 bg-white border border-gray-200 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring"/>
<input type="file" name="files" multiple class="block w-full px-4 py-2 mt-2 text-gray-700 bg-white border border-gray-200 rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-blue-400 focus:ring-blue-300 focus:ring-opacity-40 dark:focus:border-blue-300 focus:outline-none focus:ring"/>
<button class="btn btn-sm">Save</button>
</form>
/*<form hx-post="/lib/new" hx-target="#asset-sidebar">
<h1>Move Uploaded gcode</h1>
<input name="mode" type="hidden" value="tempFiles"/>
<input name="parentID" type="hidden" value={ m.ParentID }/>
Expand All @@ -31,5 +36,6 @@ templ New(m *NewModel) {
<button class="btn btn-sm">Move here</button>
</form>
*/
}
</div>
}
34 changes: 24 additions & 10 deletions v2/library/web/comp/sidebar.templ
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@ templ Sidebar() {
<aside class="flex flex-row-reverse p-1" x-ref="libSidebar">
<ul class="self-start menu bg-base-200 rounded-box">
<li>
<a
class="tooltip tooltip-left"
<button
class="btn btn-square btn-ghost tooltip tooltip-left"
data-tip="New"
@click="openTab('new')"
:class="$data.tab == 'new' ? 'active' : ''"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
class="inline-block h-5 w-5 stroke-current"
><title>note-plus</title><path d="M19 13C19.7 13 20.37 13.13 21 13.35V9L15 3H5C3.89 3 3 3.89 3 5V19C3 20.11 3.9 21 5 21H13.35C13.13 20.37 13 19.7 13 19C13 15.69 15.69 13 19 13M14 4.5L19.5 10H14V4.5M23 18V20H20V23H18V20H15V18H18V15H20V18H23Z"></path></svg>
</button>
<button
class="btn btn-square btn-ghost tooltip tooltip-left"
data-tip="3D View"
@click="openTab('viewer')"
:class="$data.tab == 'viewer' ? 'active' : ''"
Expand All @@ -15,21 +28,21 @@ templ Sidebar() {
viewBox="0 0 24 24"
class="inline-block h-5 w-5 stroke-current"
><title>cube</title><path d="M12,2L2,7V17L12,22L22,17V7L12,2M12,4.54L19.76,8.5L12,12.46L4.24,8.5L12,4.54M12,13.46L4.24,9.5L12,5.54L19.76,9.5L12,13.46M4,19V9.89L12,14.46L20,9.89V19L12,23.46L4,19Z"></path></svg>
</a>
</button>
</li>
<li>
<a
class="tooltip tooltip-left"
<button
class="btn btn-square btn-ghost tooltip tooltip-left"
data-tip="details"
@click="openTab('details')"
:class="$data.tab == 'details' ? 'active' : ''"
>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="inline-block h-5 w-5x stroke-current"><title>information-outline</title><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z"></path></svg>
</a>
</button>
</li>
<li>
<a
class="tooltip tooltip-left"
<button
class="btn btn-square btn-ghost tooltip tooltip-left"
data-tip="edit"
@click="openTab('edit')"
:class="$data.tab == 'edit' ? 'active' : ''"
Expand All @@ -39,10 +52,11 @@ templ Sidebar() {
viewBox="0 0 24 24"
class="inline-block h-5 w-5 stroke-current"
><title>edit</title><path d="M20,6.41L17.41,4L6,15.41V18H8.59L20,6.59V6.41M18.5,3.5L20.5,5.5L18.5,7.5L16.5,5.5L18.5,3.5M4,20H18V22H4A2,2 0 0,1 2,20V6H4V20Z"></path></svg>
</a>
</button>
</li>
</ul>
<div class="flex-auto pr-1">
<div class="flex-auto px-1">
@New(nil)
@View3D()
@Details(nil)
@Edit(nil)
Expand Down
5 changes: 4 additions & 1 deletion v2/library/web/comp/view3d.templ
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import (
)

templ View3D() {
<div class="flex flex-col w-96" :class="tab == 'viewer' ? '' : 'hidden'">
<div
class="flex flex-col w-96 bg-base-200 rounded-box p-2"
:class="tab == 'viewer' ? '' : 'hidden'"
>
<p>3D Viewer</p>
<div
class="h-72 viewer-container bg-slate-400"
Expand Down

0 comments on commit ff7b76c

Please sign in to comment.