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>
11 $(document).ready(function() {
12 $('#threshold_alarms').DataTable( {
13 "order": [[ 0, "asc" ]]
21 <div class="well well-sm">
22 <h3>Threshold Alarms</h3>
25 <% if ( typeof result != 'undefined' ) {
26 if (result.code.length > 0) {
27 if ( result.code == 'success' ) { %>
28 <div class='alert alert-success' role='alert'>
30 for ( x in result.msg ){ %>
31 <div><%= result.msg[x] %></div>
35 <div class='alert alert-danger' role='danger'>
37 for ( x in result.msg ){ %>
38 <div><%= result.msg[x] %></div>
45 <% if( typeof privilege != 'undefined'){
46 var priv = privilege.privilege;
52 <div class="container-fluid">
54 <% if (priv == 'A'){ %>
55 <div class="actions" style="padding:15px 0px;">
56 <button class="btn btn-primary" data-toggle="modal" data-target="#add_threshold_alarm">
62 <table id="threshold_alarms" class="table table-hover table-condensed">
65 <th>*Resource Threshold ID</th>
66 <th>*Resource Rule ID</th>
67 <th>Threshold Expression</th>
68 <th>Threshold Message</th>
69 <% if(priv == 'A'){ %>
75 <% rows.forEach( function(row) { %>
77 <td><%= row.resource_threshold_id %></td>
78 <td><%= row.resource_rule_id %></td>
79 <td><%= row.threshold_expression %></td>
80 <td><%= row.threshold_message %></td>
81 <% if(priv == 'A') { %>
83 <button type="button" class="btn btn-default btn-xs"
84 onclick="updateThresholdAlarm('<%= row.resource_threshold_id %>','<%=row.resource_rule_id %>','<%= row.threshold_expression %>','<%= row.threshold_message %>');">Update</button>
85 <button type="button" class="btn btn-default btn-xs"
86 onclick="deleteThresholdAlarm('<%= row.resource_threshold_id %>');">Delete</button>
97 <% include ../partials/threshold_alarm %>
99 <% include ../partials/footer %>
102 <script type="text/javascript">
103 function submitThresholdAlarm(form)
105 var resource_rule_id = '';
106 var threshold_expression = '';
107 var threshold_message = '';
110 if ( form.name == 'addForm' )
112 resource_rule_id = form.nf_resource_rule_id;
113 threshold_expression = form.nf_threshold_expression;
114 threshold_message = form.nf_threshold_message;
118 resource_rule_id = form.uf_resource_rule_id;
119 threshold_expression = form.uf_threshold_expression;
120 threshold_message = form.uf_threshold_message;
122 if ( (resource_rule_id.value == null) || (resource_rule_id.value == "") || isblank(resource_rule_id.value) )
124 errorMsg += 'Resource Rule ID is required.\n';
126 if ( (threshold_expression.value == null) || (threshold_expression.value == "") || isblank(threshold_expression.value) )
128 errorMsg += 'Threshold Expression is required.\n';
130 if ( (threshold_message.value == null) || (threshold_message.value == "") || isblank(threshold_message.value) )
132 errorMsg += 'Threshold Message is required.\n';
134 if( errorMsg.length > 0 ) {
139 if ( !isDigit(resource_rule_id.value) )
141 alert('Resource Rule ID must be a number.');
148 function updateThresholdAlarm(resource_threshold_id,resource_rule_id,threshold_expression,threshold_message) {
150 document.getElementById('uf_resource_threshold_id').value=resource_threshold_id;
151 document.getElementById('uf_resource_rule_id').value=resource_rule_id;
152 document.getElementById('uf_threshold_expression').value=threshold_expression;
153 document.getElementById('uf_threshold_message').value=threshold_message;
155 document.getElementById('uf_key_resource_threshold_id').value=resource_threshold_id;
157 $('#update_threshold_alarm').modal('show');
160 function deleteThresholdAlarm(resource_threshold_id) {
163 message: "Are you sure you want to delete Threshold Alarm [" + resource_threshold_id + "]",
164 callback: function(result) {
167 location.assign("/resalloc/deleteThresholdAlarm?resource_threshold_id=" + resource_threshold_id);