github.com/cs3org/reva/v2@v2.27.7/pkg/siteacc/account/settings/template.go (about) 1 // Copyright 2018-2020 CERN 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 // In applying this license, CERN does not waive the privileges and immunities 16 // granted to it by virtue of its status as an Intergovernmental Organization 17 // or submit itself to any jurisdiction. 18 19 package settings 20 21 const tplJavaScript = ` 22 function verifyForm(formData) { 23 return true; 24 } 25 26 function handleAction(action) { 27 const formData = new FormData(document.querySelector("form")); 28 if (!verifyForm(formData)) { 29 return; 30 } 31 32 setState(STATE_STATUS, "Configuring account... this should only take a moment.", "form", null, false); 33 34 var xhr = new XMLHttpRequest(); 35 xhr.open("POST", "{{getServerAddress}}/" + action); 36 xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); 37 38 xhr.onload = function() { 39 if (this.status == 200) { 40 setState(STATE_SUCCESS, "Your account was successfully configured!", "form", null, true); 41 } else { 42 var resp = JSON.parse(this.responseText); 43 setState(STATE_ERROR, "An error occurred while trying to configure your account:<br><em>" + resp.error + "</em>", "form", null, true); 44 } 45 } 46 47 var postData = { 48 "settings": { 49 "receiveAlerts": (formData.get("rcvAlerts") === "on") 50 } 51 }; 52 53 xhr.send(JSON.stringify(postData)); 54 } 55 ` 56 57 const tplStyleSheet = ` 58 html * { 59 font-family: arial !important; 60 } 61 62 input[type="checkbox"] { 63 width: auto; 64 } 65 ` 66 67 const tplBody = ` 68 <div> 69 <p>Configure your ScienceMesh Site Administrator Account below.</p> 70 </div> 71 <div> </div> 72 <div> 73 <form id="form" method="POST" class="box container-inline" style="width: 100%;" onSubmit="handleAction('configure?invoker=user'); return false;"> 74 <div style="grid-row: 1; grid-column: 1 / span 2;"> 75 <h3>Notification settings</h3> 76 <hr> 77 </div> 78 79 <div style="grid-row: 2; grid-column: 1 / span 2;"> 80 <input type="checkbox" id="rcvAlerts" name="rcvAlerts" value="on" checked disabled/> 81 <label for="rcvAlerts" style="font-weight: normal;">Receive email notifications about site alerts <em>(mandatory; always on)</em></label> 82 </div> 83 84 <div style="grid-row: 3; grid-column: 2; text-align: right;"> 85 <button type="reset">Reset</button> 86 <button type="submit" style="font-weight: bold;">Save</button> 87 </div> 88 </form> 89 </div> 90 <div> 91 <p>Go <a href="{{getServerAddress}}/account/?path=manage">back</a> to the main account page.</p> 92 </div> 93 `