Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Extensions/Signum.Alerts/Signum.Alerts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReference Include="Microsoft.Graph" Version="5.94.0" />
<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion Extensions/Signum.Caching/CacheLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Signum.API;
using Signum.Authorization;
using Signum.Authorization.Rules;
using DocumentFormat.OpenXml.Office2013.Drawing.Chart;
using Signum.Caching;

namespace Signum.Cache;
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Signum.Caching/Signum.Caching.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.1.2" />
<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Signum.Calendar/Signum.Calendar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Signum.Chart/Signum.Chart.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Signum.CodeMirror/Signum.CodeMirror.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.3.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Signum.Dashboard/Signum.Dashboard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Signum.DiffLog/Signum.DiffLog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Signum.Dynamic/Signum.Dynamic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Signum.Eval/Signum.Eval.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.3.0" />
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Signum.Excel/Signum.Excel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.3.0" />
</ItemGroup>

Expand Down
20 changes: 13 additions & 7 deletions Extensions/Signum.Files/FilesController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Azure.Core;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.IO;
using Microsoft.Net.Http.Headers;
using Signum.Utilities.Reflection;
using System.Collections.Concurrent;
using System.Security.Cryptography;
using System.Reflection.Metadata.Ecma335;
using Azure.Core;
using System.IO;

namespace Signum.Files;

Expand All @@ -24,7 +24,7 @@ public FileStreamResult DownloadFilePath(string filePathId)
{
var filePath = Database.Retrieve<FilePathEntity>(PrimaryKey.Parse(filePathId, typeof(FilePathEntity)));

Response.Headers.CacheControl = $"max-age={FilePathLogic.MaxAge(filePath)}, private";
Response.GetTypedHeaders().CacheControl = FilesCacheControl(filePath);

return MimeMapping.GetFileStreamResult(filePath.OpenRead(), filePath.FileName);
}
Expand Down Expand Up @@ -53,11 +53,17 @@ public FileStreamResult DownloadFilePath(string filePathId)
if (fpe == null)
return null;

Response.Headers.CacheControl = $"max-age={FilePathLogic.MaxAge(fpe)}, private";
Response.GetTypedHeaders().CacheControl = FilesCacheControl(fpe);

return MimeMapping.GetFileStreamResult(fpe.OpenRead(), fpe.FileName);
return MimeMapping.GetFileStreamResult(fpe.OpenRead(), fpe.FileName);
}

private static CacheControlHeaderValue FilesCacheControl(IFilePath fpe) => new()
{
Private = true,
MaxAge = TimeSpan.FromSeconds(FilePathLogic.MaxAge(fpe))
};

static ConcurrentDictionary<PropertyRoute, Func<PrimaryKey, string?, FilePathEmbedded?>> queryBuilderCache =
new ConcurrentDictionary<PropertyRoute, Func<PrimaryKey, string?, FilePathEmbedded?>>();

Expand Down
2 changes: 1 addition & 1 deletion Extensions/Signum.Files/Signum.Files.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<PackageReference Include="Signum.Analyzer" Version="3.2.0" />
<PackageReference Include="Signum.MSBuildTask" Version="9.0.0" />
<PackageReference Include="Signum.TSGenerator" Version="9.2.1" />
<PackageReference Include="Signum.TSGenerator" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
61 changes: 39 additions & 22 deletions Extensions/Signum.Help/Editor/HelpImageHandler.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { PropertyRoute } from "@framework/Lines";
import { getSymbol } from "@framework/Reflection";
import { useAPI } from "@framework/Hooks";
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { FileImage } from "../../Signum.Files/Components/FileImage";
import { toFileEntity } from "../../Signum.Files/Components/FileUploader";
import { FilePathEmbedded, FileTypeSymbol } from "../../Signum.Files/Signum.Files";
import type { FilesClient } from '../../Signum.Files/FilesClient';
import { ImageHandlerBase, ImageInfo } from "../../Signum.HtmlEditor/Extensions/ImageExtension/ImageHandlerBase";
import { HelpImageEntity } from "../Signum.Help";
import { HelpImageEntity, HelpMessage } from "../Signum.Help";
import { HelpImageNode } from "./HelpImageNode";
import { ImageNodeBase } from "../../Signum.HtmlEditor/Extensions/ImageExtension/ImageNodeBase";
import { HelpClient } from "../HelpClient";

export class HelpImageHandler implements ImageHandlerBase {

Expand All @@ -24,7 +26,7 @@ export class HelpImageHandler implements ImageHandlerBase {

val.binaryFile && img.setAttribute("data-binary-file", val.binaryFile);
img.setAttribute("data-file-name", val.fileName || "");
val.imageId && img.setAttribute("data-help-image-id", val.imageId);
val.key && img.setAttribute("data-help-image-guid", val.key);

return img;
}
Expand All @@ -43,41 +45,56 @@ export class HelpImageHandler implements ImageHandlerBase {
}));
}

