api_form.twig (9402B)
1 {{ header }}{{ column_left }} 2 <div id="content"> 3 <div class="page-header"> 4 <div class="container-fluid"> 5 <div class="pull-right"> 6 <button type="submit" form="form-api" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i class="fa fa-save"></i></button> 7 <a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a></div> 8 <h1>{{ heading_title }}</h1> 9 <ul class="breadcrumb"> 10 {% for breadcrumb in breadcrumbs %} 11 <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li> 12 {% endfor %} 13 </ul> 14 </div> 15 </div> 16 <div class="container-fluid">{% if error_warning %} 17 <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }} 18 <button type="button" class="close" data-dismiss="alert">×</button> 19 </div> 20 {% endif %} 21 <div class="panel panel-default"> 22 <div class="panel-heading"> 23 <h3 class="panel-title"><i class="fa fa-pencil"></i> {{ text_form }}</h3> 24 </div> 25 <div class="panel-body"> 26 <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-api" class="form-horizontal"> 27 <ul class="nav nav-tabs"> 28 <li class="active"><a href="#tab-general" data-toggle="tab">{{ tab_general }}</a></li> 29 <li><a href="#tab-ip" data-toggle="tab">{{ tab_ip }}</a></li> 30 <li><a href="#tab-session" data-toggle="tab">{{ tab_session }}</a></li> 31 </ul> 32 <div class="tab-content"> 33 <div class="tab-pane active" id="tab-general"> 34 <div class="form-group required"> 35 <label class="col-sm-2 control-label" for="input-username">{{ entry_username }}</label> 36 <div class="col-sm-10"> 37 <input type="text" name="username" value="{{ username }}" placeholder="{{ entry_username }}" id="input-username" class="form-control" /> 38 {% if error_username %} 39 <div class="text-danger">{{ error_username }}</div> 40 {% endif %} </div> 41 </div> 42 <div class="form-group required"> 43 <label class="col-sm-2 control-label" for="input-key">{{ entry_key }}</label> 44 <div class="col-sm-10"> 45 <textarea name="key" placeholder="{{ entry_key }}" rows="5" id="input-key" class="form-control">{{ key }}</textarea> 46 <br /> 47 <button type="button" id="button-generate" class="btn btn-primary"><i class="fa fa-refresh"></i> {{ button_generate }}</button> 48 {% if error_key %} 49 <div class="text-danger">{{ error_key }}</div> 50 {% endif %} </div> 51 </div> 52 <div class="form-group"> 53 <label class="col-sm-2 control-label" for="input-status">{{ entry_status }}</label> 54 <div class="col-sm-10"> 55 <select name="status" id="input-status" class="form-control"> 56 57 {% if status %} 58 59 <option value="0">{{ text_disabled }}</option> 60 <option value="1" selected="selected">{{ text_enabled }}</option> 61 62 {% else %} 63 64 <option value="0" selected="selected">{{ text_disabled }}</option> 65 <option value="1">{{ text_enabled }}</option> 66 67 {% endif %} 68 69 </select> 70 </div> 71 </div> 72 </div> 73 <div class="tab-pane" id="tab-ip"> 74 <div class="alert alert-info"><i class="fa fa-info-circle"></i> {{ text_ip }}</div> 75 <div class="table-responsive"> 76 <table id="ip" class="table table-striped table-bordered table-hover"> 77 <thead> 78 <tr> 79 <td class="text-left">{{ entry_ip }}</td> 80 <td class="text-left"></td> 81 </tr> 82 </thead> 83 <tbody> 84 85 {% set ip_row = 0 %} 86 {% for api_ip in api_ips %} 87 <tr id="ip-row{{ ip_row }}"> 88 <td class="text-left"><input type="text" name="api_ip[]" value="{{ api_ip.ip }}" placeholder="{{ entry_ip }}" class="form-control" /></td> 89 <td class="text-left"><button type="button" onclick="$('#ip-row{{ ip_row }}').remove()" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td> 90 </tr> 91 {% set ip_row = ip_row + 1 %} 92 {% endfor %} 93 </tbody> 94 95 <tfoot> 96 <tr> 97 <td></td> 98 <td class="text-left"><button type="button" onclick="addIp()" data-toggle="tooltip" title="{{ button_ip_add }}" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></td> 99 </tr> 100 </tfoot> 101 </table> 102 </div> 103 </div> 104 <div class="tab-pane" id="tab-session"> 105 <div class="table-responsive"> 106 <table id="session" class="table table-striped table-bordered table-hover"> 107 <thead> 108 <tr> 109 <td class="text-left">{{ column_token }}</td> 110 <td class="text-left">{{ column_ip }}</td> 111 <td class="text-left">{{ column_date_added }}</td> 112 <td class="text-left">{{ column_date_modified }}</td> 113 <td class="text-right">{{ column_action }}</td> 114 </tr> 115 </thead> 116 <tbody> 117 118 {% if api_sessions %} 119 {% for api_session in api_sessions %} 120 <tr> 121 <td class="text-left">{{ api_session.session_id }}</td> 122 <td class="text-left">{{ api_session.ip }}</td> 123 <td class="text-left">{{ api_session.date_added }}</td> 124 <td class="text-left">{{ api_session.date_modified }}</td> 125 <td class="text-right"><button type="button" value="{{ api_session.api_session_id }}" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td> 126 </tr> 127 {% endfor %} 128 {% else %} 129 <tr> 130 <td class="text-center" colspan="5">{{ text_no_results }}</td> 131 </tr> 132 {% endif %} 133 </tbody> 134 135 </table> 136 </div> 137 </div> 138 </div> 139 </form> 140 </div> 141 </div> 142 </div> 143 <script type="text/javascript"><!-- 144 $('#button-generate').on('click', function() { 145 rand = ''; 146 147 string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; 148 149 for (i = 0; i < 256; i++) { 150 rand += string[Math.floor(Math.random() * (string.length - 1))]; 151 } 152 153 $('#input-key').val(rand); 154 }); 155 //--></script> 156 <script type="text/javascript"><!-- 157 var ip_row = {{ ip_row }}; 158 159 function addIp() { 160 html = '<tr id="ip-row' + ip_row + '">'; 161 html += ' <td class="text-right"><input type="text" name="api_ip[]" value="" placeholder="{{ entry_ip }}" class="form-control" /></td>'; 162 html += ' <td class="text-left"><button type="button" onclick="$(\'#ip-row' + ip_row + '\').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>'; 163 html += '</tr>'; 164 165 $('#ip tbody').append(html); 166 167 ip_row++; 168 } 169 //--></script> 170 <script type="text/javascript"><!-- 171 $('#session button').on('click', function(e) { 172 e.preventDefault(); 173 174 var node = this; 175 176 $.ajax({ 177 url: 'index.php?route=user/api/deletesession&user_token={{ user_token }}&api_session_id=' + $(node).val(), 178 type: 'post', 179 dataType: 'json', 180 beforeSend: function() { 181 $(node).button('loading'); 182 }, 183 complete: function() { 184 $(node).button('reset'); 185 }, 186 success: function(json) { 187 $('.alert-dismissible').remove(); 188 189 if (json['error']) { 190 $('#tab-session').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 191 } 192 193 if (json['success']) { 194 $('#tab-session').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 195 196 $(node).parent().parent().remove(); 197 } 198 }, 199 error: function(xhr, ajaxOptions, thrownError) { 200 alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); 201 } 202 }); 203 }); 204 //--></script> 205 </div> 206 {{ footer }}