/
preferences.blade.php
235 lines (224 loc) · 10.6 KB
/
preferences.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
@extends('layouts.librenmsv1')
@section('title', __('Preferences'))
@section('content')
<div class="container">
<row>
<legend>@lang('User Preferences')</legend>
</row>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
@if($can_change_password)
<div class="panel panel-default panel-condensed">
<div class="panel-heading">@lang('Change Password')</div>
<div class="panel-body">
<form method="POST" action="{{ route('users.update', [$user->user_id]) }}" class="form-horizontal" role="form">
<input type="hidden" name="_method" value="PATCH">
<div class="form-group">
<label for="old_password" class="col-sm-4 control-label">@lang('Current Password')</label>
<div class="col-sm-4">
<input type="password" name="old_password" autocomplete="off" class="form-control input-sm">
</div>
</div>
<div class="form-group">
<label for="new_password" class="col-sm-4 control-label">@lang('New Password')</label>
<div class="col-sm-4">
<input type="password" name="new_password" autocomplete="off" class="form-control input-sm">
</div>
</div>
<div class="form-group">
<label for="new_password_confirmation" class="col-sm-4 control-label">@lang('Verify New Password')</label>
<div class="col-sm-4">
<input type="password" name="new_password_confirmation" autocomplete="off" class="form-control input-sm">
</div>
</div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-3">
<button type="submit" class="btn btn-default">@lang('Change Password')</button>
</div>
</div>
</form>
</div>
</div>
@endif
<div class="panel panel-default panel-condensed">
<div class="panel-heading">@lang('Preferences')</div>
<div class="panel-body">
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="dashboard" class="col-sm-4 control-label">@lang('Dashboard')</label>
<div class="col-sm-4">
<select class="form-control ajax-select" name="dashboard" data-pref="dashboard" data-previous="{{ $default_dashboard }}">
@foreach($dashboards as $dash)
<option value="{{ $dash->dashboard_id }}" @if($dash->dashboard_id == $default_dashboard) selected @endif>{{ $dash->user ? $dash->user->username : __('<deleted>') }}:{{ $dash->dashboard_name }}</option>
@endforeach
</select>
</div>
</div>
<div class="form-group">
<label for="locale" class="col-sm-4 control-label">@lang('Language')</label>
<div class="col-sm-4">
<select class="form-control ajax-select" name="locale" data-pref="locale" data-previous="{{ $locale }}">
@foreach($locales as $lang => $descr)
<option value="{{ $lang }}" @if($lang == $locale) selected @endif>{{ $descr }}</option>
@endforeach
</select>
</div>
<div class="col-sm-4">
<small>* @lang('Translation not fully supported')</small>
</div>
</div>
<div class="form-group">
<label for="notetodevice" class="col-sm-4 control-label">@lang('Add schedule notes to devices notes')</label>
<div class="col-sm-4">
<input id="notetodevice" type="checkbox" name="notetodevice" @if($note_to_device) checked @endif>
</div>
</div>
</form>
</div>
</div>
@config('twofactor')
<div class="panel panel-default panel-condensed">
<div class="panel-heading">@lang('Two-Factor Authentication')</div>
<div class="panel-body">
@if($twofactor)
<div id="twofactorqrcontainer">
<div id="twofactorqr"></div>
<script>$("#twofactorqr").qrcode({"text": "{{ $twofactor_uri }}"});</script>
<button class="btn btn-default" onclick="$('#twofactorkeycontainer').show(); $('#twofactorqrcontainer').hide();">@lang('Manual')</button>
</div>
<div id="twofactorkeycontainer">
<form id="twofactorkey" class="form-horizontal" role="form">
<div class="form-group">
<label for="twofactorkey" class="col-sm-4 control-label">@lang('Secret Key')</label>
<div class="col-sm-4">
<input type="text" name="twofactorkey" autocomplete="off" disabled class="form-control input-sm" value="{{ $twofactor['key'] }}" />
</div>
</div>
@if($twofactor['counter'] !== false)
<div class="form-group">
<label for="twofactorcounter" class="col-sm-4 control-label">@lang('Counter')</label>
<div class="col-sm-4">
<input type="text" name="twofactorcounter" autocomplete="off" disabled class="form-control input-sm" value="{{ $twofactor['counter'] }}" />
</div>
</div>
@endif
</form>
<button class="btn btn-default" onclick="$('#twofactorkeycontainer').hide(); $('#twofactorqrcontainer').show();">@lang('QR')</button>
</div>
<br/>
<form method="post" class="form-horizontal" role="form" action="{{ route('2fa.remove') }}">
<button class="btn btn-danger" type="submit">@lang('Disable TwoFactor')</button>
</form>
@else
<form method="post" class="form-horizontal" role="form" action="{{ route('2fa.add') }}">
<div class="form-group">
<label for="twofactortype" class="col-sm-4 control-label">@lang('TwoFactor Type')</label>
<div class="col-sm-4">
<select name="twofactortype" class="select form-control">
<option value="time">@lang('Time Based (TOTP)')</option>
<option value="counter">@lang('Counter Based (HOTP)')</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-3">
<button class="btn btn-default" type="submit" id="twofactor-generate">@lang('Generate TwoFactor Secret Key')</button>
</div>
</div>
</form>
@endif
</div>
</div>
@endconfig
<div class="panel panel-default panel-condensed">
<div class="panel-heading">@lang('Device Permissions')</div>
<div class="panel-body">
@if(auth()->user()->hasGlobalAdmin())
<strong class="blue">@lang('Global Administrative Access')</strong>
@elseif(auth()->user()->hasGlobalRead())
<strong class="green">@lang('Global Viewing Access')</strong>
@else
@forelse($devices as $device)
{!! \LibreNMS\Util\Url::deviceLink($device) !!} <br />
@empty
<strong class="red">@lang('No access!')</strong>
@endforelse
@endif
</div>
</div>
</div>
@endsection
@section('javascript')
<script src="{{ asset('js/jquery.qrcode.min.js') }}"></script>
@endsection
@section('scripts')
<script>
$("[name='notetodevice']")
.bootstrapSwitch('offColor', 'danger')
.on('switchChange.bootstrapSwitch', function (e, state) {
var $this = $(this);
$.ajax({
url: '{{ route('preferences.store') }}',
dataType: 'json',
type: 'POST',
data: {
pref: 'add_schedule_note_to_device',
value: state ? 1 : 0
},
success: function () {
$this.closest('.form-group').addClass('has-success');
setTimeout(function () {
$this.closest('.form-group').removeClass('has-success');
}, 2000);
},
error: function () {
$this.bootstrapSwitch('toggleState', true);
$this.closest('.form-group').addClass('has-error');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-error');
}, 2000);
}
});
});
$('.ajax-select').change(function () {
var $this = $(this);
var value = $this.val();
console.log($this.data('pref'));
$.ajax({
url: '{{ route('preferences.store') }}',
dataType: 'json',
type: 'POST',
data: {
pref: $this.data('pref'),
value: value
},
success: function () {
$this.data('previous', value);
$this.closest('.form-group').addClass('has-success');
setTimeout(function () {
$this.closest('.form-group').removeClass('has-success');
}, 2000);
},
error: function () {
$this.val($this.data('previous'));
$this.closest('.form-group').addClass('has-error');
setTimeout(function(){
$this.closest('.form-group').removeClass('has-error');
}, 2000);
}
});
});
</script>
@endsection
@section('css')
<style>
#twofactorkeycontainer { display: none; }
</style>
@endsection