Added new modules to help prevent Cross Site Request Forgery
[sdnc/oam.git] / admportal / views / sla / list.ejs
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4   <meta charset="UTF-8" />
5   <meta http-equiv="X-UA-Compatible" content="IE=edge">
6   <% include ../partials/head %>
7   <% include ../partials/header %>
8   <script type="text/javascript" src="/javascripts/admportal.js" async></script>
9   <title>SDN-C AdminPortal</title>
10 <script class="init">
11     $(document).ready(function() {
12     $('#sla').DataTable( {
13         "order": [[ 0, "asc" ]]
14     } );
15 } );
16 </script>
17
18 </head>
19 <body>
20
21 <div class="well well-sm">
22 <h3>Service Logic Administration</h3>
23 </div>
24
25 <% if ( typeof result != 'undefined' ) {
26                 if (result.code.length > 0) { 
27                         if ( result.code == 'success' ) { %>
28                                 <div class='alert alert-success' role='alert'><%=result.msg %></div>
29                         <% } else { %>
30                                 <div class='alert alert-danger' role='danger'><%=result.msg %></div>
31                         <% } %>
32                 <% } %>
33 <% } %>
34
35 <% if( typeof privilege != 'undefined'){
36     var priv = privilege.privilege;
37 } else { 
38     var priv = 'A';
39 } %>
40
41 <div class="container-fluid">
42         <table id="sla" class="table table-hover table-condensed">
43         <thead>
44         <tr>
45                 <th>Module</th>
46                 <th>RPC</th>
47                 <th>Version</th>
48                 <th>Mode</th>
49                 <th>Active</th>
50                 <% if(priv == 'A') { %>
51                 <th>Activate/Deactive</th>
52                 <% } %>
53                 <th>XML code</th>
54                 <% if(priv=='A') { %>
55                 <th>Delete</th>
56                 <% } %>
57         </tr>
58         </thead>
59         <tbody>
60         <% var i=0; rows.forEach( function(row) { %> 
61         <tr>
62                 <td><%= row.module %></td>
63                 <td><%= row.rpc %></td>
64                 <td><%= row.version %></td>
65                 <td><%= row.mode %></td>
66                 <td><%= row.active %></td>
67                 <% if ( priv == 'A' ) { 
68                         if (row.active == "Y") { %>
69                 <td><button type="button" class="btn btn-default btn-xs" onclick="toggleState('deactivate','<%= row.module %>','<%= row.rpc %>','<%= row.version %>','<%= row.mode %>');" >Deactivate</button> </td>
70                 <% } else { %>
71                 <td><button type="button" class="btn btn-default btn-xs" onclick="toggleState('activate','<%= row.module %>','<%= row.rpc %>','<%= row.version %>','<%= row.mode %>');" >Activate</button></td>
72                 <% } %>
73                 <% } %>
74                 <td>
75                         <button type="button" class="btn btn-default btn-xs"
76                                 onclick='location.assign("/sla/printAsXml?module=<%= row.module %>&rpc=<%= row.rpc %>&version=<%= row.version %>&mode=<%= row.mode %>");'>XML code</button>
77                 </td>
78                 <% if ( priv == 'A' ) { %>
79                 <td>
80                         <button type="button" class="btn btn-default btn-xs"
81                                 onclick="deleteGraph('<%=row.module %>',
82                                 '<%=row.rpc %>', '<%=row.version %>','<%=row.mode %>');">Delete</button>
83                 </td>
84                 <% } %>
85         </tr>
86         <% i++; }); %>
87         </tbody>
88         </table>
89
90         <% if(priv == 'A') { %>
91         <div class="actions" style="padding:0px 25px;">
92         <form method="POST" action="/sla/upload" enctype="multipart/form-data">
93                 <div class="form-group">
94                         <label for="dest">File input</label>
95                         <input name="filename" type="file" id="dest" />
96                         <input type="hidden" name="_csrf" value="<%= privilege.csrfToken %>" />
97                         <p class="help-block">Choose a file to upload.</p>
98                 </div>
99                 <% if ( priv == 'A' ) { %>
100                 <button type="button" class="btn btn-default"
101                         onclick="uploadFile(this.form);">Upload File</button>
102                 <% } else { %>
103                 <button type="button" class="btn btn-default disabled"
104                         onclick="uploadFile(this.form);">Upload File</button>
105                 <% } %>
106         </form>
107         </div>
108         <% } %>
109
110 </div>
111
112
113
114 <footer>
115     <% include ../partials/footer %>
116 </footer>
117
118 <script type="text/javascript">
119 function deleteGraph(_module,rpc,version,mode) {
120
121         bootbox.confirm({
122         message: "Are you sure you want to delete Directed Graph [" + _module + "][" + rpc + "][" + version + "] ?",
123         callback: function(result) {
124             if ( result )
125             {
126                         location.assign("/sla/deleteDG?module=" + _module 
127                                         + "&rpc=" + rpc + "&version=" + version + "&mode=" + mode );
128             }
129             return;
130         },
131         buttons: {
132             cancel: {
133                 label: "Cancel"
134             },
135             confirm: {
136                 label: "Yes"
137             }
138         }
139     });
140 }
141 function toggleState(laction,_module,rpc,version,mode)
142 {
143         var myprompt = '';
144         var myaction = '';
145         if(laction == 'activate'){
146                 myprompt = "Are you sure you want to Activate Directed Graph [" + _module + "] ?";
147         myaction = "/sla/activate"
148                         + "?module=" + _module
149                         + "&rpc=" + rpc 
150                         + "&version=" + version
151                         + "&mode=" + mode;
152         } else {
153                 myprompt = "Are you sure you want to Deactivate Directed Graph [" + _module + "] ?";
154                 myaction = "/sla/deactivate"
155                         + "?module=" + _module
156                         + "&rpc=" + rpc 
157                         + "&version=" + version
158                         + "&mode=" + mode;
159         }
160                 
161         bootbox.confirm({
162         message: myprompt,
163         callback: function(result) {
164             if ( result )
165             {
166                 location.assign(myaction);
167             }
168             return;
169         },
170         buttons: {
171             cancel: {
172                 label: "Cancel"
173             },
174             confirm: {
175                 label: "Yes"
176             }
177         }
178     });
179 }
180 </script>
181 </body>
182 </html>
183