renderImage(info: ImageInfo): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> {
var fp = FilePathEmbedded.New({
binaryFile: info.binaryFile,
entityId: info.imageId,
mListRowId: null,
fileType: getSymbol(FileTypeSymbol, this.pr.member!.defaultFileTypeInfo!.key),
rootType: this.pr.findRootType().name,
propertyRoute: this.pr.propertyPath()
});

if (fp.entityId == null && fp.binaryFile == null)
return <div className="alert alert-danger">{JSON.stringify(info)}</div>;

return <FileImage file={fp} />;
renderImage(info: ImageInfo): React.ReactElement {
return <InlineImage info={info} pr={this.pr} />;
}

toHtml(val: ImageInfo): string | undefined {
if (val.binaryFile)
return `<img data-binary-file="${val.binaryFile}" data-file-name="${val.fileName}" />`;

if (val.imageId)
return `<img data-help-image-id="${val.imageId}" />`;
if (val.key)
return `<img data-help-image-guid="${val.key}" />`;

return undefined;
}

fromElement(element: HTMLDivElement): ImageInfo | undefined {
if (element.tagName == "IMG") {
return {
binaryFile: element.dataset["binaryFile"],
fileName: element.dataset["fileName"],
imageId: element.dataset["helpImageId"],
binaryFile: element.getAttribute("data-binary-file") ?? undefined,
fileName: element.getAttribute("data-file-name") ?? undefined,
key: element.getAttribute("data-help-image-guid") ?? undefined,
};
}

return undefined;
}
}

function InlineImage(p: { info: ImageInfo, pr: PropertyRoute }): React.ReactElement | undefined
{
const imageId = useAPI(() => p.info.key && HelpClient.API.getImageId(p.info.key), []);

if (!imageId && !p.info.binaryFile)
return (
<div className="alert alert-info d-inline-block" >
<span>
<FontAwesomeIcon icon="gear" className="fa-fw me-2" style={{ fontSize: "larger" }} spin />
{HelpMessage.LoadingImage.niceToString()}...
</span>
</div>
);

const fp = FilePathEmbedded.New({
binaryFile: p.info.binaryFile,
entityId: imageId,
mListRowId: null,
fileType: getSymbol(FileTypeSymbol, p.pr.member!.defaultFileTypeInfo!.key),
rootType: p.pr.findRootType().name,
propertyRoute: p.pr.propertyPath()
});

return <FileImage file={fp} />;

}
4 changes: 2 additions & 2 deletions Extensions/Signum.Help/Editor/HelpImageNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { ImageInfo } from '../../Signum.HtmlEditor/Extensions/ImageExtension/Ima

export class HelpImageNode extends ImageNodeBase {
static {
this.converter = new HelpImageHandler();
this.dataImageIdAttribute = "data-help-image-id";
this.handler = new HelpImageHandler();
this.dataImageIdAttribute = "data-help-image-guid";
}

static getType(): string {
Expand Down
10 changes: 10 additions & 0 deletions Extensions/Signum.Help/HelpClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { NamespaceHelpEntity, TypeHelpEntity, AppendixHelpEntity, QueryHelpEntit
import { QueryString } from '@framework/QueryString';
import { OmniboxClient } from '../Signum.Omnibox/OmniboxClient';
import HelpOmniboxProvider from './HelpOmniboxProvider';
import * as OmniboxSpecialAction from '@framework/OmniboxSpecialAction'
import { CultureInfoEntity } from '@framework/Signum.Basics';
import { WidgetContext, onWidgets } from '@framework/Frames/Widgets';
import { HelpIcon, HelpWidget } from './HelpWidget';
Expand All @@ -28,6 +29,12 @@ export namespace HelpClient {

OmniboxClient.registerProvider(new HelpOmniboxProvider());

OmniboxSpecialAction.registerSpecialAction({
allowed: () => AppContext.isPermissionAuthorized(HelpPermissions.ExportHelp),
key: "ImportHelp",
onClick: () => Promise.resolve("/help/import")
});

options.routes.push({ path: "/help", element: <ImportComponent onImport={() => import("./Pages/HelpIndexPage")} /> });
options.routes.push({ path: "/help/namespace/:namespace", element: <ImportComponent onImport={() => import("./Pages/NamespaceHelpPage")} /> });
options.routes.push({ path: "/help/type/:cleanName", element: <ImportComponent onImport={() => import("./Pages/TypeHelpPage")} /> });
Expand Down Expand Up @@ -164,6 +171,9 @@ export namespace HelpClient {
return ajaxPost({ url: "/api/help/applyImport" }, { file, model });
}

export function getImageId(guid: string): Promise<string> {
return ajaxGet({ url: `/api/help/getImageId?guid=${guid}`, cache: 'default' as RequestCache });
}


}
Expand Down
3 changes: 2 additions & 1 deletion Extensions/Signum.Help/HelpCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ public enum HelpMessage
SelectedFile,
HelpZipContents,
NewKey,
ActionStatus
ActionStatus,
LoadingImage,
}

public enum HelpKindMessage
Expand Down
18 changes: 15 additions & 3 deletions Extensions/Signum.Help/HelpController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers;
using Signum.API.Filters;
using Signum.Basics;
using Signum.Files;
using Signum.UserAssets;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.IO;

namespace Signum.Help;
Expand Down Expand Up @@ -155,6 +154,19 @@ public FileStreamResult Export([Required, FromBody] Lite<IHelpEntity>[] lites)
return MimeMapping.GetFileStreamResult(new MemoryStream(bytes), fileName);
}

[HttpGet("api/help/getImageId")]
public ActionResult<string> GetImageId([Required, FromQuery] Guid guid)
{
Response.GetTypedHeaders().CacheControl = new CacheControlHeaderValue
{
Public = true,
MaxAge = TimeSpan.FromDays(365),
};

var id = HelpLogic.GetImageId(guid);
return id is null ? NotFound() : id.Value.ToString();
}

[HttpPost("api/help/importPreview")]
public HelpImportPreviewModel ImportPreview([Required, FromBody] FileUpload file)
{
Expand Down
Loading