diff --git a/csharp/App/Backend/Controller.cs b/csharp/App/Backend/Controller.cs index 2c54fd319..ca7deabb2 100644 --- a/csharp/App/Backend/Controller.cs +++ b/csharp/App/Backend/Controller.cs @@ -5,7 +5,7 @@ using InnovEnergy.App.Backend.Relations; using InnovEnergy.Lib.Utils; using Microsoft.AspNetCore.Mvc; -namespace InnovEnergy.App.Backend.Controllers; +namespace InnovEnergy.App.Backend; using Token = String; @@ -81,7 +81,9 @@ public class Controller : ControllerBase if (installation is null || !user.HasAccessTo(installation)) return Unauthorized(); - return installation.FillOrderNumbers().HideParentIfUserHasNoAccessToParent(user); + return installation + .FillOrderNumbers() + .HideParentIfUserHasNoAccessToParent(user); } [HttpGet(nameof(GetUsersWithDirectAccessToInstallation))] diff --git a/csharp/App/Backend/DataTypes/Installation.cs b/csharp/App/Backend/DataTypes/Installation.cs index 4a01de8dc..428ce3dbe 100644 --- a/csharp/App/Backend/DataTypes/Installation.cs +++ b/csharp/App/Backend/DataTypes/Installation.cs @@ -15,8 +15,9 @@ public class Installation : TreeNode public Double Lat { get; set; } public Double Long { get; set; } - public String S3Bucket { get; set; } = ""; - public String S3KeySecret { get; set; } = ""; - - + public String S3Bucket { get; set; } = ""; + public String S3Region { get; set; } = ""; + public String S3Provider { get; set; } = ""; + public String S3Key { get; set; } = ""; + public String S3Secret { get; set; } = ""; } \ No newline at end of file diff --git a/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs b/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs new file mode 100644 index 000000000..50be5aafb --- /dev/null +++ b/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs @@ -0,0 +1,48 @@ +using CliWrap; +using CliWrap.Buffered; +using InnovEnergy.Lib.Utils; + +namespace InnovEnergy.App.Backend.DataTypes.Methods; + +public static class ExoCmd +{ + private static readonly Command Exo = Cli.Wrap("exo"); + private const String ConfigFile = "./exoscale.toml"; + + public static async Task<(String key, String secret)> CreateKey(this Installation installation) + { + //if (installation.Id != 1) return "help"; //Todo remove me I am for debugging + + var preParse = await Exo + .WithArguments("iam access-key create " + installation.BucketName() + + " --operation get-sos-object" + + " --resource sos/bucket:" + installation.BucketName() + + " -C " + ConfigFile + + " -O text") + .ExecuteBufferedAsync(); + + var key = preParse.StandardOutput.Split("\t")[2]; + var secret = preParse.StandardOutput.Split("\t")[3]; + + return (key, secret); + + //return $"{key};{secret}"; + } + + public static async void RevokeKey(this Installation installation) + { + try + { + await Exo + .WithArguments("iam access-key revoke " + installation.S3Key + " -f " + " -C " + ConfigFile) + .ExecuteAsync(); + + } + catch + { + // TODO + ("Failed to revoke key for installation " + installation.Name).WriteLine(); + } + } + +} \ No newline at end of file diff --git a/csharp/App/Backend/DataTypes/Methods/Installation.cs b/csharp/App/Backend/DataTypes/Methods/Installation.cs index f3c89995d..92ca2a4c7 100644 --- a/csharp/App/Backend/DataTypes/Methods/Installation.cs +++ b/csharp/App/Backend/DataTypes/Methods/Installation.cs @@ -1,5 +1,3 @@ -using CliWrap; -using CliWrap.Buffered; using InnovEnergy.App.Backend.Database; using InnovEnergy.App.Backend.S3; using InnovEnergy.Lib.Utils; @@ -19,7 +17,11 @@ public static class InstallationMethods public static async Task RenewS3BucketUrl(this Installation installation) { installation.RevokeKey(); - installation.S3KeySecret = await installation.CreateKey(); + var (key, secret) = await installation.CreateKey(); + + installation.S3Key = key; + installation.S3Secret = secret; + return Db.Update(installation); } @@ -124,41 +126,4 @@ public static class InstallationMethods return installation; } -} - -public static class ExoCmd -{ - private static readonly Command Exo = Cli.Wrap("exo"); - private static String ConfigFile = "./exoscale.toml"; - - public static async Task CreateKey(this Installation installation) - { - if (installation.Id != 1) return "help"; //Todo remove me I am for debugging - var preParse = await Exo - .WithArguments("iam access-key create " + installation.BucketName() - + " --operation get-sos-object" - + " --resource sos/bucket:" + installation.BucketName() - + " -C " + ConfigFile - + " -O text") - .ExecuteBufferedAsync(); - - return preParse.StandardOutput.Split("\t")[2] + ";" + preParse.StandardOutput.Split("\t")[3]; - } - - public static async void RevokeKey(this Installation installation) - { - try - { - await Exo - .WithArguments("iam access-key revoke " + installation.S3KeySecret.Split(";", 2)[0] + " -f " + " -C " + ConfigFile) - .ExecuteAsync(); - - } - catch - { - // todo Fill me there is no key for this installation - } - } - -} - +} \ No newline at end of file diff --git a/csharp/App/Backend/db.sqlite b/csharp/App/Backend/db.sqlite index b553a5903..629857e5c 100644 Binary files a/csharp/App/Backend/db.sqlite and b/csharp/App/Backend/db.sqlite differ diff --git a/typescript/Frontend/lang/de.json b/typescript/Frontend/lang/de.json new file mode 100644 index 000000000..903777cdf --- /dev/null +++ b/typescript/Frontend/lang/de.json @@ -0,0 +1,136 @@ +{ + "Information": { + "defaultMessage": "Information" + }, + "addNewChild": { + "defaultMessage": "Neues Kind hinzufügen" + }, + "addNewDialogButton": { + "defaultMessage": "Neue Dialogschaltfläche hinzufügen" + }, + "addUser": { + "defaultMessage": "Nutzer erstellen" + }, + "alarms": { + "defaultMessage": "Alarme" + }, + "applyChanges": { + "defaultMessage": "Änderungen speichern" + }, + "country": { + "defaultMessage": "Land" + }, + "createNewFolder": { + "defaultMessage": "Neuen Ordner erstellen" + }, + "createNewUser": { + "defaultMessage": "Neuen Nutzer erstellen" + }, + "customerName": { + "defaultMessage": "Kundenname" + }, + "email": { + "defaultMessage": "Email" + }, + "english": { + "defaultMessage": "Englisch" + }, + "error": { + }, + "folder": { + "defaultMessage": "Ordner" + }, + "german": { + "defaultMessage": "Deutsch" + }, + "groupTabs": { + "defaultMessage": "Gruppen" + }, + "groupTree": { + "defaultMessage": "Gruppenbaum" + }, + "information": { + "defaultMessage": "Information" + }, + "inheritedAccess": { + "defaultMessage": "Vererbter Zugriff von" + }, + "installation": { + "defaultMessage": "Installation" + }, + "installationTabs": { + "defaultMessage": "Installationen" + }, + "installations": { + "defaultMessage": "Installationen" + }, + "lastWeek": { + "defaultMessage": "Letzte Woche" + }, + "location": { + "defaultMessage": "Standort" + }, + "log": { + "defaultMessage": "Logbuch" + }, + "logout": { + "defaultMessage": "Abmelden" + }, + "makeASelection": { + "defaultMessage": "Bitte wählen Sie links eine Auswahl" + }, + "manageAccess": { + "defaultMessage": "Zugriff verwalten" + }, + "move": { + "defaultMessage": "Verschieben" + }, + "moveTo": { + "defaultMessage": "Verschieben zu" + }, + "moveTree": { + "defaultMessage": "Baum verschieben" + }, + "name": { + "defaultMessage": "Name" + }, + "navigationTabs": { + "defaultMessage": "Navigation" + }, + "orderNumbers": { + "defaultMessage": "Bestellnummer" + }, + "region": { + "defaultMessage": "Region" + }, + "requiredLocation": { + "defaultMessage": "Standort ist erforderlich" + }, + "requiredName": { + "defaultMessage": "Name ist erforderlich" + }, + "requiredRegion": { + "defaultMessage": "Region ist erforderlich" + }, + "search": { + "defaultMessage": "Suche" + }, + "submit": { + "defaultMessage": "Senden" + }, + "updateFolderErrorMessage": { + "defaultMessage": "Fehler, Ordner kann nicht aktualisiert werden" + }, + "updatedSuccessfully": { + "defaultMessage": "Erfolgreich aktualisiert" + }, + "user": { + "defaultMessage": "Nutzer" + }, + "userTabs": { + "defaultMessage": "Nutzer" + }, + "users": { + "defaultMessage": "Nutzer" + } +} diff --git a/typescript/Frontend/lang/fr.json b/typescript/Frontend/lang/fr.json new file mode 100644 index 000000000..a1178e87d --- /dev/null +++ b/typescript/Frontend/lang/fr.json @@ -0,0 +1,136 @@ +{ + "Information": { + "defaultMessage": "Informations" + }, + "addNewChild": { + "defaultMessage": "Ajouter un nouvel enfant" + }, + "addNewDialogButton": { + "defaultMessage": "Ajouter un nouveau bouton de dialogue" + }, + "addUser": { + "defaultMessage": "Créer un utilisateur" + }, + "alarms": { + "defaultMessage": "Alarmes" + }, + "applyChanges": { + "defaultMessage": "Appliquer les modifications" + }, + "country": { + "defaultMessage": "Pays" + }, + "createNewFolder": { + "defaultMessage": "Créer un nouveau dossier" + }, + "createNewUser": { + "defaultMessage": "Créer un nouvel utilisateur" + }, + "customerName": { + "defaultMessage": "Nom du client" + }, + "email": { + "defaultMessage": "E-mail" + }, + "english": { + "defaultMessage": "Anglais" + }, + "error": { + }, + "folder": { + "defaultMessage": "Dossier" + }, + "german": { + "defaultMessage": "Allemand" + }, + "groupTabs": { + "defaultMessage": "Onglets de groupe" + }, + "groupTree": { + "defaultMessage": "Arbre de groupe" + }, + "information": { + "defaultMessage": "Informations" + }, + "inheritedAccess": { + "defaultMessage": "Accès hérité de" + }, + "installation": { + "defaultMessage": "Installation" + }, + "installationTabs": { + "defaultMessage": "Onglets d'installation" + }, + "installations": { + "defaultMessage": "Installations" + }, + "lastWeek": { + "defaultMessage": "La semaine dernière" + }, + "location": { + "defaultMessage": "Localisation" + }, + "log": { + "defaultMessage": "Journal" + }, + "logout": { + "defaultMessage": "Déconnexion" + }, + "makeASelection": { + "defaultMessage": "Veuillez faire une sélection à gauche" + }, + "manageAccess": { + "defaultMessage": "Gérer l'accès" + }, + "move": { + "defaultMessage": "Déplacer" + }, + "moveTo": { + "defaultMessage": "Déplacer à" + }, + "moveTree": { + "defaultMessage": "Déplacer l'arbre" + }, + "name": { + "defaultMessage": "Nom" + }, + "navigationTabs": { + "defaultMessage": "Onglets de navigation" + }, + "orderNumbers": { + "defaultMessage": "Numéro de commande" + }, + "region": { + "defaultMessage": "Région" + }, + "requiredLocation": { + "defaultMessage": "L'emplacement est requis" + }, + "requiredName": { + "defaultMessage": "Le nom est obligatoire" + }, + "requiredRegion": { + "defaultMessage": "La région est obligatoire" + }, + "search": { + "defaultMessage": "Recherche" + }, + "submit": { + "defaultMessage": "Soumettre" + }, + "updateFolderErrorMessage": { + "defaultMessage": "Une erreur s'est produite, impossible de mettre à jour le dossier." + }, + "updatedSuccessfully": { + "defaultMessage": "Mise à jour réussie" + }, + "user": { + "defaultMessage": "Utilisateur" + }, + "userTabs": { + "defaultMessage": "Onglets utilisateurs" + }, + "users": { + "defaultMessage": "Utilisateurs" + } +} diff --git a/typescript/Frontend/src/components/Installations/Log/ScalarGraph.tsx b/typescript/Frontend/src/components/Installations/Log/ScalarGraph.tsx index cebe80296..29cac776e 100644 --- a/typescript/Frontend/src/components/Installations/Log/ScalarGraph.tsx +++ b/typescript/Frontend/src/components/Installations/Log/ScalarGraph.tsx @@ -29,9 +29,8 @@ const s3Access = new S3Access( "saliomameiringen", "sos-ch-dk-2", "exo.io", - "EXO464a9ff62fdfa407aa742855", - "f2KtCWN4EHFqtvH2kotdyI0w5SjjdHVPAADdcD3ik8g", - "" + "EXO464a9ff62fdfa407aa742855", // key + "f2KtCWN4EHFqtvH2kotdyI0w5SjjdHVPAADdcD3ik8g" // secret ); export const fetchData = ( diff --git a/typescript/Frontend/src/dataCache/S3/S3Access.ts b/typescript/Frontend/src/dataCache/S3/S3Access.ts index 6780f0ced..eeb90b795 100644 --- a/typescript/Frontend/src/dataCache/S3/S3Access.ts +++ b/typescript/Frontend/src/dataCache/S3/S3Access.ts @@ -10,8 +10,7 @@ export class S3Access readonly region: string, readonly provider: string, readonly key: string, - readonly secret: string, - readonly contentType: string + readonly secret: string ) {} @@ -46,8 +45,7 @@ export class S3Access s3Path, date, this.key, - this.secret, - this.contentType + this.secret ); } } @@ -58,7 +56,7 @@ function createAuthorizationHeader(method: string, date: string, s3Key: string, s3Secret: string, - contentType: string, + contentType: string = "", md5Hash: string = "") { // StringToSign = HTTP-Verb + "\n" + diff --git a/typescript/Frontend/src/util/types.tsx b/typescript/Frontend/src/util/types.tsx index 139941d49..5b6bfcc25 100644 --- a/typescript/Frontend/src/util/types.tsx +++ b/typescript/Frontend/src/util/types.tsx @@ -11,12 +11,16 @@ export interface I_Installation { orderNumbers: string; lat: number; long: number; - s3Bucket: string; id: number; name: string; information: string; parentId: number; - s3Url: string; + + s3Bucket: string; + s3Region: string; + s3Provider: string; + s3Key: string; + s3Secret: string; } export interface I_Folder {