mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/stashapp/stash/pkg/manager/config"
|
|
"github.com/stashapp/stash/pkg/models"
|
|
"github.com/stashapp/stash/pkg/utils"
|
|
)
|
|
|
|
func (r *queryResolver) Configuration(ctx context.Context) (*models.ConfigResult, error) {
|
|
return makeConfigResult(), nil
|
|
}
|
|
|
|
func (r *queryResolver) Directories(ctx context.Context, path *string) ([]string, error) {
|
|
var dirPath = ""
|
|
if path != nil {
|
|
dirPath = *path
|
|
}
|
|
return utils.ListDir(dirPath), nil
|
|
}
|
|
|
|
func makeConfigResult() *models.ConfigResult {
|
|
return &models.ConfigResult{
|
|
General: makeConfigGeneralResult(),
|
|
Interface: makeConfigInterfaceResult(),
|
|
}
|
|
}
|
|
|
|
func makeConfigGeneralResult() *models.ConfigGeneralResult {
|
|
return &models.ConfigGeneralResult{
|
|
Stashes: config.GetStashPaths(),
|
|
DatabasePath: config.GetDatabasePath(),
|
|
GeneratedPath: config.GetGeneratedPath(),
|
|
Username: config.GetUsername(),
|
|
Password: config.GetPasswordHash(),
|
|
}
|
|
}
|
|
|
|
func makeConfigInterfaceResult() *models.ConfigInterfaceResult {
|
|
css := config.GetCSS()
|
|
cssEnabled := config.GetCSSEnabled()
|
|
return &models.ConfigInterfaceResult{
|
|
CSS: &css,
|
|
CSSEnabled: &cssEnabled,
|
|
}
|
|
}
|