Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #120 from slashbaseide/develop
Browse files Browse the repository at this point in the history
Release v0.9.0
  • Loading branch information
paraswaykole authored Apr 19, 2023
2 parents 6f9ac8b + 1fe194d commit 3cd5966
Show file tree
Hide file tree
Showing 301 changed files with 22,081 additions and 278 deletions.
38 changes: 38 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# General
.DS_Store

# Visual Studio Code
.vscode/*
.history/
__debug_bin

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Environment
.env
development.env
development.server.env
production.env

# Database
app.db

# Wails
build/bin
node_modules
frontend/desktop/dist
build/darwin/gon-notarize.json

# Frontend Server
frontend/server/dist
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ __debug_bin
*.out

# Environment
local.env
.env
development.env
development.server.env
production.env

# Database
Expand All @@ -30,5 +31,8 @@ app.db
# Wails
build/bin
node_modules
frontend/dist
build/darwin/gon-notarize.json
frontend/desktop/dist
build/darwin/gon-notarize.json

# Frontend Server
frontend/server/dist
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## THIS IS PRODUCTION DOCKERFILE.
## USED TO BUILD: slashbaseide/slashbase image

# Create base image for building go binary
FROM golang:1.20.3-alpine3.17 as base
WORKDIR /app

ENV GO111MODULE="on"
ENV GOOS="linux"
ENV CGO_ENABLED=1

# System dependencies
RUN apk update && apk add --no-cache ca-certificates git build-base && update-ca-certificates

COPY go.mod go.sum ./
RUN go mod download

# Executable builder
FROM base as backendbuilder

WORKDIR /app
COPY . .
RUN mkdir -p /app/frontend/desktop/dist
RUN touch /app/frontend/desktop/dist/nofile
RUN make build-server

# Install dependencies only when needed
FROM node:alpine AS deps

RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY ./frontend/server/package.json ./frontend/server/yarn.lock ./
RUN yarn install --frozen-lockfile

# Rebuild the source code only when needed
FROM node:alpine AS frontendbuilder

WORKDIR /app
COPY ./frontend/server/ .
COPY --from=deps /app/node_modules ./node_modules
RUN yarn build

# Production
FROM alpine:3.14

WORKDIR /slashbase
COPY --from=backendbuilder /app/slashbase /slashbase
COPY --from=frontendbuilder /app/dist /slashbase/web

ENTRYPOINT ["/slashbase/slashbase"]
EXPOSE 3000
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ WAILS ?= $(GOPATH)/bin/wails

.PHONY: build
build:
env CGO_ENABLED=1 $(WAILS) build -trimpath -ldflags="-s -w -X 'main.build=production' -X 'main.version=$(VERSION)'"
env CGO_ENABLED=1 $(WAILS) build -trimpath -ldflags="-s -w -X 'main.envName=production' -X 'main.version=$(VERSION)'"

.PHONY: build-server
build-server:
env CGO_ENABLED=1 go build -trimpath -ldflags="-s -w -X 'main.envName=production' -X 'main.build=server' -X 'main.version=$(VERSION)'"

# DO NOT USE THE FOLLOWING PHONY RECIPIES, THEY ARE ONLY FOR DISTRIBUTION

.PHONY: build-win
build-win:
env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC="x86_64-w64-mingw32-gcc" $(WAILS) build -trimpath -ldflags="-s -w -X 'main.build=production' -X 'main.version=$(VERSION)'" -skipbindings
env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC="x86_64-w64-mingw32-gcc" $(WAILS) build -trimpath -ldflags="-s -w -X 'main.envName=production' -X 'main.version=$(VERSION)'" -skipbindings

.PHONY: sign
sign:
Expand Down
1 change: 1 addition & 0 deletions deploy/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO: write install script
11 changes: 11 additions & 0 deletions deploy/server.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ROOT_USER_EMAIL=${slashbase_root_email}
ROOT_USER_PASSWORD=${slashbase_root_password}

AUTH_TOKEN_SECRET=${auth_secret}
CRYPTED_DATA_SECRET=${crypted_data_secret}

APP_DB_HOST=${app_db_host}
APP_DB_PORT=${app_db_port}
APP_DB_USER=${app_db_user}
APP_DB_PASS=${app_db_pass}
APP_DB_NAME=${app_db_name}
1 change: 0 additions & 1 deletion development.env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# rename this file to development.env and replace the comments below to get started on development of slashbase
ENV_NAME=development

# some secrets are pre-generated for development and can be changed
CRYPTED_DATA_SECRET=ca8f161ccd170f5600f2beb6c17873a69b689ad1be5c5e97513e39b3158643ba
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
99 changes: 99 additions & 0 deletions frontend/desktop/src/components/dbfragments/history.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import React, { useContext, useEffect } from 'react'
import { DBConnection, Tab } from '../../data/models'
import { selectDBConnection } from '../../redux/dbConnectionSlice'
import { useAppDispatch, useAppSelector } from '../../redux/hooks'
import toast from 'react-hot-toast'
import InfiniteScroll from 'react-infinite-scroll-component'
import dateformat from 'dateformat'
import { getDBQueryLogs, reset, selectDBQueryLogs, selectDBQueryLogsNext } from '../../redux/dbHistorySlice'
import TabContext from '../layouts/tabcontext'


type DBHistoryPropType = {
}

const DBHistoryFragment = ({ }: DBHistoryPropType) => {

const dispatch = useAppDispatch()

const currentTab: Tab = useContext(TabContext)!

const dbConnection: DBConnection | undefined = useAppSelector(selectDBConnection)
const dbQueryLogs = useAppSelector(selectDBQueryLogs)
const dbQueryLogsNext = useAppSelector(selectDBQueryLogsNext)

useEffect(() => {
if (dbConnection) {
(async () => {
dispatch(reset())
})()
fetchDBQueryLogs()
}
}, [dispatch, dbConnection])

const fetchDBQueryLogs = async () => {
const result = await dispatch(getDBQueryLogs({ dbConnId: dbConnection!.id })).unwrap()
if (!result.success) {
toast.error(result.error!)
}
}

function refreshHandler() {
dispatch(reset())
fetchDBQueryLogs()
}

return (
<div className={currentTab.isActive ? "db-tab-active" : "db-tab"}>
{dbConnection &&
<React.Fragment>
<div className="is-flex is-justify-content-space-between">
<h1>Showing History in {dbConnection.name}</h1>
<button className="button is-flex" onClick={refreshHandler}>
<span className="icon is-small">
<i className="fas fa-sync" />
</span>
<span>Refresh</span>
</button>
</div>
<br />
<InfiniteScroll
dataLength={dbQueryLogs.length}
next={fetchDBQueryLogs}
hasMore={dbQueryLogsNext !== -1}
loader={
<p style={{ textAlign: 'center' }}>
Loading...
</p>
}
endMessage={
<p style={{ textAlign: 'center' }}>
<b>You have seen it all!</b>
</p>
}
scrollableTarget="maincontent"
>
<table className={"table is-bordered is-striped is-narrow is-hoverable is-fullwidth"}>
<tbody>
{dbQueryLogs.map((log) => (
<tr key={log.id}>
<td>
<code>{log.query}</code>
</td>
<td style={{ fontSize: '14px', width: '120px' }}>
{dateformat(log.createdAt, "mmm dd, yyyy HH:MM:ss")}
</td>
</tr>
)
)}
</tbody>
</table>
</InfiniteScroll>
</React.Fragment>
}
</div>
)
}


export default DBHistoryFragment
Loading

0 comments on commit 3cd5966

Please sign in to comment.