github.com/cs3org/reva/v2@v2.27.7/pkg/siteacc/account/manage/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 manage
    20  
    21  const tplJavaScript = `
    22  function handleAccountSettings() {
    23  	setState(STATE_STATUS, "Redirecting to the account settings...");
    24  	window.location.replace("{{getServerAddress}}/account/?path=settings");
    25  }
    26  
    27  function handleEditAccount() {
    28  	setState(STATE_STATUS, "Redirecting to the account editor...");
    29  	window.location.replace("{{getServerAddress}}/account/?path=edit");
    30  }
    31  
    32  function handleSiteSettings() {
    33  	setState(STATE_STATUS, "Redirecting to the site settings...");
    34  	window.location.replace("{{getServerAddress}}/account/?path=site");
    35  }
    36  
    37  function handleRequestAccess(scope) {
    38  	setState(STATE_STATUS, "Redirecting to the contact form...");		
    39  	window.location.replace("{{getServerAddress}}/account/?path=contact&subject=" + encodeURIComponent("Request " + scope + " access"));
    40  }
    41  
    42  function handleLogout() {
    43  	var xhr = new XMLHttpRequest();
    44      xhr.open("GET", "{{getServerAddress}}/logout");
    45      xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
    46  
    47  	setState(STATE_STATUS, "Logging out...");
    48  
    49  	xhr.onload = function() {
    50  		if (this.status == 200) {
    51  			setState(STATE_SUCCESS, "Done! Redirecting...");
    52  			window.location.replace("{{getServerAddress}}/account/?path=login");
    53  		} else {
    54  			setState(STATE_ERROR, "An error occurred while logging out: " + this.responseText);
    55  		}
    56  	}
    57      
    58      xhr.send();
    59  }
    60  `
    61  
    62  const tplStyleSheet = `
    63  html * {
    64  	font-family: arial !important;
    65  }
    66  button {
    67  	min-width: 170px;
    68  }
    69  `
    70  
    71  const tplBody = `
    72  <div>
    73  	<p><strong>Hello {{.Account.FirstName}} {{.Account.LastName}},</strong></p>
    74  	<p>On this page, you can manage your ScienceMesh Site Administrator Account. This includes editing your personal information, requesting access to the GOCDB and more.</p>
    75  </div>
    76  <div>&nbsp;</div>
    77  <div>
    78  	<strong>Personal information:</strong>
    79  	<ul style="margin-top: 0em;">
    80  		<li>Name: <em>{{.Account.Title}}. {{.Account.FirstName}} {{.Account.LastName}}</em></li>
    81  		<li>Email: <em><a href="mailto:{{.Account.Email}}">{{.Account.Email}}</a></em></li>
    82  		<li>ScienceMesh Site: <em>{{getSiteName .Account.Site false}} ({{getSiteName .Account.Site true}})</em></li>
    83  		<li>Role: <em>{{.Account.Role}}</em></li>
    84  		{{if .Account.PhoneNumber}}
    85  		<li>Phone: <em>{{.Account.PhoneNumber}}</em></li>
    86  		{{end}}
    87  	</ul>
    88  </div>
    89  <div>
    90  	<strong>Account data:</strong>
    91  	<ul style="margin-top: 0em;">	
    92  		<li>Site access: <em>{{if .Account.Data.SiteAccess}}Granted{{else}}Not granted{{end}}</em></li>
    93  		<li>GOCDB access: <em>{{if .Account.Data.GOCDBAccess}}Granted{{else}}Not granted{{end}}</em></li>	
    94  	</ul>
    95  </div>
    96  <div>
    97  	<form id="form" method="POST" class="box" style="width: 100%;">
    98  		<div>
    99  			<button type="button" onClick="handleAccountSettings();">Account settings</button>
   100  			<button type="button" onClick="handleEditAccount();">Edit account</button>
   101  			<span style="width: 25px;">&nbsp;</span>
   102  			
   103  			{{if .Account.Data.SiteAccess}}
   104  			<button type="button" onClick="handleSiteSettings();">Site settings</button>
   105  			<span style="width: 25px;">&nbsp;</span>
   106  			{{end}}	
   107  
   108  			<button type="button" onClick="handleLogout();" style="float: right;">Logout</button>
   109  		</div>
   110  		<div style="margin-top: 0.5em;">
   111  			<button type="button" onClick="handleRequestAccess('Site');" {{if .Account.Data.SiteAccess}}disabled{{end}}>Request Site access</button>
   112  			<button type="button" onClick="handleRequestAccess('GOCDB');" {{if .Account.Data.GOCDBAccess}}disabled{{end}}>Request GOCDB access</button>	
   113  		</div>
   114  	</form>
   115  </div>
   116  <div style="font-size: 90%; margin-top: 1em;">
   117  	<div>
   118  		<div>Notes:</div>
   119  		<ul style="margin-top: 0em;">
   120  			<li>The <em>Site access</em> allows you to access and modify the global configuration of your site.</li>
   121  			<li>The <em>GOCDB access</em> allows you to log into the central database where all site metadata is stored.</li>
   122  		</ul>
   123  	</div>
   124  	<div>
   125  		<div>Quick links:</div>
   126  		<ul style="margin-top: 0em;">
   127  			<li><a href="https://gocdb.sciencemesh.uni-muenster.de" target="_blank">Central Database (GOCDB)</a></li>
   128  			<li><a href="https://developer.sciencemesh.io/docs/technical-documentation/central-database/" target="_blank">Central Database documentation</a></li>
   129  		</ul>
   130  	</div>
   131  </div>
   132  `