<commit_before>﻿@*******************************************************************************************************
    //  LineSegments.cshtml - Gbtc
    //
    //  Copyright © 2016, Grid Protection Alliance.  All Rights Reserved.
    //
    //  Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
    //  the NOTICE file distributed with this work for additional information regarding copyright ownership.
    //  The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
    //  file except in compliance with the License. You may obtain a copy of the License at:
    //
    //      http://opensource.org/licenses/MIT
    //
    //  Unless agreed to in writing, the subject software distributed under the License is distributed on an
    //  "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
    //  License for the specific language governing permissions and limitations.
    //
    //  Code Modification History:
    //  ----------------------------------------------------------------------------------------------------
    //  01/15/2016 - <NAME>
    //       Generated original version of source code.
    //  08/23/2019 - <NAME>
    //       Added Relay Alert Settings.
    //  12/20/2019 - <NAME>
    //       Changed to point to Asset Model and removed Line specific attributes.
    //
    //*****************************************************************************************************@
@using System.Collections.Generic
@using System.Net.Http
@using System.Text.RegularExpressions
@using GSF.Web
@using GSF.Web.Model
@using openXDA
@using openXDA.Model
@using RazorEngine.Templating
@using openXDA.Hubs

@inherits ExtendedTemplateBase<AppModel>
@{
    DataContext dataContext = ViewBag.DataContext;
    Layout = "Assets/Layout.cshtml";
    ViewBag.Title = "Line Segments";
    HttpRequestMessage request = ViewBag.Request;
    Dictionary<string, string> parameters = request.QueryParameters();

    ViewBag.LineID = -1;
    ViewBag.lengthUnits = dataContext.Connection.ExecuteScalar<string>("Select Value From [Setting] WHERE Name = 'LengthUnits'");

    string LineName = null;

    if (parameters.ContainsKey("Asset"))
    {
        ViewBag.Asset = parameters["Asset"];
    }

    if (parameters.ContainsKey("LineID"))
    {
        ViewBag.LineID = int.Parse(parameters["LineID"] ?? "-1");
        LineName = dataContext.Connection.ExecuteScalar<string>("SELECT AssetKey FROM Line WHERE ID = {0}", ViewBag.LineID);
        ViewBag.CustomHeader = "Segments of <a href=\"/Assets/Lines.cshtml?Asset=" + LineName + "\">" + LineName + "</a>";
        ViewBag.Title = "Segments of " + LineName;
    }

    ViewBag.ParentKeys = ViewBag.LineID;


    // Define column headers, use null for field name to make column non-sortable
    ViewBag.HeaderColumns = new[]
    {   //    { "Field", "Label", "Classes" }
new[] { "AssetKey", "Key", "text-Left" },
new[] { "AssetName", "Asset Name", "text-left" },
new[] { "Length", "Length", "text-left" },
new[] { "ThermalRating", "Thermal Rating", "text-left"},
new[] { "IsEnd", "End of Line", "text-left"},
};

    ViewBag.AddNewEditTitle = "Segment";
    ViewBag.BodyRows = BodyRows().ToString();
    ViewBag.AddNewEditDialog = AddNewEditDialog(dataContext).ToString();
    ViewBag.lengthUnits = dataContext.Connection.ExecuteScalar<string>("Select Value From [Setting] WHERE Name = 'LengthUnits'");
}
@helper AssetFilter()
{
    <div class='row'>
        <div class='col-md-12'>
            <div class='form-group'>
                <label for='linefilter'>Asset Key Filter:</label>
                <div class='right-inner-addon'>
                    <i class='glyphicon glyphicon-search'></i>
                    <input class='form-control' type='search' id='linefilter' placeholder='Search' />
                </div>
            </div>
        </div>
    </div>
}
@helper BodyRows()
{
    <td width="25%" class="text-left valign-middle" nowrap><button type="button" class="btn btn-link" data-bind="text: AssetKey, click: $parent.viewPageRecord"></button></td>
    <td width="25%" class="text-left valign-middle" data-bind="text: AssetName"></td>
    <td width="20%" class="text-left valign-middle" data-bind="text: Length"></td>
    <td width="20%" class="text-left valign-middle" data-bind="text: ThermalRating"></td>
    <td width="5%" class="text-left valign-middle" data-bind="text: IsEnd"></td>
    <td width="5%" class="text-center valign-middle" nowrap>
        <button type="button" class="btn btn-xs" data-bind="click: $parent.editPageRecord, enable: $parent.dataHubIsConnected()"><span class="glyphicon glyphicon-pencil"></span></button>
        <button type="button" class="btn btn-xs" data-bind="click: $parent.removePageRecord, enable: $parent.canDelete() && $parent.dataHubIsConnected()"><span class="glyphicon glyphicon-remove"></span></button>
    </td>
}
@helper AddNewEditDialog(DataContext dataContext)
{
    <div class="col-md-4">
        @Raw(dataContext.AddInputField<LineSegment>("AssetKey", fieldLabel: "Key"))
        @Raw(dataContext.AddInputField<LineSegment>("AssetName", fieldLabel: "Name"))
        @Raw(dataContext.AddInputField<LineSegment>("VoltageKV", fieldLabel: "Line-to-Line Nominal Voltage (kV)"))
        @Raw(dataContext.AddCheckBoxField<LineSegment>("IsEnd", fieldLabel: "End of the Line"))
        @Raw(dataContext.AddTextAreaField<LineSegment>("Description"))
    </div>
    <div class="col-md-4">


        @Raw(dataContext.AddInputField<LineSegment>("R0", fieldLabel: "R0 (p.u.)"))
        @Raw(dataContext.AddInputField<LineSegment>("X0", fieldLabel: "X0 (p.u.)"))
        @Raw(dataContext.AddInputField<LineSegment>("R1", fieldLabel: "R1 (p.u.)"))
        @Raw(dataContext.AddInputField<LineSegment>("X1", fieldLabel: "X1 (p.u.)"))
    </div>
    <div class="col-md-4">
        @Raw(dataContext.AddInputField<LineSegment>("ThermalRating", fieldLabel: "ThermalRating (A)"))<commit_msg>Fix erroneous impedance labels for line segments<commit_after>﻿@*******************************************************************************************************
    //  LineSegments.cshtml - Gbtc
    //
    //  Copyright © 2016, Grid Protection Alliance.  All Rights Reserved.
    //
    //  Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
    //  the NOTICE file distributed with this work for additional information regarding copyright ownership.
    //  The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
    //  file except in compliance with the License. You may obtain a copy of the License at:
    //
    //      http://opensource.org/licenses/MIT
    //
    //  Unless agreed to in writing, the subject software distributed under the License is distributed on an
    //  "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
    //  License for the specific language governing permissions and limitations.
    //
    //  Code Modification History:
    //  ----------------------------------------------------------------------------------------------------
    //  01/15/2016 - <NAME>
    //       Generated original version of source code.
    //  08/23/2019 - <NAME>
    //       Added Relay Alert Settings.
    //  12/20/2019 - <NAME>
    //       Changed to point to Asset Model and removed Line specific attributes.
    //
    //*****************************************************************************************************@
@using System.Collections.Generic
@using System.Net.Http
@using System.Text.RegularExpressions
@using GSF.Web
@using GSF.Web.Model
@using openXDA
@using openXDA.Model
@using RazorEngine.Templating
@using openXDA.Hubs

@inherits ExtendedTemplateBase<AppModel>
@{
    DataContext dataContext = ViewBag.DataContext;
    Layout = "Assets/Layout.cshtml";
    ViewBag.Title = "Line Segments";
    HttpRequestMessage request = ViewBag.Request;
    Dictionary<string, string> parameters = request.QueryParameters();

    ViewBag.LineID = -1;
    ViewBag.lengthUnits = dataContext.Connection.ExecuteScalar<string>("Select Value From [Setting] WHERE Name = 'LengthUnits'");

    string LineName = null;

    if (parameters.ContainsKey("Asset"))
    {
        ViewBag.Asset = parameters["Asset"];
    }

    if (parameters.ContainsKey("LineID"))
    {
        ViewBag.LineID = int.Parse(parameters["LineID"] ?? "-1");
        LineName = dataContext.Connection.ExecuteScalar<string>("SELECT AssetKey FROM Line WHERE ID = {0}", ViewBag.LineID);
        ViewBag.CustomHeader = "Segments of <a href=\"/Assets/Lines.cshtml?Asset=" + LineName + "\">" + LineName + "</a>";
        ViewBag.Title = "Segments of " + LineName;
    }

    ViewBag.ParentKeys = ViewBag.LineID;


    // Define column headers, use null for field name to make column non-sortable
    ViewBag.HeaderColumns = new[]
    {   //    { "Field", "Label", "Classes" }
new[] { "AssetKey", "Key", "text-Left" },
new[] { "AssetName", "Asset Name", "text-left" },
new[] { "Length", "Length", "text-left" },
new[] { "ThermalRating", "Thermal Rating", "text-left"},
new[] { "IsEnd", "End of Line", "text-left"},
};

    ViewBag.AddNewEditTitle = "Segment";
    ViewBag.BodyRows = BodyRows().ToString();
    ViewBag.AddNewEditDialog = AddNewEditDialog(dataContext).ToString();
    ViewBag.lengthUnits = dataContext.Connection.ExecuteScalar<string>("Select Value From [Setting] WHERE Name = 'LengthUnits'");
}
@helper AssetFilter()
{
    <div class='row'>
        <div class='col-md-12'>
            <div class='form-group'>
                <label for='linefilter'>Asset Key Filter:</label>
                <div class='right-inner-addon'>
                    <i class='glyphicon glyphicon-search'></i>
                    <input class='form-control' type='search' id='linefilter' placeholder='Search' />
                </div>
            </div>
        </div>
    </div>
}
@helper BodyRows()
{
    <td width="25%" class="text-left valign-middle" nowrap><button type="button" class="btn btn-link" data-bind="text: AssetKey, click: $parent.viewPageRecord"></button></td>
    <td width="25%" class="text-left valign-middle" data-bind="text: AssetName"></td>
    <td width="20%" class="text-left valign-middle" data-bind="text: Length"></td>
    <td width="20%" class="text-left valign-middle" data-bind="text: ThermalRating"></td>
    <td width="5%" class="text-left valign-middle" data-bind="text: IsEnd"></td>
    <td width="5%" class="text-center valign-middle" nowrap>
        <button type="button" class="btn btn-xs" data-bind="click: $parent.editPageRecord, enable: $parent.dataHubIsConnected()"><span class="glyphicon glyphicon-pencil"></span></button>
        <button type="button" class="btn btn-xs" data-bind="click: $parent.removePageRecord, enable: $parent.canDelete() && $parent.dataHubIsConnected()"><span class="glyphicon glyphicon-remove"></span></button>
    </td>
}
@helper AddNewEditDialog(DataContext dataContext)
{
    <div class="col-md-4">
        @Raw(dataContext.AddInputField<LineSegment>("AssetKey", fieldLabel: "Key"))
        @Raw(dataContext.AddInputField<LineSegment>("AssetName", fieldLabel: "Name"))
        @Raw(dataContext.AddInputField<LineSegment>("VoltageKV", fieldLabel: "Line-to-Line Nominal Voltage (kV)"))
        @Raw(dataContext.AddCheckBoxField<LineSegment>("IsEnd", fieldLabel: "End of the Line"))
        @Raw(dataContext.AddTextAreaField<LineSegment>("Description"))
    </div>
    <div class="col-md-4">


        @Raw(dataContext.AddInputField<LineSegment>("R0", fieldLabel: "R0 (Ohms)"))
        @Raw(dataContext.AddInputField<LineSegment>("X0", fieldLabel: "X0 (Ohms)"))
        @Raw(dataContext.AddInputField<LineSegment>("R1", fieldLabel: "R1 (Ohms)"))
        @Raw(dataContext.AddInputField<LineSegment>("X1", fieldLabel: "X1 (Ohms)"))
    </div>
    <div class="col-md-4">
        @Raw(dataContext.AddInputField<LineSegment>("ThermalRating", fieldLabel: "ThermalRating (A)"))
{'fraction_non_alphanumeric': 0.19377219790204014, 'fraction_numerical': 0.008920459238457091, 'mean_word_length': 3.350700682716493, 'pattern_counts': {'":': 0, '<': 123, '<?xml version=': 0, '>': 123, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7661313', 'n_tokens_mistral': 3594, 'n_tokens_neox': 3454, 'n_words': 851}