1111 <ul class =" nav" >
1212 @if (isset ($page_actions ) && $page_actions -> contains (' export' ) )
1313 <li >
14- <span data-bs-toggle =" modal" data-bs-target =" #entry_export -modal" >
14+ <span id = " entry-export " data-bs-toggle =" modal" data-bs-target =" #page -modal" >
1515 <button class =" btn btn-outline-dark p-1 m-1" data-bs-toggle =" tooltip" data-bs-placement =" bottom" title =" @lang (' Export' )" ><i class =" fas fa-fw fa-download fs-5" ></i ></button >
1616 </span >
1717 </li >
114114 </div >
115115 </div >
116116
117- <!-- EXPORT -->
118- <div class =" modal fade" id =" entry_export-modal" tabindex =" -1" aria-labelledby =" entry_export-label" aria-hidden =" true" >
119- <div class =" modal-dialog modal-lg modal-fullscreen-lg-down" >
120- <div class =" modal-content" >
121- <div class =" modal-header" >
122- <h1 class =" modal-title fs-5" id =" entry_export-label" >LDIF for {{ $dn } } </h1 >
123- <button type =" button" class =" btn-close" data-bs-dismiss =" modal" aria-label =" Close" ></button >
124- </div >
125-
126- <div class =" modal-body" >
127- <div id =" entry_export" ><div class =" fa-3x" ><i class =" fas fa-spinner fa-pulse fa-sm" ></i ></div ></div >
128- </div >
129-
130- <div class =" modal-footer" >
131- <button type =" button" class =" btn btn-sm btn-secondary" data-bs-dismiss =" modal" >Close</button >
132- <button type =" button" class =" btn btn-sm btn-primary" id =" entry_export-download" >Download</button >
133- </div >
134- </div >
135- </div >
136- </div >
137-
138117 @if ($up = $o -> getObject (' userpassword' ) )
139118 <!-- CHECK USERPASSWORD -->
140119 <div class =" modal fade" id =" userpassword_check-modal" tabindex =" -1" aria-labelledby =" userpassword_check-label" aria-hidden =" true" >
177156 var dn = ' {{ $o -> getDNSecure () } }' ;
178157 var oc = {!! $o -> getObject (' objectclass' )-> values ! !} ;
179158
180- function download (filename ,text ) {
181- var element = document .createElement (' a' );
182-
183- element .setAttribute (' href' , ' data:text/plain;charset=utf-8,' + encodeURIComponent (text));
184- element .setAttribute (' download' , filename);
185- element .style .display = ' none' ;
186- document .body .appendChild (element);
187-
188- element .click ();
189- document .body .removeChild (element);
190- }
191-
192159 function editmode () {
193160 $ (' #dn-edit input[name="dn"]' ).val (dn);
194161
@@ -231,7 +198,7 @@ function editmode() {
231198 $ (' #newattrs' ).append (data);
232199 },
233200 error : function (e ) {
234- if (e .status != 412 )
201+ if (e .status !== 412 )
235202 alert (' That didnt work? Please try again....' );
236203 },
237204 url: ' {{ url (' entry/attr/add' ) } } /' + item .target .value ,
@@ -249,13 +216,6 @@ function editmode() {
249216 $ (' #newattr-select' ).remove ();
250217 });
251218
252- $ (' #entry_export-download' ).on (' click' ,function (item ) {
253- item .preventDefault ();
254-
255- let ldif = $ (' #entry_export' ).find (' pre:first' ); // update this selector in your local version
256- download (' ldap-export.ldif' ,ldif .html ());
257- });
258-
259219 $ (' #page-modal' ).on (' shown.bs.modal' ,function (item ) {
260220 var that = $ (this ).find (' .modal-content' );
261221
@@ -273,7 +233,44 @@ function editmode() {
273233 that .empty ().html (data);
274234 },
275235 error : function (e ) {
276- if (e .status != 412 )
236+ if (e .status !== 412 )
237+ alert (' That didnt work? Please try again....' );
238+ },
239+ })
240+ break ;
241+
242+ case ' entry-export' :
243+ $ .ajax ({
244+ method: ' GET' ,
245+ url: ' {{ url (' modal/export' ) } } /' + dn,
246+ dataType: ' html' ,
247+ cache: false ,
248+ beforeSend : function () {
249+ that .empty ().append (' <span class="p-3"><i class="fas fa-3x fa-spinner fa-pulse"></i></span>' );
250+ },
251+ success : function (data ) {
252+ that .empty ().html (data);
253+
254+ that = $ (' #entry_export' );
255+
256+ $ .ajax ({
257+ type: ' GET' ,
258+ url: ' {{ url (' entry/export' ) } } /' + dn,
259+ cache: false ,
260+ beforeSend : function () {
261+ that .empty ().append (' <span class="p-3"><i class="fas fa-3x fa-spinner fa-pulse"></i></span>' );
262+ },
263+ success : function (data ) {
264+ that .empty ().append (data);
265+ },
266+ error : function (e ) {
267+ if (e .status !== 412 )
268+ alert (' That didnt work? Please try again....' );
269+ },
270+ })
271+ },
272+ error : function (e ) {
273+ if (e .status !== 412 )
277274 alert (' That didnt work? Please try again....' );
278275 },
279276 })
@@ -284,21 +281,6 @@ function editmode() {
284281 }
285282 });
286283
287- $ (' #entry_export-modal' ).on (' shown.bs.modal' ,function () {
288- $ .ajax ({
289- type: ' GET' ,
290- success : function (data ) {
291- $ (' #entry_export' ).empty ().append (data);
292- },
293- error : function (e ) {
294- if (e .status != 412 )
295- alert (' That didnt work? Please try again....' );
296- },
297- url: ' {{ url (' entry/export' ) } } /' + dn,
298- cache: false
299- })
300- })
301-
302284 @if ($up )
303285 $ (' button[id=userpassword_check-submit]' ).on (' click' ,function (item ) {
304286 var that = $ (this );
@@ -342,7 +324,7 @@ function editmode() {
342324 })
343325 },
344326 error : function (e ) {
345- if (e .status != 412 )
327+ if (e .status !== 412 )
346328 alert (' That didnt work? Please try again....' );
347329 },
348330 url: ' {{ url (' entry/password/check' ) } }' ,
0 commit comments