mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
feature(csharp): forgotten files page
This commit is contained in:
114
web/documentserver-example/csharp/App_Themes/forgotten.css
Executable file
114
web/documentserver-example/csharp/App_Themes/forgotten.css
Executable file
@ -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%;
|
||||||
|
}
|
||||||
|
}
|
||||||
125
web/documentserver-example/csharp/Forgotten.aspx
Executable file
125
web/documentserver-example/csharp/Forgotten.aspx
Executable file
@ -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" %>
|
||||||
|
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head runat="server">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width" />
|
||||||
|
<meta name="server-version" content=<%= GetVersion() %> />
|
||||||
|
<title>ONLYOFFICE</title>
|
||||||
|
<!--
|
||||||
|
*
|
||||||
|
* (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.
|
||||||
|
*
|
||||||
|
-->
|
||||||
|
<link rel="icon" href="~/favicon.ico" type="image/x-icon" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Open+Sans:900,800,700,600,500,400,300&subset=latin,cyrillic-ext,cyrillic,latin-ext" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="app_themes/stylesheet.css" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="app_themes/media.css" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="app_themes/forgotten.css" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="app_themes/jquery-ui.css" />
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form id="form1" runat="server">
|
||||||
|
<header>
|
||||||
|
<div class="center">
|
||||||
|
<a href="">
|
||||||
|
<img src ="app_themes/images/logo.svg" alt="ONLYOFFICE" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="center main">
|
||||||
|
<table class="table-main">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="left-panel section"></td>
|
||||||
|
<td class="section">
|
||||||
|
<div class="main-panel">
|
||||||
|
<div class="stored-list">
|
||||||
|
<div class="storedHeader">
|
||||||
|
<div class="storedHeaderText">
|
||||||
|
<span class="header-list">Forgotten files</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<table class="tableHeader" cellspacing="0" cellpadding="0" width="100%">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td class="tableHeaderCell">Filename</td>
|
||||||
|
<td class="tableHeaderCell">Action</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</table>
|
||||||
|
<div class="scroll-table-body">
|
||||||
|
<table cellspacing="0" cellpadding="0" width="100%">
|
||||||
|
<tbody>
|
||||||
|
<% foreach (var file in GetForgottenFiles()) { %>
|
||||||
|
<tr class="tableRow" title="<%= file["key"] %>">
|
||||||
|
<td>
|
||||||
|
<a class="stored-edit <%= file["type"] %>>" href="<%= file["url"] %>" target="_blank">
|
||||||
|
<span><%= file["key"] %></span>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="<%= file["url"] %>">
|
||||||
|
<img class="icon-download" src="app_themes/images/download.svg" alt="Download" title="Download" /></a>
|
||||||
|
<a class="delete-file" data="<%= file["key"] %>">
|
||||||
|
<img class="icon-action" src="app_themes/images/delete.svg" alt="Delete" title="Delete" /></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% } %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<div class="center">
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="http://api.onlyoffice.com/editors/howitworks" target="_blank">API Documentation</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="mailto:sales@onlyoffice.com">Submit your request</a>
|
||||||
|
</td>
|
||||||
|
<td class="copy">
|
||||||
|
© Ascensio System SIA <%= DateTime.Now.Year.ToString() %>. All rights reserved.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script language="javascript" type="text/javascript" src="script/forgotten.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
82
web/documentserver-example/csharp/Forgotten.aspx.cs
Executable file
82
web/documentserver-example/csharp/Forgotten.aspx.cs
Executable file
@ -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<Dictionary<string, string>> GetForgottenFiles()
|
||||||
|
{
|
||||||
|
var files = new List<Dictionary<string, string>>();
|
||||||
|
|
||||||
|
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<string, string>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
web/documentserver-example/csharp/Forgotten.aspx.designer.cs
generated
Executable file
24
web/documentserver-example/csharp/Forgotten.aspx.designer.cs
generated
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace OnlineEditorsExample {
|
||||||
|
|
||||||
|
|
||||||
|
public partial class Forgotten {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// form1 control.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Auto-generated field.
|
||||||
|
/// To modify move field declaration from designer file to code-behind file.
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -69,6 +69,9 @@ namespace OnlineEditorsExample
|
|||||||
case "remove":
|
case "remove":
|
||||||
Remove(context);
|
Remove(context);
|
||||||
break;
|
break;
|
||||||
|
case "removeforgotten":
|
||||||
|
RemoveForgotten(context);
|
||||||
|
break;
|
||||||
case "assets":
|
case "assets":
|
||||||
Assets(context);
|
Assets(context);
|
||||||
break;
|
break;
|
||||||
@ -811,5 +814,25 @@ namespace OnlineEditorsExample
|
|||||||
context.Response.Write("{ \"error\": \"" + e.Message + "\"}");
|
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 + "\"}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
19
web/documentserver-example/csharp/script/forgotten.js
Executable file
19
web/documentserver-example/csharp/script/forgotten.js
Executable file
@ -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);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user