github.com/cs3org/reva/v2@v2.27.7/pkg/siteacc/admin/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 admin
    20  
    21  const tplJavaScript = `
    22  function handleAction(action, email) {
    23  	var xhr = new XMLHttpRequest();
    24      xhr.open("POST", "{{getServerAddress}}/" + action);
    25      xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
    26  
    27  	setState(STATE_STATUS, "Performing request...");
    28  
    29  	xhr.onload = function() {
    30  		if (this.status == 200) {
    31  			setState(STATE_SUCCESS, "Done! Reloading...");
    32  			location.reload();
    33  		} else {
    34  			setState(STATE_ERROR, "An error occurred while performing the request: " + this.responseText);
    35  		}
    36  	}
    37      
    38  	var postData = {
    39          "email": email,
    40      };
    41  
    42      xhr.send(JSON.stringify(postData));
    43  }
    44  `
    45  
    46  const tplStyleSheet = `
    47  html * {
    48  	font-family: monospace !important;
    49  }
    50  `
    51  
    52  const tplBody = `
    53  <div style="font-size: 14px;">
    54  	<ul>
    55  	{{range .Accounts}}
    56  		<li>
    57  			<div>
    58  				<div>
    59  					<strong>{{.Email}}</strong><br>
    60  					{{.Title}}. {{.FirstName}} {{.LastName}} <em>(Joined: {{.DateCreated.Format "Jan 02, 2006 15:04"}}; Last modified: {{.DateModified.Format "Jan 02, 2006 15:04"}})</em>
    61  				</div>
    62  				<div>
    63  					<ul style="padding-left: 1em;">
    64  						<li>ScienceMesh Site: {{getSiteName .Site false}} ({{getSiteName .Site true}})</li>
    65  						<li>Role: {{.Role}}</li>
    66  						<li>Phone: {{.PhoneNumber}}</li>
    67  					</ul>
    68  				</div>
    69  			</div>
    70  
    71  			<div>&nbsp;</div>
    72  
    73  			<div>
    74  				<strong>Account data:</strong>
    75  				<ul style="padding-left: 1em; padding-top: 0em;">	
    76  					<li>Site access: <em>{{if .Data.SiteAccess}}Granted{{else}}Not granted{{end}}</em></li>
    77  					<li>GOCDB access: <em>{{if .Data.GOCDBAccess}}Granted{{else}}Not granted{{end}}</em></li>	
    78  				</ul>
    79  			</div>
    80  
    81  			<div>&nbsp;</div>
    82  
    83  			<div>
    84  				<form method="POST" style="width: 100%;">
    85  				{{if .Data.SiteAccess}}
    86  					<button type="button" onClick="handleAction('grant-site-access?status=false', '{{.Email}}');">Revoke Site access</button>
    87  				{{else}}
    88  					<button type="button" onClick="handleAction('grant-site-access?status=true', '{{.Email}}');">Grant Site access</button>
    89  				{{end}}
    90  
    91  				{{if .Data.GOCDBAccess}}
    92  					<button type="button" onClick="handleAction('grant-gocdb-access?status=false', '{{.Email}}');">Revoke GOCDB access</button>
    93  				{{else}}
    94  					<button type="button" onClick="handleAction('grant-gocdb-access?status=true', '{{.Email}}');">Grant GOCDB access</button>
    95  				{{end}}
    96  
    97  					<span style="width: 25px;">&nbsp;</span>
    98  					<button type="button" onClick="handleAction('remove', '{{.Email}}');" style="float: right;">Remove</button>
    99  				</form>
   100  			</div>
   101  			<hr>
   102  		</li>
   103  	{{end}}
   104  	</ul>
   105  </div>
   106  `