UI controller fixes
This commit is contained in:
parent
b3d6e85ec5
commit
6df0a3871b
75
controllers/helper.go
Normal file
75
controllers/helper.go
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"forge.redroom.link/yves/sqldb"
|
||||||
|
beego "github.com/beego/beego/v2/server/web"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Operations about schema
|
||||||
|
type HelperController struct {
|
||||||
|
beego.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title ParseHeader
|
||||||
|
// @Description Post raw header
|
||||||
|
// @Param body body form data "body of jsonform data"
|
||||||
|
// @Success 200 {string} success !
|
||||||
|
// @Failure 500 query error
|
||||||
|
// @router /header [post]
|
||||||
|
func (s *HelperController) ParseHeader() {
|
||||||
|
db := sqldb.Open(os.Getenv("driverdb"), os.Getenv("paramsdb"))
|
||||||
|
data, err := db.ListTables()
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msg(err.Error())
|
||||||
|
s.Data["json"] = map[string]string{"error": err.Error()}
|
||||||
|
s.Ctx.Output.SetStatus(http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
s.Data["json"] = data
|
||||||
|
s.ServeJSON()
|
||||||
|
|
||||||
|
db.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title CreateTable
|
||||||
|
// @Description Post raw header
|
||||||
|
// @Param body body form data "body of jsonform data"
|
||||||
|
// @Success 200 {string} success !
|
||||||
|
// @Failure 500 query error
|
||||||
|
// @router /create [post]
|
||||||
|
func (s *HelperController) CreateTable() {
|
||||||
|
db := sqldb.Open(os.Getenv("driverdb"), os.Getenv("paramsdb"))
|
||||||
|
data, err := db.ListTables()
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msg(err.Error())
|
||||||
|
s.Data["json"] = map[string]string{"error": err.Error()}
|
||||||
|
s.Ctx.Output.SetStatus(http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
s.Data["json"] = data
|
||||||
|
s.ServeJSON()
|
||||||
|
|
||||||
|
db.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Title Import
|
||||||
|
// @Description Post raw header
|
||||||
|
// @Param body body form data "body of jsonform data"
|
||||||
|
// @Success 200 {string} success !
|
||||||
|
// @Failure 500 query error
|
||||||
|
// @router /import/:table [post]
|
||||||
|
func (s *HelperController) Import() {
|
||||||
|
db := sqldb.Open(os.Getenv("driverdb"), os.Getenv("paramsdb"))
|
||||||
|
data, err := db.ListTables()
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msg(err.Error())
|
||||||
|
s.Data["json"] = map[string]string{"error": err.Error()}
|
||||||
|
s.Ctx.Output.SetStatus(http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
s.Data["json"] = data
|
||||||
|
s.ServeJSON()
|
||||||
|
|
||||||
|
db.Close()
|
||||||
|
}
|
@ -23,7 +23,7 @@ type UiController struct {
|
|||||||
// @Param uid path string true "The uid you want to edit"
|
// @Param uid path string true "The uid you want to edit"
|
||||||
// @Success 200 json form
|
// @Success 200 json form
|
||||||
// @Failure 403 body is empty
|
// @Failure 403 body is empty
|
||||||
// @router /:fid/:uid [get]
|
// @router /form/:fid/:uid [get]
|
||||||
func (u *UiController) GetEditForm() {
|
func (u *UiController) GetEditForm() {
|
||||||
fid := u.Ctx.Input.Query(":fid")
|
fid := u.Ctx.Input.Query(":fid")
|
||||||
uid := u.Ctx.Input.Query(":uid")
|
uid := u.Ctx.Input.Query(":uid")
|
||||||
@ -36,7 +36,7 @@ func (u *UiController) GetEditForm() {
|
|||||||
// @Param fid path string true "The fid of the form"
|
// @Param fid path string true "The fid of the form"
|
||||||
// @Success 200 json form
|
// @Success 200 json form
|
||||||
// @Failure 403 body is empty
|
// @Failure 403 body is empty
|
||||||
// @router /:fid [get]
|
// @router /form/:fid [get]
|
||||||
func (u *UiController) GetEmptyForm() {
|
func (u *UiController) GetEmptyForm() {
|
||||||
fid := u.Ctx.Input.Query(":fid")
|
fid := u.Ctx.Input.Query(":fid")
|
||||||
u.buildForm(fid, "")
|
u.buildForm(fid, "")
|
||||||
@ -142,41 +142,29 @@ func (u *UiController) buildForm(fid string, uid string) {
|
|||||||
|
|
||||||
// @Title Access form data post
|
// @Title Access form data post
|
||||||
// @Description insert access
|
// @Description insert access
|
||||||
|
// @Param fid path string true "The fid of the form"
|
||||||
// @Param uid path string true "The uid you want to edit"
|
// @Param uid path string true "The uid you want to edit"
|
||||||
// @Param body body form data "body of jsonform data"
|
// @Param body body form data "body of jsonform data"
|
||||||
// @Success 200 json
|
// @Success 200 json
|
||||||
// @Failure 403 body is empty
|
// @Failure 403 body is empty
|
||||||
// @router /:uid [post]
|
// @router /form/:fid/:uid [post]
|
||||||
func (u *UiController) PostAccessForm() {
|
func (u *UiController) PostAccessForm() {
|
||||||
var err error
|
var err error
|
||||||
|
fid := u.Ctx.Input.Query(":uid")
|
||||||
uid := u.Ctx.Input.Query(":uid")
|
uid := u.Ctx.Input.Query(":uid")
|
||||||
var formdata map[string]interface{}
|
var formdata map[string]interface{}
|
||||||
json.Unmarshal(u.Ctx.Input.RequestBody, &formdata)
|
json.Unmarshal(u.Ctx.Input.RequestBody, &formdata)
|
||||||
db := sqldb.Open(os.Getenv("driverdb"), os.Getenv("paramsdb"))
|
db := sqldb.Open(os.Getenv("driverdb"), os.Getenv("paramsdb"))
|
||||||
accesslist := formdata["fields"].([]interface{})
|
formdesc, err := getFormDesc(db, fid)
|
||||||
switcheslist := accesslist[:len(accesslist)-3]
|
table := formdesc[0]["tablename"]
|
||||||
families := []string{}
|
print(table, uid)
|
||||||
for _, accessif := range switcheslist {
|
updateJson := map[string]interface{}{}
|
||||||
access := accessif.(map[string]interface{})
|
fields := formdata["fields"].([]map[string]interface{})
|
||||||
basefamily := fmt.Sprint(access["key"].(float64))
|
for _, f := range fields {
|
||||||
if access["value"].(bool) {
|
// todo manage types
|
||||||
_, err = db.QueryAssociativeArray("insert ignore into user_basefamily(user_id, family_id) values(" + uid + "," + basefamily + ")")
|
updateJson[f["key"].(string)] = f["value"]
|
||||||
if err != nil {
|
|
||||||
log.Error().Msg(err.Error())
|
|
||||||
u.Ctx.Output.SetStatus(http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
families = append(families, basefamily)
|
|
||||||
} else {
|
|
||||||
// remove off
|
|
||||||
_, err = db.QueryAssociativeArray("delete from user_basefamily where user_id=" + uid + " and family_id=" + basefamily)
|
|
||||||
if err != nil {
|
|
||||||
log.Error().Msg(err.Error())
|
|
||||||
u.Ctx.Output.SetStatus(http.StatusBadRequest)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// todo send update
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Msg(err.Error())
|
log.Error().Msg(err.Error())
|
||||||
u.Ctx.Output.SetStatus(http.StatusBadRequest)
|
u.Ctx.Output.SetStatus(http.StatusBadRequest)
|
||||||
@ -186,6 +174,56 @@ func (u *UiController) PostAccessForm() {
|
|||||||
u.ServeJSON()
|
u.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title Tableview
|
||||||
|
// @Description Get table view
|
||||||
|
// @Param tvid path string true "The id of the tableview"
|
||||||
|
// @Success 200 json form
|
||||||
|
// @Failure 403 body is empty
|
||||||
|
// @router /tableview/:tvid [get]
|
||||||
|
func (u *UiController) GetListView() {
|
||||||
|
lvid := u.Ctx.Input.Query(":tvid")
|
||||||
|
tvdata := map[string]interface{}{}
|
||||||
|
db := sqldb.Open(os.Getenv("driverdb"), os.Getenv("paramsdb"))
|
||||||
|
lv, err := getTableView(db, lvid)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msg(err.Error())
|
||||||
|
u.Ctx.Output.SetStatus(http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
tvdata["title"] = lv[0]["title"].(string)
|
||||||
|
tvdata["header"] = lv[0]["header"].(string)
|
||||||
|
tvdata["form_id"] = lv[0]["form_id"].(int64)
|
||||||
|
if lv[0]["tablerestriction"] == nil {
|
||||||
|
tvdata["tablerestriction"] = ""
|
||||||
|
} else {
|
||||||
|
tvdata["tablerestriction"] = lv[0]["tablerestriction"].(string)
|
||||||
|
}
|
||||||
|
if lv[0]["tableorder"] == nil {
|
||||||
|
tvdata["tableorder"] = ""
|
||||||
|
} else {
|
||||||
|
tvdata["tableorder"] = lv[0]["tableorder"].(string)
|
||||||
|
}
|
||||||
|
if lv[0]["tableorderdir"] == nil {
|
||||||
|
tvdata["tableorderdir"] = ""
|
||||||
|
} else {
|
||||||
|
tvdata["tableorderdir"] = lv[0]["tableorderdir"].(string)
|
||||||
|
}
|
||||||
|
schema, err := db.Table(lv[0]["tablename"].(string)).GetSchema()
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msg(err.Error())
|
||||||
|
u.Ctx.Output.SetStatus(http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
tvdata["columns"] = schema.Columns
|
||||||
|
data, err := db.Table(lv[0]["tablename"].(string)).GetAssociativeArray(strings.Split("id,"+lv[0]["tablecolumns"].(string), ","), tvdata["tablerestriction"].(string), strings.Split(tvdata["tableorder"].(string), ","), tvdata["tableorderdir"].(string))
|
||||||
|
tvdata["items"] = data
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msg(err.Error())
|
||||||
|
u.Ctx.Output.SetStatus(http.StatusBadRequest)
|
||||||
|
} else {
|
||||||
|
u.Data["json"] = tvdata
|
||||||
|
}
|
||||||
|
u.ServeJSON()
|
||||||
|
}
|
||||||
|
|
||||||
func getFormDesc(db *sqldb.Db, fid string) ([]sqldb.AssRow, error) {
|
func getFormDesc(db *sqldb.Db, fid string) ([]sqldb.AssRow, error) {
|
||||||
columns := []string{"*"}
|
columns := []string{"*"}
|
||||||
restriction := "id=" + fid
|
restriction := "id=" + fid
|
||||||
@ -208,3 +246,11 @@ func getData(db *sqldb.Db, table string, columns []string, uid string) ([]sqldb.
|
|||||||
dir := ""
|
dir := ""
|
||||||
return db.Table(table).GetAssociativeArray(columns, restriction, sortkeys, dir)
|
return db.Table(table).GetAssociativeArray(columns, restriction, sortkeys, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getTableView(db *sqldb.Db, lvid string) ([]sqldb.AssRow, error) {
|
||||||
|
columns := []string{"*"}
|
||||||
|
restriction := "id=" + lvid
|
||||||
|
sortkeys := []string{}
|
||||||
|
dir := ""
|
||||||
|
return db.Table("dbtableview").GetAssociativeArray(columns, restriction, sortkeys, dir)
|
||||||
|
}
|
||||||
|
@ -9,6 +9,7 @@ CREATE SEQUENCE sq_dbuserrole;
|
|||||||
CREATE SEQUENCE sq_dbentity;
|
CREATE SEQUENCE sq_dbentity;
|
||||||
CREATE SEQUENCE sq_dbform;
|
CREATE SEQUENCE sq_dbform;
|
||||||
CREATE SEQUENCE sq_dbformfields;
|
CREATE SEQUENCE sq_dbformfields;
|
||||||
|
CREATE SEQUENCE sq_dbtableview;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS public.dbrole
|
CREATE TABLE IF NOT EXISTS public.dbrole
|
||||||
(
|
(
|
||||||
@ -60,6 +61,7 @@ CREATE TABLE IF NOT EXISTS public.dbform
|
|||||||
(
|
(
|
||||||
id integer NOT NULL DEFAULT nextval('sq_dbform'),
|
id integer NOT NULL DEFAULT nextval('sq_dbform'),
|
||||||
tablename character varying(255),
|
tablename character varying(255),
|
||||||
|
formtype character varying(255),
|
||||||
formname character varying(255),
|
formname character varying(255),
|
||||||
title character varying(255),
|
title character varying(255),
|
||||||
header character varying(2000),
|
header character varying(2000),
|
||||||
@ -76,12 +78,31 @@ CREATE TABLE IF NOT EXISTS public.dbformfields
|
|||||||
label character varying(255),
|
label character varying(255),
|
||||||
placeholder character varying(255),
|
placeholder character varying(255),
|
||||||
defaultvalue character varying(255),
|
defaultvalue character varying(255),
|
||||||
linkcolumns character varying(255),
|
linkcolumns character varying(1000),
|
||||||
linkrestriction character varying(255),
|
linkrestriction character varying(255),
|
||||||
linkorder character varying(255),
|
linkorder character varying(255),
|
||||||
required bool,
|
required bool,
|
||||||
description text,
|
description text,
|
||||||
|
readonly bool,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public.dbtableview
|
||||||
|
(
|
||||||
|
id integer NOT NULL DEFAULT nextval('sq_dbtableview'),
|
||||||
|
form_id integer,
|
||||||
|
tablename character varying(255),
|
||||||
|
tableviewtype character varying(255),
|
||||||
|
title character varying(255),
|
||||||
|
header character varying(2000),
|
||||||
|
tablecolumns character varying(2000),
|
||||||
|
tablerestriction character varying(255),
|
||||||
|
tableorder character varying(255),
|
||||||
|
tableorderdir character varying(255),
|
||||||
|
required bool,
|
||||||
|
description text,
|
||||||
PRIMARY KEY (id)
|
PRIMARY KEY (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
END;
|
END;
|
@ -2,7 +2,6 @@
|
|||||||
-- Please log an issue at https://redmine.postgresql.org/projects/pgadmin4/issues/new if you find any bugs, including reproduction steps.
|
-- Please log an issue at https://redmine.postgresql.org/projects/pgadmin4/issues/new if you find any bugs, including reproduction steps.
|
||||||
BEGIN;
|
BEGIN;
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS public.axis
|
CREATE TABLE IF NOT EXISTS public.axis
|
||||||
(
|
(
|
||||||
id SERIAL,
|
id SERIAL,
|
||||||
@ -11,7 +10,6 @@ CREATE TABLE IF NOT EXISTS public.axis
|
|||||||
PRIMARY KEY (id)
|
PRIMARY KEY (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS public.employee
|
CREATE TABLE IF NOT EXISTS public.employee
|
||||||
(
|
(
|
||||||
id SERIAL,
|
id SERIAL,
|
||||||
@ -52,20 +50,64 @@ CREATE TABLE IF NOT EXISTS public.project
|
|||||||
PRIMARY KEY (id)
|
PRIMARY KEY (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public.metric
|
||||||
|
(
|
||||||
|
id SERIAL,
|
||||||
|
name character varying(255),
|
||||||
|
entity_id integer,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public.metricvalue
|
||||||
|
(
|
||||||
|
id SERIAL,
|
||||||
|
measuredate date,
|
||||||
|
intvalue integer,
|
||||||
|
floatvalue float,
|
||||||
|
metric_id integer,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public.position
|
||||||
|
(
|
||||||
|
id SERIAL,
|
||||||
|
reference character varying(255),
|
||||||
|
label character varying(255),
|
||||||
|
latitude float,
|
||||||
|
longitude float,
|
||||||
|
metric_id integer,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public.action
|
||||||
|
(
|
||||||
|
id SERIAL,
|
||||||
|
status character varying(255),
|
||||||
|
position_id integer,
|
||||||
|
machine_id integer,
|
||||||
|
description character varying(255),
|
||||||
|
priority integer,
|
||||||
|
driver_dbuser_id integer,
|
||||||
|
actor_dbuser_id integer,
|
||||||
|
creationdate date,
|
||||||
|
planneddate date,
|
||||||
|
closingdate date,
|
||||||
|
comment character varying(1000),
|
||||||
|
verified boolean,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
ALTER TABLE public.axis
|
ALTER TABLE public.axis
|
||||||
ADD FOREIGN KEY (entity_id)
|
ADD FOREIGN KEY (entity_id)
|
||||||
REFERENCES public.entity (id)
|
REFERENCES public.entity (id)
|
||||||
NOT VALID;
|
NOT VALID;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ALTER TABLE public.employee
|
ALTER TABLE public.employee
|
||||||
ADD FOREIGN KEY (dbuser_id)
|
ADD FOREIGN KEY (dbuser_id)
|
||||||
REFERENCES public.dbuser (id)
|
REFERENCES public.dbuser (id)
|
||||||
NOT VALID;
|
NOT VALID;
|
||||||
|
|
||||||
|
|
||||||
ALTER TABLE public.project
|
ALTER TABLE public.project
|
||||||
ADD FOREIGN KEY (entity_id)
|
ADD FOREIGN KEY (entity_id)
|
||||||
REFERENCES public.entity (id)
|
REFERENCES public.entity (id)
|
||||||
|
@ -7,6 +7,7 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- ./autoload:/docker-entrypoint-initdb.d
|
- ./autoload:/docker-entrypoint-initdb.d
|
||||||
|
- /opt/data/containers/sqldb/pgdata:/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: test
|
POSTGRES_DB: test
|
||||||
POSTGRES_USER: test
|
POSTGRES_USER: test
|
||||||
@ -19,3 +20,16 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- 8888:8080
|
- 8888:8080
|
||||||
|
|
||||||
|
grafana:
|
||||||
|
image: grafana/grafana:9.5.12
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
GF_SMTP_ENABLED: "true"
|
||||||
|
GF_SMTP_HOST: "smtp.example.com"
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
volumes:
|
||||||
|
- /opt/data/containers/sqldb/grafana:/var/lib/grafana
|
||||||
|
depends_on:
|
||||||
|
- pg
|
Binary file not shown.
Before Width: | Height: | Size: 665 B |
Binary file not shown.
Before Width: | Height: | Size: 628 B |
@ -1,60 +0,0 @@
|
|||||||
<!-- HTML for static distribution bundle build -->
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Swagger UI</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
|
|
||||||
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
|
||||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
|
||||||
<style>
|
|
||||||
html
|
|
||||||
{
|
|
||||||
box-sizing: border-box;
|
|
||||||
overflow: -moz-scrollbars-vertical;
|
|
||||||
overflow-y: scroll;
|
|
||||||
}
|
|
||||||
|
|
||||||
*,
|
|
||||||
*:before,
|
|
||||||
*:after
|
|
||||||
{
|
|
||||||
box-sizing: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
body
|
|
||||||
{
|
|
||||||
margin:0;
|
|
||||||
background: #fafafa;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<div id="swagger-ui"></div>
|
|
||||||
|
|
||||||
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
|
|
||||||
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
|
|
||||||
<script>
|
|
||||||
window.onload = function() {
|
|
||||||
// Begin Swagger UI call region
|
|
||||||
const ui = SwaggerUIBundle({
|
|
||||||
url: "https://petstore.swagger.io/v2/swagger.json",
|
|
||||||
dom_id: '#swagger-ui',
|
|
||||||
deepLinking: true,
|
|
||||||
presets: [
|
|
||||||
SwaggerUIBundle.presets.apis,
|
|
||||||
SwaggerUIStandalonePreset
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
SwaggerUIBundle.plugins.DownloadUrl
|
|
||||||
],
|
|
||||||
layout: "StandaloneLayout"
|
|
||||||
});
|
|
||||||
// End Swagger UI call region
|
|
||||||
|
|
||||||
window.ui = ui;
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,79 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html lang="en-US">
|
|
||||||
<head>
|
|
||||||
<title>Swagger UI: OAuth2 Redirect</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script>
|
|
||||||
'use strict';
|
|
||||||
function run () {
|
|
||||||
var oauth2 = window.opener.swaggerUIRedirectOauth2;
|
|
||||||
var sentState = oauth2.state;
|
|
||||||
var redirectUrl = oauth2.redirectUrl;
|
|
||||||
var isValid, qp, arr;
|
|
||||||
|
|
||||||
if (/code|token|error/.test(window.location.hash)) {
|
|
||||||
qp = window.location.hash.substring(1);
|
|
||||||
} else {
|
|
||||||
qp = location.search.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
arr = qp.split("&");
|
|
||||||
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
|
|
||||||
qp = qp ? JSON.parse('{' + arr.join() + '}',
|
|
||||||
function (key, value) {
|
|
||||||
return key === "" ? value : decodeURIComponent(value);
|
|
||||||
}
|
|
||||||
) : {};
|
|
||||||
|
|
||||||
isValid = qp.state === sentState;
|
|
||||||
|
|
||||||
if ((
|
|
||||||
oauth2.auth.schema.get("flow") === "accessCode" ||
|
|
||||||
oauth2.auth.schema.get("flow") === "authorizationCode" ||
|
|
||||||
oauth2.auth.schema.get("flow") === "authorization_code"
|
|
||||||
) && !oauth2.auth.code) {
|
|
||||||
if (!isValid) {
|
|
||||||
oauth2.errCb({
|
|
||||||
authId: oauth2.auth.name,
|
|
||||||
source: "auth",
|
|
||||||
level: "warning",
|
|
||||||
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qp.code) {
|
|
||||||
delete oauth2.state;
|
|
||||||
oauth2.auth.code = qp.code;
|
|
||||||
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
|
||||||
} else {
|
|
||||||
let oauthErrorMsg;
|
|
||||||
if (qp.error) {
|
|
||||||
oauthErrorMsg = "["+qp.error+"]: " +
|
|
||||||
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
|
|
||||||
(qp.error_uri ? "More info: "+qp.error_uri : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
oauth2.errCb({
|
|
||||||
authId: oauth2.auth.name,
|
|
||||||
source: "auth",
|
|
||||||
level: "error",
|
|
||||||
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
|
|
||||||
}
|
|
||||||
window.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (document.readyState !== 'loading') {
|
|
||||||
run();
|
|
||||||
} else {
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
|
||||||
run();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
{"/home/yves/Documents/code/go/sqldb-ws/controllers":1652773494349305287,"/home/yves/code/go/sqldb-ws/controllers":1638799919866497768}
|
|
@ -7,6 +7,33 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["sqldb-ws/controllers:HelperController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:HelperController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "CreateTable",
|
||||||
|
Router: `/create`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["sqldb-ws/controllers:HelperController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:HelperController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "ParseHeader",
|
||||||
|
Router: `/header`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["sqldb-ws/controllers:HelperController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:HelperController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "Import",
|
||||||
|
Router: `/import/:table`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["sqldb-ws/controllers:LoginController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:LoginController"],
|
beego.GlobalControllerRouter["sqldb-ws/controllers:LoginController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:LoginController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "AddUser",
|
Method: "AddUser",
|
||||||
@ -127,7 +154,7 @@ func init() {
|
|||||||
beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"],
|
beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetEmptyForm",
|
Method: "GetEmptyForm",
|
||||||
Router: `/:fid`,
|
Router: `/form/:fid`,
|
||||||
AllowHTTPMethods: []string{"get"},
|
AllowHTTPMethods: []string{"get"},
|
||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Filters: nil,
|
Filters: nil,
|
||||||
@ -136,7 +163,7 @@ func init() {
|
|||||||
beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"],
|
beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetEditForm",
|
Method: "GetEditForm",
|
||||||
Router: `/:fid/:uid`,
|
Router: `/form/:fid/:uid`,
|
||||||
AllowHTTPMethods: []string{"get"},
|
AllowHTTPMethods: []string{"get"},
|
||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Filters: nil,
|
Filters: nil,
|
||||||
@ -145,10 +172,19 @@ func init() {
|
|||||||
beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"],
|
beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "PostAccessForm",
|
Method: "PostAccessForm",
|
||||||
Router: `/:uid`,
|
Router: `/form/:fid/:uid`,
|
||||||
AllowHTTPMethods: []string{"post"},
|
AllowHTTPMethods: []string{"post"},
|
||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"] = append(beego.GlobalControllerRouter["sqldb-ws/controllers:UiController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetListView",
|
||||||
|
Router: `/tableview/:tvid`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,11 @@ func init() {
|
|||||||
&controllers.UiController{},
|
&controllers.UiController{},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
beego.NSNamespace("/helper",
|
||||||
|
beego.NSInclude(
|
||||||
|
&controllers.HelperController{},
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
beego.AddNamespace(ns)
|
beego.AddNamespace(ns)
|
||||||
|
|
||||||
|
@ -15,6 +15,87 @@
|
|||||||
},
|
},
|
||||||
"basePath": "/v1",
|
"basePath": "/v1",
|
||||||
"paths": {
|
"paths": {
|
||||||
|
"/helper/create": {
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"helper"
|
||||||
|
],
|
||||||
|
"description": "Post raw header\n\u003cbr\u003e",
|
||||||
|
"operationId": "HelperController.CreateTable",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "body",
|
||||||
|
"name": "body",
|
||||||
|
"description": "body of jsonform data",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/form"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{string} success !"
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "query error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/helper/header": {
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"helper"
|
||||||
|
],
|
||||||
|
"description": "Post raw header\n\u003cbr\u003e",
|
||||||
|
"operationId": "HelperController.ParseHeader",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "body",
|
||||||
|
"name": "body",
|
||||||
|
"description": "body of jsonform data",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/form"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{string} success !"
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "query error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/helper/import/{table}": {
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"helper"
|
||||||
|
],
|
||||||
|
"description": "Post raw header\n\u003cbr\u003e",
|
||||||
|
"operationId": "HelperController.Import",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "body",
|
||||||
|
"name": "body",
|
||||||
|
"description": "body of jsonform data",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/form"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "{string} success !"
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "query error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/l/adduser": {
|
"/l/adduser": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@ -437,7 +518,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/ui/{fid}": {
|
"/ui/form/{fid}": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"ui"
|
"ui"
|
||||||
@ -463,7 +544,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/ui/{fid}/{uid}": {
|
"/ui/form/{fid}/{uid}": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"ui"
|
"ui"
|
||||||
@ -494,9 +575,7 @@
|
|||||||
"description": "body is empty"
|
"description": "body is empty"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
|
||||||
"/ui/{uid}": {
|
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
"ui"
|
"ui"
|
||||||
@ -504,6 +583,13 @@
|
|||||||
"description": "insert access\n\u003cbr\u003e",
|
"description": "insert access\n\u003cbr\u003e",
|
||||||
"operationId": "UiController.Access form data post",
|
"operationId": "UiController.Access form data post",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "fid",
|
||||||
|
"description": "The fid of the form",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"name": "uid",
|
"name": "uid",
|
||||||
@ -529,6 +615,32 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/ui/tableview/{tvid}": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"ui"
|
||||||
|
],
|
||||||
|
"description": "Get table view\n\u003cbr\u003e",
|
||||||
|
"operationId": "UiController.Tableview",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "path",
|
||||||
|
"name": "tvid",
|
||||||
|
"description": "The id of the tableview",
|
||||||
|
"required": true,
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "json form"
|
||||||
|
},
|
||||||
|
"403": {
|
||||||
|
"description": "body is empty"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
@ -569,6 +681,10 @@
|
|||||||
{
|
{
|
||||||
"name": "ui",
|
"name": "ui",
|
||||||
"description": "Operations about table\n"
|
"description": "Operations about table\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "helper",
|
||||||
|
"description": "Operations about schema\n"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -12,6 +12,63 @@ info:
|
|||||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
basePath: /v1
|
basePath: /v1
|
||||||
paths:
|
paths:
|
||||||
|
/helper/create:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- helper
|
||||||
|
description: |-
|
||||||
|
Post raw header
|
||||||
|
<br>
|
||||||
|
operationId: HelperController.CreateTable
|
||||||
|
parameters:
|
||||||
|
- in: body
|
||||||
|
name: body
|
||||||
|
description: body of jsonform data
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/form'
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{string} success !'
|
||||||
|
"500":
|
||||||
|
description: query error
|
||||||
|
/helper/header:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- helper
|
||||||
|
description: |-
|
||||||
|
Post raw header
|
||||||
|
<br>
|
||||||
|
operationId: HelperController.ParseHeader
|
||||||
|
parameters:
|
||||||
|
- in: body
|
||||||
|
name: body
|
||||||
|
description: body of jsonform data
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/form'
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{string} success !'
|
||||||
|
"500":
|
||||||
|
description: query error
|
||||||
|
/helper/import/{table}:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- helper
|
||||||
|
description: |-
|
||||||
|
Post raw header
|
||||||
|
<br>
|
||||||
|
operationId: HelperController.Import
|
||||||
|
parameters:
|
||||||
|
- in: body
|
||||||
|
name: body
|
||||||
|
description: body of jsonform data
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/form'
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: '{string} success !'
|
||||||
|
"500":
|
||||||
|
description: query error
|
||||||
/l/adduser:
|
/l/adduser:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
@ -319,7 +376,7 @@ paths:
|
|||||||
description: '{string} success !'
|
description: '{string} success !'
|
||||||
"403":
|
"403":
|
||||||
description: no table
|
description: no table
|
||||||
/ui/{fid}:
|
/ui/form/{fid}:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- ui
|
- ui
|
||||||
@ -338,7 +395,7 @@ paths:
|
|||||||
description: json form
|
description: json form
|
||||||
"403":
|
"403":
|
||||||
description: body is empty
|
description: body is empty
|
||||||
/ui/{fid}/{uid}:
|
/ui/form/{fid}/{uid}:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- ui
|
- ui
|
||||||
@ -362,7 +419,6 @@ paths:
|
|||||||
description: json form
|
description: json form
|
||||||
"403":
|
"403":
|
||||||
description: body is empty
|
description: body is empty
|
||||||
/ui/{uid}:
|
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- ui
|
- ui
|
||||||
@ -371,6 +427,11 @@ paths:
|
|||||||
<br>
|
<br>
|
||||||
operationId: UiController.Access form data post
|
operationId: UiController.Access form data post
|
||||||
parameters:
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: fid
|
||||||
|
description: The fid of the form
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
- in: path
|
- in: path
|
||||||
name: uid
|
name: uid
|
||||||
description: The uid you want to edit
|
description: The uid you want to edit
|
||||||
@ -386,6 +447,25 @@ paths:
|
|||||||
description: json
|
description: json
|
||||||
"403":
|
"403":
|
||||||
description: body is empty
|
description: body is empty
|
||||||
|
/ui/tableview/{tvid}:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- ui
|
||||||
|
description: |-
|
||||||
|
Get table view
|
||||||
|
<br>
|
||||||
|
operationId: UiController.Tableview
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: tvid
|
||||||
|
description: The id of the tableview
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: json form
|
||||||
|
"403":
|
||||||
|
description: body is empty
|
||||||
definitions:
|
definitions:
|
||||||
Credential:
|
Credential:
|
||||||
title: Credential
|
title: Credential
|
||||||
@ -415,3 +495,6 @@ tags:
|
|||||||
- name: ui
|
- name: ui
|
||||||
description: |
|
description: |
|
||||||
Operations about table
|
Operations about table
|
||||||
|
- name: helper
|
||||||
|
description: |
|
||||||
|
Operations about schema
|
||||||
|
Loading…
Reference in New Issue
Block a user