Use PAS UI

This commit is contained in:
2025-05-20 20:41:26 +02:00
parent 90f1c4738e
commit 6b8ae2f236
17 changed files with 794 additions and 100 deletions

View File

@@ -23,19 +23,19 @@ import (
)
type CDSView struct {
TechnicalName string `json:"Name"`
DisplayName string `json:"DisplayName"`
Description string `json:"Description"`
Version string `json:"Version"`
State string `json:"State"`
CreatedAt int `json:"CreatedAt"`
ModifiedAt int `json:"ModifiedAt"`
TechnicalName `json:"Name"`
DisplayName `json:"DisplayName"`
Description `json:"Description"`
Version `json:"Version"`
State `json:"State"`
CreatedAt `json:"CreatedAt"`
ModifiedAt `json:"ModifiedAt"`
}
//go:embed sql/query_cds_view.sql
var query_cds_view string
func GetCDSView(TechnicalName string) (*CDSView, error) {
func GetCDSView(TechnicalName TechnicalName) (*CDSView, error) {
row := database.DB.QueryRow(query_cds_view, TechnicalName)
var CDSView CDSView
@@ -50,15 +50,15 @@ func GetCDSView(TechnicalName string) (*CDSView, error) {
//go:embed sql/query_all_cds_view_technical_names.sql
var query_all_cds_view_technical_names string
func QueryAllCDSViewTechnicalNames() (*[]string, error) {
func QueryAllCDSViewTechnicalNames() (*[]TechnicalName, error) {
rows, err := database.DB.Query(query_all_cds_view_technical_names)
if err != nil {
return nil, err
}
var technicalNames []string
var technicalNames []TechnicalName
for rows.Next() {
var technicalName string
var technicalName TechnicalName
err := rows.Scan(&technicalName)
if err != nil {
return nil, err

View File

@@ -23,11 +23,11 @@ import (
)
type CDSViewField struct {
CDSViewTechnicalName string
FieldName string `json:"fieldname"`
Description string `json:"description"`
DataType string `json:"datatype"`
FieldLength string `json:"fieldlength"`
CDSViewTechnicalName TechnicalName
FieldName `json:"fieldname"`
Description `json:"description"`
DataType `json:"datatype"`
FieldLength `json:"fieldlength"`
}
//go:embed sql/query_cds_view_fields.sql
@@ -53,7 +53,7 @@ func GetCDSViewFields(CDSViewTechnicalName string) (*[]CDSViewField, error) {
//go:embed sql/query_cds_view_number_of_fields.sql
var query_cds_view_number_of_fields string
func GetCDSViewNumberOfFields(CDSViewTechnicalName string) (int, error) {
func GetCDSViewNumberOfFields(CDSViewTechnicalName TechnicalName) (int, error) {
rows, err := database.DB.Query(query_cds_view_number_of_fields, CDSViewTechnicalName)
if err != nil {
return 0, err

135
cmd/database/table/field.go Normal file
View File

@@ -0,0 +1,135 @@
package table
import "code.achtarmig.org/pas/ui/field"
// CDS View
type (
TechnicalName string
DisplayName string
Description string
Version string
State string
CreatedAt int
ModifiedAt int
)
// CDS View Field
type (
FieldName string
DataType string
FieldLength string
)
func (t TechnicalName) Info(language string) field.Info {
return field.Info{
Title: "Technical Name",
Details: "Technical Name of the CDS View",
}
}
func (t TechnicalName) String() string {
return string(t)
}
func (t DisplayName) Info(language string) field.Info {
return field.Info{
Title: "Name",
Details: "Name of the CDS View",
}
}
func (t DisplayName) String() string {
return string(t)
}
func (t Description) Info(language string) field.Info {
return field.Info{
Title: "Description",
Details: "Discription",
}
}
func (t Description) String() string {
return string(t)
}
func (t Version) Info(language string) field.Info {
return field.Info{
Title: "Version",
Details: "Version of the CDS View",
Justify: field.JustifyRight,
}
}
func (t Version) String() string {
return string(t)
}
func (t State) Info(language string) field.Info {
return field.Info{
Title: "Release State",
Details: "Release State of the CDS View. Non-Released views may not be used",
}
}
func (t State) String() string {
return string(t)
}
func (t CreatedAt) Info(language string) field.Info {
return field.Info{
Title: "Created At",
Details: "Timestamp of creation of the dataset",
Justify: field.JustifyRight,
}
}
func (t CreatedAt) Int() int {
return int(t)
}
func (t ModifiedAt) Info(language string) field.Info {
return field.Info{
Title: "Modified At",
Details: "Timestamp of last modification of the dataset",
Justify: field.JustifyRight,
}
}
func (t ModifiedAt) Int() int {
return int(t)
}
func (t FieldName) Info(language string) field.Info {
return field.Info{
Title: "Field",
Details: "Name of the CDS View field",
}
}
func (t FieldName) String() string {
return string(t)
}
func (t DataType) Info(language string) field.Info {
return field.Info{
Title: "Type",
Details: "Data type of the CDS View field",
}
}
func (t DataType) String() string {
return string(t)
}
func (t FieldLength) Info(language string) field.Info {
return field.Info{
Title: "Length",
Details: "Length of the CDS View field",
Justify: field.JustifyRight,
}
}
func (t FieldLength) String() string {
return string(t)
}

View File

@@ -23,7 +23,7 @@ import (
)
type Keyword struct {
CDSViewTechnicalName string
CDSViewTechnicalName TechnicalName
Keyword string
}