Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The creation time of workflow is not intuitive enough #12070

Open
hyzx86 opened this issue Jul 24, 2022 · 13 comments
Open

The creation time of workflow is not intuitive enough #12070

hyzx86 opened this issue Jul 24, 2022 · 13 comments
Milestone

Comments

@hyzx86
Copy link
Contributor

hyzx86 commented Jul 24, 2022

In the current list of workflow instances, the process creation time is not intuitive enough. We only can open a detailed page to check the exact execution time

image

I adjusted the time format of the list page to make it consistent with the details page
image

@Skrypt
If necessary, I can submit a PR,Or you can update directly with the following code

<span class="hint">@T["Created {0}", await LocalClock.ConvertToLocalAsync(entry.Workflow.CreatedUtc)]</span>  
@hishamco
Copy link
Member

Do we really show time zone, coz this is the first time I notice that ;)

@jtkech
Copy link
Member

jtkech commented Jul 25, 2022

Here the "concern" is the usage by design of our coded TimeSpan shape

[Shape]
public IHtmlContent TimeSpan(IHtmlHelper Html, DateTime? Utc, DateTime? Origin)
{
Utc = Utc ?? _clock.UtcNow;
Origin = Origin ?? _clock.UtcNow;
var time = _clock.UtcNow - Utc.Value;
if (time.TotalYears() > 1)
return H.Plural(time.TotalYears(), "1 year ago", "{0} years ago");
if (time.TotalYears() < -1)
return H.Plural(-time.TotalYears(), "in 1 year", "in {0} years");

@hyzx86 would prefer the usage of our DateTime shape whose code looks like his suggestion ;)

[Shape]
public async Task<IHtmlContent> DateTime(IHtmlHelper Html, DateTime? Utc, string Format)
{
Utc = Utc ?? _clock.UtcNow;
var zonedTime = await _localClock.ConvertToLocalAsync(Utc.Value);

@hyzx86
Copy link
Contributor Author

hyzx86 commented Jul 25, 2022

🤣This is the first time I use shape..

Refer to official documents https://docs.orchardcore.net/en/dev/docs/reference/core/Placement/#datetime

I use it this way, I don't konw why it is empty ..
this code is in my custom theme project
image
image

@hishamco
Copy link
Member

You might need to override the shape

@hyzx86
Copy link
Contributor Author

hyzx86 commented Jul 25, 2022

Done ,but that will be show a correct time , 8 hours missing..

Looks like the Format is not work

 <span class="hint">@T["Created"]@await DisplayAsync(await New.DateTime(entry.Workflow.CreatedUtc, Format: "yyyy-MM-dd hh:mm:ss"))</span>
 @* <span class="hint">@T["Created: {0}", await LocalClock.ConvertToLocalAsync(entry.Workflow.CreatedUtc)]</span> *@
 @if (entry.Workflow.State.ContainsKey("LastExecutedOn")
      && entry.Workflow.State["LastExecutedOn"] is not null
      && DateTime.TryParse(entry.Workflow.State["LastExecutedOn"].ToString(), out var lastExecutedOn))
 {
 lastExecutedOn = DateTime.SpecifyKind(lastExecutedOn, DateTimeKind.Utc);
 <span class="hint">@T["| Last Executed: {0}", await LocalClock.ConvertToLocalAsync(lastExecutedOn)]</span>
 }

image

@hishamco
Copy link
Member

@hyzx86 why you didn't set a proper time zone

@hyzx86
Copy link
Contributor Author

hyzx86 commented Jul 25, 2022

In my orginal code ,it is work well

<span class="hint">@T["Created {0}", await LocalClock.ConvertToLocalAsync(entry.Workflow.CreatedUtc)]</span>  

The following code also uses ConvertToLocalAsync. I think it should output the same or similar results, but this is not the case

[Shape]
public async Task<IHtmlContent> DateTime(IHtmlHelper Html, DateTime? Utc, string Format)
{
Utc = Utc ?? _clock.UtcNow;
var zonedTime = await _localClock.ConvertToLocalAsync(Utc.Value);
if (Format == null)
{
Format = S[LongDateTimeFormat].Value;
}
return Html.Raw(Html.Encode(zonedTime.ToString(Format, CultureInfo.CurrentUICulture)));

@hishamco
Copy link
Member

hishamco commented Aug 8, 2022

What you wanna undo?

@sebastienros
Copy link
Member

Suggestion:

Change this line:

https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.Workflows/Views/Workflow/Index.cshtml#L104

With

<span class="hint">@T["Created {0}", (object)(await DisplayAsync(await New.DateTime(Utc: entry.Workflow.CreatedUtc)))]</span>

@sebastienros sebastienros added this to the 1.x milestone Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@sebastienros @hishamco @jtkech @hyzx86 and others