Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #360 from pondersource/owncloud-dev
Browse files Browse the repository at this point in the history
Release ownCloud: version 0.4.3
  • Loading branch information
MahdiBaghbani authored Jun 7, 2023
2 parents 04fdbf3 + 4855938 commit fb67458
Show file tree
Hide file tree
Showing 14 changed files with 364 additions and 71 deletions.
5 changes: 5 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
['name' => 'reva#addSentShare', 'url' => '/~{userId}/api/ocm/addSentShare', 'verb' => 'POST'],
['name' => 'reva#addReceivedShare', 'url' => '/~{userId}/api/ocm/addReceivedShare', 'verb' => 'POST'],
['name' => 'reva#GetSentShare', 'url' => '/~{userId}/api/ocm/GetSentShare', 'verb' => 'POST'],
['name' => 'reva#GetSentShareByToken', 'url' => '/~nobody/api/ocm/GetSentShareByToken', 'verb' => 'POST'],
['name' => 'reva#Unshare', 'url' => '/~{userId}/api/ocm/Unshare', 'verb' => 'POST'],
['name' => 'reva#UpdateShare', 'url' => '/~{userId}/api/ocm/UpdateShare', 'verb' => 'POST'],
['name' => 'reva#ListSentShares', 'url' => '/~{userId}/api/ocm/ListSentShares', 'verb' => 'POST'],
Expand Down Expand Up @@ -77,9 +78,13 @@
['name' => 'app#contacts', 'url' => '/contacts', 'verb' => 'GET'],
['name' => 'app#settings', 'url' => '/settings', 'verb' => 'GET'],
['name' => 'app#invitationsGenerate', 'url' => '/invitations/generate', 'verb' => 'GET'],
['name' => 'app#invitationsSends', 'url' => '/invitations/emailsend', 'verb' => 'POST'],
['name' => 'app#contactsAccept', 'url' => '/contacts/accept', 'verb' => 'POST'],
['name' => 'app#contactsFindUsers', 'url' => '/contacts/users', 'verb' => 'GET'],

// contacts routes
['name' => 'contacts#deleteContact', 'url' => '/contact/deleteContact', 'verb' => 'POST'],

// page routes
['name' => 'page#get_internal_metrics', 'url' => '/internal_metrics', 'verb' => 'GET'],
['name' => 'page#get_metrics', 'url' => '/metrics', 'verb' => 'GET'],
Expand Down
22 changes: 22 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@
width: 45% !important;
border-bottom: 1px solid #ececec;
}
.contacts-table tbody tr td:nth-child(4){
width: 5% !important;
border-bottom: 1px solid var(--color-placeholder-light);
text-align: center;
}
.contacts-profile-img{
height: 35px;
margin: 2.5px 0px;
Expand Down Expand Up @@ -370,7 +375,24 @@
background-size: 20px !important;
width: 30px;
}

#contact-search-input{
margin-top: 20px;
margin-left: 10px;
}

#recipient{
width: 25% !important;
border-radius: 3px !important;
height: 36px;
}

#oc-dialog-0-content #oc-dialog-0-content-input{
width: 95% !important;
}

