Add testfile for uploading + fixes ui + added translations

This commit is contained in:
Cedric Verstraeten
2023-04-07 21:42:35 +02:00
parent 2925e19b90
commit b0af6b2e2b
12 changed files with 146 additions and 5 deletions
+4 -4
View File
@@ -579,7 +579,9 @@ func VerifyPersistence(c *gin.Context) {
err := c.BindJSON(&config)
if err != nil || config.Cloud != "" {
if config.Cloud == "s3" {
if config.Cloud == "dropbox" {
VerifyDropbox(config, c)
} else if config.Cloud == "s3" {
// timestamp_microseconds_instanceName_regionCoordinates_numberOfChanges_token
// 1564859471_6-474162_oprit_577-283-727-375_1153_27.mp4
@@ -660,9 +662,7 @@ func VerifyPersistence(c *gin.Context) {
})
}
}
}
if config.Cloud == "kstorage" {
} else if config.Cloud == "kstorage" {
uri := config.KStorage.URI
accessKey := config.KStorage.AccessKey
+61 -1
View File
@@ -1,11 +1,14 @@
package cloud
import (
"bytes"
"errors"
"os"
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox"
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/files"
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/users"
"github.com/gin-gonic/gin"
"github.com/kerberos-io/agent/machinery/src/log"
"github.com/kerberos-io/agent/machinery/src/models"
)
@@ -43,7 +46,7 @@ func UploadDropbox(configuration *models.Configuration, fileName string) (bool,
defer file.Close()
}
if err != nil {
if err == nil {
// Upload the file
dbf := files.New(dConfig)
res, err := dbf.Upload(&files.UploadArg{
@@ -69,3 +72,60 @@ func UploadDropbox(configuration *models.Configuration, fileName string) (bool,
return false, true, err
}
}
func VerifyDropbox(config models.Config, c *gin.Context) {
token := config.Dropbox.AccessToken
directory := config.Dropbox.Directory
if directory != "" {
// Check if trailing slash if not we'll add one.
if directory[len(directory)-1:] != "/" {
directory = directory + "/"
}
}
if token != "" {
dConfig := dropbox.Config{
Token: token,
LogLevel: dropbox.LogInfo, // if needed, set the desired logging level. Default is off
}
dbx := users.New(dConfig)
_, err := dbx.GetCurrentAccount()
if err != nil {
c.JSON(400, models.APIResponse{
Data: "Something went wrong while reaching the Dropbox API: " + err.Error(),
})
} else {
// Upload the file
content := TestFile
file := bytes.NewReader(content)
dbf := files.New(dConfig)
_, err := dbf.Upload(&files.UploadArg{
CommitInfo: files.CommitInfo{
Path: "/" + directory + "kerbers-agent-test.mp4",
Mode: &files.WriteMode{
Tagged: dropbox.Tagged{
Tag: "overwrite",
},
},
},
}, file)
if err != nil {
c.JSON(400, models.APIResponse{
Data: "Something went wrong while reaching the Dropbox API: " + err.Error(),
})
} else {
c.JSON(200, models.APIResponse{
Data: "Dropbox is working fine.",
})
}
}
} else {
c.JSON(400, models.APIResponse{
Data: "Dropbox token is not set.",
})
}
}
File diff suppressed because one or more lines are too long
+4
View File
@@ -199,6 +199,10 @@
"kerberosvault_secretkey": "Geheimer Schlüssel",
"kerberosvault_description_secretkey": "Der geheime Schlüssel des Kerberos Vault Accounts.",
"verify_connection": "Verbindung prüfen",
"dropbox_directory": "Directory",
"dropbox_description_directory": "The sub directory where the recordings will be stored in your Dropbox account.",
"dropbox_accesstoken": "Access token",
"dropbox_description_accesstoken": "The access token of your Dropbox account/app.",
"remove_after_upload": "Once recordings are uploaded to some persistence, you might want to remove them from the local Kerberos Agent.",
"remove_after_upload_description": "Remove recordings after they are uploaded successfully.",
"remove_after_upload_enabled": "Enabled delete on upload"
+4
View File
@@ -198,6 +198,10 @@
"kerberosvault_description_accesskey": "The access key of your Kerberos Vault account.",
"kerberosvault_secretkey": "Secret key",
"kerberosvault_description_secretkey": "The secret key of your Kerberos Vault account.",
"dropbox_directory": "Directory",
"dropbox_description_directory": "The sub directory where the recordings will be stored in your Dropbox account.",
"dropbox_accesstoken": "Access token",
"dropbox_description_accesstoken": "The access token of your Dropbox account/app.",
"verify_connection": "Verify Connection",
"remove_after_upload": "Once recordings are uploaded to some persistence, you might want to remove them from the local Kerberos Agent.",
"remove_after_upload_description": "Remove recordings after they are uploaded successfully.",
+4
View File
@@ -198,6 +198,10 @@
"kerberosvault_description_accesskey": "The access key of your Kerberos Vault account.",
"kerberosvault_secretkey": "Secret key",
"kerberosvault_description_secretkey": "The secret key of your Kerberos Vault account.",
"dropbox_directory": "Directory",
"dropbox_description_directory": "The sub directory where the recordings will be stored in your Dropbox account.",
"dropbox_accesstoken": "Access token",
"dropbox_description_accesstoken": "The access token of your Dropbox account/app.",
"verify_connection": "Verify Connection",
"remove_after_upload": "Once recordings are uploaded to some persistence, you might want to remove them from the local Kerberos Agent.",
"remove_after_upload_description": "Remove recordings after they are uploaded successfully.",
+4
View File
@@ -198,6 +198,10 @@
"kerberosvault_description_accesskey": "La clé d'accès de votre compte Kerberos Vault.",
"kerberosvault_secretkey": "Clé secrète",
"kerberosvault_description_secretkey": "La clé secrète de votre compte Kerberos Vault.",
"dropbox_directory": "Directory",
"dropbox_description_directory": "The sub directory where the recordings will be stored in your Dropbox account.",
"dropbox_accesstoken": "Access token",
"dropbox_description_accesstoken": "The access token of your Dropbox account/app.",
"verify_connection": "Vérifier la connexion",
"remove_after_upload": "Once recordings are uploaded to some persistence, you might want to remove them from the local Kerberos Agent.",
"remove_after_upload_description": "Remove recordings after they are uploaded successfully.",
+4
View File
@@ -198,6 +198,10 @@
"kerberosvault_description_accesskey": "Kerberos Vault アカウントのアクセス キー。",
"kerberosvault_secretkey": "秘密鍵",
"kerberosvault_description_secretkey": "Kerberos Vault アカウントの秘密鍵。",
"dropbox_directory": "Directory",
"dropbox_description_directory": "The sub directory where the recordings will be stored in your Dropbox account.",
"dropbox_accesstoken": "Access token",
"dropbox_description_accesstoken": "The access token of your Dropbox account/app.",
"verify_connection": "接続の確認",
"remove_after_upload": "Once recordings are uploaded to some persistence, you might want to remove them from the local Kerberos Agent.",
"remove_after_upload_description": "Remove recordings after they are uploaded successfully.",
+4
View File
@@ -199,6 +199,10 @@
"kerberosvault_description_accesskey": "De access key van jouw Kerberos Vault account.",
"kerberosvault_secretkey": "Secret key",
"kerberosvault_description_secretkey": "De secret key van jouw Kerberos Vault account.",
"dropbox_directory": "Directory",
"dropbox_description_directory": "The sub directory where the recordings will be stored in your Dropbox account.",
"dropbox_accesstoken": "Access token",
"dropbox_description_accesstoken": "The access token of your Dropbox account/app.",
"verify_connection": "Verifieer verbinding",
"remove_after_upload": "Wanneer opnames opgeslagen zijn, kan je ze verwijderen in de lokale Kerberos Agent.",
"remove_after_upload_description": "Verwijder opnames wanneer ze zijn geupload naar een opslag locatie.",
+4
View File
@@ -198,6 +198,10 @@
"kerberosvault_description_accesskey": "The access key of your Kerberos Vault account.",
"kerberosvault_secretkey": "Secret key",
"kerberosvault_description_secretkey": "The secret key of your Kerberos Vault account.",
"dropbox_directory": "Directory",
"dropbox_description_directory": "The sub directory where the recordings will be stored in your Dropbox account.",
"dropbox_accesstoken": "Access token",
"dropbox_description_accesstoken": "The access token of your Dropbox account/app.",
"verify_connection": "Verify Connection",
"remove_after_upload": "Once recordings are uploaded to some persistence, you might want to remove them from the local Kerberos Agent.",
"remove_after_upload_description": "Remove recordings after they are uploaded successfully.",
+4
View File
@@ -198,6 +198,10 @@
"kerberosvault_description_accesskey": "A chave de acesso da sua conta do Kerberos Vault.",
"kerberosvault_secretkey": "Chave secreta(Secret key)",
"kerberosvault_description_secretkey": "A chave secreta da sua conta do Kerberos Vault.",
"dropbox_directory": "Directory",
"dropbox_description_directory": "The sub directory where the recordings will be stored in your Dropbox account.",
"dropbox_accesstoken": "Access token",
"dropbox_description_accesstoken": "The access token of your Dropbox account/app.",
"verify_connection": "Verificar conexão",
"remove_after_upload": "Once recordings are uploaded to some persistence, you might want to remove them from the local Kerberos Agent.",
"remove_after_upload_description": "Remove recordings after they are uploaded successfully.",
+45
View File
@@ -40,6 +40,8 @@ class Settings extends React.Component {
KERBEROS_HUB = 's3'; // @TODO needs to change
DROPBOX = 'dropbox';
constructor() {
super();
this.state = {
@@ -74,6 +76,10 @@ class Settings extends React.Component {
label: 'Kerberos Vault',
value: this.KERBEROS_VAULT,
},
{
label: 'Dropbox',
value: this.DROPBOX,
},
];
this.tags = {
@@ -95,6 +101,7 @@ class Settings extends React.Component {
'gcp',
'aws',
'minio',
'dropbox',
],
};
this.timezones = [];
@@ -2165,6 +2172,44 @@ class Settings extends React.Component {
/>
</>
)}
{config.cloud === this.DROPBOX && (
<>
<Input
noPadding
label={t('settings.persistence.dropbox_directory')}
placeholder={t(
'settings.persistence.dropbox_description_directory'
)}
value={config.dropbox ? config.dropbox.directory : ''}
onChange={(value) =>
this.onUpdateField(
'dropbox',
'directory',
value,
config.dropbox
)
}
/>
<Input
noPadding
label={t('settings.persistence.dropbox_accesstoken')}
placeholder={t(
'settings.persistence.dropbox_description_accesstoken'
)}
value={
config.dropbox ? config.dropbox.access_token : ''
}
onChange={(value) =>
this.onUpdateField(
'dropbox',
'access_token',
value,
config.dropbox
)
}
/>
</>
)}
</BlockBody>
<BlockFooter>
<Button