From 93fc385f0b958cdcf9420ab890f47b6636d75443 Mon Sep 17 00:00:00 2001 From: Uncled1023 Date: Sun, 13 Jan 2019 21:42:13 -0800 Subject: [PATCH] Added separate page for viewing service data. Added ability to delete any service data if logged in. --- Teknik/Areas/Admin/Views/Admin/UploadResult.cshtml | 2 +- Teknik/Areas/Help/Views/Help/API/v1/Upload.cshtml | 2 +- Teknik/Areas/Paste/Controllers/PasteController.cs | 26 ++++ .../Shortener/Controllers/ShortenerController.cs | 18 +++ .../Areas/Upload/Controllers/UploadController.cs | 32 ++++- Teknik/Areas/User/Controllers/UserController.cs | 40 +++++- .../User/ViewModels/ViewServiceDataViewModel.cs | 21 +++ Teknik/Areas/User/Views/User/ViewProfile.cshtml | 145 ------------------- .../Areas/User/Views/User/ViewServiceData.cshtml | 157 +++++++++++++++++++++ Teknik/Areas/User/Views/User/_LoginPartial.cshtml | 3 + Teknik/Areas/Vault/Controllers/VaultController.cs | 4 +- Teknik/Areas/Vault/Views/Vault/ViewVault.cshtml | 2 +- Teknik/Routes.cs | 36 ++++- Teknik/Scripts/User/Profile.js | 68 --------- Teknik/Scripts/User/ViewServiceData.js | 54 +++++++ Teknik/Scripts/Vault/Vault.js | 2 +- Teknik/bundleconfig.json | 7 + 17 files changed, 392 insertions(+), 227 deletions(-) create mode 100644 Teknik/Areas/User/ViewModels/ViewServiceDataViewModel.cs create mode 100644 Teknik/Areas/User/Views/User/ViewServiceData.cshtml create mode 100644 Teknik/Scripts/User/ViewServiceData.js diff --git a/Teknik/Areas/Admin/Views/Admin/UploadResult.cshtml b/Teknik/Areas/Admin/Views/Admin/UploadResult.cshtml index b0bbef9..86695d8 100644 --- a/Teknik/Areas/Admin/Views/Admin/UploadResult.cshtml +++ b/Teknik/Areas/Admin/Views/Admin/UploadResult.cshtml @@ -23,7 +23,7 @@
@{ - string deleteUrl = (string.IsNullOrEmpty(Model.DeleteKey)) ? string.Empty : Url.SubRouteUrl("u", "Upload.Delete", new { file = Model.Url, key = Model.DeleteKey }); + string deleteUrl = (string.IsNullOrEmpty(Model.DeleteKey)) ? string.Empty : Url.SubRouteUrl("u", "Upload.DeleteByKey", new { file = Model.Url, key = Model.DeleteKey }); }

