<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" Inherits="Kesion.NET.WebSite.Admin_AccessTokens" Codebehind="KS.AccessTokens.aspx.cs" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" runat="Server">
    <div class="content-area mt20">
        <script>
            function GetAccess(id) {
                parent.openWin("获取秘钥","<%=KSCMS.GetInstallDir()+MyCache.GetCacheConfig(4)%>/System/KS.AccessTokens.Aspx?action=get&id=" + id, true);
            }
            function ResetAccess() {
                //重设
                $.ajax({
                    url: "KS.AccessTokens.aspx?action=reset&id=<%=id%>&rnd=" + Math.random(),
                    context: document.body,
                    type: "get",
                    success: function (data) {
                        location.reload();
                    }
                });

                return false;
            }
        </script>
        <asp:Panel ID="ListPannel" runat="server" Width="100%">
            <div class="myTitle"><asp:LinkButton ID="addApi" runat="server" OnClick="addApi_Click" CssClass="fr button button_on">添加API密钥</asp:LinkButton>API密钥管理 </div>
            <asp:GridView CssClass="CTable" ID="AccessTokensList" runat="server" AutoGenerateColumns="False" EmptyDataText="还没有添加API密钥!"
                GridLines="None"
                Width="99%">
                <EmptyDataRowStyle CssClass="emptycss" />
                <Columns>
                    <asp:TemplateField HeaderText="序号" InsertVisible="False">
                        <ItemStyle HorizontalAlign="Center" Width="60px" />
                        <ItemTemplate>
                            <%#Container.DataItemIndex+1%>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="名称">
                        <ItemStyle HorizontalAlign="Left" />
                        <ItemTemplate>
                            <%#Eval("title").ToString() %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="授权范围">
                        <ItemStyle HorizontalAlign="Left" />
                        <ItemTemplate>
                            <%#Eval("Limits").ToString() %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="操作">
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <a href="javascript:GetAccess(<%#Eval("id") %>)" class="greenFont">获取秘钥</a>&nbsp;&nbsp;
                            <a href="KS.AccessTokens.aspx?action=modify&id=<%#Eval("id") %>" class="greenFont">修改</a>&nbsp;&nbsp;
                            <a href="KS.AccessTokens.aspx?action=delete&id=<%#Eval("id") %>" class="greenFont">删除</a>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <HeaderStyle CssClass="CTitle" />
            </asp:GridView>
            <KS:Page ID="Page1" runat="server" />
        </asp:Panel>
        <asp:Panel ID="AddPannel" runat="server" Width="100%" Visible="false">
            <!--<KS:TopNav ID="TopNav2" runat="server" Text="修改API密钥" />-->
			<div class="myTitle">修改API密钥</div>
            <table width="99%" style="margin: 0 auto;" border="0" cellpadding="0" cellspacing="0" class="CTable no-borderTable">

                <tr>
                    <td class="lefttd" height="30" align="right" style="width: 198px"><b>名称：</b></td>
                    <td class="righttd">&nbsp;<asp:TextBox CssClass="textbox" ID="TxtTitle" Width="300px" runat="server"></asp:TextBox>
                        <span style="color: #ff0000">*</span>如课程等
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtTitle"
                    ErrorMessage="请输入名称!"></asp:RequiredFieldValidator></td>
                </tr>
                <tr>
                    <td align="right" class="lefttd" height="30" style="width: 198px">
                        <strong>授权范围：</strong></td>
                    <td class="righttd">
                        <asp:CheckBoxList ID="Limits" runat="server" RepeatLayout="Flow"  RepeatDirection="Vertical">
                            <asp:ListItem Value="Course">Course(课程等)</asp:ListItem>
                            <asp:ListItem Value="ClassRoom">ClassRoom(班级)</asp:ListItem>
                             <asp:ListItem Value="Groups">Groups(小组)</asp:ListItem>
                            <asp:ListItem Value="Model">Model(文章,图片,下载等)</asp:ListItem>
                            <asp:ListItem Value="User">User(登陆,注册,修改用户信息会员中心等)</asp:ListItem>
                            <asp:ListItem Value="Pay">Pay(支付)</asp:ListItem>
                            <asp:ListItem Value="Other">Other(首页轮播图等)</asp:ListItem>
                             <asp:ListItem Value="School">School(机构中心等)</asp:ListItem>
                            <asp:ListItem Value="Paper">Paper(考试等)</asp:ListItem>
                            <asp:ListItem Value="Teacher">Teacher(教师等)</asp:ListItem>

                            <asp:ListItem Value="app">app权限</asp:ListItem>
                        </asp:CheckBoxList>
                        <br />
                        <span class="tips">Tips:授权范围定义API密钥可访问的API地址，API密钥能够访问的API地址将被限制在授权范围内 </span>
                    </td>
                </tr>
            </table>
            <KS:Foot ID="Foot2" runat="server" OnSubmit="Foot2_Submit" />
        </asp:Panel>
        <asp:Panel ID="GetPanel" runat="server" Width="100%" Visible="false">
            
            <table width="99%" style="margin: 0 auto;" border="0" cellpadding="0" cellspacing="0" class="CTable no-borderTable">
                <tr>
                    <td class="lefttd" height="30" align="right" style="width: 198px"><b>设置名称：</b></td>
                    <td class="righttd">
                        <asp:Label ID="title" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td align="right" class="lefttd" height="30" style="width: 198px">
                        <strong>API密钥：</strong></td>
                    <td class="righttd">
                        <asp:Label ID="AccessToken" runat="server" />
                        <asp:Button ID="BtnReset" runat="server" Text="重设" class="mainButton button" OnClientClick="ResetAccess()" />
                    </td>
                </tr>
                <tr>
                    <td align="right" class="lefttd" height="30" style="width: 198px">
                        <strong>添加时间：</strong></td>
                    <td class="righttd">
                        <asp:Label ID="addDate" runat="server" />
                    </td>
                </tr>
            </table>
            <div class="message">API密钥属于敏感信息，请妥善保管不要泄露；如果怀疑信息泄露，请重设密钥。</div>
            <div class="pop-button">
                <input type="button" value="关闭" accesskey="C" onclick="top.isreload = false; parent.box.close()" class="button" onmouseover="this.className='button_on';" onmouseout="this.className='button';" />
            </div>
        </asp:Panel>
    </div>

</asp:Content>

