- Added button to delete a vault on both the vault page and the user profile page. - Added logo designs by @rug3ytags/2.0.6
@@ -17,9 +17,7 @@ namespace Teknik.Areas.Paste.Models | |||
public virtual User User { get; set; } | |||
public int? VaultId { get; set; } | |||
public virtual Vault.Models.Vault Vault { get; set; } | |||
public virtual ICollection<Vault.Models.PasteVaultItem> PasteVaultItems { get; set; } | |||
public DateTime DatePosted { get; set; } | |||
@@ -1,3 +1,13 @@ | |||
$(document).ready(function () { | |||
$('#content').focus(); | |||
}); | |||
linkCreateVault($('#create-vault')); | |||
}); | |||
function linkCreateVault(element) { | |||
element.click(function () { | |||
var pasteUrl = $(this).data('paste-url'); | |||
var pasteTitle = $(this).data('paste-title'); | |||
window.open(createVaultURL + '&urls=' + encodeURIComponent(pasteUrl + ':' + pasteTitle), '_blank'); | |||
}); | |||
} |
@@ -3,15 +3,11 @@ | |||
@using Teknik.Utilities | |||
@Styles.Render("~/Content/paste") | |||
@Scripts.Render("~/bundles/paste") | |||
@{ | |||
string syntax = string.Empty; | |||
if (Model.Syntax != "auto-detect") | |||
{ | |||
syntax = Model.Syntax; | |||
} | |||
} | |||
<script type="text/javascript"> | |||
var createVaultURL = '@Url.SubRouteUrl("vault", "Vault.NewVaultFromService", new { type = "Paste" })'; | |||
</script> | |||
<div class="container"> | |||
<div class="row text-center"> | |||
<div class="col-sm-12 text-center"> | |||
@@ -25,6 +21,7 @@ | |||
<a role="button" class="btn btn-default" href="@Url.SubRouteUrl("paste", "Paste.Simple", new { url = Model.Url })">Simple</a> | |||
<a role="button" class="btn btn-default" href="@Url.SubRouteUrl("paste", "Paste.Raw", new { url = Model.Url })">Raw</a> | |||
<a role="button" class="btn btn-default" href="@Url.SubRouteUrl("paste", "Paste.Download", new { url = Model.Url })">Download</a> | |||
<button type="button" class="btn btn-default" id="create-vault" data-paste-url="@Model.Url" data-paste-title="@((string.IsNullOrEmpty(Model.Title)) ? "Untitled" : Model.Title)">Create Vault</button> | |||
</div> | |||
</div> | |||
</div> | |||
@@ -32,4 +29,6 @@ | |||
<div class="row"> | |||
<div class="col-sm-12">@Html.Raw(Model.Content)</div> | |||
</div> | |||
</div> | |||
</div> | |||
@Scripts.Render("~/bundles/paste") |
@@ -15,9 +15,7 @@ namespace Teknik.Areas.Upload.Models | |||
public virtual User User { get; set; } | |||
public int? VaultId { get; set; } | |||
public virtual Vault.Models.Vault Vault { get; set; } | |||
public virtual ICollection<Vault.Models.UploadVaultItem> UploadVaultItems { get; set; } | |||
public DateTime DateUploaded { get; set; } | |||
@@ -32,4 +32,30 @@ | |||
} | |||
}); | |||
}); | |||
$('.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 (html) { | |||
if (html.result) { | |||
window.location = html.result.url; | |||
} | |||
else { | |||
$("#top_msg").css('display', 'inline', 'important'); | |||
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' + html.error.message + '</div>'); | |||
} | |||
} | |||
}); | |||
} | |||
}); | |||
}); | |||
}); |
@@ -4,6 +4,7 @@ | |||
<script> | |||
var generateDeleteKeyURL = '@Url.SubRouteUrl("u", "Upload.GenerateDeleteKey")'; | |||
var deleteVaultURL = '@Url.SubRouteUrl("v", "Vault.DeleteVault")'; | |||
</script> | |||
<div class="container"> |
@@ -12,12 +12,13 @@ | |||
margin-bottom: 10px; | |||
} | |||
.showContent{ | |||
.showContent { | |||
height: 100%; | |||
max-height: none; | |||
} | |||
.show-more { | |||
display: none; | |||
padding: 10px 0; | |||
text-align: center; | |||
} |
@@ -33,28 +33,30 @@ namespace Teknik.Areas.Vault.Controllers | |||
db.Entry(foundVault).State = EntityState.Modified; | |||
db.SaveChanges(); | |||
ViewBag.Title = foundVault.Title + " - Vault"; | |||
ViewBag.Title = foundVault.Title + " - Teknik Vault"; | |||
VaultViewModel model = new VaultViewModel(); | |||
model.Url = foundVault.Url; | |||
model.UserId = foundVault.UserId; | |||
model.User = foundVault.User; | |||
model.Title = foundVault.Title; | |||
model.Description = foundVault.Description; | |||
model.DateCreated = foundVault.DateCreated; | |||
model.DateEdited = foundVault.DateEdited; | |||
if (foundVault.Items.Any()) | |||
if (foundVault.VaultItems.Any()) | |||
{ | |||
foreach (VaultItem item in foundVault.Items) | |||
foreach (VaultItem item in foundVault.VaultItems) | |||
{ | |||
VaultItemViewModel itemModel = new VaultItemViewModel(); | |||
itemModel.Title = item.Title; | |||
itemModel.Description = item.Description; | |||
itemModel.DateAdded = item.DateAdded; | |||
if (item.GetType().BaseType == typeof(UploadItem)) | |||
if (item.GetType().BaseType == typeof(UploadVaultItem)) | |||
{ | |||
UploadItem upload = (UploadItem)item; | |||
UploadVaultItem upload = (UploadVaultItem)item; | |||
// Increment Views | |||
upload.Upload.Downloads += 1; | |||
db.Entry(upload.Upload).State = EntityState.Modified; | |||
@@ -67,9 +69,9 @@ namespace Teknik.Areas.Vault.Controllers | |||
uploadModel.Upload = upload.Upload; | |||
model.Items.Add(uploadModel); | |||
} | |||
else if (item.GetType().BaseType == typeof(PasteItem)) | |||
else if (item.GetType().BaseType == typeof(PasteVaultItem)) | |||
{ | |||
PasteItem paste = (PasteItem)item; | |||
PasteVaultItem paste = (PasteVaultItem)item; | |||
// Increment Views | |||
paste.Paste.Views += 1; | |||
db.Entry(paste.Paste).State = EntityState.Modified; | |||
@@ -103,8 +105,8 @@ namespace Teknik.Areas.Vault.Controllers | |||
public ActionResult NewVault() | |||
{ | |||
ViewBag.Title = "Create Vault"; | |||
NewVaultViewModel model = new NewVaultViewModel(); | |||
return View(model); | |||
ModifyVaultViewModel model = new ModifyVaultViewModel(); | |||
return View("~/Areas/Vault/Views/Vault/ModifyVault.cshtml", model); | |||
} | |||
[HttpGet] | |||
@@ -112,7 +114,7 @@ namespace Teknik.Areas.Vault.Controllers | |||
public ActionResult NewVaultFromService(string type, string urls) | |||
{ | |||
ViewBag.Title = "Create Vault"; | |||
NewVaultViewModel model = new NewVaultViewModel(); | |||
ModifyVaultViewModel model = new ModifyVaultViewModel(); | |||
string[] allURLs = urls.Split(','); | |||
int index = 0; | |||
@@ -128,7 +130,7 @@ namespace Teknik.Areas.Vault.Controllers | |||
} | |||
if (IsValidItem(type, uploadId)) | |||
{ | |||
NewVaultItemViewModel item = new NewVaultItemViewModel(); | |||
ModifyVaultItemViewModel item = new ModifyVaultItemViewModel(); | |||
item.isTemplate = false; | |||
item.index = index; | |||
item.title = title; | |||
@@ -139,13 +141,66 @@ namespace Teknik.Areas.Vault.Controllers | |||
} | |||
} | |||
return View("~/Areas/Vault/Views/Vault/NewVault.cshtml", model); | |||
return View("~/Areas/Vault/Views/Vault/ModifyVault.cshtml", model); | |||
} | |||
[HttpGet] | |||
public ActionResult EditVault(string url) | |||
{ | |||
ViewBag.Title = "Edit Vault"; | |||
Vault.Models.Vault foundVault = db.Vaults.Where(v => v.Url == url).FirstOrDefault(); | |||
if (foundVault != null) | |||
{ | |||
if (foundVault.User.Username == User.Identity.Name) | |||
{ | |||
ViewBag.Title = "Edit Vault - " + foundVault.Title; | |||
ModifyVaultViewModel model = new ModifyVaultViewModel(); | |||
model.isEdit = true; | |||
model.vaultId = foundVault.VaultId; | |||
model.title = foundVault.Title; | |||
model.description = foundVault.Description; | |||
int index = 0; | |||
foreach (VaultItem item in foundVault.VaultItems) | |||
{ | |||
ModifyVaultItemViewModel itemModel = new ModifyVaultItemViewModel(); | |||
itemModel.index = index; | |||
itemModel.isTemplate = false; | |||
if (item.GetType().BaseType == typeof(UploadVaultItem)) | |||
{ | |||
UploadVaultItem upload = (UploadVaultItem)item; | |||
itemModel.title = upload.Title; | |||
itemModel.description = upload.Description; | |||
itemModel.type = "Upload"; | |||
itemModel.url = upload.Upload.Url; | |||
model.items.Add(itemModel); | |||
index++; | |||
} | |||
else if (item.GetType().BaseType == typeof(PasteVaultItem)) | |||
{ | |||
PasteVaultItem paste = (PasteVaultItem)item; | |||
itemModel.title = paste.Title; | |||
itemModel.description = paste.Description; | |||
itemModel.type = "Paste"; | |||
itemModel.url = paste.Paste.Url; | |||
model.items.Add(itemModel); | |||
index++; | |||
} | |||
} | |||
return View("~/Areas/Vault/Views/Vault/ModifyVault.cshtml", model); | |||
} | |||
return Redirect(Url.SubRouteUrl("error", "Error.Http403")); | |||
} | |||
return Redirect(Url.SubRouteUrl("error", "Error.Http404")); | |||
} | |||
[HttpPost] | |||
[AllowAnonymous] | |||
[ValidateAntiForgeryToken] | |||
public ActionResult CreateVault(NewVaultViewModel model) | |||
public ActionResult CreateVault(ModifyVaultViewModel model) | |||
{ | |||
if (model != null) | |||
{ | |||
@@ -174,27 +229,27 @@ namespace Teknik.Areas.Vault.Controllers | |||
// Add/Verify items | |||
if (model.items.Any()) | |||
{ | |||
foreach (NewVaultItemViewModel item in model.items) | |||
foreach (ModifyVaultItemViewModel item in model.items) | |||
{ | |||
if (IsValidItem(item.type, item.url)) | |||
{ | |||
switch (item.type.ToLower()) | |||
{ | |||
case "upload": | |||
UploadItem newUpload = new UploadItem(); | |||
UploadVaultItem newUpload = new UploadVaultItem(); | |||
newUpload.DateAdded = DateTime.Now; | |||
newUpload.Title = item.title; | |||
newUpload.Description = item.description; | |||
newUpload.UploadId = db.Uploads.Where(u => u.Url == item.url).FirstOrDefault().UploadId; | |||
newVault.Items.Add(newUpload); | |||
newVault.VaultItems.Add(newUpload); | |||
break; | |||
case "paste": | |||
PasteItem newPaste = new PasteItem(); | |||
PasteVaultItem newPaste = new PasteVaultItem(); | |||
newPaste.DateAdded = DateTime.Now; | |||
newPaste.Title = item.title; | |||
newPaste.Description = item.description; | |||
newPaste.PasteId = db.Pastes.Where(p => p.Url == item.url).FirstOrDefault().PasteId; | |||
newVault.Items.Add(newPaste); | |||
newVault.VaultItems.Add(newPaste); | |||
break; | |||
default: | |||
return Json(new { error = new { message = "You have an invalid item type: " + item.type } }); | |||
@@ -217,6 +272,98 @@ namespace Teknik.Areas.Vault.Controllers | |||
return Json(new { error = new { message = "Invalid Parameters" } }); | |||
} | |||
[HttpPost] | |||
[ValidateAntiForgeryToken] | |||
public ActionResult EditVault(ModifyVaultViewModel model) | |||
{ | |||
if (model != null) | |||
{ | |||
Vault.Models.Vault foundVault = db.Vaults.Where(v => v.VaultId == model.vaultId).FirstOrDefault(); | |||
if (foundVault != null) | |||
{ | |||
if (foundVault.User.Username == User.Identity.Name) | |||
{ | |||
foundVault.DateEdited = DateTime.Now; | |||
foundVault.Title = model.title; | |||
foundVault.Description = model.description; | |||
// Clear previous items | |||
List<VaultItem> vaultItems = db.VaultItems.Where(v => v.VaultId == foundVault.VaultId).ToList(); | |||
if (vaultItems != null) | |||
{ | |||
foreach (VaultItem item in vaultItems) | |||
{ | |||
db.VaultItems.Remove(item); | |||
} | |||
} | |||
foundVault.VaultItems.Clear(); | |||
// Add/Verify items | |||
if (model.items.Any()) | |||
{ | |||
foreach (ModifyVaultItemViewModel item in model.items) | |||
{ | |||
if (IsValidItem(item.type, item.url)) | |||
{ | |||
switch (item.type.ToLower()) | |||
{ | |||
case "upload": | |||
UploadVaultItem newUpload = new UploadVaultItem(); | |||
newUpload.DateAdded = DateTime.Now; | |||
newUpload.Title = item.title; | |||
newUpload.Description = item.description; | |||
newUpload.UploadId = db.Uploads.Where(u => u.Url == item.url).FirstOrDefault().UploadId; | |||
foundVault.VaultItems.Add(newUpload); | |||
break; | |||
case "paste": | |||
PasteVaultItem newPaste = new PasteVaultItem(); | |||
newPaste.DateAdded = DateTime.Now; | |||
newPaste.Title = item.title; | |||
newPaste.Description = item.description; | |||
newPaste.PasteId = db.Pastes.Where(p => p.Url == item.url).FirstOrDefault().PasteId; | |||
foundVault.VaultItems.Add(newPaste); | |||
break; | |||
default: | |||
return Json(new { error = new { message = "You have an invalid item type: " + item.type } }); | |||
} | |||
} | |||
else | |||
{ | |||
return Json(new { error = new { message = "You have an invalid item URL: " + item.url } }); | |||
} | |||
} | |||
} | |||
db.Entry(foundVault).State = EntityState.Modified; | |||
db.SaveChanges(); | |||
return Json(new { result = new { url = Url.SubRouteUrl("v", "Vault.ViewVault", new { id = foundVault.Url }) } }); | |||
} | |||
return Json(new { error = new { message = "You do not have permission to edit this Vault" } }); | |||
} | |||
return Json(new { error = new { message = "That Vault does not exist" } }); | |||
} | |||
return Json(new { error = new { message = "Invalid Parameters" } }); | |||
} | |||
[HttpPost] | |||
public ActionResult DeleteVault(string url) | |||
{ | |||
Vault.Models.Vault foundVault = db.Vaults.Where(v => v.Url == url).FirstOrDefault(); | |||
if (foundVault != null) | |||
{ | |||
if (foundVault.User.Username == User.Identity.Name) | |||
{ | |||
db.Vaults.Remove(foundVault); | |||
db.SaveChanges(); | |||
return Json(new { result = new { url = Url.SubRouteUrl("vault", "Vault.CreateVault") } }); | |||
} | |||
return Json(new { error = new { message = "You do not have permission to edit this Vault" } }); | |||
} | |||
return Json(new { error = new { message = "That Vault does not exist" } }); | |||
} | |||
[HttpPost] | |||
[AllowAnonymous] | |||
[ValidateAntiForgeryToken] |
@@ -5,7 +5,7 @@ using System.Web; | |||
namespace Teknik.Areas.Vault.Models | |||
{ | |||
public class PasteItem : VaultItem | |||
public class PasteVaultItem : VaultItem | |||
{ | |||
public int PasteId { get; set; } | |||
public virtual Paste.Models.Paste Paste { get; set; } |
@@ -5,7 +5,7 @@ using System.Web; | |||
namespace Teknik.Areas.Vault.Models | |||
{ | |||
public class UploadItem : VaultItem | |||
public class UploadVaultItem : VaultItem | |||
{ | |||
public int UploadId { get; set; } | |||
public virtual Upload.Models.Upload Upload { get; set; } |
@@ -25,7 +25,7 @@ namespace Teknik.Areas.Vault.Models | |||
public int Views { get; set; } | |||
public virtual ICollection<VaultItem> Items { get; set; } | |||
public virtual ICollection<VaultItem> VaultItems { get; set; } | |||
public Vault() | |||
{ | |||
@@ -34,7 +34,7 @@ namespace Teknik.Areas.Vault.Models | |||
DateCreated = DateTime.Now; | |||
DateEdited = DateTime.Now; | |||
Views = 0; | |||
Items = new List<VaultItem>(); | |||
VaultItems = new List<VaultItem>(); | |||
} | |||
} | |||
} |
@@ -1,4 +1,12 @@ | |||
$(document).ready(function () { | |||
$('.hideContent').each(function () { | |||
if ($(this).find('pre').height() > 400) { | |||
var id = $(this).attr('id'); | |||
$('#show-more-bottom-' + id).show(); | |||
linkShowMore($('#show-more-bottom-' + id).find(".show-more-button")); | |||
} | |||
}) | |||
$('#newItem').on('show.bs.modal', function (e) { | |||
var newDiv = $('#newItem'); | |||
newDiv.find("#item_title").val(""); | |||
@@ -113,6 +121,7 @@ | |||
}); | |||
$("#submit").click(function () { | |||
var vaultId = $('#vaultId').val(); | |||
var title = $("#title").val(); | |||
var description = $("#description").val(); | |||
var items = []; | |||
@@ -142,8 +151,8 @@ | |||
// Create the vault | |||
$.ajax({ | |||
type: "POST", | |||
url: createVaultURL, | |||
data: AddAntiForgeryToken({ title: title, description: description, items: items }), | |||
url: modifyVaultURL, | |||
data: AddAntiForgeryToken({ vaultId: vaultId, title: title, description: description, items: items }), | |||
success: function (response) { | |||
if (response.result) { | |||
window.location = response.result.url; | |||
@@ -157,22 +166,30 @@ | |||
return false; | |||
}); | |||
$("#show-more-button").on("click", function () { | |||
var link = $(this); | |||
var contentDiv = link.parent().prev("div.paste-content"); | |||
var linkText = link.text().toUpperCase(); | |||
if (linkText === "SHOW MORE") { | |||
linkText = "Show Less"; | |||
contentDiv.removeClass('hideContent'); | |||
contentDiv.addClass('showContent'); | |||
} else { | |||
linkText = "Show More"; | |||
contentDiv.removeClass('showContent'); | |||
contentDiv.addClass('hideContent'); | |||
}; | |||
link.text(linkText); | |||
$('.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 (html) { | |||
if (html.result) { | |||
window.location = html.result.url; | |||
} | |||
else { | |||
$("#top_msg").css('display', 'inline', 'important'); | |||
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' + html.error.message + '</div>'); | |||
} | |||
} | |||
}); | |||
} | |||
}); | |||
}); | |||
}); | |||
@@ -190,4 +207,29 @@ function linkMoveDown(element) { | |||
element.find('#move-down').click(function () { | |||
moveDown(element); | |||
}); | |||
} | |||
function linkShowMore(element) { | |||
$(element).on("click", function () { | |||
var link = $(this); | |||
var contentDiv = link.parent().prev("div.paste-content"); | |||
var id = contentDiv.attr('id'); | |||
var btnTop = $('#show-more-top-' + id); | |||
var btnBottom = $('#show-more-bottom-' + id); | |||
var linkText = link.text().toUpperCase(); | |||
if (linkText === "SHOW MORE") { | |||
linkText = "Show Less"; | |||
contentDiv.removeClass('hideContent'); | |||
contentDiv.addClass('showContent'); | |||
btnBottom.show(); | |||
btnBottom.find('.show-more-button').text(linkText); | |||
} else { | |||
linkText = "Show More"; | |||
contentDiv.removeClass('showContent'); | |||
contentDiv.addClass('hideContent'); | |||
btnBottom.show(); | |||
btnBottom.find('.show-more-button').text(linkText); | |||
}; | |||
}); | |||
} |
@@ -46,6 +46,24 @@ namespace Teknik.Areas.Vault | |||
new[] { typeof(Controllers.VaultController).Namespace } | |||
); | |||
context.MapSubdomainRoute( | |||
"Vault.EditVault", | |||
new List<string>() { "vault", "v" }, // Subdomains | |||
new List<string>() { config.Host }, // domains | |||
"Edit/{url}", | |||
new { controller = "Vault", action = "EditVault" }, | |||
new[] { typeof(Controllers.VaultController).Namespace } | |||
); | |||
context.MapSubdomainRoute( | |||
"Vault.DeleteVault", | |||
new List<string>() { "vault", "v" }, // Subdomains | |||
new List<string>() { config.Host }, // domains | |||
"Delete", | |||
new { controller = "Vault", action = "DeleteVault" }, | |||
new[] { typeof(Controllers.VaultController).Namespace } | |||
); | |||
context.MapSubdomainRoute( | |||
"Vault.ViewVault", | |||
new List<string>() { "vault", "v" }, // Subdomains | |||
@@ -71,6 +89,7 @@ namespace Teknik.Areas.Vault | |||
// Register Script Bundle | |||
BundleTable.Bundles.Add(new CdnScriptBundle("~/bundles/vault", config.CdnHost).Include( | |||
"~/Scripts/jquery.blockUI.js", | |||
"~/Scripts/bootbox/bootbox.min.js", | |||
"~/Areas/Vault/Scripts/Vault.js")); | |||
} | |||
} |
@@ -6,7 +6,7 @@ using Teknik.ViewModels; | |||
namespace Teknik.Areas.Vault.ViewModels | |||
{ | |||
public class NewVaultItemViewModel : ViewModelBase | |||
public class ModifyVaultItemViewModel : ViewModelBase | |||
{ | |||
public bool isTemplate { get; set; } | |||
public int index { get; set; } | |||
@@ -15,7 +15,7 @@ namespace Teknik.Areas.Vault.ViewModels | |||
public string type { get; set; } | |||
public string url { get; set; } | |||
public NewVaultItemViewModel() | |||
public ModifyVaultItemViewModel() | |||
{ | |||
isTemplate = true; | |||
index = 0; |
@@ -7,17 +7,21 @@ using Teknik.ViewModels; | |||
namespace Teknik.Areas.Vault.ViewModels | |||
{ | |||
public class NewVaultViewModel : ViewModelBase | |||
public class ModifyVaultViewModel : ViewModelBase | |||
{ | |||
public bool isEdit { get; set; } | |||
public int vaultId { get; set; } | |||
public string title { get; set; } | |||
public string description { get; set; } | |||
public List<NewVaultItemViewModel> items { get; set; } | |||
public List<ModifyVaultItemViewModel> items { get; set; } | |||
public NewVaultViewModel() | |||
public ModifyVaultViewModel() | |||
{ | |||
isEdit = false; | |||
vaultId = -1; | |||
title = string.Empty; | |||
description = string.Empty; | |||
items = new List<NewVaultItemViewModel>(); | |||
items = new List<ModifyVaultItemViewModel>(); | |||
} | |||
} | |||
} |
@@ -1,14 +1,19 @@ | |||
@model Teknik.Areas.Vault.ViewModels.NewVaultViewModel | |||
@model Teknik.Areas.Vault.ViewModels.ModifyVaultViewModel | |||
@using Teknik.Utilities | |||
@using Teknik.Areas.Vault.ViewModels | |||
@Styles.Render("~/Content/vault") | |||
@{ | |||
string action = (Model.isEdit) ? "EditVault" : "CreateVault"; | |||
string title = (Model.isEdit) ? "Edit Vault" : "Create a New Vault"; | |||
} | |||
<script type="text/javascript"> | |||
var validateItemURL = '@Url.SubRouteUrl("vault", "Vault.Action", new { action = "ValidateItem" })'; | |||
var createVaultURL = '@Url.SubRouteUrl("vault", "Vault.Action", new { action = "CreateVault" })'; | |||
var modifyVaultURL = '@Url.SubRouteUrl("vault", "Vault.Action", new { action = action })'; | |||
var itemCount = @Model.items.Count(); | |||
@@ -114,22 +119,23 @@ | |||
<div class="row"> | |||
<div class="col-sm-10 col-sm-offset-1 text-center"> | |||
<h2>Create a New Vault</h2> | |||
<h2>@title</h2> | |||
</div> | |||
</div> | |||
<form class="form" action="@Url.SubRouteUrl("vault", "Vault.Action", new { action = "CreateVault" })" method="post" id="newVaultForm"> | |||
<form class="form" action="##" method="post" id="vaultForm"> | |||
<input type="hidden" id="vaultId" name="vaultId" value="@Model.vaultId" /> | |||
<div class="row"> | |||
<div class="col-sm-10"> | |||
<div class="row"> | |||
<div class="form-group col-sm-10 col-sm-offset-1"> | |||
<label for="title"><h4>Title</h4></label> | |||
<input class="form-control" name="title" id="title" placeholder="Collection of items" title="enter a title for your vault." type="text" /> | |||
<input class="form-control" name="title" id="title" placeholder="Collection of items" title="enter a title for your vault." type="text" value="@Model.title" /> | |||
</div> | |||
</div> | |||
<div class="row"> | |||
<div class="form-group col-sm-10 col-sm-offset-1"> | |||
<label for="article"><h4>Description</h4></label> | |||
<textarea class="form-control" name="description" id="description" placeholder="This is a cool collection of uploads and pastes" title="enter the description for this vault" rows="5"></textarea> | |||
<textarea class="form-control" name="description" id="description" placeholder="This is a cool collection of uploads and pastes" title="enter the description for this vault" rows="5">@Model.description</textarea> | |||
</div> | |||
</div> | |||
</div> | |||
@@ -156,9 +162,9 @@ | |||
<div class="col-sm-10" id="vault-items"> | |||
@if (Model.items.Any()) | |||
{ | |||
foreach (NewVaultItemViewModel item in Model.items) | |||
foreach (ModifyVaultItemViewModel item in Model.items) | |||
{ | |||
@Html.Partial("~/Areas/Vault/Views/Vault/NewVaultItem.cshtml", item) | |||
@Html.Partial("~/Areas/Vault/Views/Vault/ModifyVaultItem.cshtml", item) | |||
} | |||
} | |||
</div> | |||
@@ -166,7 +172,7 @@ | |||
</form> | |||
</div> | |||
<div id="templates" style="display: none"> | |||
@Html.Partial("~/Areas/Vault/Views/Vault/NewVaultItem.cshtml", new NewVaultItemViewModel()) | |||
@Html.Partial("~/Areas/Vault/Views/Vault/ModifyVaultItem.cshtml", new ModifyVaultItemViewModel()) | |||
</div> | |||
@Scripts.Render("~/bundles/vault") |
@@ -1,4 +1,4 @@ | |||
@model Teknik.Areas.Vault.ViewModels.NewVaultItemViewModel | |||
@model Teknik.Areas.Vault.ViewModels.ModifyVaultItemViewModel | |||
@{ | |||
bool isTemplate = (Model.isTemplate); | |||
} |
@@ -37,7 +37,7 @@ | |||
</div> | |||
<br /> | |||
<div class="row paste-item"> | |||
<div class="col-sm-12 paste-content hideContent"> | |||
<div class="col-sm-12 paste-content hideContent" id="@Model.VaultItemId"> | |||
@if (!string.IsNullOrEmpty(Model.Paste.HashedPassword)) | |||
{ | |||
<p class="text-center">Password Required</p> | |||
@@ -47,8 +47,8 @@ | |||
@Html.Raw(Model.Paste.Content) | |||
} | |||
</div> | |||
<div class="show-more"> | |||
<button class="btn btn-default btn-sm" id="show-more-button">Show More</button> | |||
<div class="show-more" id="show-more-bottom-@Model.VaultItemId"> | |||
<button role="button" class="btn btn-default btn-sm show-more-button">Show More</button> | |||
</div> | |||
</div> | |||
</div> |
@@ -6,12 +6,27 @@ | |||
@Styles.Render("~/Content/vault") | |||
<script type="text/javascript"> | |||
var deleteVaultURL = '@Url.SubRouteUrl("v", "Vault.DeleteVault")'; | |||
</script> | |||
<div class="container"> | |||
<div class="row text-center"> | |||
<div class="col-sm-12 text-center"> | |||
<h2><b>@((string.IsNullOrEmpty(Model.Title)) ? "Untitled" : Model.Title)</b> <small>Created on <time datetime="@Model.DateCreated.ToString("s")">@Model.DateCreated.ToString("dddd, MMMM d, yyyy") at @Model.DateCreated.ToString("h:mm:ss tt")</time></small></h2> | |||
</div> | |||
</div> | |||
@if (User.Identity.IsAuthenticated && Model.User.Username == User.Identity.Name) | |||
{ | |||
<div class="row"> | |||
<div class="col-sm-12"> | |||
<div role="group" class="btn-group pull-right"> | |||
<a role="button" class="btn btn-primary edit-vault-button" href="@Url.SubRouteUrl("v", "Vault.EditVault", new { url = Model.Url })">Edit</a> | |||
<button role="button" class="btn btn-danger delete-vault-button" data-vault-url="@Model.Url">Delete</button> | |||
</div> | |||
</div> | |||
</div> | |||
} | |||
@if (!string.IsNullOrEmpty(Model.Description)) | |||
{ | |||
<hr /> |
@@ -55,6 +55,7 @@ namespace Teknik.Models | |||
public DbSet<ShortenedUrl> ShortenedUrls { get; set; } | |||
// Vaults | |||
public DbSet<Vault> Vaults { get; set; } | |||
public DbSet<VaultItem> VaultItems { get; set; } | |||
protected override void OnModelCreating(DbModelBuilder modelBuilder) | |||
{ | |||
@@ -158,6 +159,7 @@ namespace Teknik.Models | |||
modelBuilder.Entity<ShortenedUrl>().ToTable("ShortenedUrls"); | |||
// Vaults | |||
modelBuilder.Entity<Vault>().ToTable("Vaults"); | |||
modelBuilder.Entity<VaultItem>().ToTable("VaultItems"); | |||
// Podcasts | |||
modelBuilder.Entity<Podcast>().ToTable("Podcasts"); | |||
modelBuilder.Entity<PodcastFile>().ToTable("PodcastFiles"); |
@@ -242,8 +242,8 @@ | |||
<Compile Include="Areas\User\Models\TrustedDevice.cs" /> | |||
<Compile Include="Areas\User\ViewModels\AuthTokenViewModel.cs" /> | |||
<Compile Include="Areas\User\ViewModels\TwoFactorViewModel.cs" /> | |||
<Compile Include="Areas\Vault\ViewModels\NewVaultViewModel.cs" /> | |||
<Compile Include="Areas\Vault\ViewModels\NewVaultItemViewModel.cs" /> | |||
<Compile Include="Areas\Vault\ViewModels\ModifyVaultViewModel.cs" /> | |||
<Compile Include="Areas\Vault\ViewModels\ModifyVaultItemViewModel.cs" /> | |||
<Compile Include="Areas\Vault\ViewModels\UploadItemViewModel.cs" /> | |||
<Compile Include="Areas\Vault\ViewModels\PasteItemViewModel.cs" /> | |||
<Compile Include="Areas\Vault\ViewModels\VaultItemViewModel.cs" /> | |||
@@ -289,8 +289,8 @@ | |||
<Compile Include="Areas\Upload\ViewModels\DownloadViewModel.cs" /> | |||
<Compile Include="Areas\Upload\ViewModels\UploadViewModel.cs" /> | |||
<Compile Include="Areas\Vault\Controllers\VaultController.cs" /> | |||
<Compile Include="Areas\Vault\Models\PasteItem.cs" /> | |||
<Compile Include="Areas\Vault\Models\UploadItem.cs" /> | |||
<Compile Include="Areas\Vault\Models\PasteVaultItem.cs" /> | |||
<Compile Include="Areas\Vault\Models\UploadVaultItem.cs" /> | |||
<Compile Include="Areas\Vault\Models\Vault.cs" /> | |||
<Compile Include="Areas\Vault\Models\VaultItem.cs" /> | |||
<Compile Include="Areas\Vault\VaultAreaRegistration.cs" /> | |||
@@ -580,8 +580,8 @@ | |||
<Content Include="Areas\User\Views\User\AuthToken.cshtml" /> | |||
<Content Include="Areas\Error\Views\Error\Http401.cshtml" /> | |||
<Content Include="Areas\Transparency\Views\_ViewStart.cshtml" /> | |||
<Content Include="Areas\Vault\Views\Vault\NewVault.cshtml" /> | |||
<Content Include="Areas\Vault\Views\Vault\NewVaultItem.cshtml" /> | |||
<Content Include="Areas\Vault\Views\Vault\ModifyVault.cshtml" /> | |||
<Content Include="Areas\Vault\Views\Vault\ModifyVaultItem.cshtml" /> | |||
<Content Include="Areas\Vault\Views\Vault\PasteItem.cshtml" /> | |||
<Content Include="Areas\Vault\Views\Vault\UploadItem.cshtml" /> | |||
<None Include="Properties\PublishProfiles\Teknik Dev.pubxml" /> |