#share-token-btn-email{
width: 30px;
background-size: 24px;
opacity: 0.5;
}
204 changes: 181 additions & 23 deletions js/contacts.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,139 @@
document.addEventListener("DOMContentLoaded", function(event) {
//Everything will be for working with contacts
loadData("");
var baseUrl = OC.generateUrl('/apps/sciencemesh');
$('#test_error').hide();
$.ajax({
url: baseUrl + '/contacts/users',
type: 'GET',
contentType: 'application/json',
}).done(function (response) {
if(response == '' || response === false) {
var element = document.getElementById("show_result");
element.innerHTML= `
<tr class="app-content-list-item">
<th style="border-radius:100%">
No Sciencemesh Connection
</th>
</tr>`;
$('#show_result').show();
} else {
let acceptedUsers = JSON.parse(response);
if (acceptedUsers.length == 0) {
const result = `
<tr>
<td>
<p class="username-provider">There are no contacts!</p>
</td>
</tr>`;
var element = document.getElementById("show_result");
element.innerHTML = result;
$('#show_result').show();
} else {
let result = '';
for(i in acceptedUsers) {
const displayName = acceptedUsers[i].display_name;
const username = acceptedUsers[i].id.opaque_id;
const idp = acceptedUsers[i].id.idp;
const provider = (idp.startsWith("http") ? new URL(idp).host : idp);
result += `
<tr>
<td style="border-radius:100%">
<p class="icon-contacts-dark contacts-profile-img"></p>
</td>
<td class="app-content-list-item-line-one contact-item">
<p class="displayname">${displayName}</p>
</td>
<td>
<p class="username-provider">${username}@${provider}</p>
</td>
<td>
<button type="button" class="deleteContact" data-username="${username}" data-idp="${idp}">Unfriend</button>
</td>
</tr>
`;
}
var element = document.getElementById("show_result");
element.innerHTML = result;

var button = $(".deleteContact");
button.each(function( index , ele) {
ele.addEventListener("click", function() {
deleteContact($(this).data('idp'),$(this).data('username'));
});
});
$('#show_result').show();
}
}
}).fail(function (response, code) {
console.log(response)
//alert('The token is invalid')
});
document.getElementById('token-generator').onclick = function () {
var baseUrl = OC.generateUrl('/apps/sciencemesh');
var recipient = document.getElementById("recipient");
$.ajax({
url: baseUrl + '/invitations/generate',
type: 'GET',
contentType: 'application/json',
//data: JSON.stringify(note)
data: {
email: recipient.value,
},
}).done(function (response) {
if (response === '' || response === false) {
var element = document.getElementById("invitation-details");
element.innerHTML = 'No Sciencemesh Connection';
} else {
var element = document.getElementById("invitation-details");
element.innerHTML = `<div class="token-generator"><i class="fa-thin fa-square-check"></i><input type="text" value="${response}" onclick="get_token()" readonly name="meshtoken" class="generated-token-link"><span class="icon-clippy svg" id="share-token-btn"></span><h4 class="message-token" style="padding:8px 0;">New Token Generated!</h4></div>`;
element.innerHTML = `<div class="token-generator"><i class="fa-thin fa-square-check"></i><input type="text" value="${response}" readonly name="meshtoken" class="generated-token-link"><span class="icon-clippy svg" onclick="get_token()" id="share-token-btn"></span><span class="icon-mail svg" id="share-token-btn-email"></span><h4 class="message-token" style="padding:8px 0;">New Token Generated!</h4></div>`;
$('#test').show();
var button = document.querySelector("#share-token-btn");
button.addEventListener("click", function() {
copyToClipboard();
});

var buttonEmail = document.querySelector("#share-token-btn-email");
buttonEmail.addEventListener("click", function() {
OC.dialogs.prompt(
'',
'Share Token',
function (result,input) {
var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (input !== null) {
if(emailPattern.test(input)){
$.ajax({
url: 'invitations/emailsend',
method: 'POST',
data: {
email: input,
token: document.querySelector("input[name='meshtoken']").value
},
success: function (response) {
if(response){
alert('Email sent successfully!');
}else{
alert('Email sent failed! Please check the configuration.');
}
},
error: function (xhr, status, error) {
alert('Email sent failed! Please check the configuration.');
}
});
}else{
alert('Please input Email correctly!')
}
// var email = result.trim();

}else{
alert('Please input Email address!')
}
},
'',
'Please input the recipient email',
'',
''
);

});
}
}).fail(function (response, code) {
alert('The token is invalid')
Expand Down Expand Up @@ -50,6 +163,25 @@ document.addEventListener("DOMContentLoaded", function(event) {
}



function deleteContact(idp,username){
var baseUrl = OC.generateUrl('/apps/sciencemesh');
var data = 'idp=' + encodeURIComponent(idp) + '&username=' + encodeURIComponent(username);
$.ajax({
url: baseUrl + '/contact/deleteContact',
type: 'POST',
contentType: 'application/x-www-form-urlencoded',
data:data
}).done(function (response) {
if (response === '' || response === false) {
console.log('failed');
}else{
console.log(response);
}
}).fail(function (response, code) {
alert('The token is invalid')
});
}
function secondsToDhms(seconds) {
seconds = Number(seconds);
var d = Math.floor(seconds / (3600 * 24));
Expand Down Expand Up @@ -82,29 +214,55 @@ document.addEventListener("DOMContentLoaded", function(event) {
</tr>`;
$('#show_result').show();
} else {
let acceptedUsers = JSON.parse(response);
let result = '';
for(i in acceptedUsers) {
var displayName = acceptedUsers[i].display_name;
var username = acceptedUsers[i].id.opaque_id;
var idp = acceptedUsers[i].id.idp;
var provider = (idp.startsWith("http") ? new URL(idp).host : idp);
result += `
let token = JSON.parse(response);

if(token.length) {
for(tokenData in token) {
let acceptedUsers = JSON.parse(response);
let result = '';
for(i in acceptedUsers) {
var displayName = acceptedUsers[i].display_name;
var username = acceptedUsers[i].id.opaque_id;
var idp = acceptedUsers[i].id.idp;
var provider = (idp.startsWith("http") ? new URL(idp).host : idp);
result += `
<tr>
<td style="border-radius:100%">
<p class="icon-contacts-dark contacts-profile-img"></p>
</td>
<td class="app-content-list-item-line-one contact-item">
<p class="displayname">${displayName}</p>
</td>
<td>
<p class="username-provider">${username}@${provider}</p>
</td>
<td>
<button type="button" class="deleteContact" data-username="${username}" data-idp="${idp}">Unfriend</button>
</td>
</tr>
`;
}
var element = document.getElementById("show_result");
element.innerHTML = result;

var button = $(".deleteContact");
button.each(function( index , ele) {
ele.addEventListener("click", function() {
deleteContact($(this).data('idp'),$(this).data('username'));
});
});
}
}else{
const result = `
<tr>
<td style="border-radius:100%">
<p class="icon-contacts-dark contacts-profile-img"></p>
</td>
<td class="app-content-list-item-line-one contact-item">
<p class="displayname">${displayName}</p>
</td>
<td>
<p class="username-provider">${username}@${provider}</p>
<p class="username-provider">There are no contacts!</p>
</td>
</tr>
`;
</tr>`;
var element = document.getElementById("show_result");
element.innerHTML = result;

}
var element = document.getElementById("show_result");
element.innerHTML = result;

$('#show_result').show();
}
Expand All @@ -113,4 +271,4 @@ document.addEventListener("DOMContentLoaded", function(event) {
//alert('The token is invalid')
});
}
});
});
3 changes: 2 additions & 1 deletion js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
success: function onSuccess(res) {
$(".section-sciencemesh").removeClass("icon-loading");
if(res){
if (res.enabled) {
let result = JSON.parse(res)
if (result.enabled) {
var message = t(OCA.ScienceMesh.AppName, "Connection is available");
}else{
var message = t(OCA.ScienceMesh.AppName, "Connection is not available");
Expand Down
1 change: 1 addition & 0 deletions lib/AppInfo/ScienceMeshApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class ScienceMeshApp extends App {
public const APP_ID = 'sciencemesh';
public const SCIENCEMESH_POSTFIX = ' (Sciencemesh)';
public const SHARE_TYPE_REMOTE = 6;
public const SHARE_TYPE_SCIENCEMESH = 6;

Expand Down
Loading

0 comments on commit fb67458

Please sign in to comment.