add interface page
authorStricted <info@stricted.de>
Sat, 9 Jan 2016 18:24:08 +0000 (19:24 +0100)
committerStricted <info@stricted.de>
Sat, 9 Jan 2016 18:24:08 +0000 (19:24 +0100)
12 files changed:
SpeedportHybridControl/App.xaml
SpeedportHybridControl/Data/SpeedportHybrid.cs
SpeedportHybridControl/MainWindow.xaml
SpeedportHybridControl/Model/InterfaceList.cs [new file with mode: 0644]
SpeedportHybridControl/PageModel/InterfacePageModel.cs [new file with mode: 0644]
SpeedportHybridControl/PageModel/LoginPageModel.cs
SpeedportHybridControl/PageModel/MainWindowModel.cs
SpeedportHybridControl/SpeedportHybridControl.csproj
SpeedportHybridControl/ltepopup.xaml
SpeedportHybridControl/ltepopup.xaml.cs
SpeedportHybridControl/page/InterfacePage.xaml [new file with mode: 0644]
SpeedportHybridControl/page/InterfacePage.xaml.cs [new file with mode: 0644]

index 17cacfb4b62b5d656a660ca1fc00a76b13ff269c..160dd15cb30683a426ba19044e025cd2e42dd42d 100644 (file)
@@ -18,6 +18,7 @@
             <pagemodel:TR181PageModel x:Key="TR181PageModel"></pagemodel:TR181PageModel>
             <pagemodel:PhonePageModel x:Key="PhonePageModel"></pagemodel:PhonePageModel>
             <pagemodel:LanPageModel x:Key="LanPageModel"></pagemodel:LanPageModel>
+            <pagemodel:InterfacePageModel x:Key="InterfacePageModel"></pagemodel:InterfacePageModel>
             <pagemodel:ControlsPageModel x:Key="ControlsPageModel"></pagemodel:ControlsPageModel>
             <pagemodel:AboutPageModel x:Key="AboutPageModel"></pagemodel:AboutPageModel>
             <pagemodel:ltepopupModel x:Key="ltepopupModel"></pagemodel:ltepopupModel>
index ac6a427f2a4c1f4830af46f2a2ea0a0ecbb263b2..d1a061fa3c7f552dfc2332be0b2aeda1a49235e8 100644 (file)
@@ -832,5 +832,46 @@ namespace SpeedportHybridControl.Data {
                                LogManager.WriteToLog(ex.Message);
                        }
                }
+
+               public static void initInterface () {
+                       try {
+                               if (SpeedportHybridAPI.getInstance().checkLogin().Equals(false))
+                                       return;
+
+                               InterfacePageModel IPM = Application.Current.FindResource("InterfacePageModel") as InterfacePageModel;
+
+                               string response = SpeedportHybridAPI.getInstance().sendEnryptedRequest("data/interfaces.json");
+                               if (response.IsNullOrEmpty())
+                                       return;
+
+                               JToken jArray = JToken.Parse(response);
+                               response = null;
+
+                               List<InterfaceList> interfaceList = new List<InterfaceList>();
+                               foreach (JToken jToken in jArray.SelectToken("line_status")) {
+                                       string ifc = jToken.SelectToken("interface").ToString();
+                                       string mtu = jToken.SelectToken("MTU").ToString();
+                                       string tx_packets = jToken.SelectToken("tx_packets").ToString();
+                                       string tx_errors = jToken.SelectToken("tx_errors").ToString();
+                                       string rx_packets = jToken.SelectToken("rx_packets").ToString();
+                                       string rx_errors = jToken.SelectToken("rx_errors").ToString();
+                                       string collisions = jToken.SelectToken("collisions").ToString();
+
+                                       interfaceList.Add(new InterfaceList() { ifc = ifc, mtu = mtu, tx_packets = tx_packets, tx_errors = tx_errors, rx_packets = rx_packets, rx_errors = rx_errors, collisions = collisions });
+                               }
+
+                               IPM.interfaceList = interfaceList;
+
+                               interfaceList = null;
+                               jArray = null;
+
+                               DateTime time = DateTime.Now;
+                               string format = "dd.MM.yyyy HH:mm:ss";
+                               IPM.datetime = time.ToString(format);
+                       }
+                       catch (Exception ex) {
+                               LogManager.WriteToLog(ex.Message);
+                       }
+               }
        }
 }
