2217 lines · 102.7 KB · Text
RawDownload
@*******************************************************************************************************//  ModbusConfig.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://  ----------------------------------------------------------------------------------------------------//  07/08/2016 - J. Ritchie Carroll//       Generated original version of source code.////******************************************************************************************************//  To use in an ASP.NET destination project, include a ModbusConfig.cshtml view with following content:////  @using GSF.Web//  @section StyleSheets{@Html.Raw(ViewBag.StyleSheetsSection?.ToString())}//  @Html.RenderResource("ModbusAdapters.ModbusConfig.cshtml")//  @section Scripts{@Html.Raw(ViewBag.ScriptsSection?.ToString())}////******************************************************************************************************//  To use in a self-hosted web project, include a ModbusConfig.cshtml view with following content:////  @using GSF.Web.Model//  @using <MyAppNameSpace>.Model//  @inherits ExtendedTemplateBase<AppModel>//  @section StyleSheets{@Html.Raw(ViewBag.StyleSheetsSection.ToString())}//  @{Layout = "Layout.cshtml";}//  @Html.RenderResource("ModbusAdapters.ModbusConfig.cshtml")//  @section Scripts{@Html.Raw(ViewBag.ScriptsSection.ToString())}////*****************************************************************************************************@@* ReSharper disable UnknownCssClass *@@* ReSharper disable Html.PathError *@@* ReSharper disable InlineOutVariableDeclaration *@@* ReSharper disable ArrangeAccessorOwnerBody *@@using System@using System.Collections.Generic@using System.Net.Http@using GSF@using GSF.Data.Model@using GSF.Security@using GSF.Web@using GSF.Web.Model@using GSF.Web.Shared@using ModbusAdapters.Model@inherits ExtendedTemplateBase@{    const string ModbusRoot = "/@ModbusAdapters";     // Layout will depend on rendering environment, so do not specify one    ViewBag.HidePageTitle = true;    ViewBag.Title = "Modbus Configuration Editor";     if (ViewBag.ModbusLogo == null) {        ViewBag.ModbusLogo = ModbusRoot + "/Images/ModbusConfigEditor.png";    }     const string ReadSequencePanelType = "panel-success";    const string WriteSequencePanelType = "panel-warning";     DataContext dataContext = ViewBag.DataContext;    HttpRequestMessage request = ViewBag.Request;    Dictionary<string, string> parameters = request.QueryParameters();    string parameter;    int deviceID;     if (!parameters.TryGetValue("DeviceID", out parameter) || !int.TryParse(parameter, out deviceID)) {        deviceID = 0;    }     parameters.TryGetValue("ShowMenu", out parameter);     if (string.IsNullOrEmpty(parameter)) {        parameter = "true";    }     ViewBag.ShowMenu = parameter.ParseBoolean();     parameters.TryGetValue("HideLogo", out parameter);     if (string.IsNullOrEmpty(parameter)) {        parameter = "false";    }     ViewBag.HideLogo = parameter.ParseBoolean();     bool userIsEditor = UserIsEditor();}@functions {    // This function simply limits access to UI elements that the user does not have access to, server-side    // functions will further validate user rights even if UI restriction was somehow bypassed    public bool UserIsEditor()    {        SecurityPrincipal securityPrincipal = ViewBag.SecurityPrincipal as SecurityPrincipal;         if ((object)securityPrincipal == null)            return false;         return securityPrincipal.IsInRole("Administrator") || securityPrincipal.IsInRole("Editor");    }}@section StyleSheets {    <link href="@Resources.Root/Shared/Content/jquery-ui.css" rel="stylesheet">    <link href="@Resources.Root/Shared/Content/primeui-theme.css" rel="stylesheet">    <link href="@Resources.Root/Shared/Content/font-awesome.css" rel="stylesheet">    <link href="@Resources.Root/Shared/Content/primeui.css" rel="stylesheet">    <style>        /* Show move cursor over sequence panels to indicate drag-drop re-order capability */        #sequencePanels .panel-heading {            cursor: move;            padding-top: 5px;        }         form.form-inline-sequence {            cursor: move;        }             form.form-inline-sequence div label {                cursor: move;            }         a.move-sequence-up {            cursor: pointer;            position: absolute;            z-index: 999;        }         a.move-sequence-up span {            cursor: pointer;            color: darkgray;            font-weight: bold;            font-size: 12pt;            margin-left: 3px;            top: -12px;        }         a.move-sequence-up:hover span {            color: #0000EE;        }         a.move-sequence-down {            cursor: pointer;            position: absolute;            z-index: 999;        }         a.move-sequence-down span {            cursor: pointer;            color: darkgray;            font-weight: bold;            font-size: 12pt;            margin-left: 3px;            top: 1px;        }         a.move-sequence-down:hover span {            color: #0000EE;        }         @@supports (-ms-accelerator:true) {            /* Handle adjustments for Microsoft Edge */            a.move-sequence-up span {                margin-left: 2px;            }             a.move-sequence-down span {                margin-left: -135px;                top: 20px;            }        }         @@media all and (-ms-high-contrast:none) {            /* Handle adjustments for IE 11 */            a.move-sequence-up span {                margin-left: 2px;            }             a.move-sequence-down span {                margin-left: -139px;                top: 20px;            }        }         span.sequence-record-count {            color: darkgray;            font-size: 7pt;            position: absolute;        }         @@media screen {            .sequence-name {                margin-left: 30px;                width: calc(100% - 30px);                width: -o-calc(100% - 30px);                width: -webkit-calc(100% - 30px);                width: -moz-calc(100% - 30px);            }             span.sequence-record-count {                margin-top: -15px;            }             span.sequence-record-count span {                margin-left: 155px;            }        }         @@media screen and (min-width: 768px) {            .sequence-name {                margin-left: 5px;                width: 100%;            }             span.sequence-record-count {                margin-top: 3px;            }             span.sequence-record-count span {                margin-left: 40px;            }        }         @@supports (-ms-accelerator:true) {            /* Handle adjustments for Microsoft Edge */            span.sequence-record-count {                margin-top: 3px;            }             span.sequence-record-count span {                margin-left: 15px;            }        }         @@supports (-ms-accelerator:true) and (min-width: 768px) {            /* Handle adjustments for Microsoft Edge */            span.sequence-record-count {                margin-top: 21px;            }             span.sequence-record-count span {                margin-left: -95px;            }        }         @@media all and (-ms-high-contrast:none) {            /* Handle adjustments for IE 11 */            span.sequence-record-count {                margin-top: 3px;            }             span.sequence-record-count span {                margin-left: 15px;            }        }         @@media all and (-ms-high-contrast:none) and (min-width: 768px) {            /* Handle adjustments for IE 11 */            span.sequence-record-count {                margin-top: 21px;            }             span.sequence-record-count span {                margin-left: -95px;            }        }         .panel {            margin-top: 5px;            margin-bottom: 5px;        }         .panel-body.warning-border {            border-color: yellow;            border-style: solid;        }         div.warning-message {            font-size: 9.5pt;            font-weight: bold;            text-align: center;            text-shadow: 1px 1px lightgray;            margin-top: -10px;            margin-bottom: 12px;        }         div.sequence-records-message {            font-size: 9pt;            text-align: center;            color: darkgray;            margin-top: -10px;            margin-bottom: 0;        }         span.sequence-group-count {            position: absolute;            font-size: 8pt;            margin-top: 6px;            margin-left: -36px;            height: 6px;            width: 6px;            -moz-transform: rotate(-90.0deg);            -o-transform: rotate(-90.0deg);            -webkit-transform: rotate(-90.0deg);            -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083)";            filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083);            transform: rotate(-90.0deg);        }         @@media screen and (min-width: 1200px) {            span.sequence-group-count {                margin-left: -44px;            }        }         .form-group {            padding-top: 5px;        }         .top-padding {            padding-top: 5px;        }         .top-margin {            margin-top: 5px;        }         .bottom-margin {            margin-bottom: 5px;        }         .connection-status {            background-color: black;            padding: 10px;            margin: 0;            overflow: auto;        }         .glyphicon-interpret-type {            color: darkgrey;            vertical-align: middle;            font-size: 15pt;            margin-right: -5px;            margin-left: -5px;        }         .glyphicon-interpret-result {            color: darkgrey;            vertical-align: middle;            font-size: 17pt;        }         .glyphicon-delete-sequence {            vertical-align: text-top;            color: red;            font-size: larger;        }         .glyphicon-action-button {            color: #606060;            vertical-align: text-top;        }         /*.model-index {            color: lightgray;            font-size: 7pt;            position: relative;            top: -24px;            right: -8px;            margin-left: -8px;            height: 5px;            float: right !important;            opacity: 0.5;        }*/         /* Collapsable button style */        .btn-collapsable.btn {            color: #606060;            font-family: "Glyphicons Halflings";            font-size: 8pt;            position: relative;            top: -9px;            right: -14px;            padding: 0 2px 2px 2px;            height: 18px;            float: right !important;        }         /* Collapsable button icon when content is shown - arrow down */        .btn-collapsable.btn:after {            content: "\e114";        }         /* Collapsable button icon when content is hidden - arrow right */        .btn-collapsable.btn.collapsed:after {            content: "\e080";        }         input[type=text].exists {            border: 3px solid #0C0;        }         @@media screen {            .page-logo {                margin-bottom: -25px;                margin-top: -50px;            }        }         @@media screen and (min-width: 567px) {            .page-logo {                margin-bottom: -25px;                margin-top: -24px;            }        }         @@media screen and (min-width: 992px) {            .page-logo {                margin-bottom: -25px;                margin-top: -20px;            }        }    </style>    <!--[if IE]>    <style type="text/css">        /* Handle adjustments for older IE versions */        a.move-sequence-up span {            margin-left: 2px;        }         a.move-sequence-down span {            margin-left: -139px;            top: 20px;        }         @@media screen        {            span.sequence-record-count {                margin-top: 3px;            }             span.sequence-record-count span {                margin-left: 15px;            }        }         @@media screen and (min-width: 768px)        {            span.sequence-record-count {                margin-top: 21px;            }             span.sequence-record-count span {                margin-left: -95px;            }        }    </style>    <![endif]-->}@section Scripts {    <script src="@Resources.Root/Shared/Scripts/knockout.js"></script>    <script src="@Resources.Root/Shared/Scripts/knockout.mapping.js"></script>    <script src="@Resources.Root/Shared/Scripts/knockout.validation.js"></script>    <script src="@Resources.Root/Shared/Scripts/knockout.reactor.js"></script>    <script src="@Resources.Root/Shared/Scripts/gsf.web.knockout.js"></script>    <script src="@Resources.Root/Shared/Scripts/jquery-ui.js"></script>    <script src="@Resources.Root/Shared/Scripts/primeui.js"></script>    <script src="@ModbusRoot/Scripts/RecordViewModel.js"></script>    <script src="@ModbusRoot/Scripts/SequenceViewModel.js"></script>    <script src="@ModbusRoot/Scripts/MapViewModel.js"></script>    <script>        "use strict";         var deviceID = @deviceID;        var deviceConnected = false;        var sourceCheckbox = null;        var loadAppendMode = false;         // Define primary view model for page        const viewModel = new MapViewModel();         function addSequenceRecord(sequence, recordType) {            if (recordType === RecordType.DerivedValue) {                sequence.addNewSequenceRecord(null,                {                    recordType: recordType,                    selected: false,                    address: getDerivedValueAddressExpression(sequence),                    description: "",                    dataValue: ""                }, true);

Lines 1–500 of 2217.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t