-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
116 additions
and
191 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,88 @@ | ||
// SPDX-FileCopyrightText: Pondersource <[email protected]> | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
(function () { | ||
function renderHTML(enabled) { | ||
return ` | ||
<div style="text-align:center; word-wrap:break-word;"> | ||
<style> | ||
.switch { | ||
position: relative; | ||
display: inline; | ||
} | ||
.switch input { | ||
opacity: 0; | ||
width: 0; | ||
height: 0; | ||
} | ||
.slider { | ||
position: absolute; | ||
cursor: pointer; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
width: 30px; | ||
height: 15px; | ||
background-color: #ccc; | ||
-webkit-transition: .4s; | ||
transition: .4s; | ||
margin-top: auto; | ||
} | ||
.slider:before { | ||
position: absolute; | ||
content: ""; | ||
height: 9px; | ||
width: 9px; | ||
left: 3px; | ||
bottom: 3px; | ||
background-color: white; | ||
-webkit-transition: .4s; | ||
transition: .4s; | ||
} | ||
input:checked + .slider { | ||
background-color: #2196F3; | ||
} | ||
input:focus + .slider { | ||
box-shadow: 0 0 1px #2196F3; | ||
} | ||
input:checked + .slider:before { | ||
-webkit-transform: translateX(15px); | ||
-ms-transform: translateX(15px); | ||
transform: translateX(15px); | ||
} | ||
/* Rounded sliders */ | ||
.slider.round { | ||
border-radius: 15px; | ||
} | ||
.slider.round:before { | ||
border-radius: 50%; | ||
} | ||
</style> | ||
<span id="mfa-current-file-path" hidden></span> | ||
<span style="--icon-size:36px;"> | ||
<label class="switch"> | ||
<input id="checkbox-radio-switch-mfa" type="checkbox" ${enabled ? '' : 'disabled'}> | ||
<span class="slider round"></span> Enforce MFA requirement | ||
</label> | ||
</span> | ||
<br/> | ||
<br/> | ||
<br/> | ||
<div id="need-mfa" style="--icon-size:36px;"> | ||
<label for="enable-2fa-button">You need to login with two factor authentication to use this feature.</label><br><br> | ||
<button id="enable-2fa-button">Enable 2FA</button> | ||
</div> | ||
</div> | ||
`; | ||
} | ||
const MfaZoneTabView = OCA.Files.DetailTabView.extend({ | ||
id: 'mfazoneTabView', | ||
className: 'tab mfazoneTabView', | ||
|
@@ -16,166 +98,12 @@ | |
console.error("File info not found!"); | ||
return; | ||
} | ||
const $html = ` | ||
<div style="text-align:center; word-wrap:break-word;"> | ||
<style> | ||
.switch { | ||
position: relative; | ||
display: inline; | ||
} | ||
.switch input { | ||
opacity: 0; | ||
width: 0; | ||
height: 0; | ||
} | ||
.slider { | ||
position: absolute; | ||
cursor: pointer; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
width: 30px; | ||
height: 15px; | ||
background-color: #ccc; | ||
-webkit-transition: .4s; | ||
transition: .4s; | ||
margin-top: auto; | ||
} | ||
.slider:before { | ||
position: absolute; | ||
content: ""; | ||
height: 9px; | ||
width: 9px; | ||
left: 3px; | ||
bottom: 3px; | ||
background-color: white; | ||
-webkit-transition: .4s; | ||
transition: .4s; | ||
} | ||
input:checked + .slider { | ||
background-color: #2196F3; | ||
} | ||
input:focus + .slider { | ||
box-shadow: 0 0 1px #2196F3; | ||
} | ||
input:checked + .slider:before { | ||
-webkit-transform: translateX(15px); | ||
-ms-transform: translateX(15px); | ||
transform: translateX(15px); | ||
} | ||
/* Rounded sliders */ | ||
.slider.round { | ||
border-radius: 15px; | ||
} | ||
.slider.round:before { | ||
border-radius: 50%; | ||
} | ||
</style> | ||
<span id="mfa-current-file-path" hidden></span> | ||
<span style="--icon-size:36px;"> | ||
<label class="switch"> | ||
<input id="checkbox-radio-switch-mfa" type="checkbox"> | ||
<span class="slider round"></span> Enforce MFA requirement | ||
</label> | ||
</span> | ||
<br/> | ||
<br/> | ||
<br/> | ||
<div id="need-mfa" style="--icon-size:36px;"> | ||
<label for="enable-2fa-button">You need to login with two factor authentication to use this feature.</label><br><br> | ||
<button id="enable-2fa-button">Enable 2FA</button> | ||
</div> | ||
</div> | ||
`; | ||
const $htmlDisabled = ` | ||
<div style="text-align:center; word-wrap:break-word;"> | ||
<style> | ||
.switch { | ||
position: relative; | ||
display: inline; | ||
} | ||
.switch input { | ||
opacity: 0; | ||
width: 0; | ||
height: 0; | ||
} | ||
.slider { | ||
position: absolute; | ||
cursor: pointer; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
width: 30px; | ||
height: 15px; | ||
background-color: #ccc; | ||
-webkit-transition: .4s; | ||
transition: .4s; | ||
margin-top: auto; | ||
} | ||
.slider:before { | ||
position: absolute; | ||
content: ""; | ||
height: 9px; | ||
width: 9px; | ||
left: 3px; | ||
bottom: 3px; | ||
background-color: white; | ||
-webkit-transition: .4s; | ||
transition: .4s; | ||
} | ||
input:checked + .slider { | ||
background-color: #2196F3; | ||
} | ||
input:focus + .slider { | ||
box-shadow: 0 0 1px #2196F3; | ||
} | ||
input:checked + .slider:before { | ||
-webkit-transform: translateX(15px); | ||
-ms-transform: translateX(15px); | ||
transform: translateX(15px); | ||
} | ||
/* Rounded sliders */ | ||
.slider.round { | ||
border-radius: 15px; | ||
} | ||
.slider.round:before { | ||
border-radius: 50%; | ||
} | ||
</style> | ||
<span id="mfa-current-file-path" hidden></span> | ||
<span style="--icon-size:36px;"> | ||
<label class="switch"> | ||
<input id="checkbox-radio-switch-mfa" type="checkbox" disabled> | ||
<span class="slider round"></span> Enforce MFA requirement | ||
</label> | ||
</span> | ||
<br/> | ||
<br/> | ||
<br/> | ||
<div id="need-mfa" style="--icon-size:36px;"> | ||
<label for="enable-2fa-button">You need to login with two factor authentication to use this feature.</label><br><br> | ||
<button id="enable-2fa-button">Enable 2FA</button> | ||
</div> | ||
</div> | ||
`; | ||
console.log("Rendering MFA Zone tab for " + fileInfo.getFullPath()); | ||
// if (!fileInfo.isDirectory()) { | ||
// this.$el.html(`<div>MFA Zones are currently disabled for files.</div>`); | ||
// console.log("Not a directory, MFA zone detail tab disabled."); | ||
// return; | ||
// } | ||
const accessUrl = OC.generateUrl('/apps/mfazones/access'), | ||
data = { | ||
source: fileInfo.getFullPath() | ||
|
@@ -190,20 +118,16 @@ | |
async: true, | ||
success: function (response) { | ||
console.log(response); | ||
if (response.access === false) { | ||
_self.addHtml(_self, $htmlDisabled, data, false); | ||
} else { | ||
_self.addHtml(_self, $html, data, true); | ||
} | ||
_self.addHtml(_self, data, response.access); | ||
}, | ||
error: function (xhr, ajaxOptions, thrownError) { | ||
console.log(xhr.status); | ||
console.log(thrownError); | ||
}, | ||
}); | ||
}, | ||
addHtml: function (context, html, data, enabled) { | ||
context.$el.html(html); | ||
addHtml: function (context, data, enabled) { | ||
context.$el.html(renderHTML(enabled)); | ||
const statusUrl = OC.generateUrl('/apps/mfazones/get'); | ||
$.ajax({ | ||
type: 'GET', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters