10bd4f4c5afff79cab069f66a35c94f0010380f6
[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>Display</th>
54           <th>XML code</th>
55                   <% if(priv=='A') { %>
56           <th>Delete</th>
57                   <% } %>
58         </tr>
59       </thead>
60       <tbody>
61       <% var i=0; rows.forEach( function(row) { %> 
62         <tr>
63             <td><%= row.module %></td>
64             <td><%= row.rpc %></td>
65             <td><%= row.version %></td>
66             <td><%= row.mode %></td>
67             <td><%= row.active %></td>
68                         <% if ( priv == 'A' ) { 
69                 if (row.active == "Y") { %>
70                         <td><button type="button" class="btn btn-default btn-xs" onclick="toggleState('deactivate','<%= row.module %>','<%= row.rpc %>','<%= row.version %>','<%= row.mode %>');" >Deactivate</button> </td>
71                                 <% } else { %>
72                         <td><button type="button" class="btn btn-default btn-xs" onclick="toggleState('activate','<%= row.module %>','<%= row.rpc %>','<%= row.version %>','<%= row.mode %>');" >Activate</button></td>
73                                 <% } %>
74                         <% } %>
75             <td>
76                                 <button type="button" class="btn btn-default btn-xs"
77                 onclick='location.assign("/sla/printAsGv?module=<%= row.module %>&rpc=<%= row.rpc %>&version=<%= row.version %>&mode=<%= row.mode %>");'>Display</button>
78                         </td>
79                         <td>
80                                 <button type="button" class="btn btn-default btn-xs"
81                 onclick='location.assign("/sla/printAsXml?module=<%= row.module %>&rpc=<%= row.rpc %>&version=<%= row.version %>&mode=<%= row.mode %>");'>XML code</button>
82             </td>
83                         <% if ( priv == 'A' ) { %>
84             <td>
85                                 <button type="button" class="btn btn-default btn-xs"
86                                 onclick="deleteGraph('<%=row.module %>',
87                                                 '<%=row.rpc %>', '<%=row.version %>','<%=row.mode %>');">Delete</button>
88                         </td>
89                         <% } %>
90         </tr>
91     <% i++; }); %>
92       </tbody>
93     </table>
94
95         <% if(priv == 'A') { %>
96         <div class="actions" style="padding:0px 25px;">
97         <form method="POST" action="/sla/upload" enctype="multipart/form-data">
98                 <div class="form-group">
99                 <label for="dest">File input</label>
100                 <input name="filename" type="file" id="dest">
101                 <p class="help-block">Choose a file to upload.</p>
102                 </div>
103                 <%
104         if ( priv == 'A' )
105         {
106         %>
107                 <button type="button" class="btn btn-default"
108                     onclick="uploadFile(this.form);">Upload File</button>
109         <% } else { %>
110             <button type="button" class="btn btn-default disabled"
111                     onclick="uploadFile(this.form);">Upload File</button>
112         <% } %>
113         </form>
114         </div>
115         <% } %>
116 </div>
117
118
119
120 <footer>
121     <% include ../partials/footer %>
122 </footer>
123
124 <script type="text/javascript">
125 function deleteGraph(_module,rpc,version,mode) {
126
127         bootbox.confirm({
128         message: "Are you sure you want to delete Directed Graph [" + _module + "][" + rpc + "][" + version + "] ?",
129         callback: function(result) {
130             if ( result )
131             {
132                         location.assign("/sla/deleteDG?module=" + _module 
133                                         + "&rpc=" + rpc + "&version=" + version + "&mode=" + mode );
134             }
135             return;
136         },
137         buttons: {
138             cancel: {
139                 label: "Cancel"
140             },
141             confirm: {
142                 label: "Yes"
143             }
144         }
145     });
146 }
147 function toggleState(laction,_module,rpc,version,mode)
148 {
149         var myprompt = '';
150         var myaction = '';
151         if(laction == 'activate'){
152                 myprompt = "Are you sure you want to Activate Directed Graph [" + _module + "] ?";
153         myaction = "/sla/activate"
154                         + "?module=" + _module
155                         + "&rpc=" + rpc 
156                         + "&version=" + version
157                         + "&mode=" + mode;
158         } else {
159                 myprompt = "Are you sure you want to Deactivate Directed Graph [" + _module + "] ?";
160                 myaction = "/sla/deactivate"
161                         + "?module=" + _module
162                         + "&rpc=" + rpc 
163                         + "&version=" + version
164                         + "&mode=" + mode;
165         }
166                 
167         bootbox.confirm({
168         message: myprompt,
169         callback: function(result) {
170             if ( result )
171             {
172                 location.assign(myaction);
173             }
174             return;
175         },
176         buttons: {
177             cancel: {
178                 label: "Cancel"
179             },
180             confirm: {
181                 label: "Yes"
182             }
183         }
184     });
185 }
186 </script>
187 </body>
188 </html>
189