Skip to content

Commit

Permalink
Setup tos/pp dialog for online usage (WIP)
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Jan 18, 2024
1 parent c112f6f commit 828765b
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 37 deletions.
16 changes: 16 additions & 0 deletions html/css/pedals.css
Original file line number Diff line number Diff line change
Expand Up @@ -1036,3 +1036,19 @@ body > .mod-settings.mod-window-visible {
#pedalboard-info .js-save.unmodified-changes {
background-color: #883996;
}

#mod-cloud-terms {
z-index: 100000;
}
#mod-cloud-terms .mod-box {
width: 500px;
left: 0;
right: 0;
margin: -150px auto;
}
#mod-cloud-terms .actions {
text-align: center;
}
#mod-cloud-terms .btn {
margin: 0px 4px;
}
116 changes: 86 additions & 30 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@
console.log = function() {}
}

var TERMS_ACCEPTED = true;
var CLOUD_TERMS_ACCEPTED = PREFERENCES['cloud-terms-accepted'] === "true";
var USING_MOD_APP = {{using_app}};
var USING_MOD_DEVICE = {{using_mod}} && !{{using_app}};

/*
var INFO = {
Expand All @@ -98,7 +100,7 @@
// for mod-app control
var desktop = null

var startApp = function() {
$('document').ready(function() {
desktop = new Desktop({
titleBox: $('#pedalboard-info h1'),
pedalboard: $('#pedalboard-dashboard'),
Expand Down Expand Up @@ -164,16 +166,10 @@
$('#mod-bypassRight').hide()
}

if ({{using_mod}} && !{{using_app}}) {
desktop.authenticateDevice(function (ok) {
if (ok) {
console.log("MOD authentication succeeded")
desktop.resetPedalboardStats();
} else {
console.log("MOD authentication failed")
desktop.upgradeWindow.upgradeWindow('setErrored')
}
})
if (USING_MOD_DEVICE) {
if (CLOUD_TERMS_ACCEPTED) {
desktop.setupDeviceAuthentication()
}
} else {
desktop.upgradeWindow.upgradeWindow('setErrored')

Expand Down Expand Up @@ -221,6 +217,36 @@

// end code for ajax loading bar

// start of terms handling

var terms = $('#mod-cloud-terms')
if (PREFERENCES['cloud-terms-accepted'] !== undefined && (USING_MOD_DEVICE || PREFERENCES['cloud-terms-accepted'] === "true")) {
if (CLOUD_TERMS_ACCEPTED) {
desktop.setupMatomo()
terms.hide()
$('#pedalboard-info').find('.js-cloud').show()
}
terms.hide()
} else {
terms.find('.js-accept').click(function () {
CLOUD_TERMS_ACCEPTED = true
desktop.saveConfigValue("cloud-terms-accepted", true)
desktop.setupMatomo()
if (USING_MOD_DEVICE) {
desktop.setupDeviceAuthentication()
$('#pedalboard-info').find('.js-cloud').show()
}
terms.hide()
})
terms.find('.js-reject').click(function () {
desktop.saveConfigValue("cloud-terms-accepted", false)
terms.hide()
})
terms.show()
}

// end of terms handling

/*
$.ajax({
url: '/system/info',
Expand Down Expand Up @@ -253,12 +279,7 @@
}
})();
*/
};
if (TERMS_ACCEPTED) {
$('document').ready(startApp);
} else {
document.location.href = '/terms.html';
}
})
</script>

<script type="text/javascript" src="js/templates.js?v={{version}}"></script>
Expand Down Expand Up @@ -292,17 +313,6 @@
<!-- For browsers with shields on, avoid breaking on Matomo related code -->
<script>var _paq = { push: new Function() }</script>