index 24a8ff98f842ee39347f4fe7fb04b2c4a1fb122d..88294ae84f9185e4376953dc744721ce99f1c567 100644 (file)
@@ -29,6 +29,7 @@
             <Button Command="{Binding Path=SwitchToTR181Page}" IsEnabled="{Binding Path=ButtonTR181PageIsActive}" Background="{Binding Path=ButtonTR181PageBackground}" x:Name="btnTR181" Content="TR-181"/>
             <Button Command="{Binding Path=SwitchToPhonePage}" IsEnabled="{Binding Path=ButtonPhonePageIsActive}" Background="{Binding Path=ButtonPhonePageBackground}" x:Name="btnPhone" Content="Anrufe"/>
             <Button Command="{Binding Path=SwitchToLanPage}" IsEnabled="{Binding Path=ButtonLanPageIsActive}" Background="{Binding Path=ButtonLanPageBackground}" x:Name="btnLan" Content="Lan"/>
+            <Button Command="{Binding Path=SwitchToInterfacePage}" IsEnabled="{Binding Path=ButtonInterfacePageIsActive}" Background="{Binding Path=ButtonInterfacePageBackground}" x:Name="btnInterface" Content="Interface"/>
             <Button Command="{Binding Path=SwitchToControlsPage}" IsEnabled="{Binding Path=ButtonControlsPageIsActive}" Background="{Binding Path=ButtonControlsPageBackground}" x:Name="btnControls" Content="Controls"/>
         </StackPanel>
 
diff --git a/SpeedportHybridControl/Model/InterfaceList.cs b/SpeedportHybridControl/Model/InterfaceList.cs
new file mode 100644 (file)
index 0000000..4a3aae6
--- /dev/null
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SpeedportHybridControl.Model {
+       class InterfaceList : SuperViewModel {
+               private string _ifc;
+               private string _mtu;
+               private string _tx_packets;
+               private string _tx_errors;
+               private string _rx_packets;
+               private string _rx_errors;
+               private string _collisions;
+
+               public string ifc {
+                       get { return _ifc; }
+                       set { SetProperty(ref _ifc, value); }
+               }
+
+               public string mtu
+               {
+                       get { return _mtu; }
+                       set { SetProperty(ref _mtu, value); }
+               }
+
+               public string tx_packets
+               {
+                       get { return _tx_packets; }
+                       set { SetProperty(ref _tx_packets, value); }
+               }
+
+               public string tx_errors
+               {
+                       get { return _tx_errors; }
+                       set { SetProperty(ref _tx_errors, value); }
+               }
+
+               public string rx_packets
+               {
+                       get { return _rx_packets; }
+                       set { SetProperty(ref _rx_packets, value); }
+               }
+
+               public string rx_errors
+               {
+                       get { return _rx_errors; }
+                       set { SetProperty(ref _rx_errors, value); }
+               }
+
+               public string collisions
+               {
+                       get { return _collisions; }
+                       set { SetProperty(ref _collisions, value); }
+               }
+       }
+}
diff --git a/SpeedportHybridControl/PageModel/InterfacePageModel.cs b/SpeedportHybridControl/PageModel/InterfacePageModel.cs
new file mode 100644 (file)
index 0000000..456ebd5
--- /dev/null
@@ -0,0 +1,43 @@
+using SpeedportHybridControl.Data;
+using SpeedportHybridControl.Implementations;
+using SpeedportHybridControl.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace SpeedportHybridControl.PageModel {
+       class InterfacePageModel : SuperViewModel {
+               private DelegateCommand _reloadCommand;
+               private List<InterfaceList> _interfaceList;
+               private string _datetime;
+
+               public DelegateCommand ReloadCommand
+               {
+                       get { return _reloadCommand; }
+                       set { SetProperty(ref _reloadCommand, value); }
+               }
+
+               public List<InterfaceList> interfaceList
+               {
+                       get { return _interfaceList; }
+                       set { SetProperty(ref _interfaceList, value); }
+               }
+
+               public string datetime
+               {
+                       get { return _datetime; }
+                       set { SetProperty(ref _datetime, value); }
+               }
+
+               private void OnReloadCommandExecute () {
+                       new Thread(() => { SpeedportHybrid.initInterface(); }).Start();
+               }
+
+               public InterfacePageModel () {
+                       ReloadCommand = new DelegateCommand(new Action(OnReloadCommandExecute));
+               }
+       }
+}
index 94f9c1da3f82a7596f5ecd09bbf2ea10a19fdf4c..0787c6917c18b70f7bb7a3870cd6ad196f86f355 100644 (file)
@@ -124,6 +124,7 @@ namespace SpeedportHybridControl.PageModel {
                                        mwm.ButtonTR181PageIsActive = true;
                                        mwm.ButtonPhonePageIsActive = true;
                                        mwm.ButtonLanPageIsActive = true;
+                                       mwm.ButtonInterfacePageIsActive = true;
                                        mwm.ButtonControlsPageIsActive = true;
 
                                        LoginButtonText = "Logout";
@@ -152,6 +153,7 @@ namespace SpeedportHybridControl.PageModel {
                        mwm.ButtonTR181PageIsActive = false;
                        mwm.ButtonPhonePageIsActive = false;
                        mwm.ButtonLanPageIsActive = false;
+                       mwm.ButtonInterfacePageIsActive = false;
                        mwm.ButtonControlsPageIsActive = false;
 
                        LoginButtonText = "Login";
index d3a4af9450fbd3aafeaab6edbf471e5a51cd7976..77428569ac78c0a21b68d4b259ba6aeb661b6c8f 100644 (file)
@@ -23,6 +23,7 @@ namespace SpeedportHybridControl.PageModel {
                private DelegateCommand _switchToTR181Page;
                private DelegateCommand _switchToPhonePage;
                private DelegateCommand _switchToLanPage;
+               private DelegateCommand _switchToInterfacePage;
                private DelegateCommand _switchToControlsPage;
                private DelegateCommand _sitchToAboutPage;
 
@@ -33,6 +34,7 @@ namespace SpeedportHybridControl.PageModel {
                private bool _buttonTR181PageIsActive = false;
                private bool _buttonPhonePageIsActive = false;
                private bool _buttonLanPageIsActive = false;
+               private bool _buttonInterfacePageIsActive = false;
                private bool _buttonControlsPageIsActive = false;
 
                private Brush _buttonLoginPageBackground = Brushes.LightGray;
@@ -44,6 +46,7 @@ namespace SpeedportHybridControl.PageModel {
                private Brush _buttonTR181PageBackground = Brushes.LightGray;
                private Brush _buttonPhonePageBackground = Brushes.LightGray;
                private Brush _buttonLanPageBackground = Brushes.LightGray;
+               private Brush _buttonInterfacePageBackground = Brushes.LightGray;
                private Brush _buttonControlsPageBackground = Brushes.LightGray;
                private Brush _buttonAboutPageBackground = Brushes.LightGray;
 
@@ -101,6 +104,12 @@ namespace SpeedportHybridControl.PageModel {
                        set { SetProperty(ref _switchToLanPage, value); }
                }
 
+               public DelegateCommand SwitchToInterfacePage
+               {
+                       get { return _switchToInterfacePage; }
+                       set { SetProperty(ref _switchToInterfacePage, value); }
+               }
+
                public DelegateCommand SwitchToControlsPage {
                        get { return _switchToControlsPage; }
                        set { SetProperty(ref _switchToControlsPage, value); }
@@ -146,6 +155,12 @@ namespace SpeedportHybridControl.PageModel {
                        set { SetProperty(ref _buttonLanPageIsActive, value); }
                }
 
+               public bool ButtonInterfacePageIsActive
+               {
+                       get { return _buttonInterfacePageIsActive; }
+                       set { SetProperty(ref _buttonInterfacePageIsActive, value); }
+               }
+
                public bool ButtonControlsPageIsActive {
                        get { return _buttonControlsPageIsActive; }
                        set { SetProperty(ref _buttonControlsPageIsActive, value); }
@@ -196,6 +211,12 @@ namespace SpeedportHybridControl.PageModel {
                        set { SetProperty(ref _buttonLanPageBackground, value); }
                }
 
+               public Brush ButtonInterfacePageBackground
+               {
+                       get { return _buttonInterfacePageBackground; }
+                       set { SetProperty(ref _buttonInterfacePageBackground, value); }
+               }
+
                public Brush ButtonControlsPageBackground {
                        get { return _buttonControlsPageBackground; }
                        set { SetProperty(ref _buttonControlsPageBackground, value); }
@@ -260,6 +281,11 @@ namespace SpeedportHybridControl.PageModel {
                        new Thread(() => { SpeedportHybrid.initLan(); }).Start();
                }
 
+               private void OnSwitchToInterfacePageExecute () {
+                       changePage("interface");
+                       new Thread(() => { SpeedportHybrid.initInterface(); }).Start();
+               }
+
                private void OnSwitchToControlsPageExecute () {
                        changePage("controls");
                }
@@ -308,6 +334,9 @@ namespace SpeedportHybridControl.PageModel {
                        else if (page.Equals("lan")) {
                                FrameSource = new LanPage();
                        }
+                       else if (page.Equals("interface")) {
+                               FrameSource = new InterfacePage();
+                       }
                        else if (page.Equals("controls")) {
                                FrameSource = new ControlsPage();
                        }
@@ -328,6 +357,7 @@ namespace SpeedportHybridControl.PageModel {
                        ButtonTR181PageBackground = Brushes.LightGray;
                        ButtonPhonePageBackground = Brushes.LightGray;
                        ButtonLanPageBackground = Brushes.LightGray;
+                       ButtonInterfacePageBackground = Brushes.LightGray;
                        ButtonControlsPageBackground = Brushes.LightGray;
                        ButtonAboutPageBackground = Brushes.LightGray;
 
@@ -367,6 +397,10 @@ namespace SpeedportHybridControl.PageModel {
                                ButtonLanPageBackground = Brushes.LightGreen;
                        }
 
+                       if (page.Equals("interface")) {
+                               ButtonInterfacePageBackground = Brushes.LightGreen;
+                       }
+
                        if (page.Equals("controls")) {
                                ButtonControlsPageBackground = Brushes.LightGreen;
                        }
@@ -398,6 +432,7 @@ namespace SpeedportHybridControl.PageModel {
                        SwitchToTR181Page = new DelegateCommand(new Action(OnSwitchToTR181PageExecute));
                        SwitchToPhonePage = new DelegateCommand(new Action(OnSwitchToPhonePageExecute));
                        SwitchToLanPage = new DelegateCommand(new Action(OnSwitchToLanPageExecute));
+                       SwitchToInterfacePage = new DelegateCommand(new Action(OnSwitchToInterfacePageExecute));
                        SwitchToControlsPage = new DelegateCommand(new Action(OnSwitchToControlsPageExecute));
 
                        SwitchToAboutPage = new DelegateCommand(new Action(OnSwitchToAboutPageExecute));
index 3244f9ee12a5616221cf69986fd27b0f72713e4b..727d5548d5c9e23580b261d049890fb4fa94f923 100644 (file)
@@ -49,7 +49,6 @@
     <Reference Include="System" />
     <Reference Include="System.Data" />
     <Reference Include="System.Windows" />
-    <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
     <Reference Include="System.Xml" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Core" />
@@ -75,6 +74,7 @@
     <Compile Include="Model\bonding_client.cs" />
     <Compile Include="Model\Connection.cs" />
     <Compile Include="Model\DeviceList.cs" />
+    <Compile Include="Model\InterfaceList.cs" />
     <Compile Include="Model\Line.cs" />
     <Compile Include="Model\LTECollection.cs" />
     <Compile Include="Model\LTEData.cs" />
@@ -84,6 +84,7 @@
     <Compile Include="PageModel\AboutPageModel.cs" />
     <Compile Include="PageModel\ControlsPageModel.cs" />
     <Compile Include="PageModel\DslPageModel.cs" />
+    <Compile Include="PageModel\InterfacePageModel.cs" />
     <Compile Include="PageModel\LanPageModel.cs" />
     <Compile Include="PageModel\LoginPageModel.cs" />
     <Compile Include="PageModel\LteInfoModel.cs" />
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="page\InterfacePage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="page\LanPage.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     <Compile Include="page\DslPage.xaml.cs">
       <DependentUpon>DslPage.xaml</DependentUpon>
     </Compile>
+    <Compile Include="page\InterfacePage.xaml.cs">
+      <DependentUpon>InterfacePage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="page\LanPage.xaml.cs">
       <DependentUpon>LanPage.xaml</DependentUpon>
     </Compile>
index 897bd0583e44202319e40bb00f69543c82f531c4..b41c1053ff5b6de4e89dd5e67d755de242aed2fd 100644 (file)
@@ -4,21 +4,15 @@
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:SpeedportHybridControl"
-        mc:Ignorable="d"
         xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
-        xmlns:ig="http://schemas.infragistics.com/xaml"
-        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
+        mc:Ignorable="d"
         Height="423.4"
         Width="530"
         Title="LteInfo"
+        Closing="Window_Closing"
         DataContext="{StaticResource ltepopupModel}"
         Topmost="{Binding Path=Topmost}"
         Icon="t-com icon.ico">
-    <i:Interaction.Triggers>
-        <i:EventTrigger EventName="Closing">
-            <i:InvokeCommandAction Command="{Binding CloseWindowCommand}" />
-        </i:EventTrigger>
-    </i:Interaction.Triggers>
     <Grid>
         <ToggleButton Command="{Binding Path=PinCommand}" IsChecked="{Binding Path=PinActive, Mode=TwoWay}" Background="Transparent" BorderBrush="Transparent" x:Name="btnPin" HorizontalAlignment="Left" Margin="10,2,0,0" Height="20" VerticalAlignment="Top">
             <Image Source="assets/pin.png" x:Name="image" HorizontalAlignment="Left"  VerticalAlignment="Top"/>
index 2ce635c834da12b801497c5ea101d20d0c0b5457..97e0544df41eb56d02418b8449f105cc5dd054f8 100644 (file)
@@ -1,4 +1,5 @@
-using System.Windows;
+using SpeedportHybridControl.PageModel;
+using System.Windows;
 
 namespace SpeedportHybridControl {
        /// <summary>
@@ -8,5 +9,11 @@ namespace SpeedportHybridControl {
                public ltepopup () {
                        InitializeComponent();
                }
+
+               // quick & dirty
+               private void Window_Closing (object sender, System.ComponentModel.CancelEventArgs e) {
+                       ltepopupModel lm = Application.Current.FindResource("ltepopupModel") as ltepopupModel;
+                       lm.StopTimer();
+        }
        }
 }
diff --git a/SpeedportHybridControl/page/InterfacePage.xaml b/SpeedportHybridControl/page/InterfacePage.xaml
new file mode 100644 (file)
index 0000000..7c40b6b
--- /dev/null
@@ -0,0 +1,35 @@
+<Page x:Class="SpeedportHybridControl.page.InterfacePage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+      xmlns:local="clr-namespace:SpeedportHybridControl"
+      mc:Ignorable="d"
+      Width="514" Height="287"
+      Title="InterfacePage">
+
+    <Grid DataContext="{StaticResource InterfacePageModel}">
+        <ListView ItemsSource="{Binding interfaceList}" x:Name="listView4" Margin="0,0,0,39">
+            <ListView.Resources>
+                <Style TargetType="{x:Type GridViewColumnHeader}">
+                    <Setter Property="HorizontalContentAlignment" Value="Left" />
+                </Style>
+            </ListView.Resources>
+            <ListView.View>
+                <GridView>
+                    <GridViewColumn TextBlock.TextAlignment="Left" Header="Interface" DisplayMemberBinding="{Binding Path=ifc}" Width="Auto"/>
+                    <GridViewColumn TextBlock.TextAlignment="Left" Header="MTU" DisplayMemberBinding="{Binding Path=mtu}" Width="Auto"/>
+                    <GridViewColumn TextBlock.TextAlignment="Left" Header="Out_Frames" DisplayMemberBinding="{Binding Path=tx_packets}" Width="Auto"/>
+                    <GridViewColumn TextBlock.TextAlignment="Left" Header="Out_Errors" DisplayMemberBinding="{Binding Path=tx_errors}" Width="Auto"/>
+                    <GridViewColumn TextBlock.TextAlignment="Left" Header="In_Frames" DisplayMemberBinding="{Binding Path=rx_packets}" Width="Auto"/>
+                    <GridViewColumn TextBlock.TextAlignment="Left" Header="In_Errors" DisplayMemberBinding="{Binding Path=rx_errors}" Width="Auto"/>
+                    <GridViewColumn TextBlock.TextAlignment="Left" Header="Collisions" DisplayMemberBinding="{Binding Path=collisions}" Width="Auto"/>
+                </GridView>
+            </ListView.View>
+        </ListView>
+
+        <TextBlock Text="{Binding datetime}" Margin="0,0,10,0" HorizontalAlignment="Right" VerticalAlignment="Bottom" />
+
+        <Button Command="{Binding Path=ReloadCommand}" x:Name="reload" Content="Aktualisieren" Margin="218,0,218,0" VerticalAlignment="Bottom"/>
+    </Grid>
+</Page>
diff --git a/SpeedportHybridControl/page/InterfacePage.xaml.cs b/SpeedportHybridControl/page/InterfacePage.xaml.cs
new file mode 100644 (file)
index 0000000..f2a7d75
--- /dev/null
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace SpeedportHybridControl.page {
+       /// <summary>
+       /// Interaktionslogik für InterfacePage.xaml
+       /// </summary>
+       public partial class InterfacePage : Page {
+               public InterfacePage () {
+                       InitializeComponent();
+               }
+       }
+}