2018-05-09 10:18:28 +00:00
/ * *
* Privacy settings section
*
* @ author Pierre HUBERT
* /
2021-02-16 17:00:26 +00:00
const SettingsPrivacySection = {
2018-05-09 10:18:28 +00:00
/ * *
* Open settings section
*
* @ param { object } args Additionnal arguments
* @ param { HTMLElement } target The target for the page
* /
2021-02-16 17:00:26 +00:00
open : async function ( args , target ) {
2018-05-09 12:57:46 +00:00
2021-02-16 17:00:26 +00:00
try {
2018-05-22 20:23:16 +00:00
2021-02-16 17:00:26 +00:00
// Information box
this . showInfoBox ( target ) ;
2018-05-13 14:52:19 +00:00
2021-02-16 17:00:26 +00:00
// Data conservation policy
await this . showDataConservationPolicy ( target ) ;
//Export data box
this . showExportDataBox ( target ) ;
//Delete account box
this . showDeleteAccountBox ( target ) ;
}
catch ( e ) {
console . error ( e ) ;
target . appendChild ( ComunicWeb . common . messages . createCalloutElem ( "Failed to load page" , "The page failed to load !" , "danger" ) ) ;
}
2018-05-09 12:57:46 +00:00
} ,
2018-05-13 14:52:19 +00:00
2018-05-22 20:23:16 +00:00
/ * *
* Show privacy policy information box
*
* @ param { HTMLElement } target The target for the box
* /
showInfoBox : function ( target ) {
//Create a box
var box = createElem2 ( {
appendTo : target ,
type : "div" ,
class : "box box-primary box-export-account-data-settings"
} ) ;
//Add box header
var boxHead = createElem2 ( {
appendTo : box ,
type : "div" ,
class : "box-header" ,
} ) ;
var boxTitle = createElem2 ( {
appendTo : boxHead ,
type : "h3" ,
class : "box-title" ,
2021-02-16 17:00:26 +00:00
innerHTML : tr ( "About our policy" )
2018-05-22 20:23:16 +00:00
} ) ;
//Create box body
var boxBody = createElem2 ( {
appendTo : box ,
type : "div" ,
class : "box-body"
} ) ;
//Box content
createElem2 ( {
appendTo : boxBody ,
type : "p" ,
innerHTML : "We give an high importance to our users privacy. Please take some time to check our <a href='" + ComunicWeb . _ _config . aboutWebsiteURL + "about/privacy' target='_blank'>Privacy Policy</a> and our <a href='" + ComunicWeb . _ _config . aboutWebsiteURL + "about/terms' target='_blank'>Terms of use</a>."
} )
} ,
2021-02-16 17:00:26 +00:00
/ * *
* Show data conservation policy
*
* @ param { HTMLElement } target
* /
showDataConservationPolicy : async function ( target ) {
// Load template
const tpl = await Page . loadHTMLTemplate ( "pages/settings/privacy/ConservationPolicy.html" ) ;
const el = document . createElement ( "div" )
el . innerHTML = tpl ;
target . appendChild ( el )
// Load user settings
const settings = await SettingsInterface . getDataConservationPolicy ( ) ;
// Load server policy
await ServerConfig . ensureLoaded ( ) ;
const serverPolicy = ServerConfig . conf ;
// Use Vue
const oneDay = 60 * 60 * 24 ;
const lifetimeOptions = [
{ label : tr ( "Never" ) , value : 0 } ,
{ label : tr ( "7 days" ) , value : oneDay * 7 } ,
{ label : tr ( "15 days" ) , value : oneDay * 15 } ,
{ label : tr ( "1 month" ) , value : oneDay * 30 } ,
{ label : tr ( "3 months" ) , value : oneDay * 30 * 3 } ,
{ label : tr ( "6 months" ) , value : oneDay * 30 * 6 } ,
{ label : tr ( "1 year" ) , value : oneDay * 365 } ,
{ label : tr ( "5 years" ) , value : oneDay * 365 * 5 } ,
{ label : tr ( "10 years" ) , value : oneDay * 365 * 10 } ,
{ label : tr ( "50 years" ) , value : oneDay * 365 * 50 }
] ;
let findOptionIndex = ( value ) => {
if ( ! value ) return lifetimeOptions [ 0 ] . value ;
return [ ... lifetimeOptions ] . reverse ( ) . find ( v => v . value <= value ) . value
}
const DataConservationPolicyVueApp = {
data ( ) {
return {
options : lifetimeOptions ,
settings : [
{
title : tr ( "Automatically delete unread notification after" ) ,
key : "notification_lifetime" ,
value : findOptionIndex ( settings . notification _lifetime ) ,
} ,
{
title : tr ( "Automatically delete your comments after" ) ,
key : "comments_lifetime" ,
value : findOptionIndex ( settings . comments _lifetime )
} ,
{
title : tr ( "Automatically delete your posts after" ) ,
key : "posts_lifetime" ,
value : findOptionIndex ( settings . posts _lifetime )
} ,
{
title : tr ( "Automatically delete your conversation messages after" ) ,
key : "conversation_messages_lifetime" ,
value : findOptionIndex ( settings . conversation _messages _lifetime )
} ,
{
title : tr ( "Automatically delete your likes after" ) ,
key : "likes_lifetime" ,
value : findOptionIndex ( settings . likes _lifetime )
} ,
{
title : tr ( "Automatically delete your account if you have been inactive for" ) ,
key : "inactive_account_lifetime" ,
value : findOptionIndex ( settings . inactive _account _lifetime )
}
]
}
}
}
Vue . createApp ( DataConservationPolicyVueApp ) . mount ( el ) ;
} ,
2018-05-13 14:52:19 +00:00
/ * *
* Show export personnal data box
*
* @ param { HTMLElement } target The target for the box
* /
showExportDataBox : function ( target ) {
//Create a box
var box = createElem2 ( {
appendTo : target ,
type : "div" ,
class : "box box-primary box-export-account-data-settings"
} ) ;
//Add box header
var boxHead = createElem2 ( {
appendTo : box ,
type : "div" ,
class : "box-header" ,
} ) ;
var boxTitle = createElem2 ( {
appendTo : boxHead ,
type : "h3" ,
class : "box-title" ,
2021-02-16 17:00:26 +00:00
innerHTML : tr ( "Export account data" )
2018-05-13 14:52:19 +00:00
} ) ;
//Create box body
var boxBody = createElem2 ( {
appendTo : box ,
type : "div" ,
class : "box-body"
} ) ;
//Add a notice
createElem2 ( {
appendTo : boxBody ,
type : "p" ,
2021-02-16 17:00:26 +00:00
innerHTML : tr ( "You can export all the data of your account from here." )
2018-05-13 14:52:19 +00:00
} ) ;
//Add delete account button
var exportAccountDataBtn = createElem2 ( {
appendTo : boxBody ,
type : "div" ,
class : "btn btn-primary" ,
2021-02-16 17:00:26 +00:00
innerHTML : tr ( "Export account data" )
2018-05-13 14:52:19 +00:00
} ) ;
2021-02-16 17:00:26 +00:00
exportAccountDataBtn . addEventListener ( "click" , ( e ) => {
2018-05-13 14:52:19 +00:00
//Request account deletion
ComunicWeb . components . settings . helper . requestAccountDataExport ( ) ;
} ) ;
} ,
2018-05-09 10:18:28 +00:00
2018-05-09 12:57:46 +00:00
/ * *
* Display delete account box
*
* @ param { HTMLElement } target The target for the box
* /
showDeleteAccountBox : function ( target ) {
2018-05-09 10:18:28 +00:00
//Create a box
var box = createElem2 ( {
appendTo : target ,
type : "div" ,
2018-05-09 12:57:46 +00:00
class : "box box-danger box-delete-account-settings"
2018-05-09 10:18:28 +00:00
} ) ;
//Add box header
var boxHead = createElem2 ( {
appendTo : box ,
type : "div" ,
class : "box-header" ,
} ) ;
var boxTitle = createElem2 ( {
appendTo : boxHead ,
type : "h3" ,
class : "box-title" ,
2018-05-09 12:57:46 +00:00
innerHTML : "Delete account"
2018-05-09 10:18:28 +00:00
} ) ;
//Create box body
var boxBody = createElem2 ( {
appendTo : box ,
type : "div" ,
class : "box-body"
} ) ;
2018-05-09 12:57:46 +00:00
//Add a notice
createElem2 ( {
2018-05-09 10:18:28 +00:00
appendTo : boxBody ,
2018-05-09 12:57:46 +00:00
type : "p" ,
2021-02-16 17:00:26 +00:00
innerHTML : tr ( "You can decide here to delete your account. <br /><b>Warning! Warning! Warning! This operation CAN NOT BE REVERTED !!!! All your data (post, conversation messages, comments...) will be permanently deleted ! You will not be able to recover from this operation !</b>" )
2018-05-09 12:57:46 +00:00
} ) ;
//Add delete account button
var deleteAccountBtn = createElem2 ( {
appendTo : boxBody ,
type : "div" ,
class : "btn btn-danger" ,
2021-02-16 17:00:26 +00:00
innerHTML : tr ( "Delete your account" )
2018-05-09 12:57:46 +00:00
} ) ;
deleteAccountBtn . addEventListener ( "click" , function ( e ) {
//Request account deletion
ComunicWeb . components . settings . helper . requestAccountDeletion ( ) ;
2018-05-09 10:18:28 +00:00
} ) ;
} ,
2021-02-16 17:00:26 +00:00
}
ComunicWeb . pages . settings . sections . privacy = SettingsPrivacySection ;