<!-- Matomo Tag Manager -->
<script>
var _mtm = window._mtm = window._mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
(function() {
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='https://cdn.matomo.cloud/modaudio.matomo.cloud/container_DfEOyKDN.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Tag Manager -->

</head>
<!-- END HEAD -->

Expand Down Expand Up @@ -354,6 +364,52 @@
<div id="notifications" class="mod-hidden mod-init-hidden"></div>
<!-- END NOTIFICATIONS -->

{% if using_app == 'true' or using_mod == 'true' %}
<!-- CLOUD-TERMS-WINDOW -->
<div id="mod-cloud-terms" class="save-popup mod-hidden">
<div class="mod-box">
{% if using_app == 'true' %}
<h1>Terms of Service for MOD Desktop App</h1>
<div>
<p>
(NOTE: THIS AN EXAMPLE TEXT YET TO BE REVIEWED)<br/>
The use of this application...<br/>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br/>
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<br/>
</p>
<p>
Please review our <a href="#" target="_blank">Terms of Service</a> and <a href="#" target="_blank">Privacy Policy</a> before continuing.<br/>
</p>
</div>
{% else %}
<h1 class="pull-left">Terms of Service for MOD online components</h1>
<span class="js-reject close">&times;</span>
<div class="bottom">
<div class="clearfix"></div>
<p>
(NOTE: THIS AN EXAMPLE TEXT YET TO BE REVIEWED)<br/>
Your MOD unit can receive firmware updates over the internet, and also download new plugins and pedalboards.<br/>
The use of these online services is under Terms of Service and Privacy Policy in order to comply with different regulatory laws across the globe.<br/>
</p>
<p>
Please review our <a href="#" target="_blank">Terms of Service</a> and <a href="#" target="_blank">Privacy Policy</a> before continuing.<br/>
While you can freely use your MOD unit without accepting these terms, you must agree to them in order to enable or perform any online interaction.
</p>
</div>
{% end %}
<div class="controls actions">
{% if using_app == 'true' %}
<button class="js-accept btn btn-success">Agree and Continue</button>
{% else %}
<button class="js-reject btn btn-danger">Disagree</button>
<button class="js-accept btn btn-success">Agree</button>
{% end %}
</div>
</div>
</div>
<!-- END CLOUD-TERMS-WINDOW -->
{% end %}

<!-- WRAPPER -->
<div id="wrapper" class="mod-init-hidden">

Expand Down Expand Up @@ -530,7 +586,7 @@ <h1 class="top bottom {{titleblend}}">{{fulltitle}}</h1>
<button class="js-reset">New Pedalboard</button>
<button class="js-save">Save</button>
<button class="js-save-as">Save as</button>
<button class="js-cloud">Share</button>
<button class="js-cloud mod-hidden">Share</button>
</div>
</div>
<!-- END PEDALBOARD-SETTINGS -->
Expand Down
35 changes: 34 additions & 1 deletion html/js/desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ function Desktop(elements) {
this.pedalboardStats = {};
this.resetPedalboardStats = function() {
this.pedalboardStatsSuccess = false;
if (! CLOUD_TERMS_ACCEPTED) {
return
}
$.ajax({
url: SITEURL + '/pedalboards/stats',
type: 'GET',
Expand Down Expand Up @@ -330,7 +333,7 @@ function Desktop(elements) {

callback(pedals, '')
}
else
else if (CLOUD_TERMS_ACCEPTED)
{
// NOTE: this part is never called. pedalboard search is always local
$.ajax({
Expand Down Expand Up @@ -710,6 +713,7 @@ function Desktop(elements) {
success: function () {
if (callback) {
callback(true)
PREFERENCES[key] = value
}
},
error: function () {
Expand All @@ -735,6 +739,27 @@ function Desktop(elements) {
$('#pedal-presets-window').find('.js-assign-all').hide()
}

this.setupDeviceAuthentication = function () {
self.authenticateDevice(function (ok) {
if (ok) {
console.log("MOD authentication succeeded")
self.resetPedalboardStats();
} else {
console.log("MOD authentication failed")
self.upgradeWindow.upgradeWindow('setErrored')
}
})
}

this.setupMatomo = function() {
var _mtm = window._mtm = window._mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
(function() {
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='https://cdn.matomo.cloud/modaudio.matomo.cloud/container_DfEOyKDN.js'; s.parentNode.insertBefore(g,s);
})();
}

this.effectBox = self.makeEffectBox(elements.effectBox,
elements.effectBoxTrigger)
this.cloudPluginBox = self.makeCloudPluginBox(elements.cloudPluginBox,
Expand Down Expand Up @@ -831,6 +856,10 @@ function Desktop(elements) {
},

this.loadRemotePedalboard = function (pedalboard_id) {
if (! CLOUD_TERMS_ACCEPTED) {
return
}

self.windowManager.closeWindows(null, true)

if (self.cloudAccessToken == null) {
Expand Down Expand Up @@ -1177,6 +1206,10 @@ function Desktop(elements) {
})
}

if (! CLOUD_TERMS_ACCEPTED) {
return
}

if (self.cloudAccessToken == null) {
self.authenticateDevice(function (ok) {
if (ok && self.cloudAccessToken != null) {
Expand Down
5 changes: 0 additions & 5 deletions html/terms.html

This file was deleted.

2 changes: 1 addition & 1 deletion mod/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ def index(self):
'titleblend': '' if SESSION.host.pedalboard_name else 'blend',
'dev_api_class': 'dev_api' if DEV_API else '',
'using_app': 'true' if APP else 'false',
'using_mod': 'true' if DEVICE_KEY or DEV_HOST else 'false',
'using_mod': 'true' if DEVICE_KEY and hwdesc.get('platform', None) is not None else 'false',
'user_name': mod_squeeze(user_id.get("name", "")),
'user_email': mod_squeeze(user_id.get("email", "")),
'favorites': json.dumps(gState.favorites),
Expand Down

0 comments on commit 828765b

Please sign in to comment.