diff --git a/web/documentserver-example/csharp/App_Themes/forgotten.css b/web/documentserver-example/csharp/App_Themes/forgotten.css new file mode 100755 index 00000000..af09c8ca --- /dev/null +++ b/web/documentserver-example/csharp/App_Themes/forgotten.css @@ -0,0 +1,114 @@ +.center { + width: auto; +} + +.left-panel { + width: 256px; +} + +.main-panel { + width: 832px; + padding: 0; + margin: 48px 0 48px 32px; + left: 0; +} + +.tableRow { + display: flex; + width: 100%; + justify-content: space-between; + align-items: center; + border-bottom: 1px solid #E2E2E2; +} + +.tableRow td:first-child { + width: 70%; + flex-grow: 0; + max-width: none; +} + +.tableHeader td:first-child { + text-align: left; +} + +.tableHeader td:last-child, .tableRow td:last-child { + width: 10%; + text-align: center; + padding: 0 !important; +} + +.tableHeader { + width: 100%; +} + +.stored-edit { + display: block; + padding-top: 0; + max-width: none; +} + +menu.links { + width: 100%; +} + +.scroll-table-body table { + table-layout: fixed; +} + +.stored-edit span { + font-size: 12px; + line-height: normal; + position: static; +} + +@media (max-width: 1279px) and (min-width: 1024px) { + .left-panel { + width: 208px; + } + + .main-panel { + width: 688px; + } +} + +@media (max-width: 1023px) and (min-width: 593px) { + .center { + max-width: 768px; + width: calc(100% - 80px); + } + + .table-main { + width: 100%; + } + + .left-panel { + width: 208px; + } + + .main-panel { + width: calc(100% - 32px); + } + + .tableHeader td:last-child, .tableRow td:last-child { + width: 20%; + } +} + +@media (max-width: 592px) and (min-width: 320px) { + .center, .table-main { + width: 100%; + } + + .left-panel { + display: none; + } + + .main-panel { + width: calc(100% - 32px); + margin: 16px; + } + + .tableHeader td:last-child, .tableRow td:last-child { + width: 25%; + } +} \ No newline at end of file diff --git a/web/documentserver-example/csharp/Forgotten.aspx b/web/documentserver-example/csharp/Forgotten.aspx new file mode 100755 index 00000000..9d79e4cf --- /dev/null +++ b/web/documentserver-example/csharp/Forgotten.aspx @@ -0,0 +1,125 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Forgotten.aspx.cs" Inherits="OnlineEditorsExample.Forgotten" Title="ONLYOFFICE" %> + +<%@ Import Namespace="System.IO" %> +<%@ Import Namespace="OnlineEditorsExample" %> + + + + + + + + /> + ONLYOFFICE + + + + + + + + + + + + + +
+
+
+ + ONLYOFFICE + +
+
+
+ + + + + + + +
+
+
+
+
+ Forgotten files +
+
+ + + + + + + +
FilenameAction
+
+ + + <% foreach (var file in GetForgottenFiles()) { %> + "> + + + + <% } %> + +
+ >" href="<%= file["url"] %>" target="_blank"> + <%= file["key"] %> + + + "> + Download + "> + Delete +
+
+
+
+
+
+ + +
+ + + + + diff --git a/web/documentserver-example/csharp/Forgotten.aspx.cs b/web/documentserver-example/csharp/Forgotten.aspx.cs new file mode 100755 index 00000000..d683330a --- /dev/null +++ b/web/documentserver-example/csharp/Forgotten.aspx.cs @@ -0,0 +1,82 @@ +/** + * + * (c) Copyright Ascensio System SIA 2024 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Web.Configuration; +using System.Web.UI; + +namespace OnlineEditorsExample +{ + public partial class Forgotten : Page + { + + //get server version + public static string GetVersion() + { + return WebConfigurationManager.AppSettings["version"]; + } + + private static bool? _ismono; + + public static bool IsMono + { + get { return _ismono.HasValue ? _ismono.Value : (_ismono = (bool?)(Type.GetType("Mono.Runtime") != null)).Value; } + } + + // get the document type + public static string DocumentType(string fileName) + { + var ext = Path.GetExtension(fileName).ToLower(); + + if (FormatManager.DocumentExtensions().Contains(ext)) return "word"; // word for text document extensions + if (FormatManager.SpreadsheetExtensions().Contains(ext)) return "cell"; // cell for spreadsheet extensions + if (FormatManager.PresentationExtensions().Contains(ext)) return "slide"; // slide for presentation extensions + + return "word"; // the default document type is word + } + + protected void Page_Load(object sender, EventArgs e) { } + + // fetch forgotten files from the document server + public static List> GetForgottenFiles() + { + var files = new List>(); + + var response = TrackManager.commandRequest("getForgottenList", null); + ArrayList keys = (ArrayList) response["keys"]; + + // run through all the files from the directory + foreach (string key in keys) + { + // write file parameters to the file object + var file = new Dictionary(); + var fileResult = TrackManager.commandRequest("getForgotten", key); + file.Add("key", fileResult["key"].ToString()); + file.Add("url", fileResult["url"].ToString()); + file.Add("type", DocumentType(fileResult["url"].ToString())); + + files.Add(file); + } + + return files; + } + } +} \ No newline at end of file diff --git a/web/documentserver-example/csharp/Forgotten.aspx.designer.cs b/web/documentserver-example/csharp/Forgotten.aspx.designer.cs new file mode 100755 index 00000000..5e04674f --- /dev/null +++ b/web/documentserver-example/csharp/Forgotten.aspx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace OnlineEditorsExample { + + + public partial class Forgotten { + + /// + /// form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + } +} diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index f567af51..cdcc9671 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -69,6 +69,9 @@ namespace OnlineEditorsExample case "remove": Remove(context); break; + case "removeforgotten": + RemoveForgotten(context); + break; case "assets": Assets(context); break; @@ -811,5 +814,25 @@ namespace OnlineEditorsExample context.Response.Write("{ \"error\": \"" + e.Message + "\"}"); } } + + // delete a forgotten file from the document server + private static void RemoveForgotten(HttpContext context) + { + try + { + string filename = context.Request["filename"]; + + if (!String.IsNullOrEmpty(filename)) + { + TrackManager.commandRequest("deleteForgotten", filename); + } + + context.Response.StatusCode = 204; + } + catch (Exception e) + { + context.Response.Write("{ \"error\": \"" + e.Message + "\"}"); + } + } } } \ No newline at end of file diff --git a/web/documentserver-example/csharp/script/forgotten.js b/web/documentserver-example/csharp/script/forgotten.js new file mode 100755 index 00000000..e5a9af2b --- /dev/null +++ b/web/documentserver-example/csharp/script/forgotten.js @@ -0,0 +1,19 @@ +function deleteFile(event) { + let filename = event.currentTarget.getAttribute("data"); + filename = encodeURIComponent(filename); + let url = `webeditor.ashx?type=removeforgotten&filename=${filename}`; + + fetch(url, { + headers: { + "Content-Type": "application/json", + } + }).then(result => { + if (result.status == 204) { + document.location.reload(true); + } + }); +} + +document.querySelectorAll('.delete-file').forEach(el => { + el.addEventListener('click', deleteFile); +}); \ No newline at end of file