From 09b7f3b74bfaf511e50b83facc30284b04696e5c Mon Sep 17 00:00:00 2001 From: ctengiz Date: Tue, 16 Apr 2024 22:01:23 +0300 Subject: [PATCH] alfa release --- scripts/base_db_install.sh | 11 + scripts/base_svc_install.sh | 65 +++++ svc/api/acompany.go | 2 +- svc/api/atmpl.go | 44 +++ svc/api/zhandler.go | 4 + svc/model/company/company.go | 4 +- ui/package.json | 3 +- ui/quasar.config.js | 1 + ui/src/i18n/tr.js | 7 + ui/src/layouts/panelLayout.vue | 4 +- ui/src/lib/menu.js | 19 +- ui/src/pages/company.vue | 41 ++- ui/src/pages/companyList.vue | 2 +- ui/src/pages/map.vue | 247 ++++++++++++++++ ui/src/pages/tmpl.vue | 520 +++++++++++++++++++++++++++++++++ ui/src/router/routes.js | 5 + ui/yarn.lock | 4 + 17 files changed, 955 insertions(+), 28 deletions(-) create mode 100644 scripts/base_db_install.sh create mode 100644 scripts/base_svc_install.sh create mode 100644 svc/api/atmpl.go create mode 100644 ui/src/pages/map.vue create mode 100644 ui/src/pages/tmpl.vue diff --git a/scripts/base_db_install.sh b/scripts/base_db_install.sh new file mode 100644 index 0000000..946e417 --- /dev/null +++ b/scripts/base_db_install.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +apt update && apt upgrade +dpkg-reconfigure locales +dpkg-reconfigure tzdata + +sudo apt install -y postgresql-common +sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh +apt -y install postgresql-16 mc rsync curl + +cd /tmp && sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'tesnos.+ed';" diff --git a/scripts/base_svc_install.sh b/scripts/base_svc_install.sh new file mode 100644 index 0000000..f2c1984 --- /dev/null +++ b/scripts/base_svc_install.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +APP=bordro-esleme + +apt update && apt upgrade +apt -y install mc rsync curl nginx +dpkg-reconfigure tzdata + +useradd --system --shell=/usr/sbin/nologin ${APP} + +mkdir -p /opt/${APP}/sqls +mkdir -p /opt/${APP}/migrate +mkdir -p /opt/${APP}/ui +mkdir -p /opt/${APP}/files + +echo "Creating application service" +read -d '' sservice << EOF +[Unit] +Description=${APP} +After=syslog.target +After=network.target +#Requires=postgresql.service +#Requires=memcached.service +#Requires=redis.service + +[Service] +# Modify these two values and uncomment them if you have +# repos with lots of files and get an HTTP error 500 because +# of that +### +LimitMEMLOCK=infinity +LimitNOFILE=1048576 + +RestartSec=2s +Type=simple +User=${APP} +Group=${APP} +WorkingDirectory=/opt/${APP}/ +ExecStart=/opt/${APP}/${APP} +Restart=always + +Environment=AUTHSERVER=http://127.0.0.1:40200 SQLSDIR=./sqls DBHOST=10.0.0.2 DBNAME=bordroesleme DBPASS=tesnos.+ed + +# enable to bind to a port below 1024 uncomment +### +#CapabilityBoundingSet=CAP_NET_BIND_SERVICE +#AmbientCapabilities=CAP_NET_BIND_SERVICE + +# Prevent writes to /usr, /boot, and /etc +ProtectSystem=full + +# Prevent accessing /home, /root and /run/user +ProtectHome=true + +# Execute pre and post scripts as root, otherwise it does it as User= +PermissionsStartOnly=true + +[Install] +WantedBy=multi-user.target +EOF +echo "$sservice" > /etc/systemd/system/${APP}.service + +systemctl daemon-reload +systemctl enable ${APP} + diff --git a/svc/api/acompany.go b/svc/api/acompany.go index 350edf4..1895a30 100644 --- a/svc/api/acompany.go +++ b/svc/api/acompany.go @@ -60,7 +60,7 @@ func companyCreate(w http.ResponseWriter, r *http.Request) { return } - err = data.DbCreate(r.Context(), true, tc.UsrID()) + err = data.DbCreate(r.Context(), tc.ClientID(), true, tc.UsrID()) if err != nil { mhttp.InternalServerError(w, err) return diff --git a/svc/api/atmpl.go b/svc/api/atmpl.go new file mode 100644 index 0000000..f60bb33 --- /dev/null +++ b/svc/api/atmpl.go @@ -0,0 +1,44 @@ +package api + +import ( + "encoding/json" + "git.makki.io/makki/libgo/cmn" + "git.makki.io/makki/libgo/dbu" + "git.makki.io/makki/libgo/mhttp" + "github.com/go-chi/chi/v5" + "net/http" +) + +func tmplPost(w http.ResponseWriter, r *http.Request) { + companyID := cmn.StrToInt64(chi.URLParam(r, "companyID")) + var body json.RawMessage + + err := cmn.BodyToJsonReq(r, &body) + if err != nil { + mhttp.InternalServerError(w, err) + return + } + + sq := "update company set tmpl = $2 where id = $1" + _, err = dbu.DB.Exec(r.Context(), sq, companyID, body) + if err != nil { + mhttp.InternalServerError(w, err) + return + } + + mhttp.ResponseSuccess(w, true) +} + +func tmplGet(w http.ResponseWriter, r *http.Request) { + companyID := cmn.StrToInt64(chi.URLParam(r, "companyID")) + var body json.RawMessage + + sq := "select tmpl from company where id = $1" + err := dbu.DB.QueryRow(r.Context(), sq, companyID).Scan(&body) + if err != nil { + mhttp.InternalServerError(w, err) + return + } + + mhttp.ResponseSuccess(w, body) +} diff --git a/svc/api/zhandler.go b/svc/api/zhandler.go index 0d1d41c..5e1d3f1 100644 --- a/svc/api/zhandler.go +++ b/svc/api/zhandler.go @@ -71,6 +71,10 @@ func HttpHandler(re enums.TRunEnv) http.Handler { r.Put("/company", companyUpdate) r.Post("/company", companyCreate) r.Delete("/company/{id:[0-9]+}", companyDelete) + + r.Post("/tmpl/{companyID:[0-9]+}", tmplPost) + r.Get("/tmpl/{companyID:[0-9]+}", tmplGet) + }) }) diff --git a/svc/model/company/company.go b/svc/model/company/company.go index acab88b..d031880 100644 --- a/svc/model/company/company.go +++ b/svc/model/company/company.go @@ -80,7 +80,9 @@ func DbDelete(ctx context.Context, id int64, log bool, usrID *int64) error { return tx.Commit(ctx) } -func (m *Company) DbCreate(ctx context.Context, log bool, usrID *int64) error { +func (m *Company) DbCreate(ctx context.Context, clID int64, log bool, usrID *int64) error { + m.Clid = clID + rp, err := dbu.NewRepoWithFile(ctx, "company", nil) if err != nil { return err diff --git a/ui/package.json b/ui/package.json index 0017fd8..a4e656e 100644 --- a/ui/package.json +++ b/ui/package.json @@ -21,7 +21,8 @@ "quasar": "^2.8.0", "vue": "^3.4.18", "vue-i18n": "^9.9.0", - "vue-router": "^4.0.12" + "vue-router": "^4.0.12", + "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz" }, "devDependencies": { "@quasar/app-vite": "^1.8.0", diff --git a/ui/quasar.config.js b/ui/quasar.config.js index caf39fb..2beedce 100644 --- a/ui/quasar.config.js +++ b/ui/quasar.config.js @@ -63,6 +63,7 @@ module.exports = configure(function (ctx) { // publicPath: '/', // analyze: true, env: { + showLangSelect: false, apiAddr: (() => { if (process.env.CUSTOM_API) { return process.env.CUSTOM_API diff --git a/ui/src/i18n/tr.js b/ui/src/i18n/tr.js index 27a00e6..3b32d0b 100644 --- a/ui/src/i18n/tr.js +++ b/ui/src/i18n/tr.js @@ -4,6 +4,13 @@ const prjI18n = { menu: { app: 'Uygulamalar' }, + Company: { + Code: 'Şirket Kod', + Title: 'Şirket Ad', + IsActive: 'Kullanımda', + Notes: 'Açıklamalar', + Tmpl: 'Eşleme Şablonu' + }, Usr: {}, } diff --git a/ui/src/layouts/panelLayout.vue b/ui/src/layouts/panelLayout.vue index 8717514..72b2f76 100644 --- a/ui/src/layouts/panelLayout.vue +++ b/ui/src/layouts/panelLayout.vue @@ -20,7 +20,7 @@