From 70febafc2bd2531618148707fa486fa947b0f2c2 Mon Sep 17 00:00:00 2001 From: sffetlio Date: Thu, 20 Sep 2018 13:57:03 +0300 Subject: [PATCH] Add Description field to backups --- Duplicati/Server/Database/Backup.cs | 4 ++++ Duplicati/Server/Database/Connection.cs | 23 +++++++++++-------- .../6. Add Description to Backup.sql | 1 + .../Database/Database schema/Schema.sql | 1 + .../Interface/IBackup.cs | 4 ++++ Duplicati/Server/Duplicati.Server.csproj | 3 +++ .../webroot/ngax/templates/addoredit.html | 6 ++++- .../Server/webroot/ngax/templates/home.html | 5 ++++ 8 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 Duplicati/Server/Database/Database schema/6. Add Description to Backup.sql diff --git a/Duplicati/Server/Database/Backup.cs b/Duplicati/Server/Database/Backup.cs index 3317421b2..c3808c004 100644 --- a/Duplicati/Server/Database/Backup.cs +++ b/Duplicati/Server/Database/Backup.cs @@ -57,6 +57,10 @@ namespace Duplicati.Server.Database /// public string Name { get; set; } /// + /// The backup description + /// + public string Description { get; set; } + /// /// The backup tags /// public string[] Tags { get; set; } diff --git a/Duplicati/Server/Database/Connection.cs b/Duplicati/Server/Database/Connection.cs index f2347f20a..3ebd6103d 100644 --- a/Duplicati/Server/Database/Connection.cs +++ b/Duplicati/Server/Database/Connection.cs @@ -293,11 +293,12 @@ namespace Duplicati.Server.Database (rd) => new Backup() { ID = ConvertToInt64(rd, 0).ToString(), Name = ConvertToString(rd, 1), - Tags = (ConvertToString(rd, 2) ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), - TargetURL = ConvertToString(rd, 3), - DBPath = ConvertToString(rd, 4), + Description = ConvertToString(rd, 2), + Tags = (ConvertToString(rd, 3) ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), + TargetURL = ConvertToString(rd, 4), + DBPath = ConvertToString(rd, 5), }, - @"SELECT ""ID"", ""Name"", ""Tags"", ""TargetURL"", ""DBPath"" FROM ""Backup"" WHERE ID = ?", id) + @"SELECT ""ID"", ""Name"", ""Description"", ""Tags"", ""TargetURL"", ""DBPath"" FROM ""Backup"" WHERE ID = ?", id) .FirstOrDefault(); if (bk != null) @@ -506,8 +507,8 @@ namespace Duplicati.Server.Database new object[] { long.Parse(item.ID ?? "-1") }, new IBackup[] { item }, update ? - @"UPDATE ""Backup"" SET ""Name""=?, ""Tags""=?, ""TargetURL""=? WHERE ""ID""=?" : - @"INSERT INTO ""Backup"" (""Name"", ""Tags"", ""TargetURL"", ""DBPath"") VALUES (?,?,?,?)", + @"UPDATE ""Backup"" SET ""Name""=?, ""Description""=?, ""Tags""=?, ""TargetURL""=? WHERE ""ID""=?" : + @"INSERT INTO ""Backup"" (""Name"", ""Description"", ""Tags"", ""TargetURL"", ""DBPath"") VALUES (?,?,?,?,?)", (n) => { if (n.TargetURL.IndexOf(Duplicati.Server.WebServer.Server.PASSWORD_PLACEHOLDER, StringComparison.Ordinal) >= 0) @@ -517,6 +518,7 @@ namespace Duplicati.Server.Database return new object[] { n.Name, + n.Description, string.Join(",", n.Tags ?? new string[0]), n.TargetURL, update ? (object)item.ID : (object)n.DBPath @@ -685,11 +687,12 @@ namespace Duplicati.Server.Database (rd) => (IBackup)new Backup() { ID = ConvertToInt64(rd, 0).ToString(), Name = ConvertToString(rd, 1), - Tags = (ConvertToString(rd, 2) ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), - TargetURL = ConvertToString(rd, 3), - DBPath = ConvertToString(rd, 4), + Description = ConvertToString(rd, 2), + Tags = (ConvertToString(rd, 3) ?? "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), + TargetURL = ConvertToString(rd, 4), + DBPath = ConvertToString(rd, 5), }, - @"SELECT ""ID"", ""Name"", ""Tags"", ""TargetURL"", ""DBPath"" FROM ""Backup"" ") + @"SELECT ""ID"", ""Name"", ""Description"", ""Tags"", ""TargetURL"", ""DBPath"" FROM ""Backup"" ") .ToArray(); foreach(var n in lst) diff --git a/Duplicati/Server/Database/Database schema/6. Add Description to Backup.sql b/Duplicati/Server/Database/Database schema/6. Add Description to Backup.sql new file mode 100644 index 000000000..61e5edeb1 --- /dev/null +++ b/Duplicati/Server/Database/Database schema/6. Add Description to Backup.sql @@ -0,0 +1 @@ +ALTER TABLE "Backup" ADD COLUMN "Description" TEXT NULL; diff --git a/Duplicati/Server/Database/Database schema/Schema.sql b/Duplicati/Server/Database/Database schema/Schema.sql index 6ebd58082..19e526ba0 100644 --- a/Duplicati/Server/Database/Database schema/Schema.sql +++ b/Duplicati/Server/Database/Database schema/Schema.sql @@ -9,6 +9,7 @@ CREATE TABLE "Backup" ( "ID" INTEGER PRIMARY KEY AUTOINCREMENT, "Name" TEXT NOT NULL, + "Description" TEXT NOT NULL, "Tags" TEXT NOT NULL, "TargetURL" TEXT NOT NULL, "DBPath" TEXT NOT NULL diff --git a/Duplicati/Server/Duplicati.Server.Serialization/Interface/IBackup.cs b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IBackup.cs index d857b7f28..e54ed5a9e 100644 --- a/Duplicati/Server/Duplicati.Server.Serialization/Interface/IBackup.cs +++ b/Duplicati/Server/Duplicati.Server.Serialization/Interface/IBackup.cs @@ -34,6 +34,10 @@ namespace Duplicati.Server.Serialization.Interface /// string Name { get; set; } /// + /// The backup description + /// + string Description { get; set; } + /// /// The backup tags /// string[] Tags { get; set; } diff --git a/Duplicati/Server/Duplicati.Server.csproj b/Duplicati/Server/Duplicati.Server.csproj index d956775a8..2f4623991 100644 --- a/Duplicati/Server/Duplicati.Server.csproj +++ b/Duplicati/Server/Duplicati.Server.csproj @@ -319,6 +319,9 @@ + + +