From 8be123dba2fe7c0a006d677ce76039f39a420a69 Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Fri, 23 Aug 2024 10:05:03 +0200 Subject: [PATCH 01/21] task --- .../Modals/LogCurvePriorityModal.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx index 12b5bfc56..9cabbb5e2 100644 --- a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx +++ b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx @@ -1,4 +1,4 @@ -import { Icon, TextField } from "@equinor/eds-core-react"; +import { Checkbox, Icon, Label, TextField } from "@equinor/eds-core-react"; import { Button } from "components/StyledComponents/Button"; import { useOperationState } from "hooks/useOperationState"; import React, { ChangeEvent, useState } from "react"; @@ -13,6 +13,7 @@ import { } from "../ContextMenus/ContextMenu"; import { LogCurvePriorityContextMenu } from "../ContextMenus/LogCurvePriorityContextMenu"; import ModalDialog from "./ModalDialog"; +import { property } from "lodash"; export interface LogCurvePriorityModalProps { wellUid: string; @@ -46,7 +47,13 @@ export const LogCurvePriorityModal = ( property: "mnemonic", label: "mnemonic", type: ContentType.String, - width: 500 + width: 440 + }, + { + property: "global", + label: "global", + type: ContentType.Component, + width: 60 } ]; @@ -54,7 +61,11 @@ export const LogCurvePriorityModal = ( return updatedPrioritizedCurves.sort().map((mnemonic) => { return { id: mnemonic, - mnemonic: mnemonic + mnemonic: mnemonic, + global:
}; }); }; @@ -143,7 +154,7 @@ const Layout = styled.div` display: grid; grid-template-rows: 1fr auto; max-height: 100%; - gap: 20px; + gap: 40px; `; const AddItemLayout = styled.div` From 59424fb617c0badce3d2720fb097691ae0de720c Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Thu, 29 Aug 2024 10:01:30 +0200 Subject: [PATCH 02/21] priority log curves --- .../HttpHandlers/LogCurvePriorityHandler.cs | 5 ++- .../Models/LogCurvePriorities.cs | 10 +++++ .../Services/LogCurvePriorityService.cs | 44 ++++++++++++++----- .../ContentViews/LogCurveInfoListView.tsx | 5 ++- .../ContextMenus/LogCurveInfoContextMenu.tsx | 11 +++-- .../Modals/LogCurvePriorityModal.tsx | 29 ++++++++++-- .../services/logCurvePriorityService.tsx | 8 +++- 7 files changed, 90 insertions(+), 22 deletions(-) create mode 100644 Src/WitsmlExplorer.Api/Models/LogCurvePriorities.cs diff --git a/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs b/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs index 12b9ccf03..0c3c529f4 100644 --- a/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs +++ b/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using WitsmlExplorer.Api.Models; using WitsmlExplorer.Api.Services; namespace WitsmlExplorer.Api.HttpHandlers @@ -18,9 +19,9 @@ public static async Task GetPrioritizedCurves(string wellUid, string we } [Produces(typeof(IList))] - public static async Task SetPrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves, ILogCurvePriorityService logCurvePriorityService) + public static async Task SetPrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities priorities, ILogCurvePriorityService logCurvePriorityService) { - var createdPrioritizedCurves = await logCurvePriorityService.SetPrioritizedCurves(wellUid, wellboreUid, prioritizedCurves) ?? new List(); + var createdPrioritizedCurves = await logCurvePriorityService.SetPrioritizedCurves(wellUid, wellboreUid, priorities) ?? new List(); return TypedResults.Ok(createdPrioritizedCurves); } } diff --git a/Src/WitsmlExplorer.Api/Models/LogCurvePriorities.cs b/Src/WitsmlExplorer.Api/Models/LogCurvePriorities.cs new file mode 100644 index 000000000..0e75e3eff --- /dev/null +++ b/Src/WitsmlExplorer.Api/Models/LogCurvePriorities.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace WitsmlExplorer.Api.Models +{ + public class LogCurvePriorities + { + public IList PrioritizedCurves { get; set; } + public IList PrioritizedGlobalCurves { get; set; } + } +} diff --git a/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs b/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs index 7337d1aca..7e0590169 100644 --- a/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs +++ b/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs @@ -14,7 +14,7 @@ namespace WitsmlExplorer.Api.Services public interface ILogCurvePriorityService { Task> GetPrioritizedCurves(string wellUid, string wellboreUid); - Task> SetPrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves); + Task> SetPrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities priorities); } public class LogCurvePriorityService : ILogCurvePriorityService @@ -30,12 +30,13 @@ public async Task> GetPrioritizedCurves(string wellUid, string wel { string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); LogCurvePriority logCurvePriority = await logCurvePriorityRepository.GetDocumentAsync(logCurvePriorityId); + LogCurvePriority logCurvePriorityGlobal = await logCurvePriorityRepository.GetDocumentAsync("global"); return logCurvePriority?.PrioritizedCurves; } - public async Task> SetPrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves) + public async Task> SetPrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities priorities) { - if (prioritizedCurves.IsNullOrEmpty()) + if (priorities.PrioritizedCurves.IsNullOrEmpty()) { await DeleteLogCurvePriorityObject(wellUid, wellboreUid); return null; @@ -44,18 +45,27 @@ public async Task> SetPrioritizedCurves(string wellUid, string wel IList currentPrioritizedCurves = await GetPrioritizedCurves(wellUid, wellboreUid); if (currentPrioritizedCurves == null) { - return await CreatePrioritizedCurves(wellUid, wellboreUid, prioritizedCurves); + return await CreatePrioritizedCurves(wellUid, wellboreUid, priorities); } + return await CreatePrioritizedGlobalCurves( priorities); + // string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); + // LogCurvePriority logCurvePriorityToUpdate = CreateLogCurvePriorityObject(wellUid, wellboreUid, priorities); + var globalist = CreateLogCurveGlobalPriorityObject(priorities); + // LogCurvePriority updatedLogCurvePriority = await logCurvePriorityRepository.UpdateDocumentAsync(logCurvePriorityId, logCurvePriorityToUpdate); + var updateGlobal = await logCurvePriorityRepository.CreateDocumentAsync( globalist); + return updateGlobal.PrioritizedCurves; + } - string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); - LogCurvePriority logCurvePriorityToUpdate = CreateLogCurvePriorityObject(wellUid, wellboreUid, prioritizedCurves); - LogCurvePriority updatedLogCurvePriority = await logCurvePriorityRepository.UpdateDocumentAsync(logCurvePriorityId, logCurvePriorityToUpdate); - return updatedLogCurvePriority.PrioritizedCurves; + private async Task> CreatePrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities logCurvePriorities) + { + LogCurvePriority logCurvePriorityToCreate = CreateLogCurvePriorityObject(wellUid, wellboreUid, logCurvePriorities); + LogCurvePriority inserted = await logCurvePriorityRepository.CreateDocumentAsync(logCurvePriorityToCreate); + return inserted.PrioritizedCurves; } - private async Task> CreatePrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves) + private async Task> CreatePrioritizedGlobalCurves( LogCurvePriorities logCurvePriorities) { - LogCurvePriority logCurvePriorityToCreate = CreateLogCurvePriorityObject(wellUid, wellboreUid, prioritizedCurves); + LogCurvePriority logCurvePriorityToCreate = CreateLogCurveGlobalPriorityObject( logCurvePriorities); LogCurvePriority inserted = await logCurvePriorityRepository.CreateDocumentAsync(logCurvePriorityToCreate); return inserted.PrioritizedCurves; } @@ -76,12 +86,22 @@ private string GetLogCurvePriorityId(string wellUid, string wellboreUid) return $"{wellUid}-{wellboreUid}"; } - private LogCurvePriority CreateLogCurvePriorityObject(string wellUid, string wellboreUid, IList prioritizedCurves) + private LogCurvePriority CreateLogCurvePriorityObject(string wellUid, string wellboreUid, LogCurvePriorities prioritizedCurves) { string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); LogCurvePriority logCurvePriorityObject = new(logCurvePriorityId) { - PrioritizedCurves = prioritizedCurves + PrioritizedCurves = prioritizedCurves.PrioritizedCurves + }; + return logCurvePriorityObject; + } + + private LogCurvePriority CreateLogCurveGlobalPriorityObject(LogCurvePriorities prioritizedCurves) + { + string logCurvePriorityId = "global"; + LogCurvePriority logCurvePriorityObject = new(logCurvePriorityId) + { + PrioritizedCurves = prioritizedCurves.PrioritizedGlobalCurves.Where(x => x.Equals("WOB")).ToList() }; return logCurvePriorityObject; } diff --git a/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx b/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx index 511a4f8d8..926478d65 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx @@ -62,6 +62,7 @@ export default function LogCurveInfoListView() { const [showOnlyPrioritizedCurves, setShowOnlyPrioritizedCurves] = useState(false); const [prioritizedCurves, setPrioritizedCurves] = useState([]); + const [prioritizedGlobalCurves, setPrioritizedGlobalCurves] = useState([]); const logObjects = new Map([[objectUid, logObject]]); const isDepthIndex = logType === RouterLogType.DEPTH; const isFetching = isFetchingLog || isFetchingLogCurveInfo; @@ -83,6 +84,7 @@ export default function LogCurveInfoListView() { wellboreUid ); setPrioritizedCurves(prioritizedCurves); + setPrioritizedGlobalCurves(prioritizedCurves); }; getLogCurvePriority().catch(truncateAbortHandler); @@ -102,7 +104,8 @@ export default function LogCurveInfoListView() { selectedServer: connectedServer, servers, prioritizedCurves, - setPrioritizedCurves + setPrioritizedCurves, + prioritizedGlobalCurves }; const position = getContextMenuPosition(event); dispatchOperation({ diff --git a/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx b/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx index acaaf7bf4..2f788cbcd 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx @@ -61,6 +61,7 @@ export interface LogCurveInfoContextMenuProps { servers: Server[]; prioritizedCurves: string[]; setPrioritizedCurves: (prioritizedCurves: string[]) => void; + prioritizedGlobalCurves: string[]; isMultiLog?: boolean; } @@ -75,6 +76,7 @@ const LogCurveInfoContextMenu = ( servers, prioritizedCurves, setPrioritizedCurves, + prioritizedGlobalCurves, isMultiLog = false } = props; @@ -175,7 +177,8 @@ const LogCurveInfoContextMenu = ( wellUid: selectedLog.wellUid, wellboreUid: selectedLog.wellboreUid, prioritizedCurves, - setPrioritizedCurves + setPrioritizedCurves, + prioritizedGlobalCurves }; dispatchOperation({ type: OperationType.DisplayModal, @@ -211,7 +214,8 @@ const LogCurveInfoContextMenu = ( await LogCurvePriorityService.setPrioritizedCurves( selectedLog.wellUid, selectedLog.wellboreUid, - curvesToPrioritize + curvesToPrioritize, + null ); setPrioritizedCurves(newPrioritizedCurves); }; @@ -226,7 +230,8 @@ const LogCurveInfoContextMenu = ( await LogCurvePriorityService.setPrioritizedCurves( selectedLog.wellUid, selectedLog.wellboreUid, - curvesToPrioritize + curvesToPrioritize, + null ); setPrioritizedCurves(newPrioritizedCurves); }; diff --git a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx index 9cabbb5e2..3436b9a34 100644 --- a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx +++ b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx @@ -13,12 +13,12 @@ import { } from "../ContextMenus/ContextMenu"; import { LogCurvePriorityContextMenu } from "../ContextMenus/LogCurvePriorityContextMenu"; import ModalDialog from "./ModalDialog"; -import { property } from "lodash"; export interface LogCurvePriorityModalProps { wellUid: string; wellboreUid: string; prioritizedCurves: string[]; + prioritizedGlobalCurves: string[]; setPrioritizedCurves: (prioritizedCurves: string[]) => void; } @@ -30,10 +30,12 @@ export interface LogCurvePriorityRow { export const LogCurvePriorityModal = ( props: LogCurvePriorityModalProps ): React.ReactElement => { - const { wellUid, wellboreUid, prioritizedCurves, setPrioritizedCurves } = + const { wellUid, wellboreUid, prioritizedCurves, prioritizedGlobalCurves, setPrioritizedCurves} = props; const [updatedPrioritizedCurves, setUpdatedPrioritizedCurves] = useState(prioritizedCurves); + const [updatedPrioritizedGlobalCurves, setUpdatedPrioritizedGlobalCurves] = + useState(prioritizedGlobalCurves); const [newCurve, setNewCurve] = useState(""); const { dispatchOperation } = useOperationState(); const [position, setPosition] = useState({ @@ -65,10 +67,24 @@ export const LogCurvePriorityModal = ( global:
) => { + console.log(e) + if (e.target.checked) { + addPrioritizedGlobalCurve(mnemonic); + } else { + deleteGlobalCurve(mnemonic); + } + }} />
}; }); }; + + const addPrioritizedGlobalCurve = (mnemonic: string) => { + setUpdatedPrioritizedGlobalCurves([...updatedPrioritizedGlobalCurves, mnemonic]); + } + const onDelete = (curvesToDelete: string[]) => { setUpdatedPrioritizedCurves( @@ -76,6 +92,11 @@ export const LogCurvePriorityModal = ( ); }; + const deleteGlobalCurve = (curveToDelete: string) => { + const toDelete = updatedPrioritizedGlobalCurves.filter((c) => curveToDelete !== c); + setUpdatedPrioritizedGlobalCurves(toDelete); + }; + const onContextMenu = ( event: React.MouseEvent, {}, @@ -91,13 +112,15 @@ export const LogCurvePriorityModal = ( await LogCurvePriorityService.setPrioritizedCurves( wellUid, wellboreUid, - updatedPrioritizedCurves + updatedPrioritizedCurves, + updatedPrioritizedGlobalCurves ); dispatchOperation({ type: OperationType.HideModal }); setPrioritizedCurves(updatedPrioritizedCurves); }; const addCurve = () => { + console.log("add curev") setUpdatedPrioritizedCurves([...updatedPrioritizedCurves, newCurve]); setNewCurve(""); }; diff --git a/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx b/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx index 32fa17bbc..024fb6738 100644 --- a/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx +++ b/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx @@ -23,13 +23,19 @@ export default class LogCurvePriorityService { wellUid: string, wellboreUid: string, prioritizedCurves: string[], + prioritizedGlogalCurves: string[], abortSignal?: AbortSignal ): Promise { + const payload = { + prioritizedCurves: prioritizedCurves, + prioritizedGlobalCurves: prioritizedGlogalCurves, + }; + console.log(payload) const response = await ApiClient.post( `/api/wells/${encodeURIComponent(wellUid)}/wellbores/${encodeURIComponent( wellboreUid )}/logCurvePriority`, - JSON.stringify(prioritizedCurves), + JSON.stringify(payload), abortSignal ); if (response.ok) { From 7adafd561833fde09792f2f596de5ad942387694 Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Mon, 9 Sep 2024 14:47:56 +0200 Subject: [PATCH 03/21] global curvers --- .../Services/LogCurvePriorityService.cs | 50 +++++++++++++------ .../ContentViews/LogCurveInfoListView.tsx | 7 +-- .../ContextMenus/LogCurveInfoContextMenu.tsx | 11 ++-- .../Modals/LogCurvePriorityModal.tsx | 5 +- .../models/logCurvePriorities.ts | 4 ++ .../services/logCurvePriorityService.tsx | 10 ++-- 6 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 Src/WitsmlExplorer.Frontend/models/logCurvePriorities.ts diff --git a/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs b/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs index 7e0590169..f0a6f5fe5 100644 --- a/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs +++ b/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs @@ -14,7 +14,8 @@ namespace WitsmlExplorer.Api.Services public interface ILogCurvePriorityService { Task> GetPrioritizedCurves(string wellUid, string wellboreUid); - Task> SetPrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities priorities); + Task SetPrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities priorities); + Task> GetPrioritizedGlobalCurves(); } public class LogCurvePriorityService : ILogCurvePriorityService @@ -30,30 +31,52 @@ public async Task> GetPrioritizedCurves(string wellUid, string wel { string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); LogCurvePriority logCurvePriority = await logCurvePriorityRepository.GetDocumentAsync(logCurvePriorityId); - LogCurvePriority logCurvePriorityGlobal = await logCurvePriorityRepository.GetDocumentAsync("global"); return logCurvePriority?.PrioritizedCurves; } - public async Task> SetPrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities priorities) + public async Task> GetPrioritizedGlobalCurves() + { + LogCurvePriority logCurvePriorityGlobal = await logCurvePriorityRepository.GetDocumentAsync("global"); + return logCurvePriorityGlobal?.PrioritizedCurves; + } + + public async Task SetPrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities priorities) { if (priorities.PrioritizedCurves.IsNullOrEmpty()) { await DeleteLogCurvePriorityObject(wellUid, wellboreUid); - return null; } + var result = new LogCurvePriorities(); + IList currentPrioritizedCurves = await GetPrioritizedCurves(wellUid, wellboreUid); if (currentPrioritizedCurves == null) { - return await CreatePrioritizedCurves(wellUid, wellboreUid, priorities); + var prioritedCurves = + await CreatePrioritizedCurves(wellUid, wellboreUid, + priorities); + result.PrioritizedCurves = prioritedCurves; } - return await CreatePrioritizedGlobalCurves( priorities); - // string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); - // LogCurvePriority logCurvePriorityToUpdate = CreateLogCurvePriorityObject(wellUid, wellboreUid, priorities); - var globalist = CreateLogCurveGlobalPriorityObject(priorities); - // LogCurvePriority updatedLogCurvePriority = await logCurvePriorityRepository.UpdateDocumentAsync(logCurvePriorityId, logCurvePriorityToUpdate); - var updateGlobal = await logCurvePriorityRepository.CreateDocumentAsync( globalist); - return updateGlobal.PrioritizedCurves; + else + { + string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); + LogCurvePriority logCurvePriorityToUpdate = CreateLogCurvePriorityObject(wellUid, wellboreUid, priorities); + LogCurvePriority updatedLogCurvePriority = await logCurvePriorityRepository.UpdateDocumentAsync(logCurvePriorityId, logCurvePriorityToUpdate); + result.PrioritizedCurves = updatedLogCurvePriority.PrioritizedCurves; + } + + + var globalist = await GetPrioritizedGlobalCurves(); + + if (globalist != null) + { + LogCurvePriority logCurvePriorityToUpdate = CreateLogCurveGlobalPriorityObject( priorities); + var globalDocument = await logCurvePriorityRepository.GetDocumentAsync("global"); + LogCurvePriority updatedLogCurvePriority = await logCurvePriorityRepository.UpdateDocumentAsync("global", logCurvePriorityToUpdate); + result.PrioritizedGlobalCurves = updatedLogCurvePriority.PrioritizedCurves; + } + + return result; } private async Task> CreatePrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities logCurvePriorities) @@ -78,7 +101,6 @@ private async Task DeleteLogCurvePriorityObject(string wellUid, string wellboreU string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); await logCurvePriorityRepository.DeleteDocumentAsync(logCurvePriorityId); } - return; } private string GetLogCurvePriorityId(string wellUid, string wellboreUid) @@ -101,7 +123,7 @@ private LogCurvePriority CreateLogCurveGlobalPriorityObject(LogCurvePriorities p string logCurvePriorityId = "global"; LogCurvePriority logCurvePriorityObject = new(logCurvePriorityId) { - PrioritizedCurves = prioritizedCurves.PrioritizedGlobalCurves.Where(x => x.Equals("WOB")).ToList() + PrioritizedCurves = prioritizedCurves.PrioritizedGlobalCurves }; return logCurvePriorityObject; } diff --git a/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx b/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx index 926478d65..14bb75ad8 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx @@ -83,8 +83,8 @@ export default function LogCurveInfoListView() { wellUid, wellboreUid ); - setPrioritizedCurves(prioritizedCurves); - setPrioritizedGlobalCurves(prioritizedCurves); + setPrioritizedCurves(prioritizedCurves.prioritizedCurves); + setPrioritizedGlobalCurves(prioritizedCurves.prioritizedGlobalCurves); }; getLogCurvePriority().catch(truncateAbortHandler); @@ -105,7 +105,8 @@ export default function LogCurveInfoListView() { servers, prioritizedCurves, setPrioritizedCurves, - prioritizedGlobalCurves + prioritizedGlobalCurves, + setPrioritizedGlobalCurves }; const position = getContextMenuPosition(event); dispatchOperation({ diff --git a/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx b/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx index 2f788cbcd..f01a9ec0a 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx @@ -62,6 +62,7 @@ export interface LogCurveInfoContextMenuProps { prioritizedCurves: string[]; setPrioritizedCurves: (prioritizedCurves: string[]) => void; prioritizedGlobalCurves: string[]; + setPrioritizedGlobalCurves: (prioritizedGlobalCurves: string[]) => void; isMultiLog?: boolean; } @@ -77,6 +78,7 @@ const LogCurveInfoContextMenu = ( prioritizedCurves, setPrioritizedCurves, prioritizedGlobalCurves, + setPrioritizedGlobalCurves, isMultiLog = false } = props; @@ -178,7 +180,8 @@ const LogCurveInfoContextMenu = ( wellboreUid: selectedLog.wellboreUid, prioritizedCurves, setPrioritizedCurves, - prioritizedGlobalCurves + prioritizedGlobalCurves, + setPrioritizedGlobalCurves }; dispatchOperation({ type: OperationType.DisplayModal, @@ -217,7 +220,8 @@ const LogCurveInfoContextMenu = ( curvesToPrioritize, null ); - setPrioritizedCurves(newPrioritizedCurves); + setPrioritizedCurves(newPrioritizedCurves.prioritizedCurves); + setPrioritizedGlobalCurves(newPrioritizedCurves.prioritizedGlobalCurves); }; const onClickRemovePriority = async () => { @@ -233,7 +237,8 @@ const LogCurveInfoContextMenu = ( curvesToPrioritize, null ); - setPrioritizedCurves(newPrioritizedCurves); + setPrioritizedCurves(newPrioritizedCurves.prioritizedCurves); + setPrioritizedGlobalCurves(newPrioritizedCurves.prioritizedGlobalCurves) }; const toDelete = createComponentReferences( diff --git a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx index 3436b9a34..f78833090 100644 --- a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx +++ b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx @@ -20,6 +20,7 @@ export interface LogCurvePriorityModalProps { prioritizedCurves: string[]; prioritizedGlobalCurves: string[]; setPrioritizedCurves: (prioritizedCurves: string[]) => void; + setPrioritizedGlobalCurves: (prioritizedGlobalCurves: string[]) => void; } export interface LogCurvePriorityRow { @@ -30,7 +31,7 @@ export interface LogCurvePriorityRow { export const LogCurvePriorityModal = ( props: LogCurvePriorityModalProps ): React.ReactElement => { - const { wellUid, wellboreUid, prioritizedCurves, prioritizedGlobalCurves, setPrioritizedCurves} = + const { wellUid, wellboreUid, prioritizedCurves, prioritizedGlobalCurves, setPrioritizedCurves, setPrioritizedGlobalCurves} = props; const [updatedPrioritizedCurves, setUpdatedPrioritizedCurves] = useState(prioritizedCurves); @@ -117,6 +118,8 @@ export const LogCurvePriorityModal = ( ); dispatchOperation({ type: OperationType.HideModal }); setPrioritizedCurves(updatedPrioritizedCurves); + console.log(updatedPrioritizedCurves) + setPrioritizedGlobalCurves(updatedPrioritizedGlobalCurves) }; const addCurve = () => { diff --git a/Src/WitsmlExplorer.Frontend/models/logCurvePriorities.ts b/Src/WitsmlExplorer.Frontend/models/logCurvePriorities.ts new file mode 100644 index 000000000..5ce9cffd9 --- /dev/null +++ b/Src/WitsmlExplorer.Frontend/models/logCurvePriorities.ts @@ -0,0 +1,4 @@ +export default interface LogCurvePriorites { + prioritizedCurves: string[]; + prioritizedGlobalCurves: string[]; +} \ No newline at end of file diff --git a/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx b/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx index 024fb6738..77d57d708 100644 --- a/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx +++ b/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx @@ -1,3 +1,4 @@ +import LogCurvePriorites from "models/logCurvePriorities"; import { ApiClient } from "./apiClient"; export default class LogCurvePriorityService { @@ -5,7 +6,7 @@ export default class LogCurvePriorityService { wellUid: string, wellboreUid: string, abortSignal?: AbortSignal - ): Promise { + ): Promise { const response = await ApiClient.get( `/api/wells/${encodeURIComponent(wellUid)}/wellbores/${encodeURIComponent( wellboreUid @@ -15,7 +16,7 @@ export default class LogCurvePriorityService { if (response.ok) { return response.json(); } else { - return []; + return null; } } @@ -25,12 +26,11 @@ export default class LogCurvePriorityService { prioritizedCurves: string[], prioritizedGlogalCurves: string[], abortSignal?: AbortSignal - ): Promise { + ): Promise { const payload = { prioritizedCurves: prioritizedCurves, prioritizedGlobalCurves: prioritizedGlogalCurves, }; - console.log(payload) const response = await ApiClient.post( `/api/wells/${encodeURIComponent(wellUid)}/wellbores/${encodeURIComponent( wellboreUid @@ -41,7 +41,7 @@ export default class LogCurvePriorityService { if (response.ok) { return response.json(); } else { - return []; + return null; } } } From cf913d5e9529a473b740871afc1b298939082e46 Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Mon, 9 Sep 2024 14:49:56 +0200 Subject: [PATCH 04/21] log curve --- .../HttpHandlers/LogCurvePriorityHandler.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs b/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs index 0c3c529f4..260d873d5 100644 --- a/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs +++ b/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs @@ -11,17 +11,24 @@ namespace WitsmlExplorer.Api.HttpHandlers { public static class LogCurvePriorityHandler { - [Produces(typeof(List))] + [Produces(typeof(LogCurvePriorities))] public static async Task GetPrioritizedCurves(string wellUid, string wellboreUid, ILogCurvePriorityService logCurvePriorityService) { var prioritizedCurves = await logCurvePriorityService.GetPrioritizedCurves(wellUid, wellboreUid) ?? new List(); - return TypedResults.Ok(prioritizedCurves); + var prioritizedGlobalCurves = + await logCurvePriorityService.GetPrioritizedGlobalCurves() ?? new List(); + var result = new LogCurvePriorities() + { + PrioritizedCurves = prioritizedCurves, + PrioritizedGlobalCurves = prioritizedGlobalCurves + }; + return TypedResults.Ok(result); } - [Produces(typeof(IList))] + [Produces(typeof(LogCurvePriorities))] public static async Task SetPrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities priorities, ILogCurvePriorityService logCurvePriorityService) { - var createdPrioritizedCurves = await logCurvePriorityService.SetPrioritizedCurves(wellUid, wellboreUid, priorities) ?? new List(); + var createdPrioritizedCurves = await logCurvePriorityService.SetPrioritizedCurves(wellUid, wellboreUid, priorities) ?? new LogCurvePriorities(); return TypedResults.Ok(createdPrioritizedCurves); } } From c450828458646161371379e349ba5e569a3170d4 Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Tue, 10 Sep 2024 11:04:22 +0200 Subject: [PATCH 05/21] test --- .../HttpHandlers/LogCurvePriorityHandler.cs | 10 +++- Src/WitsmlExplorer.Api/Routes.cs | 1 + .../Services/LogCurvePriorityService.cs | 22 +++++++-- .../ContentViews/LogCurveInfoListView.tsx | 1 + .../ContextMenus/LogCurveInfoContextMenu.tsx | 33 +++++++++---- .../Modals/LogCurvePriorityModal.tsx | 47 +++---------------- .../services/logCurvePriorityService.tsx | 20 ++++---- 7 files changed, 70 insertions(+), 64 deletions(-) diff --git a/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs b/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs index 260d873d5..da99ff31b 100644 --- a/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs +++ b/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs @@ -26,10 +26,18 @@ public static async Task GetPrioritizedCurves(string wellUid, string we } [Produces(typeof(LogCurvePriorities))] - public static async Task SetPrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities priorities, ILogCurvePriorityService logCurvePriorityService) + public static async Task SetPrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves, ILogCurvePriorityService logCurvePriorityService) { + var priorities = new LogCurvePriorities(); var createdPrioritizedCurves = await logCurvePriorityService.SetPrioritizedCurves(wellUid, wellboreUid, priorities) ?? new LogCurvePriorities(); return TypedResults.Ok(createdPrioritizedCurves); } + + [Produces(typeof(LogCurvePriorities))] + public static async Task SetPrioritizedGlobalCurves(IList prioritizedCurves, ILogCurvePriorityService logCurvePriorityService) + { + var createdPrioritizedCurves = await logCurvePriorityService.GetPrioritizedGlobalCurves(); + return TypedResults.Ok(createdPrioritizedCurves); + } } } diff --git a/Src/WitsmlExplorer.Api/Routes.cs b/Src/WitsmlExplorer.Api/Routes.cs index 6e84bb55d..2dd3d6ca4 100644 --- a/Src/WitsmlExplorer.Api/Routes.cs +++ b/Src/WitsmlExplorer.Api/Routes.cs @@ -40,6 +40,7 @@ public static void ConfigureApi(this WebApplication app, IConfiguration configur app.MapGet("/wells/{wellUid}/wellbores/{wellboreUid}/countexpandable", ObjectHandler.GetExpandableObjectsCount, useOAuth2); app.MapGet("/wells/{wellUid}/wellbores/{wellboreUid}/logCurvePriority", LogCurvePriorityHandler.GetPrioritizedCurves, useOAuth2); + app.MapPost("/global/logCurvePriority", LogCurvePriorityHandler.SetPrioritizedGlobalCurves, useOAuth2); app.MapPost("/wells/{wellUid}/wellbores/{wellboreUid}/logCurvePriority", LogCurvePriorityHandler.SetPrioritizedCurves, useOAuth2); Dictionary types = EntityTypeHelper.ToPluralLowercase(); diff --git a/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs b/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs index f0a6f5fe5..8d01ad8de 100644 --- a/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs +++ b/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs @@ -31,6 +31,7 @@ public async Task> GetPrioritizedCurves(string wellUid, string wel { string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); LogCurvePriority logCurvePriority = await logCurvePriorityRepository.GetDocumentAsync(logCurvePriorityId); + return logCurvePriority?.PrioritizedCurves; } @@ -66,16 +67,22 @@ await CreatePrioritizedCurves(wellUid, wellboreUid, } - var globalist = await GetPrioritizedGlobalCurves(); - if (globalist != null) { LogCurvePriority logCurvePriorityToUpdate = CreateLogCurveGlobalPriorityObject( priorities); var globalDocument = await logCurvePriorityRepository.GetDocumentAsync("global"); - LogCurvePriority updatedLogCurvePriority = await logCurvePriorityRepository.UpdateDocumentAsync("global", logCurvePriorityToUpdate); - result.PrioritizedGlobalCurves = updatedLogCurvePriority.PrioritizedCurves; + if (globalDocument == null) + { + var s = CreatePrioritizedGlobalCurves(priorities); + } + else + { + var s = UpdatePrioritizedGlobalCurves(priorities); + } + } + return result; } @@ -93,6 +100,13 @@ private async Task> CreatePrioritizedGlobalCurves( LogCurvePriorit return inserted.PrioritizedCurves; } + private async Task> UpdatePrioritizedGlobalCurves( LogCurvePriorities logCurvePriorities) + { + LogCurvePriority logCurvePriorityToCreate = CreateLogCurveGlobalPriorityObject( logCurvePriorities); + LogCurvePriority inserted = await logCurvePriorityRepository.UpdateDocumentAsync("global",logCurvePriorityToCreate); + return inserted.PrioritizedCurves; + } + private async Task DeleteLogCurvePriorityObject(string wellUid, string wellboreUid) { IList currentPrioritizedCurves = await GetPrioritizedCurves(wellUid, wellboreUid); diff --git a/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx b/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx index 14bb75ad8..3087c500c 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx @@ -84,6 +84,7 @@ export default function LogCurveInfoListView() { wellboreUid ); setPrioritizedCurves(prioritizedCurves.prioritizedCurves); + console.log(prioritizedCurves.prioritizedGlobalCurves) setPrioritizedGlobalCurves(prioritizedCurves.prioritizedGlobalCurves); }; diff --git a/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx b/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx index f01a9ec0a..f377c2add 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx @@ -178,10 +178,23 @@ const LogCurveInfoContextMenu = ( const logCurvePriorityModalProps: LogCurvePriorityModalProps = { wellUid: selectedLog.wellUid, wellboreUid: selectedLog.wellboreUid, - prioritizedCurves, - setPrioritizedCurves, - prioritizedGlobalCurves, - setPrioritizedGlobalCurves + prioritizedCurves: prioritizedCurves, + setPrioritizedCurves: setPrioritizedCurves, + isGlobal: false + }; + dispatchOperation({ + type: OperationType.DisplayModal, + payload: + }); + }; + + const onClickEditGlobalPriority = () => { + console.log(prioritizedGlobalCurves) + dispatchOperation({ type: OperationType.HideContextMenu }); + const logCurvePriorityModalProps: LogCurvePriorityModalProps = { + prioritizedCurves: prioritizedGlobalCurves, + setPrioritizedCurves: setPrioritizedGlobalCurves, + isGlobal: true }; dispatchOperation({ type: OperationType.DisplayModal, @@ -221,7 +234,6 @@ const LogCurveInfoContextMenu = ( null ); setPrioritizedCurves(newPrioritizedCurves.prioritizedCurves); - setPrioritizedGlobalCurves(newPrioritizedCurves.prioritizedGlobalCurves); }; const onClickRemovePriority = async () => { @@ -237,9 +249,7 @@ const LogCurveInfoContextMenu = ( curvesToPrioritize, null ); - setPrioritizedCurves(newPrioritizedCurves.prioritizedCurves); - setPrioritizedGlobalCurves(newPrioritizedCurves.prioritizedGlobalCurves) - }; + setPrioritizedCurves(newPrioritizedCurves.prioritizedCurves); }; const toDelete = createComponentReferences( checkedLogCurveInfoRowsWithoutIndexCurve.map((lc) => lc.mnemonic), @@ -418,6 +428,13 @@ const LogCurveInfoContextMenu = ( /> Edit Priority , + + + Edit Global Priority + , , void; - setPrioritizedGlobalCurves: (prioritizedGlobalCurves: string[]) => void; + isGlobal: boolean; } export interface LogCurvePriorityRow { @@ -31,12 +30,10 @@ export interface LogCurvePriorityRow { export const LogCurvePriorityModal = ( props: LogCurvePriorityModalProps ): React.ReactElement => { - const { wellUid, wellboreUid, prioritizedCurves, prioritizedGlobalCurves, setPrioritizedCurves, setPrioritizedGlobalCurves} = + const { wellUid, wellboreUid, prioritizedCurves, setPrioritizedCurves} = props; const [updatedPrioritizedCurves, setUpdatedPrioritizedCurves] = useState(prioritizedCurves); - const [updatedPrioritizedGlobalCurves, setUpdatedPrioritizedGlobalCurves] = - useState(prioritizedGlobalCurves); const [newCurve, setNewCurve] = useState(""); const { dispatchOperation } = useOperationState(); const [position, setPosition] = useState({ @@ -51,12 +48,6 @@ export const LogCurvePriorityModal = ( label: "mnemonic", type: ContentType.String, width: 440 - }, - { - property: "global", - label: "global", - type: ContentType.Component, - width: 60 } ]; @@ -65,39 +56,16 @@ export const LogCurvePriorityModal = ( return { id: mnemonic, mnemonic: mnemonic, - global:
) => { - console.log(e) - if (e.target.checked) { - addPrioritizedGlobalCurve(mnemonic); - } else { - deleteGlobalCurve(mnemonic); - } - }} - />
}; }); }; - - const addPrioritizedGlobalCurve = (mnemonic: string) => { - setUpdatedPrioritizedGlobalCurves([...updatedPrioritizedGlobalCurves, mnemonic]); - } - - + const onDelete = (curvesToDelete: string[]) => { setUpdatedPrioritizedCurves( updatedPrioritizedCurves.filter((c) => !curvesToDelete.includes(c)) ); }; - const deleteGlobalCurve = (curveToDelete: string) => { - const toDelete = updatedPrioritizedGlobalCurves.filter((c) => curveToDelete !== c); - setUpdatedPrioritizedGlobalCurves(toDelete); - }; - const onContextMenu = ( event: React.MouseEvent, {}, @@ -114,12 +82,11 @@ export const LogCurvePriorityModal = ( wellUid, wellboreUid, updatedPrioritizedCurves, - updatedPrioritizedGlobalCurves + props.isGlobal ); dispatchOperation({ type: OperationType.HideModal }); setPrioritizedCurves(updatedPrioritizedCurves); console.log(updatedPrioritizedCurves) - setPrioritizedGlobalCurves(updatedPrioritizedGlobalCurves) }; const addCurve = () => { @@ -130,7 +97,7 @@ export const LogCurvePriorityModal = ( return ( diff --git a/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx b/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx index 77d57d708..b3ecf5190 100644 --- a/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx +++ b/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx @@ -24,18 +24,16 @@ export default class LogCurvePriorityService { wellUid: string, wellboreUid: string, prioritizedCurves: string[], - prioritizedGlogalCurves: string[], - abortSignal?: AbortSignal + isGlobal: boolean, + abortSignal?: AbortSignal, ): Promise { - const payload = { - prioritizedCurves: prioritizedCurves, - prioritizedGlobalCurves: prioritizedGlogalCurves, - }; - const response = await ApiClient.post( - `/api/wells/${encodeURIComponent(wellUid)}/wellbores/${encodeURIComponent( - wellboreUid - )}/logCurvePriority`, - JSON.stringify(payload), + const path = isGlobal + ? `/api/global/logCurvePriority` + : `/api/wells/${encodeURIComponent( + wellUid + )}/wellbores/${encodeURIComponent(wellboreUid)}/logCurvePriority`; + const response = await ApiClient.post(path, + JSON.stringify(prioritizedCurves), abortSignal ); if (response.ok) { From 3994d727b12ce2ffd6d62f277f227598b655eb6b Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Wed, 11 Sep 2024 17:19:41 +0200 Subject: [PATCH 06/21] test --- .../HttpHandlers/LogCurvePriorityHandler.cs | 11 +- .../Services/LogCurvePriorityService.cs | 116 ++++++++---------- .../ContentViews/LogCurveInfoListView.tsx | 15 ++- .../MultiLogsCurveInfoListView.tsx | 18 ++- .../ContextMenus/LogCurveInfoContextMenu.tsx | 21 ++-- .../Modals/LogCurvePriorityModal.tsx | 67 ++++++++-- 6 files changed, 150 insertions(+), 98 deletions(-) diff --git a/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs b/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs index da99ff31b..56945a63e 100644 --- a/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs +++ b/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs @@ -25,18 +25,17 @@ public static async Task GetPrioritizedCurves(string wellUid, string we return TypedResults.Ok(result); } - [Produces(typeof(LogCurvePriorities))] + [Produces(typeof(List))] public static async Task SetPrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves, ILogCurvePriorityService logCurvePriorityService) { - var priorities = new LogCurvePriorities(); - var createdPrioritizedCurves = await logCurvePriorityService.SetPrioritizedCurves(wellUid, wellboreUid, priorities) ?? new LogCurvePriorities(); + var createdPrioritizedCurves = await logCurvePriorityService.SetPrioritizedCurves(wellUid, wellboreUid, prioritizedCurves) ?? new List(); return TypedResults.Ok(createdPrioritizedCurves); } - [Produces(typeof(LogCurvePriorities))] - public static async Task SetPrioritizedGlobalCurves(IList prioritizedCurves, ILogCurvePriorityService logCurvePriorityService) + [Produces(typeof(List))] + public static async Task SetPrioritizedGlobalCurves(List prioritizedCurves, ILogCurvePriorityService logCurvePriorityService) { - var createdPrioritizedCurves = await logCurvePriorityService.GetPrioritizedGlobalCurves(); + var createdPrioritizedCurves = await logCurvePriorityService.SetPrioritizedGlobalCurves(prioritizedCurves) ?? new List(); return TypedResults.Ok(createdPrioritizedCurves); } } diff --git a/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs b/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs index 8d01ad8de..936cc41a3 100644 --- a/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs +++ b/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs @@ -14,96 +14,67 @@ namespace WitsmlExplorer.Api.Services public interface ILogCurvePriorityService { Task> GetPrioritizedCurves(string wellUid, string wellboreUid); - Task SetPrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities priorities); + Task> SetPrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves); + Task> SetPrioritizedGlobalCurves(List prioritizedCurves); Task> GetPrioritizedGlobalCurves(); } - public class LogCurvePriorityService : ILogCurvePriorityService + public class LogCurvePriorityService( + IDocumentRepository + logCurvePriorityRepository) + : ILogCurvePriorityService { - private readonly IDocumentRepository logCurvePriorityRepository; - - public LogCurvePriorityService(IDocumentRepository logCurvePriorityRepository) - { - this.logCurvePriorityRepository = logCurvePriorityRepository; - } - + private const string Global = "global"; public async Task> GetPrioritizedCurves(string wellUid, string wellboreUid) { string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); LogCurvePriority logCurvePriority = await logCurvePriorityRepository.GetDocumentAsync(logCurvePriorityId); - return logCurvePriority?.PrioritizedCurves; } - public async Task> GetPrioritizedGlobalCurves() + public async Task> SetPrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves) { - LogCurvePriority logCurvePriorityGlobal = await logCurvePriorityRepository.GetDocumentAsync("global"); - return logCurvePriorityGlobal?.PrioritizedCurves; - } - - public async Task SetPrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities priorities) - { - if (priorities.PrioritizedCurves.IsNullOrEmpty()) + if (prioritizedCurves.IsNullOrEmpty()) { await DeleteLogCurvePriorityObject(wellUid, wellboreUid); + return null; } - var result = new LogCurvePriorities(); - - IList currentPrioritizedCurves = await GetPrioritizedCurves(wellUid, wellboreUid); - if (currentPrioritizedCurves == null) - { - var prioritedCurves = - await CreatePrioritizedCurves(wellUid, wellboreUid, - priorities); - result.PrioritizedCurves = prioritedCurves; - } - else - { - string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); - LogCurvePriority logCurvePriorityToUpdate = CreateLogCurvePriorityObject(wellUid, wellboreUid, priorities); - LogCurvePriority updatedLogCurvePriority = await logCurvePriorityRepository.UpdateDocumentAsync(logCurvePriorityId, logCurvePriorityToUpdate); - result.PrioritizedCurves = updatedLogCurvePriority.PrioritizedCurves; - } - - - + string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); + LogCurvePriority logCurvePriority = await logCurvePriorityRepository.GetDocumentAsync(logCurvePriorityId); + if (logCurvePriority == null) { - LogCurvePriority logCurvePriorityToUpdate = CreateLogCurveGlobalPriorityObject( priorities); - var globalDocument = await logCurvePriorityRepository.GetDocumentAsync("global"); - if (globalDocument == null) - { - var s = CreatePrioritizedGlobalCurves(priorities); - } - else - { - var s = UpdatePrioritizedGlobalCurves(priorities); - } - + return await CreatePrioritizedCurves(wellUid, wellboreUid, prioritizedCurves); } - - return result; + LogCurvePriority logCurvePriorityToUpdate = CreateLogCurvePriorityObject(wellUid, wellboreUid, prioritizedCurves); + LogCurvePriority updatedLogCurvePriority = await logCurvePriorityRepository.UpdateDocumentAsync(logCurvePriorityId, logCurvePriorityToUpdate); + return updatedLogCurvePriority.PrioritizedCurves; } - private async Task> CreatePrioritizedCurves(string wellUid, string wellboreUid, LogCurvePriorities logCurvePriorities) + public async Task> GetPrioritizedGlobalCurves() { - LogCurvePriority logCurvePriorityToCreate = CreateLogCurvePriorityObject(wellUid, wellboreUid, logCurvePriorities); - LogCurvePriority inserted = await logCurvePriorityRepository.CreateDocumentAsync(logCurvePriorityToCreate); - return inserted.PrioritizedCurves; + LogCurvePriority logCurvePriorityGlobal = await logCurvePriorityRepository.GetDocumentAsync(Global); + return logCurvePriorityGlobal?.PrioritizedCurves; } - private async Task> CreatePrioritizedGlobalCurves( LogCurvePriorities logCurvePriorities) + public async Task> SetPrioritizedGlobalCurves(List prioritizedCurves) { - LogCurvePriority logCurvePriorityToCreate = CreateLogCurveGlobalPriorityObject( logCurvePriorities); - LogCurvePriority inserted = await logCurvePriorityRepository.CreateDocumentAsync(logCurvePriorityToCreate); - return inserted.PrioritizedCurves; + var priorities = new LogCurvePriorities(); + priorities.PrioritizedGlobalCurves = prioritizedCurves; + var globalDocument = await logCurvePriorityRepository.GetDocumentAsync(Global); + if (globalDocument == null) + { + return await CreatePrioritizedGlobalCurves(priorities); + } + return await UpdatePrioritizedGlobalCurves(priorities); } - private async Task> UpdatePrioritizedGlobalCurves( LogCurvePriorities logCurvePriorities) + + private async Task> CreatePrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves) { - LogCurvePriority logCurvePriorityToCreate = CreateLogCurveGlobalPriorityObject( logCurvePriorities); - LogCurvePriority inserted = await logCurvePriorityRepository.UpdateDocumentAsync("global",logCurvePriorityToCreate); + LogCurvePriority logCurvePriorityToCreate = CreateLogCurvePriorityObject(wellUid, wellboreUid, prioritizedCurves); + LogCurvePriority inserted = await logCurvePriorityRepository.CreateDocumentAsync(logCurvePriorityToCreate); return inserted.PrioritizedCurves; } @@ -122,20 +93,33 @@ private string GetLogCurvePriorityId(string wellUid, string wellboreUid) return $"{wellUid}-{wellboreUid}"; } - private LogCurvePriority CreateLogCurvePriorityObject(string wellUid, string wellboreUid, LogCurvePriorities prioritizedCurves) + private LogCurvePriority CreateLogCurvePriorityObject(string wellUid, string wellboreUid, IList prioritizedCurves) { string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); LogCurvePriority logCurvePriorityObject = new(logCurvePriorityId) { - PrioritizedCurves = prioritizedCurves.PrioritizedCurves + PrioritizedCurves = prioritizedCurves }; return logCurvePriorityObject; } + private async Task> CreatePrioritizedGlobalCurves( LogCurvePriorities logCurvePriorities) + { + LogCurvePriority logCurvePriorityToCreate = CreateLogCurveGlobalPriorityObject( logCurvePriorities); + LogCurvePriority inserted = await logCurvePriorityRepository.CreateDocumentAsync(logCurvePriorityToCreate); + return inserted.PrioritizedCurves; + } + + private async Task> UpdatePrioritizedGlobalCurves( LogCurvePriorities logCurvePriorities) + { + LogCurvePriority logCurvePriorityToCreate = CreateLogCurveGlobalPriorityObject( logCurvePriorities); + LogCurvePriority inserted = await logCurvePriorityRepository.UpdateDocumentAsync(Global,logCurvePriorityToCreate); + return inserted.PrioritizedCurves; + } + private LogCurvePriority CreateLogCurveGlobalPriorityObject(LogCurvePriorities prioritizedCurves) { - string logCurvePriorityId = "global"; - LogCurvePriority logCurvePriorityObject = new(logCurvePriorityId) + LogCurvePriority logCurvePriorityObject = new(Global) { PrioritizedCurves = prioritizedCurves.PrioritizedGlobalCurves }; diff --git a/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx b/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx index 3087c500c..57ced4505 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx @@ -62,10 +62,16 @@ export default function LogCurveInfoListView() { const [showOnlyPrioritizedCurves, setShowOnlyPrioritizedCurves] = useState(false); const [prioritizedCurves, setPrioritizedCurves] = useState([]); - const [prioritizedGlobalCurves, setPrioritizedGlobalCurves] = useState([]); + const [prioritizedGlobalCurves, setPrioritizedGlobalCurves] = useState< + string[] + >([]); const logObjects = new Map([[objectUid, logObject]]); const isDepthIndex = logType === RouterLogType.DEPTH; const isFetching = isFetchingLog || isFetchingLogCurveInfo; + const allPrioritizedCurves = [ + ...prioritizedCurves, + ...prioritizedGlobalCurves + ].filter((value, index, self) => self.indexOf(value) === index); useExpandSidebarNodes( wellUid, @@ -84,7 +90,6 @@ export default function LogCurveInfoListView() { wellboreUid ); setPrioritizedCurves(prioritizedCurves.prioritizedCurves); - console.log(prioritizedCurves.prioritizedGlobalCurves) setPrioritizedGlobalCurves(prioritizedCurves.prioritizedGlobalCurves); }; @@ -135,7 +140,9 @@ export default function LogCurveInfoListView() { setShowOnlyPrioritizedCurves(!showOnlyPrioritizedCurves) } @@ -159,7 +166,7 @@ export default function LogCurveInfoListView() { columns={getColumns( isDepthIndex, showOnlyPrioritizedCurves, - prioritizedCurves, + allPrioritizedCurves, logObjects, hideEmptyMnemonics, true diff --git a/Src/WitsmlExplorer.Frontend/components/ContentViews/MultiLogsCurveInfoListView.tsx b/Src/WitsmlExplorer.Frontend/components/ContentViews/MultiLogsCurveInfoListView.tsx index 05f0ad019..19fb33430 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContentViews/MultiLogsCurveInfoListView.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContentViews/MultiLogsCurveInfoListView.tsx @@ -49,6 +49,13 @@ export default function MultiLogsCurveInfoListView() { const [showOnlyPrioritizedCurves, setShowOnlyPrioritizedCurves] = useState(false); const [prioritizedCurves, setPrioritizedCurves] = useState([]); + const [prioritizedGlobalCurves, setPrioritizedGlobalCurves] = useState< + string[] + >([]); + const allPrioritizedCurves = [ + ...prioritizedCurves, + ...prioritizedGlobalCurves + ].filter((value, index, self) => self.indexOf(value) === index); const { objects: allLogs, isFetching: isFetchingLogs } = useGetObjects( connectedServer, wellUid, @@ -93,7 +100,8 @@ export default function MultiLogsCurveInfoListView() { wellUid, wellboreUid ); - setPrioritizedCurves(prioritizedCurves); + setPrioritizedCurves(prioritizedCurves.prioritizedCurves); + setPrioritizedGlobalCurves(prioritizedCurves.prioritizedGlobalCurves); }; getLogCurvePriority().catch(truncateAbortHandler); @@ -116,6 +124,8 @@ export default function MultiLogsCurveInfoListView() { servers, prioritizedCurves, setPrioritizedCurves, + prioritizedGlobalCurves, + setPrioritizedGlobalCurves, isMultiLog }; const position = getContextMenuPosition(event); @@ -140,7 +150,9 @@ export default function MultiLogsCurveInfoListView() { setShowOnlyPrioritizedCurves(!showOnlyPrioritizedCurves) } @@ -164,7 +176,7 @@ export default function MultiLogsCurveInfoListView() { columns={getColumns( isDepthIndex, showOnlyPrioritizedCurves, - prioritizedCurves, + allPrioritizedCurves, logObjects, hideEmptyMnemonics )} diff --git a/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx b/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx index f377c2add..4c1a80856 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx @@ -189,7 +189,6 @@ const LogCurveInfoContextMenu = ( }; const onClickEditGlobalPriority = () => { - console.log(prioritizedGlobalCurves) dispatchOperation({ type: OperationType.HideContextMenu }); const logCurvePriorityModalProps: LogCurvePriorityModalProps = { prioritizedCurves: prioritizedGlobalCurves, @@ -249,7 +248,8 @@ const LogCurveInfoContextMenu = ( curvesToPrioritize, null ); - setPrioritizedCurves(newPrioritizedCurves.prioritizedCurves); }; + setPrioritizedCurves(newPrioritizedCurves.prioritizedCurves); + }; const toDelete = createComponentReferences( checkedLogCurveInfoRowsWithoutIndexCurve.map((lc) => lc.mnemonic), @@ -428,13 +428,16 @@ const LogCurveInfoContextMenu = ( /> Edit Priority
, - - - Edit Global Priority - , + + + Edit Global Priority + , , { - const { wellUid, wellboreUid, prioritizedCurves, setPrioritizedCurves} = + const { wellUid, wellboreUid, prioritizedCurves, setPrioritizedCurves } = props; const [updatedPrioritizedCurves, setUpdatedPrioritizedCurves] = useState(prioritizedCurves); @@ -42,6 +43,7 @@ export const LogCurvePriorityModal = ( }); const [checkedCurves, setCheckedCurves] = useState([]); + const [uploadedFile, setUploadedFile] = useState(null); const columns = [ { property: "mnemonic", @@ -55,11 +57,11 @@ export const LogCurvePriorityModal = ( return updatedPrioritizedCurves.sort().map((mnemonic) => { return { id: mnemonic, - mnemonic: mnemonic, + mnemonic: mnemonic }; }); }; - + const onDelete = (curvesToDelete: string[]) => { setUpdatedPrioritizedCurves( updatedPrioritizedCurves.filter((c) => !curvesToDelete.includes(c)) @@ -86,18 +88,33 @@ export const LogCurvePriorityModal = ( ); dispatchOperation({ type: OperationType.HideModal }); setPrioritizedCurves(updatedPrioritizedCurves); - console.log(updatedPrioritizedCurves) }; + const handleFileChange = useCallback( + async (e: React.ChangeEvent): Promise => { + const file = e.target.files.item(0); + if (!file) return; + const text = (await file.text()).replace(/(\r)/gm, "").trim(); + const data = text.split("\n").slice(1); + const mergedArray = [...data, ...prioritizedCurves]; + const uniqueArray = mergedArray.filter( + (value, index, self) => self.indexOf(value) === index && value !== "" + ); + setUpdatedPrioritizedCurves(uniqueArray); + }, + [] + ); + const addCurve = () => { - console.log("add curev") setUpdatedPrioritizedCurves([...updatedPrioritizedCurves, newCurve]); setNewCurve(""); }; return ( @@ -111,7 +128,6 @@ export const LogCurvePriorityModal = ( value={newCurve} /> + + + + + {uploadedFile?.name ?? "No file chosen"} + + + Date: Wed, 11 Sep 2024 17:32:43 +0200 Subject: [PATCH 07/21] fix --- .../HttpHandlers/LogCurvePriorityHandler.cs | 2 +- .../Services/LogCurvePriorityService.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs b/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs index 56945a63e..d83ff3191 100644 --- a/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs +++ b/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs @@ -16,7 +16,7 @@ public static async Task GetPrioritizedCurves(string wellUid, string we { var prioritizedCurves = await logCurvePriorityService.GetPrioritizedCurves(wellUid, wellboreUid) ?? new List(); var prioritizedGlobalCurves = - await logCurvePriorityService.GetPrioritizedGlobalCurves() ?? new List(); + await logCurvePriorityService.GetPrioritizedGlobalCurves() ?? new List(); var result = new LogCurvePriorities() { PrioritizedCurves = prioritizedCurves, diff --git a/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs b/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs index 936cc41a3..772d6bc21 100644 --- a/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs +++ b/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs @@ -65,7 +65,7 @@ public async Task> SetPrioritizedGlobalCurves(List priorit var globalDocument = await logCurvePriorityRepository.GetDocumentAsync(Global); if (globalDocument == null) { - return await CreatePrioritizedGlobalCurves(priorities); + return await CreatePrioritizedGlobalCurves(priorities); } return await UpdatePrioritizedGlobalCurves(priorities); } @@ -103,17 +103,17 @@ private LogCurvePriority CreateLogCurvePriorityObject(string wellUid, string wel return logCurvePriorityObject; } - private async Task> CreatePrioritizedGlobalCurves( LogCurvePriorities logCurvePriorities) + private async Task> CreatePrioritizedGlobalCurves(LogCurvePriorities logCurvePriorities) { - LogCurvePriority logCurvePriorityToCreate = CreateLogCurveGlobalPriorityObject( logCurvePriorities); + LogCurvePriority logCurvePriorityToCreate = CreateLogCurveGlobalPriorityObject(logCurvePriorities); LogCurvePriority inserted = await logCurvePriorityRepository.CreateDocumentAsync(logCurvePriorityToCreate); return inserted.PrioritizedCurves; } - private async Task> UpdatePrioritizedGlobalCurves( LogCurvePriorities logCurvePriorities) + private async Task> UpdatePrioritizedGlobalCurves(LogCurvePriorities logCurvePriorities) { - LogCurvePriority logCurvePriorityToCreate = CreateLogCurveGlobalPriorityObject( logCurvePriorities); - LogCurvePriority inserted = await logCurvePriorityRepository.UpdateDocumentAsync(Global,logCurvePriorityToCreate); + LogCurvePriority logCurvePriorityToCreate = CreateLogCurveGlobalPriorityObject(logCurvePriorities); + LogCurvePriority inserted = await logCurvePriorityRepository.UpdateDocumentAsync(Global, logCurvePriorityToCreate); return inserted.PrioritizedCurves; } From 8c2812efc75eddf915539e2573f47cd6ef75e690 Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Wed, 11 Sep 2024 17:41:37 +0200 Subject: [PATCH 08/21] test --- .../components/Modals/LogCurvePriorityModal.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx index 6b8a14dbb..07b9373f1 100644 --- a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx +++ b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx @@ -101,6 +101,7 @@ export const LogCurvePriorityModal = ( (value, index, self) => self.indexOf(value) === index && value !== "" ); setUpdatedPrioritizedCurves(uniqueArray); + setUploadedFile(file); }, [] ); @@ -141,6 +142,7 @@ export const LogCurvePriorityModal = ( variant="contained" color={"primary"} component="label" + hidden={!props.isGlobal} startIcon={} > Upload File From 27ef89651812a49752894f0ca957502e6e39e38d Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Wed, 11 Sep 2024 17:54:42 +0200 Subject: [PATCH 09/21] test --- .../Modals/LogCurvePriorityModal.tsx | 45 ++++++++++--------- .../models/logCurvePriorities.ts | 2 +- .../services/logCurvePriorityService.tsx | 5 ++- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx index 07b9373f1..815577304 100644 --- a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx +++ b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx @@ -137,28 +137,29 @@ export const LogCurvePriorityModal = ( - - - - - {uploadedFile?.name ?? "No file chosen"} - - - + {props.isGlobal && ( + + + + + {uploadedFile?.name ?? "No file chosen"} + + + + )} { const path = isGlobal ? `/api/global/logCurvePriority` : `/api/wells/${encodeURIComponent( wellUid )}/wellbores/${encodeURIComponent(wellboreUid)}/logCurvePriority`; - const response = await ApiClient.post(path, + const response = await ApiClient.post( + path, JSON.stringify(prioritizedCurves), abortSignal ); From 4713372510fe4fef15c53ec35d6830652b46d7fc Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Thu, 12 Sep 2024 16:28:24 +0200 Subject: [PATCH 10/21] test --- .../HttpHandlers/LogCurvePriorityHandler.cs | 31 +++-- .../Models/LogCurvePriorities.cs | 10 -- Src/WitsmlExplorer.Api/Routes.cs | 7 +- .../Services/LogCurvePriorityService.cs | 49 ++++---- .../ContentViews/LogCurveInfoListView.tsx | 33 +++-- .../MultiLogsCurveInfoListView.tsx | 33 +++-- .../ContextMenus/LogCurveInfoContextMenu.tsx | 113 ++++++++++++------ .../Modals/LogCurvePriorityModal.tsx | 14 ++- .../models/logCurvePriorities.ts | 4 - .../services/logCurvePriorityService.tsx | 32 ++--- 10 files changed, 185 insertions(+), 141 deletions(-) delete mode 100644 Src/WitsmlExplorer.Api/Models/LogCurvePriorities.cs delete mode 100644 Src/WitsmlExplorer.Frontend/models/logCurvePriorities.ts diff --git a/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs b/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs index d83ff3191..43a90cfb4 100644 --- a/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs +++ b/Src/WitsmlExplorer.Api/HttpHandlers/LogCurvePriorityHandler.cs @@ -4,38 +4,37 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using WitsmlExplorer.Api.Models; using WitsmlExplorer.Api.Services; namespace WitsmlExplorer.Api.HttpHandlers { public static class LogCurvePriorityHandler { - [Produces(typeof(LogCurvePriorities))] - public static async Task GetPrioritizedCurves(string wellUid, string wellboreUid, ILogCurvePriorityService logCurvePriorityService) + [Produces(typeof(string[]))] + public static async Task GetPrioritizedLocalCurves(string wellUid, string wellboreUid, ILogCurvePriorityService logCurvePriorityService) { - var prioritizedCurves = await logCurvePriorityService.GetPrioritizedCurves(wellUid, wellboreUid) ?? new List(); - var prioritizedGlobalCurves = - await logCurvePriorityService.GetPrioritizedGlobalCurves() ?? new List(); - var result = new LogCurvePriorities() - { - PrioritizedCurves = prioritizedCurves, - PrioritizedGlobalCurves = prioritizedGlobalCurves - }; - return TypedResults.Ok(result); + var prioritizedCurves = await logCurvePriorityService.GetPrioritizedLocalCurves(wellUid, wellboreUid) ?? new List(); + return TypedResults.Ok(prioritizedCurves); + } + + [Produces(typeof(string[]))] + public static async Task GetPrioritizedUniversalCurves(ILogCurvePriorityService logCurvePriorityService) + { + var prioritizedCurves = await logCurvePriorityService.GetPrioritizedUniversalCurves() ?? new List(); + return TypedResults.Ok(prioritizedCurves); } [Produces(typeof(List))] - public static async Task SetPrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves, ILogCurvePriorityService logCurvePriorityService) + public static async Task SetPrioritizedLocalCurves(string wellUid, string wellboreUid, IList prioritizedCurves, ILogCurvePriorityService logCurvePriorityService) { - var createdPrioritizedCurves = await logCurvePriorityService.SetPrioritizedCurves(wellUid, wellboreUid, prioritizedCurves) ?? new List(); + var createdPrioritizedCurves = await logCurvePriorityService.SetPrioritizedLocalCurves(wellUid, wellboreUid, prioritizedCurves) ?? new List(); return TypedResults.Ok(createdPrioritizedCurves); } [Produces(typeof(List))] - public static async Task SetPrioritizedGlobalCurves(List prioritizedCurves, ILogCurvePriorityService logCurvePriorityService) + public static async Task SetPrioritizedGlobalUniversalCurves(List prioritizedCurves, ILogCurvePriorityService logCurvePriorityService) { - var createdPrioritizedCurves = await logCurvePriorityService.SetPrioritizedGlobalCurves(prioritizedCurves) ?? new List(); + var createdPrioritizedCurves = await logCurvePriorityService.SetPrioritizedUniversalCurves(prioritizedCurves) ?? new List(); return TypedResults.Ok(createdPrioritizedCurves); } } diff --git a/Src/WitsmlExplorer.Api/Models/LogCurvePriorities.cs b/Src/WitsmlExplorer.Api/Models/LogCurvePriorities.cs deleted file mode 100644 index 0e75e3eff..000000000 --- a/Src/WitsmlExplorer.Api/Models/LogCurvePriorities.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace WitsmlExplorer.Api.Models -{ - public class LogCurvePriorities - { - public IList PrioritizedCurves { get; set; } - public IList PrioritizedGlobalCurves { get; set; } - } -} diff --git a/Src/WitsmlExplorer.Api/Routes.cs b/Src/WitsmlExplorer.Api/Routes.cs index 2dd3d6ca4..2e2d0844d 100644 --- a/Src/WitsmlExplorer.Api/Routes.cs +++ b/Src/WitsmlExplorer.Api/Routes.cs @@ -39,9 +39,10 @@ public static void ConfigureApi(this WebApplication app, IConfiguration configur app.MapGet("/wells/{wellUid}/wellbores/{wellboreUid}/idonly/{objectType}/{objectUid}", ObjectHandler.GetObjectIdOnly, useOAuth2); app.MapGet("/wells/{wellUid}/wellbores/{wellboreUid}/countexpandable", ObjectHandler.GetExpandableObjectsCount, useOAuth2); - app.MapGet("/wells/{wellUid}/wellbores/{wellboreUid}/logCurvePriority", LogCurvePriorityHandler.GetPrioritizedCurves, useOAuth2); - app.MapPost("/global/logCurvePriority", LogCurvePriorityHandler.SetPrioritizedGlobalCurves, useOAuth2); - app.MapPost("/wells/{wellUid}/wellbores/{wellboreUid}/logCurvePriority", LogCurvePriorityHandler.SetPrioritizedCurves, useOAuth2); + app.MapGet("/wells/{wellUid}/wellbores/{wellboreUid}/logCurvePriority", LogCurvePriorityHandler.GetPrioritizedLocalCurves, useOAuth2); + app.MapGet("/universal/getLogCurvePriority", LogCurvePriorityHandler.GetPrioritizedUniversalCurves, useOAuth2); + app.MapPost("/universal/logCurvePriority", LogCurvePriorityHandler.SetPrioritizedGlobalUniversalCurves, useOAuth2); + app.MapPost("/wells/{wellUid}/wellbores/{wellboreUid}/logCurvePriority", LogCurvePriorityHandler.SetPrioritizedLocalCurves, useOAuth2); Dictionary types = EntityTypeHelper.ToPluralLowercase(); Dictionary routes = types.ToDictionary(entry => entry.Key, entry => "/wells/{wellUid}/wellbores/{wellboreUid}/" + entry.Value); diff --git a/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs b/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs index 772d6bc21..02ad324a9 100644 --- a/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs +++ b/Src/WitsmlExplorer.Api/Services/LogCurvePriorityService.cs @@ -1,7 +1,4 @@ - -using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Microsoft.IdentityModel.Tokens; @@ -13,10 +10,10 @@ namespace WitsmlExplorer.Api.Services { public interface ILogCurvePriorityService { - Task> GetPrioritizedCurves(string wellUid, string wellboreUid); - Task> SetPrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves); - Task> SetPrioritizedGlobalCurves(List prioritizedCurves); - Task> GetPrioritizedGlobalCurves(); + Task> GetPrioritizedLocalCurves(string wellUid, string wellboreUid); + Task> SetPrioritizedLocalCurves(string wellUid, string wellboreUid, IList prioritizedCurves); + Task> SetPrioritizedUniversalCurves(List prioritizedCurves); + Task> GetPrioritizedUniversalCurves(); } public class LogCurvePriorityService( @@ -25,14 +22,14 @@ public class LogCurvePriorityService( : ILogCurvePriorityService { private const string Global = "global"; - public async Task> GetPrioritizedCurves(string wellUid, string wellboreUid) + public async Task> GetPrioritizedLocalCurves(string wellUid, string wellboreUid) { string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); LogCurvePriority logCurvePriority = await logCurvePriorityRepository.GetDocumentAsync(logCurvePriorityId); return logCurvePriority?.PrioritizedCurves; } - public async Task> SetPrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves) + public async Task> SetPrioritizedLocalCurves(string wellUid, string wellboreUid, IList prioritizedCurves) { if (prioritizedCurves.IsNullOrEmpty()) { @@ -47,40 +44,38 @@ public async Task> SetPrioritizedCurves(string wellUid, string wel return await CreatePrioritizedCurves(wellUid, wellboreUid, prioritizedCurves); } - LogCurvePriority logCurvePriorityToUpdate = CreateLogCurvePriorityObject(wellUid, wellboreUid, prioritizedCurves); + LogCurvePriority logCurvePriorityToUpdate = CreateLogCurvePriorityLocalObject(wellUid, wellboreUid, prioritizedCurves); LogCurvePriority updatedLogCurvePriority = await logCurvePriorityRepository.UpdateDocumentAsync(logCurvePriorityId, logCurvePriorityToUpdate); return updatedLogCurvePriority.PrioritizedCurves; } - public async Task> GetPrioritizedGlobalCurves() + public async Task> GetPrioritizedUniversalCurves() { LogCurvePriority logCurvePriorityGlobal = await logCurvePriorityRepository.GetDocumentAsync(Global); return logCurvePriorityGlobal?.PrioritizedCurves; } - public async Task> SetPrioritizedGlobalCurves(List prioritizedCurves) + public async Task> SetPrioritizedUniversalCurves(List prioritizedCurves) { - var priorities = new LogCurvePriorities(); - priorities.PrioritizedGlobalCurves = prioritizedCurves; var globalDocument = await logCurvePriorityRepository.GetDocumentAsync(Global); if (globalDocument == null) { - return await CreatePrioritizedGlobalCurves(priorities); + return await CreatePrioritizedUniversalCurves(prioritizedCurves); } - return await UpdatePrioritizedGlobalCurves(priorities); + return await UpdatePrioritizedUniversalCurves(prioritizedCurves); } private async Task> CreatePrioritizedCurves(string wellUid, string wellboreUid, IList prioritizedCurves) { - LogCurvePriority logCurvePriorityToCreate = CreateLogCurvePriorityObject(wellUid, wellboreUid, prioritizedCurves); + LogCurvePriority logCurvePriorityToCreate = CreateLogCurvePriorityLocalObject(wellUid, wellboreUid, prioritizedCurves); LogCurvePriority inserted = await logCurvePriorityRepository.CreateDocumentAsync(logCurvePriorityToCreate); return inserted.PrioritizedCurves; } private async Task DeleteLogCurvePriorityObject(string wellUid, string wellboreUid) { - IList currentPrioritizedCurves = await GetPrioritizedCurves(wellUid, wellboreUid); + IList currentPrioritizedCurves = await GetPrioritizedLocalCurves(wellUid, wellboreUid); if (currentPrioritizedCurves != null) { string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); @@ -93,7 +88,7 @@ private string GetLogCurvePriorityId(string wellUid, string wellboreUid) return $"{wellUid}-{wellboreUid}"; } - private LogCurvePriority CreateLogCurvePriorityObject(string wellUid, string wellboreUid, IList prioritizedCurves) + private LogCurvePriority CreateLogCurvePriorityLocalObject(string wellUid, string wellboreUid, IList prioritizedCurves) { string logCurvePriorityId = GetLogCurvePriorityId(wellUid, wellboreUid); LogCurvePriority logCurvePriorityObject = new(logCurvePriorityId) @@ -103,25 +98,25 @@ private LogCurvePriority CreateLogCurvePriorityObject(string wellUid, string wel return logCurvePriorityObject; } - private async Task> CreatePrioritizedGlobalCurves(LogCurvePriorities logCurvePriorities) + private async Task> CreatePrioritizedUniversalCurves(List logCurvePriorities) { - LogCurvePriority logCurvePriorityToCreate = CreateLogCurveGlobalPriorityObject(logCurvePriorities); + LogCurvePriority logCurvePriorityToCreate = CreateLogCurveUniversalPriorityObject(logCurvePriorities); LogCurvePriority inserted = await logCurvePriorityRepository.CreateDocumentAsync(logCurvePriorityToCreate); return inserted.PrioritizedCurves; } - private async Task> UpdatePrioritizedGlobalCurves(LogCurvePriorities logCurvePriorities) + private async Task> UpdatePrioritizedUniversalCurves(List logCurvePriorities) { - LogCurvePriority logCurvePriorityToCreate = CreateLogCurveGlobalPriorityObject(logCurvePriorities); - LogCurvePriority inserted = await logCurvePriorityRepository.UpdateDocumentAsync(Global, logCurvePriorityToCreate); - return inserted.PrioritizedCurves; + LogCurvePriority logCurvePriorityToCreate = CreateLogCurveUniversalPriorityObject(logCurvePriorities); + LogCurvePriority updated = await logCurvePriorityRepository.UpdateDocumentAsync(Global, logCurvePriorityToCreate); + return updated.PrioritizedCurves; } - private LogCurvePriority CreateLogCurveGlobalPriorityObject(LogCurvePriorities prioritizedCurves) + private LogCurvePriority CreateLogCurveUniversalPriorityObject(List prioritizedCurves) { LogCurvePriority logCurvePriorityObject = new(Global) { - PrioritizedCurves = prioritizedCurves.PrioritizedGlobalCurves + PrioritizedCurves = prioritizedCurves }; return logCurvePriorityObject; } diff --git a/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx b/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx index 57ced4505..24aee8012 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContentViews/LogCurveInfoListView.tsx @@ -61,16 +61,18 @@ export default function LogCurveInfoListView() { const [hideEmptyMnemonics, setHideEmptyMnemonics] = useState(false); const [showOnlyPrioritizedCurves, setShowOnlyPrioritizedCurves] = useState(false); - const [prioritizedCurves, setPrioritizedCurves] = useState([]); - const [prioritizedGlobalCurves, setPrioritizedGlobalCurves] = useState< + const [prioritizedLocalCurves, setPrioritizedLocalCurves] = useState< + string[] + >([]); + const [prioritizedUniversalCurves, setPrioritizedUniversalCurves] = useState< string[] >([]); const logObjects = new Map([[objectUid, logObject]]); const isDepthIndex = logType === RouterLogType.DEPTH; const isFetching = isFetchingLog || isFetchingLogCurveInfo; const allPrioritizedCurves = [ - ...prioritizedCurves, - ...prioritizedGlobalCurves + ...prioritizedLocalCurves, + ...prioritizedUniversalCurves ].filter((value, index, self) => self.indexOf(value) === index); useExpandSidebarNodes( @@ -83,17 +85,24 @@ export default function LogCurveInfoListView() { useEffect(() => { if (logObject) { - const getLogCurvePriority = async () => { + const getLogCurveLocalPriority = async () => { const prioritizedCurves = await LogCurvePriorityService.getPrioritizedCurves( + false, wellUid, wellboreUid ); - setPrioritizedCurves(prioritizedCurves.prioritizedCurves); - setPrioritizedGlobalCurves(prioritizedCurves.prioritizedGlobalCurves); + setPrioritizedLocalCurves(prioritizedCurves); + }; + + const getLogCurveUniversalPriority = async () => { + const prioritizedCurves = + await LogCurvePriorityService.getPrioritizedCurves(true); + setPrioritizedUniversalCurves(prioritizedCurves); }; - getLogCurvePriority().catch(truncateAbortHandler); + getLogCurveLocalPriority().catch(truncateAbortHandler); + getLogCurveUniversalPriority().catch(truncateAbortHandler); setShowOnlyPrioritizedCurves(false); } }, [logObject]); @@ -109,10 +118,10 @@ export default function LogCurveInfoListView() { selectedLog: logObject, selectedServer: connectedServer, servers, - prioritizedCurves, - setPrioritizedCurves, - prioritizedGlobalCurves, - setPrioritizedGlobalCurves + prioritizedLocalCurves, + setPrioritizedLocalCurves, + prioritizedUniversalCurves, + setPrioritizedUniversalCurves }; const position = getContextMenuPosition(event); dispatchOperation({ diff --git a/Src/WitsmlExplorer.Frontend/components/ContentViews/MultiLogsCurveInfoListView.tsx b/Src/WitsmlExplorer.Frontend/components/ContentViews/MultiLogsCurveInfoListView.tsx index 19fb33430..70db3f5d1 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContentViews/MultiLogsCurveInfoListView.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContentViews/MultiLogsCurveInfoListView.tsx @@ -48,13 +48,15 @@ export default function MultiLogsCurveInfoListView() { const [hideEmptyMnemonics, setHideEmptyMnemonics] = useState(false); const [showOnlyPrioritizedCurves, setShowOnlyPrioritizedCurves] = useState(false); - const [prioritizedCurves, setPrioritizedCurves] = useState([]); - const [prioritizedGlobalCurves, setPrioritizedGlobalCurves] = useState< + const [prioritizedLocalCurves, setPrioritizedLocalCurves] = useState< + string[] + >([]); + const [prioritizedUniversalCurves, setPrioritizedUniversalCurves] = useState< string[] >([]); const allPrioritizedCurves = [ - ...prioritizedCurves, - ...prioritizedGlobalCurves + ...prioritizedLocalCurves, + ...prioritizedUniversalCurves ].filter((value, index, self) => self.indexOf(value) === index); const { objects: allLogs, isFetching: isFetchingLogs } = useGetObjects( connectedServer, @@ -94,17 +96,24 @@ export default function MultiLogsCurveInfoListView() { }; getMnemonics(); - const getLogCurvePriority = async () => { + const getLogCurveLocalPriority = async () => { const prioritizedCurves = await LogCurvePriorityService.getPrioritizedCurves( + false, wellUid, wellboreUid ); - setPrioritizedCurves(prioritizedCurves.prioritizedCurves); - setPrioritizedGlobalCurves(prioritizedCurves.prioritizedGlobalCurves); + setPrioritizedLocalCurves(prioritizedCurves); + }; + + const getLogCurveUniversalPriority = async () => { + const prioritizedCurves = + await LogCurvePriorityService.getPrioritizedCurves(true); + setPrioritizedUniversalCurves(prioritizedCurves); }; - getLogCurvePriority().catch(truncateAbortHandler); + getLogCurveLocalPriority().catch(truncateAbortHandler); + getLogCurveUniversalPriority().catch(truncateAbortHandler); setShowOnlyPrioritizedCurves(false); } }, [allLogs]); @@ -122,10 +131,10 @@ export default function MultiLogsCurveInfoListView() { selectedLog: selectedLog, selectedServer: connectedServer, servers, - prioritizedCurves, - setPrioritizedCurves, - prioritizedGlobalCurves, - setPrioritizedGlobalCurves, + prioritizedLocalCurves, + setPrioritizedLocalCurves, + prioritizedUniversalCurves, + setPrioritizedUniversalCurves, isMultiLog }; const position = getContextMenuPosition(event); diff --git a/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx b/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx index 4c1a80856..bc0e8a14e 100644 --- a/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx +++ b/Src/WitsmlExplorer.Frontend/components/ContextMenus/LogCurveInfoContextMenu.tsx @@ -59,10 +59,10 @@ export interface LogCurveInfoContextMenuProps { selectedLog: LogObject; selectedServer: Server; servers: Server[]; - prioritizedCurves: string[]; - setPrioritizedCurves: (prioritizedCurves: string[]) => void; - prioritizedGlobalCurves: string[]; - setPrioritizedGlobalCurves: (prioritizedGlobalCurves: string[]) => void; + prioritizedLocalCurves: string[]; + setPrioritizedLocalCurves: (prioritizedLocalCurves: string[]) => void; + prioritizedUniversalCurves: string[]; + setPrioritizedUniversalCurves: (prioritizedUniversalCurves: string[]) => void; isMultiLog?: boolean; } @@ -75,19 +75,26 @@ const LogCurveInfoContextMenu = ( selectedLog, selectedServer, servers, - prioritizedCurves, - setPrioritizedCurves, - prioritizedGlobalCurves, - setPrioritizedGlobalCurves, + prioritizedLocalCurves, + setPrioritizedLocalCurves, + prioritizedUniversalCurves, + setPrioritizedUniversalCurves, isMultiLog = false } = props; const onlyPrioritizedCurvesAreChecked = checkedLogCurveInfoRows.every( (row, index) => - prioritizedCurves.includes(row.mnemonic) || + prioritizedLocalCurves.includes(row.mnemonic) || (checkedLogCurveInfoRows.length > 1 && index === 0) ); + const onlyPrioritizedUniversalCurvesAreChecked = + checkedLogCurveInfoRows.every( + (row, index) => + prioritizedUniversalCurves.includes(row.mnemonic) || + (checkedLogCurveInfoRows.length > 1 && index === 0) + ); + const checkedLogCurveInfoRowsWithoutIndexCurve = checkedLogCurveInfoRows.filter( (lc) => lc.mnemonic !== selectedLog.indexCurve @@ -178,9 +185,9 @@ const LogCurveInfoContextMenu = ( const logCurvePriorityModalProps: LogCurvePriorityModalProps = { wellUid: selectedLog.wellUid, wellboreUid: selectedLog.wellboreUid, - prioritizedCurves: prioritizedCurves, - setPrioritizedCurves: setPrioritizedCurves, - isGlobal: false + prioritizedCurves: prioritizedLocalCurves, + setPrioritizedCurves: setPrioritizedLocalCurves, + isUniversal: false }; dispatchOperation({ type: OperationType.DisplayModal, @@ -188,12 +195,12 @@ const LogCurveInfoContextMenu = ( }); }; - const onClickEditGlobalPriority = () => { + const onClickEditUniversalPriority = () => { dispatchOperation({ type: OperationType.HideContextMenu }); const logCurvePriorityModalProps: LogCurvePriorityModalProps = { - prioritizedCurves: prioritizedGlobalCurves, - setPrioritizedCurves: setPrioritizedGlobalCurves, - isGlobal: true + prioritizedCurves: prioritizedUniversalCurves, + setPrioritizedCurves: setPrioritizedUniversalCurves, + isUniversal: true }; dispatchOperation({ type: OperationType.DisplayModal, @@ -217,38 +224,52 @@ const LogCurveInfoContextMenu = ( }); }; - const onClickSetPriority = async () => { + const onClickSetPriority = async (isUniversal: boolean) => { dispatchOperation({ type: OperationType.HideContextMenu }); const newCurvesToPrioritize = checkedLogCurveInfoRows.map( (lc) => lc.mnemonic ); - const curvesToPrioritize = Array.from( - new Set(prioritizedCurves.concat(newCurvesToPrioritize)) - ); + const curvesToPrioritize = isUniversal + ? Array.from( + new Set(prioritizedLocalCurves.concat(newCurvesToPrioritize)) + ) + : Array.from( + new Set(prioritizedUniversalCurves.concat(newCurvesToPrioritize)) + ); const newPrioritizedCurves = await LogCurvePriorityService.setPrioritizedCurves( + curvesToPrioritize, + isUniversal, selectedLog.wellUid, selectedLog.wellboreUid, - curvesToPrioritize, null ); - setPrioritizedCurves(newPrioritizedCurves.prioritizedCurves); + isUniversal + ? setPrioritizedUniversalCurves(newPrioritizedCurves) + : setPrioritizedLocalCurves(newPrioritizedCurves); }; - const onClickRemovePriority = async () => { + const onClickRemovePriority = async (isUniversal: boolean) => { dispatchOperation({ type: OperationType.HideContextMenu }); const curvesToDelete = checkedLogCurveInfoRows.map((lc) => lc.mnemonic); - const curvesToPrioritize = prioritizedCurves.filter( - (curve) => !curvesToDelete.includes(curve) - ); + const curvesToPrioritize = isUniversal + ? prioritizedLocalCurves.filter( + (curve) => !curvesToDelete.includes(curve) + ) + : prioritizedUniversalCurves.filter( + (curve) => !curvesToDelete.includes(curve) + ); const newPrioritizedCurves = await LogCurvePriorityService.setPrioritizedCurves( + curvesToPrioritize, + isUniversal, selectedLog.wellUid, selectedLog.wellboreUid, - curvesToPrioritize, null ); - setPrioritizedCurves(newPrioritizedCurves.prioritizedCurves); + isUniversal + ? setPrioritizedUniversalCurves(newPrioritizedCurves) + : setPrioritizedLocalCurves(newPrioritizedCurves); }; const toDelete = createComponentReferences( @@ -403,8 +424,8 @@ const LogCurveInfoContextMenu = ( key={"setPriority"} onClick={() => onlyPrioritizedCurvesAreChecked - ? onClickRemovePriority() - : onClickSetPriority() + ? onClickRemovePriority(false) + : onClickSetPriority(false) } > {onlyPrioritizedCurvesAreChecked - ? "Remove Priority" - : "Set Priority"} + ? "Remove Local Priority" + : "Set Local Priority"} + + , + + onlyPrioritizedUniversalCurvesAreChecked + ? onClickRemovePriority(true) + : onClickSetPriority(true) + } + > + + + {onlyPrioritizedUniversalCurvesAreChecked + ? "Remove Universal Priority" + : "Set Universal Priority"} , @@ -429,14 +472,14 @@ const LogCurveInfoContextMenu = ( Edit Priority , - Edit Global Priority + Edit Universal Priority , , void; - isGlobal: boolean; + isUniversal: boolean; } export interface LogCurvePriorityRow { @@ -81,10 +81,10 @@ export const LogCurvePriorityModal = ( const onSubmit = async () => { await LogCurvePriorityService.setPrioritizedCurves( - wellUid, - wellboreUid, updatedPrioritizedCurves, - props.isGlobal + props.isUniversal, + wellUid, + wellboreUid ); dispatchOperation({ type: OperationType.HideModal }); setPrioritizedCurves(updatedPrioritizedCurves); @@ -114,7 +114,9 @@ export const LogCurvePriorityModal = ( return ( @@ -137,7 +139,7 @@ export const LogCurvePriorityModal = ( - {props.isGlobal && ( + {props.isUniversal && ( - {props.isUniversal && ( - - - - - {uploadedFile?.name ?? "No file chosen"} - - - - )} + + + + + {uploadedFile?.name ?? "No file chosen"} + + + Date: Fri, 13 Sep 2024 12:56:54 +0200 Subject: [PATCH 17/21] pr --- .../components/Modals/LogCurvePriorityModal.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx index dba8d492a..255af67f1 100644 --- a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx +++ b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx @@ -1,7 +1,12 @@ import { Icon, TextField, Tooltip, Typography } from "@equinor/eds-core-react"; import { useOperationState } from "hooks/useOperationState"; -import React, { ChangeEvent, useCallback, useState } from "react"; +import React, { + ChangeEvent, + KeyboardEvent, + useCallback, + useState +} from "react"; import styled from "styled-components"; import { MousePosition } from "../../contexts/operationStateReducer"; import OperationType from "../../contexts/operationType"; @@ -125,9 +130,14 @@ export const LogCurvePriorityModal = ( ) => { + if (e.key === "Enter") { + e.stopPropagation(); + addCurve(); + } + }} onChange={(e: ChangeEvent) => { setNewCurve(e.target.value); - e.stopPropagation(); }} value={newCurve} /> From 21478ba1038ff5645d5ef3349149947cf07b3fea Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Fri, 13 Sep 2024 13:20:46 +0200 Subject: [PATCH 18/21] fix --- .../components/Modals/LogCurvePriorityModal.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx index 255af67f1..d58c46dbc 100644 --- a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx +++ b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx @@ -174,7 +174,11 @@ export const LogCurvePriorityModal = ( From a574a6e124d3680cc4391bbca68e60422ea00d14 Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Fri, 13 Sep 2024 13:58:45 +0200 Subject: [PATCH 19/21] fix --- .../Modals/LogCurvePriorityModal.tsx | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx index d58c46dbc..d976d22e6 100644 --- a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx +++ b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx @@ -95,21 +95,20 @@ export const LogCurvePriorityModal = ( setPrioritizedCurves(updatedPrioritizedCurves); }; - const handleFileChange = useCallback( - async (e: React.ChangeEvent): Promise => { - const file = e.target.files.item(0); - if (!file) return; - const text = (await file.text()).replace(/(\r)/gm, "").trim(); - const data = text.split("\n").slice(1); - const mergedArray = [...data, ...updatedPrioritizedCurves]; - const uniqueArray = mergedArray.filter( - (value, index, self) => self.indexOf(value) === index && value !== "" - ); - setUpdatedPrioritizedCurves(uniqueArray); - setUploadedFile(file); - }, - [] - ); + const handleFileChange = async ( + e: React.ChangeEvent + ): Promise => { + const file = e.target.files.item(0); + if (!file) return; + const text = (await file.text()).replace(/(\r)/gm, "").trim(); + const data = text.split("\n").slice(1); + const mergedArray = [...data, ...updatedPrioritizedCurves]; + const uniqueArray = mergedArray.filter( + (value, index, self) => self.indexOf(value) === index && value !== "" + ); + setUpdatedPrioritizedCurves(uniqueArray); + setUploadedFile(file); + }; const addCurve = () => { setUpdatedPrioritizedCurves([...updatedPrioritizedCurves, newCurve]); @@ -157,10 +156,10 @@ export const LogCurvePriorityModal = ( component="label" startIcon={} > - Upload File + Upload CSV File From afda76f0e622fd6e6265599be1d79ee208e917a9 Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Fri, 13 Sep 2024 14:02:10 +0200 Subject: [PATCH 20/21] fix --- .../components/Modals/LogCurvePriorityModal.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx index d976d22e6..43523bff0 100644 --- a/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx +++ b/Src/WitsmlExplorer.Frontend/components/Modals/LogCurvePriorityModal.tsx @@ -1,12 +1,7 @@ import { Icon, TextField, Tooltip, Typography } from "@equinor/eds-core-react"; import { useOperationState } from "hooks/useOperationState"; -import React, { - ChangeEvent, - KeyboardEvent, - useCallback, - useState -} from "react"; +import React, { ChangeEvent, KeyboardEvent, useState } from "react"; import styled from "styled-components"; import { MousePosition } from "../../contexts/operationStateReducer"; import OperationType from "../../contexts/operationType"; From ab45cc54e88ef6711ef8b0f9e402baa8580ff1c6 Mon Sep 17 00:00:00 2001 From: RobertBasti Date: Fri, 13 Sep 2024 14:13:42 +0200 Subject: [PATCH 21/21] routing --- Src/WitsmlExplorer.Api/Routes.cs | 2 +- .../services/logCurvePriorityService.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/WitsmlExplorer.Api/Routes.cs b/Src/WitsmlExplorer.Api/Routes.cs index 7b264897a..69acd7fa3 100644 --- a/Src/WitsmlExplorer.Api/Routes.cs +++ b/Src/WitsmlExplorer.Api/Routes.cs @@ -40,7 +40,7 @@ public static void ConfigureApi(this WebApplication app, IConfiguration configur app.MapGet("/wells/{wellUid}/wellbores/{wellboreUid}/countexpandable", ObjectHandler.GetExpandableObjectsCount, useOAuth2); app.MapGet("/wells/{wellUid}/wellbores/{wellboreUid}/logCurvePriority", LogCurvePriorityHandler.GetPrioritizedLocalCurves, useOAuth2); - app.MapGet("/universal/getLogCurvePriority", LogCurvePriorityHandler.GetPrioritizedUniversalCurves, useOAuth2); + app.MapGet("/universal/logCurvePriority", LogCurvePriorityHandler.GetPrioritizedUniversalCurves, useOAuth2); app.MapPost("/universal/logCurvePriority", LogCurvePriorityHandler.SetPrioritizedUniversalCurves, useOAuth2); app.MapPost("/wells/{wellUid}/wellbores/{wellboreUid}/logCurvePriority", LogCurvePriorityHandler.SetPrioritizedLocalCurves, useOAuth2); diff --git a/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx b/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx index aadae29e8..b03ef16ca 100644 --- a/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx +++ b/Src/WitsmlExplorer.Frontend/services/logCurvePriorityService.tsx @@ -8,7 +8,7 @@ export default class LogCurvePriorityService { abortSignal?: AbortSignal ): Promise { const path = isUniversal - ? `/api/universal/getLogCurvePriority` + ? `/api/universal/logCurvePriority` : `/api/wells/${encodeURIComponent( wellUid )}/wellbores/${encodeURIComponent(wellboreUid)}/logCurvePriority`;