@inherits CmdBase @attribute [MongoCommand(CmdType.Read, "Statistics", "Informational")] @* * dbMango * * Copyright 2025 Deutsche Bank AG * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *@
@code { // private string Json { get; set; } = ""; private List Stats { get; set; } = []; private static readonly List<(string, string, bool)> _descriptor = [ ("ns" , "Full name" , false), ("sharded" , "Is sharded" , false), ("count" , "Number of documents" , false), ("size" , "Size" , false), ("storageSize" , "Storage size" , true ), ("totalIndexSize" , "Total index size" , true ), ("totalSize" , "Total size" , true ), ("avgObjSize" , "Average object size" , true ), ("maxSize" , "Max size" , true ), ("nindexes" , "Number of indexes" , false), ("nchunks" , "Number of chunks" , false) ]; protected override Task OnAfterRenderAsync(bool firstRender) { if (firstRender ) UpdateCommand(); return Task.CompletedTask; } private void UpdateCommand() { if (Parameters == null) return; Parameters.CommandJson = $@"{{ ""collStats"": ""{Collection}"", ""scale"": 1 }}"; Parameters.NeedConfirmation = false; Validate(); } protected override Task OnCollectionChanged() { UpdateCommand(); return Task.CompletedTask; } protected override void OnResultReceived() { if (Parameters?.Result.Count > 0) { Json = Parameters.Result[0].ToJson(new() { Indent = true }); Stats = FormatDocument(Parameters.Result[0], _descriptor).Cast().ToList(); } else { Json = ""; Stats = []; } InvokeAsync(StateHasChanged); } }