diff --git a/Teknik/Areas/Help/Views/Help/API/v1/Upload.cshtml b/Teknik/Areas/Help/Views/Help/API/v1/Upload.cshtml index 0e0e4aa..fc97bec 100644 --- a/Teknik/Areas/Help/Views/Help/API/v1/Upload.cshtml +++ b/Teknik/Areas/Help/Views/Help/API/v1/Upload.cshtml @@ -306,7 +306,7 @@ Optional - The deletion key for file. Use it as follows: @Url.SubRouteUrl("u", "Upload.Delete", new { file = "file.jpg", key = "deletionKey" }) + The deletion key for file. Use it as follows: @Url.SubRouteUrl("u", "Upload.DeleteByKey", new { file = "file.jpg", key = "deletionKey" }) diff --git a/Teknik/Areas/Paste/Controllers/PasteController.cs b/Teknik/Areas/Paste/Controllers/PasteController.cs index 2ff083b..d448ef3 100644 --- a/Teknik/Areas/Paste/Controllers/PasteController.cs +++ b/Teknik/Areas/Paste/Controllers/PasteController.cs @@ -181,5 +181,31 @@ namespace Teknik.Areas.Paste.Controllers } return View("~/Areas/Paste/Views/Paste/Index.cshtml", model); } + + [HttpPost] + public IActionResult Delete(string id) + { + Models.Paste foundPaste = _dbContext.Pastes.Where(p => p.Url == id).FirstOrDefault(); + if (foundPaste != null) + { + if (foundPaste.User.Username == User.Identity.Name) + { + string filePath = foundPaste.FileName; + // Delete from the DB + _dbContext.Pastes.Remove(foundPaste); + _dbContext.SaveChanges(); + + // Delete the File + if (System.IO.File.Exists(filePath)) + { + System.IO.File.Delete(filePath); + } + + return Json(new { result = true }); + } + return Json(new { error = new { message = "You do not have permission to edit this Paste" } }); + } + return Json(new { error = new { message = "This Paste does not exist" } }); + } } } \ No newline at end of file diff --git a/Teknik/Areas/Shortener/Controllers/ShortenerController.cs b/Teknik/Areas/Shortener/Controllers/ShortenerController.cs index b17f0da..0234112 100644 --- a/Teknik/Areas/Shortener/Controllers/ShortenerController.cs +++ b/Teknik/Areas/Shortener/Controllers/ShortenerController.cs @@ -76,6 +76,24 @@ namespace Teknik.Areas.Shortener.Controllers return Json(new { error = "Must be a valid Url" }); } + [HttpPost] + public IActionResult Delete(string id) + { + ShortenedUrl shortenedUrl = _dbContext.ShortenedUrls.Where(s => s.ShortUrl == id).FirstOrDefault(); + if (shortenedUrl != null) + { + if (shortenedUrl.User.Username == User.Identity.Name) + { + _dbContext.ShortenedUrls.Remove(shortenedUrl); + _dbContext.SaveChanges(); + + return Json(new { result = true }); + } + return Json(new { error = new { message = "You do not have permission to edit this Shortened URL" } }); + } + return Json(new { error = new { message = "This Shortened URL does not exist" } }); + } + [AllowAnonymous] public IActionResult Verify() { diff --git a/Teknik/Areas/Upload/Controllers/UploadController.cs b/Teknik/Areas/Upload/Controllers/UploadController.cs index f280a7e..e296df5 100644 --- a/Teknik/Areas/Upload/Controllers/UploadController.cs +++ b/Teknik/Areas/Upload/Controllers/UploadController.cs @@ -125,7 +125,7 @@ namespace Teknik.Areas.Upload.Controllers _dbContext.SaveChanges(); } } - return Json(new { result = new { name = upload.Url, url = Url.SubRouteUrl("u", "Upload.Download", new { file = upload.Url }), contentType = upload.ContentType, contentLength = StringHelper.GetBytesReadable(upload.ContentLength), deleteUrl = Url.SubRouteUrl("u", "Upload.Delete", new { file = upload.Url, key = upload.DeleteKey }) } }); + return Json(new { result = new { name = upload.Url, url = Url.SubRouteUrl("u", "Upload.Download", new { file = upload.Url }), contentType = upload.ContentType, contentLength = StringHelper.GetBytesReadable(upload.ContentLength), deleteUrl = Url.SubRouteUrl("u", "Upload.DeleteByKey", new { file = upload.Url, key = upload.DeleteKey }) } }); } } return Json(new { error = new { message = "Unable to upload file" } }); @@ -419,7 +419,7 @@ namespace Teknik.Areas.Upload.Controllers [HttpGet] [AllowAnonymous] - public IActionResult Delete(string file, string key) + public IActionResult DeleteByKey(string file, string key) { ViewBag.Title = "File Delete - " + file + " - " + _config.Title; Models.Upload upload = _dbContext.Uploads.Where(up => up.Url == file).FirstOrDefault(); @@ -462,11 +462,37 @@ namespace Teknik.Areas.Upload.Controllers upload.DeleteKey = delKey; _dbContext.Entry(upload).State = EntityState.Modified; _dbContext.SaveChanges(); - return Json(new { result = new { url = Url.SubRouteUrl("u", "Upload.Delete", new { file = file, key = delKey }) } }); + return Json(new { result = new { url = Url.SubRouteUrl("u", "Upload.DeleteByKey", new { file = file, key = delKey }) } }); } return Json(new { error = new { message = "You do not own this upload" } }); } return Json(new { error = new { message = "Invalid URL" } }); } + + [HttpPost] + public IActionResult Delete(string id) + { + Models.Upload foundUpload = _dbContext.Uploads.Where(u => u.Url == id).FirstOrDefault(); + if (foundUpload != null) + { + if (foundUpload.User.Username == User.Identity.Name) + { + string filePath = foundUpload.FileName; + // Delete from the DB + _dbContext.Uploads.Remove(foundUpload); + _dbContext.SaveChanges(); + + // Delete the File + if (System.IO.File.Exists(filePath)) + { + System.IO.File.Delete(filePath); + } + + return Json(new { result = true }); + } + return Json(new { error = new { message = "You do not have permission to edit this Paste" } }); + } + return Json(new { error = new { message = "This Paste does not exist" } }); + } } } diff --git a/Teknik/Areas/User/Controllers/UserController.cs b/Teknik/Areas/User/Controllers/UserController.cs index 5b5aa9b..bf009eb 100644 --- a/Teknik/Areas/User/Controllers/UserController.cs +++ b/Teknik/Areas/User/Controllers/UserController.cs @@ -314,7 +314,45 @@ namespace Teknik.Areas.Users.Controllers } return View(model); } - + + public IActionResult ViewServiceData() + { + string username = User.Identity.Name; + + ViewServiceDataViewModel model = new ViewServiceDataViewModel(); + ViewBag.Title = "User Does Not Exist - " + _config.Title; + ViewBag.Description = "The User does not exist"; + + try + { + User user = UserHelper.GetUser(_dbContext, username); + + if (user != null) + { + ViewBag.Title = "Service Data - " + _config.Title; + ViewBag.Description = "Viewing all of your service data"; + + model.Uploads = _dbContext.Uploads.Where(u => u.UserId == user.UserId).OrderByDescending(u => u.DateUploaded).ToList(); + + model.Pastes = _dbContext.Pastes.Where(u => u.UserId == user.UserId).OrderByDescending(u => u.DatePosted).ToList(); + + model.ShortenedUrls = _dbContext.ShortenedUrls.Where(s => s.UserId == user.UserId).OrderByDescending(s => s.DateAdded).ToList(); + + model.Vaults = _dbContext.Vaults.Where(v => v.UserId == user.UserId).OrderByDescending(v => v.DateCreated).ToList(); + + return View(model); + } + model.Error = true; + model.ErrorMessage = "The user does not exist"; + } + catch (Exception ex) + { + model.Error = true; + model.ErrorMessage = ex.GetFullMessage(true); + } + return View(model); + } + public IActionResult Settings() { return Redirect(Url.SubRouteUrl("user", "User.ProfileSettings")); diff --git a/Teknik/Areas/User/ViewModels/ViewServiceDataViewModel.cs b/Teknik/Areas/User/ViewModels/ViewServiceDataViewModel.cs new file mode 100644 index 0000000..d8fcbdf --- /dev/null +++ b/Teknik/Areas/User/ViewModels/ViewServiceDataViewModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Teknik.ViewModels; + +namespace Teknik.Areas.Users.ViewModels +{ + public class ViewServiceDataViewModel : ViewModelBase + { + public DateTime LastSeen { get; set; } + + public List Uploads { get; set; } + + public List Pastes { get; set; } + + public List ShortenedUrls { get; set; } + + public List Vaults { get; set; } + } +} diff --git a/Teknik/Areas/User/Views/User/ViewProfile.cshtml b/Teknik/Areas/User/Views/User/ViewProfile.cshtml index 779d311..9f6bed1 100644 --- a/Teknik/Areas/User/Views/User/ViewProfile.cshtml +++ b/Teknik/Areas/User/Views/User/ViewProfile.cshtml @@ -2,11 +2,6 @@ @using Teknik.Utilities.Cryptography - -
@if (!Model.Error) { @@ -129,147 +124,7 @@
@if (OwnProfile) { - -
-
@Html.Markdown(@Model.UserSettings.About)
-
- @if (OwnProfile) - { -
- @foreach (Teknik.Areas.Upload.Models.Upload upload in Model.Uploads) - { -
- -
-
- -

@StringHelper.GetBytesReadable(upload.ContentLength)

-
-
- -

@upload.ContentType

-
-
- -

-
-
- -

@upload.Downloads

-
-
- @{ - string deleteUrl = (string.IsNullOrEmpty(upload.DeleteKey)) ? string.Empty : Url.SubRouteUrl("u", "Upload.Delete", new { file = upload.Url, key = upload.DeleteKey }); - } -

-
-
-
- } -
-
- @foreach (Teknik.Areas.Paste.Models.Paste paste in Model.Pastes) - { -
- -
-
- -

@paste.Syntax

-
-
- -

-
-
- - @{ - string expireDate = "Never"; - if (paste.ExpireDate != null) - { - expireDate = ""; - } - } -

@Html.Raw(expireDate)

-
-
- -

@paste.MaxViews

-
-
- -

@paste.Views

-
-
-
- } -
-
- @foreach (Teknik.Areas.Shortener.Models.ShortenedUrl url in Model.ShortenedUrls) - { - string shortUrl = string.Format("{0}://{1}/{2}", Context.Request.Scheme, Config.ShortenerConfig.ShortenerHost, url.ShortUrl); - if (Config.DevEnvironment) - { - shortUrl = Url.SubRouteUrl("shortened", "Shortener.View", new { url = url.ShortUrl }); - } -
- -
-
- -

@shortUrl

-
-
- -

-
-
- -

@url.Views

-
-
-
- } -
-
- @foreach (Teknik.Areas.Vault.Models.Vault vault in Model.Vaults) - { -
- -
-
- -

-
-
- -

-
-
- -

@vault.Views

-
-
-
- } -
- } -
} else { diff --git a/Teknik/Areas/User/Views/User/ViewServiceData.cshtml b/Teknik/Areas/User/Views/User/ViewServiceData.cshtml new file mode 100644 index 0000000..1b600d5 --- /dev/null +++ b/Teknik/Areas/User/Views/User/ViewServiceData.cshtml @@ -0,0 +1,157 @@ +@model Teknik.Areas.Users.ViewModels.ViewServiceDataViewModel + + + +
+
+
+ +
+
+ @foreach (Teknik.Areas.Upload.Models.Upload upload in Model.Uploads) + { +
+ +
+
+ +

@StringHelper.GetBytesReadable(upload.ContentLength)

+
+
+ +

@upload.ContentType

+
+
+ +

+
+
+ +

@upload.Downloads

+
+
+

+
+
+
+ } +
+
+ @foreach (Teknik.Areas.Paste.Models.Paste paste in Model.Pastes) + { +
+ +
+
+ +

@paste.Syntax

+
+
+ +

+
+
+ + @{ + string expireDate = "Never"; + if (paste.ExpireDate != null) + { + expireDate = ""; + } + } +

@Html.Raw(expireDate)

+
+
+ +

@paste.MaxViews

+
+
+ +

@paste.Views

+
+
+

+
+
+
+ } +
+
+ @foreach (Teknik.Areas.Shortener.Models.ShortenedUrl url in Model.ShortenedUrls) + { + string shortUrl = string.Format("{0}://{1}/{2}", Context.Request.Scheme, Config.ShortenerConfig.ShortenerHost, url.ShortUrl); + if (Config.DevEnvironment) + { + shortUrl = Url.SubRouteUrl("shortened", "Shortener.View", new { url = url.ShortUrl }); + } +
+ +
+
+ +

@shortUrl

+
+
+ +

+
+
+ +

@url.Views

+
+
+

+
+
+
+ } +
+
+ @foreach (Teknik.Areas.Vault.Models.Vault vault in Model.Vaults) + { +
+ +
+
+ +

+
+
+ +

+
+
+ +

@vault.Views

+
+
+

+
+
+
+ } +
+
+
+
+
+ + \ No newline at end of file diff --git a/Teknik/Areas/User/Views/User/_LoginPartial.cshtml b/Teknik/Areas/User/Views/User/_LoginPartial.cshtml index 626c1ff..551430c 100644 --- a/Teknik/Areas/User/Views/User/_LoginPartial.cshtml +++ b/Teknik/Areas/User/Views/User/_LoginPartial.cshtml @@ -12,6 +12,9 @@
  • View Blog
  • +
  • + Service Data +
  • Settings
  • diff --git a/Teknik/Areas/Vault/Controllers/VaultController.cs b/Teknik/Areas/Vault/Controllers/VaultController.cs index c656911..8516eae 100644 --- a/Teknik/Areas/Vault/Controllers/VaultController.cs +++ b/Teknik/Areas/Vault/Controllers/VaultController.cs @@ -386,9 +386,9 @@ namespace Teknik.Areas.Vault.Controllers } [HttpPost] - public IActionResult DeleteVault(string url) + public IActionResult Delete(string id) { - Vault.Models.Vault foundVault = _dbContext.Vaults.Where(v => v.Url == url).FirstOrDefault(); + Vault.Models.Vault foundVault = _dbContext.Vaults.Where(v => v.Url == id).FirstOrDefault(); if (foundVault != null) { if (foundVault.User.Username == User.Identity.Name) diff --git a/Teknik/Areas/Vault/Views/Vault/ViewVault.cshtml b/Teknik/Areas/Vault/Views/Vault/ViewVault.cshtml index f4f243f..00b599d 100644 --- a/Teknik/Areas/Vault/Views/Vault/ViewVault.cshtml +++ b/Teknik/Areas/Vault/Views/Vault/ViewVault.cshtml @@ -8,7 +8,7 @@ var helpURL = '@Url.SubRouteUrl("help", "Help.Markdown")'; var validateItemURL = '@Url.SubRouteUrl(Model.CurrentSub, "Vault.Action", new { action = "ValidateItem" })'; var modifyVaultURL = '@Url.SubRouteUrl(Model.CurrentSub, "Vault.Action", new { action = "EditVault" })'; - var deleteVaultURL = '@Url.SubRouteUrl(Model.CurrentSub, "Vault.DeleteVault")'; + var deleteVaultURL = '@Url.SubRouteUrl(Model.CurrentSub, "Vault.Delete")';
    diff --git a/Teknik/Routes.cs b/Teknik/Routes.cs index a3626b1..31d71a7 100644 --- a/Teknik/Routes.cs +++ b/Teknik/Routes.cs @@ -417,6 +417,13 @@ namespace Teknik template: "Download/{url}/{password?}", defaults: new { area = "Paste", controller = "Paste", action = "ViewPaste", type = "Download" } ); + routes.MapSubdomainRoute( + name: "Paste.Delete", + domains: new List() { config.Host }, + subDomains: new List() { "paste", "p" }, + template: "Delete", + defaults: new { area = "Paste", controller = "Paste", action = "Delete" } + ); routes.MapSubdomainRoute( name: "Paste.Action", domains: new List() { config.Host }, @@ -510,6 +517,13 @@ namespace Teknik template: "", defaults: new { area = "Shortener", controller = "Shortener", action = "Index" } ); + routes.MapSubdomainRoute( + name: "Shortener.Delete", + domains: new List() { config.Host }, + subDomains: new List() { "shorten", "s" }, + template: "Delete", + defaults: new { area = "Shortener", controller = "Shortener", action = "Delete" } + ); routes.MapSubdomainRoute( name: "Shortener.Action", domains: new List() { config.Host }, @@ -578,6 +592,13 @@ namespace Teknik template: "GenerateDeleteKey", defaults: new { area = "Upload", controller = "Upload", action = "GenerateDeleteKey" } ); + routes.MapSubdomainRoute( + name: "Upload.Delete", + domains: new List() { config.Host }, + subDomains: new List() { "upload", "u" }, + template: "Delete", + defaults: new { area = "Upload", controller = "Upload", action = "Delete" } + ); routes.MapSubdomainRoute( name: "Upload.Download", domains: new List() { config.Host }, @@ -586,11 +607,11 @@ namespace Teknik defaults: new { area = "Upload", controller = "Upload", action = "Download" } ); routes.MapSubdomainRoute( - name: "Upload.Delete", + name: "Upload.DeleteByKey", domains: new List() { config.Host }, subDomains: new List() { "upload", "u" }, template: "{file}/{key}", - defaults: new { area = "Upload", controller = "Upload", action = "Delete" } + defaults: new { area = "Upload", controller = "Upload", action = "DeleteByKey" } ); routes.MapSubdomainRoute( name: "Upload.Action", @@ -708,6 +729,13 @@ namespace Teknik template: "VerifyEmail/{username}", defaults: new { area = "User", controller = "User", action = "VerifyRecoveryEmail" } ); + routes.MapSubdomainRoute( + name: "User.ViewServiceData", + domains: new List() { config.Host }, + subDomains: new List() { "user" }, + template: "ServiceData", + defaults: new { area = "User", controller = "User", action = "ViewServiceData" } + ); routes.MapSubdomainRoute( name: "User.ViewProfile", domains: new List() { config.Host }, @@ -762,11 +790,11 @@ namespace Teknik defaults: new { area = "Vault", controller = "Vault", action = "EditVault" } ); routes.MapSubdomainRoute( - name: "Vault.DeleteVault", + name: "Vault.Delete", domains: new List() { config.Host }, subDomains: new List() { "vault", "v" }, template: "Delete", - defaults: new { area = "Vault", controller = "Vault", action = "DeleteVault" } + defaults: new { area = "Vault", controller = "Vault", action = "Delete" } ); routes.MapSubdomainRoute( name: "Vault.ViewVault", diff --git a/Teknik/Scripts/User/Profile.js b/Teknik/Scripts/User/Profile.js index 9029a66..9e703c2 100644 --- a/Teknik/Scripts/User/Profile.js +++ b/Teknik/Scripts/User/Profile.js @@ -1,72 +1,4 @@ $(document).ready(function () { - $('.delete-upload-button').click(function () { - var deleteUrl = $(this).attr('id'); - var uploadID = $(this).data('upload-id'); - bootbox.confirm("Are you sure you want to delete this upload?", function (result) { - if (result) { - if (deleteUrl !== '') { - window.open(deleteUrl, '_blank'); - window.location.reload(); - } - else { - $.ajax({ - type: "POST", - url: generateDeleteKeyURL, - data: { file: uploadID }, - headers: { 'X-Requested-With': 'XMLHttpRequest' }, - xhrFields: { - withCredentials: true - }, - success: function (response) { - if (response.result) { - window.open(response.result.url, '_blank'); - window.location.reload(); - } - else { - $("#top_msg").css('display', 'inline', 'important'); - $("#top_msg").html('
    ' + parseErrorMessage(response) + '
    '); - } - }, - error: function (response) { - $("#top_msg").css('display', 'inline', 'important'); - $("#top_msg").html('
    ' + parseErrorMessage(response.responseText) + '
    '); - } - }); - } - } - }); - }); - - $('.delete-vault-button').click(function () { - var vaultUrl = $(this).data('vault-url'); - bootbox.confirm("Are you sure you want to delete this vault?", function (result) { - if (result) { - $.ajax({ - type: "POST", - url: deleteVaultURL, - data: { url: vaultUrl }, - headers: { 'X-Requested-With': 'XMLHttpRequest' }, - xhrFields: { - withCredentials: true - }, - success: function (response) { - if (response.result) { - window.location = response.result.url; - } - else { - $("#top_msg").css('display', 'inline', 'important'); - $("#top_msg").html('
    ' + parseErrorMessage(response) + '
    '); - } - }, - error: function (response) { - $("#top_msg").css('display', 'inline', 'important'); - $("#top_msg").html('
    ' + parseErrorMessage(response.responseText) + '
    '); - } - }); - } - }); - }); - $('#pgpKeyBlock').click(function () { SelectAll('pgpKeyBlock'); }); diff --git a/Teknik/Scripts/User/ViewServiceData.js b/Teknik/Scripts/User/ViewServiceData.js new file mode 100644 index 0000000..7864b8b --- /dev/null +++ b/Teknik/Scripts/User/ViewServiceData.js @@ -0,0 +1,54 @@ +$(document).ready(function () { + $('.delete-upload-button').click(function () { + var id = $(this).data('upload-id'); + var element = $('#uploads [id="' + id + '"'); + deleteItem(deleteUploadURL, id, element, "Are you sure you want to delete this upload?"); + }); + + $('.delete-paste-button').click(function () { + var id = $(this).data('paste-id'); + var element = $('#pastes [id="' + id + '"'); + deleteItem(deletePasteURL, id, element, "Are you sure you want to delete this paste?"); + }); + + $('.delete-shorten-button').click(function () { + var id = $(this).data('shorten-id'); + var element = $('#shortenedUrls [id="' + id + '"'); + deleteItem(deleteShortenURL, id, element, "Are you sure you want to delete this shortened url?"); + }); + + $('.delete-vault-button').click(function () { + var id = $(this).data('vault-id'); + var element = $('#vaults [id="' + id + '"'); + deleteItem(deleteVaultURL, id, element, "Are you sure you want to delete this vault?"); + }); +}); + +function deleteItem(url, id, element, confirmationMsg) { + bootbox.confirm(confirmationMsg, function (result) { + if (result) { + $.ajax({ + type: "POST", + url: url, + data: { id: id }, + headers: { 'X-Requested-With': 'XMLHttpRequest' }, + xhrFields: { + withCredentials: true + }, + success: function (response) { + if (response.result) { + element.remove(); + } + else { + $("#top_msg").css('display', 'inline', 'important'); + $("#top_msg").html('
    ' + parseErrorMessage(response) + '
    '); + } + }, + error: function (response) { + $("#top_msg").css('display', 'inline', 'important'); + $("#top_msg").html('
    ' + parseErrorMessage(response.responseText) + '
    '); + } + }); + } + }); +} \ No newline at end of file diff --git a/Teknik/Scripts/Vault/Vault.js b/Teknik/Scripts/Vault/Vault.js index 7066ac9..6a4c054 100644 --- a/Teknik/Scripts/Vault/Vault.js +++ b/Teknik/Scripts/Vault/Vault.js @@ -196,7 +196,7 @@ $(document).ready(function () { $.ajax({ type: "POST", url: deleteVaultURL, - data: { url: vaultUrl }, + data: { id: vaultUrl }, headers: { 'X-Requested-With': 'XMLHttpRequest' }, xhrFields: { withCredentials: true diff --git a/Teknik/bundleconfig.json b/Teknik/bundleconfig.json index a3534fa..572fad4 100644 --- a/Teknik/bundleconfig.json +++ b/Teknik/bundleconfig.json @@ -192,6 +192,13 @@ "./wwwroot/js/app/User/Profile.js" ] }, + { + "outputFileName": "./wwwroot/js/user.serviceData.min.js", + "inputFiles": [ + "./wwwroot/lib/bootbox/js/bootbox.js", + "./wwwroot/js/app/User/ViewServiceData.js" + ] + }, { "outputFileName": "./wwwroot/js/user.reset.min.js", "inputFiles": [