Implemented basic functions for reject/approve accounts
This commit is contained in:
parent
8e1cc50c74
commit
3cb026382f
18
css/base.php
18
css/base.php
|
@ -48,8 +48,16 @@ body {
|
|||
}
|
||||
.btn {
|
||||
padding: .5em 1em;
|
||||
}
|
||||
button, .btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
.textbox {
|
||||
background: #e8e8e8;
|
||||
padding: 1em;
|
||||
border-radius: .3em;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
textarea {
|
||||
max-width: -moz-available;
|
||||
|
@ -124,6 +132,16 @@ a {
|
|||
margin: 0 auto;
|
||||
padding-top: 1em;
|
||||
}
|
||||
#window-instance #container #new-accounts .card {
|
||||
background: #fff;
|
||||
padding: 1em;
|
||||
margin-bottom: 1em;
|
||||
width: calc(100vw - 4em);
|
||||
max-width: 40em;
|
||||
}
|
||||
#window-instance #container #new-accounts .card > div {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
@media (max-width: 400px) {
|
||||
#window-instance #tabs .item {
|
||||
float: inherit;
|
||||
|
|
|
@ -20,6 +20,7 @@ window.consts = {
|
|||
}
|
||||
};
|
||||
window.view = {};
|
||||
window.cache = {};
|
||||
</script>
|
||||
<script>
|
||||
function apcontrol_title(str) {
|
||||
|
|
21
js/base.php
21
js/base.php
|
@ -58,6 +58,20 @@ var E = {
|
|||
elem.innerText = cback;
|
||||
else elem.innerHTML = cback(tpl);
|
||||
},
|
||||
http_template: function(name, cback) {
|
||||
const slug = 'html_cache__'+name.replaceAll('/','--');
|
||||
if (window.cache.http === undefined)
|
||||
window.cache.http = {};
|
||||
if (window.cache.http[slug] !== undefined)
|
||||
return cback(window.cache.http[slug]);
|
||||
|
||||
http.get('js/templates/'+name+'.html',
|
||||
{}, function(data) {
|
||||
data = data.trim();
|
||||
window.cache.http[slug] = data;
|
||||
cback(data);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
function isVisible(element) {
|
||||
|
@ -117,6 +131,13 @@ function _get_func_params(func) {
|
|||
return params;
|
||||
}
|
||||
|
||||
function get_hash_arguments() {
|
||||
var args = window.location.hash.substring(1).trim().split('/');
|
||||
if (args.length > 0 && args[0].trim() === '')
|
||||
args = [];
|
||||
return parse_hash_arguments(args[args.length-1]);
|
||||
}
|
||||
|
||||
function parse_ini_config(str) { return parse_hash_arguments(str, '\n') }
|
||||
function parse_hash_arguments(str,by) {
|
||||
by = by || ';';
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<div id="new-accounts"></div>
|
||||
<div id="new-accounts-item" data-id="user-{id}">
|
||||
<div class="card">
|
||||
<h4>{username}</h4>
|
||||
<div style="color:#686868">
|
||||
<span>{email}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span>{ip_address}</span>
|
||||
<button onclick="">+info</button>
|
||||
</div>
|
||||
<br>
|
||||
<div class="textbox">
|
||||
<span>{text}</span>
|
||||
</div>
|
||||
<br>
|
||||
<div class="flex">
|
||||
<button onclick="window.view.instance.do.new_accounts.reject('{id}')"
|
||||
class="btn w100">REJECT</button>
|
||||
<button onclick="window.view.instance.do.new_accounts.approve('{id}')"
|
||||
class="btn w100">ACCEPT</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,7 +1,7 @@
|
|||
<div class="hmax">
|
||||
<div id="tabs"></div>
|
||||
<div id="tabs-item" data-id="{id}">
|
||||
<a href="javascript:window.view.instance.paint('{id}')">
|
||||
<a href="javascript:window.view.instance.load_content('{id}')">
|
||||
<div class="tab-content">
|
||||
<i class="fa fa-{icon} fa-fw"></i>
|
||||
<span>{title}</span>
|
||||
|
@ -18,20 +18,66 @@ window.view.instance = {
|
|||
show_config: function() {
|
||||
window.location.hash = window.location.hash.replace('#instance/','#instance_config/');
|
||||
},
|
||||
paint: function(content) {
|
||||
do: {
|
||||
new_accounts: {
|
||||
approve: function(_id) {
|
||||
window.view.instance.do.new_accounts._perform('approve', _id);
|
||||
},
|
||||
reject: function(_id) {
|
||||
window.view.instance.do.new_accounts._perform('reject', _id);
|
||||
},
|
||||
_perform: function(action, _id) {
|
||||
const hargs = get_hash_arguments();
|
||||
http.get(`api/v1/http/${hargs.software}/accounts/${action}/?instance=${hargs.instance}&id=${_id}`,
|
||||
{}, function(js) {
|
||||
E.removeAll(`#user-${_id}`);
|
||||
// TODO: do a animation to remove stuff
|
||||
console.log(js);
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
load: {
|
||||
new_accounts: function() {
|
||||
const hargs = get_hash_arguments();
|
||||
E.http_template('instance/new-account', function(html) {
|
||||
E.element('#window-instance #container').innerHTML = html;
|
||||
http.get(`api/v1/database/${hargs.software}/get-pending-users/?instance=${hargs.instance}`,
|
||||
{}, function(js) {
|
||||
E.template('new-accounts', function(TPL) {
|
||||
var html = '';
|
||||
for (var i = 0; i < js.length; i++) {
|
||||
var tpl = TPL;
|
||||
tpl = tpl.replaceAll('{id}', js[i].id);
|
||||
tpl = tpl.replaceAll('{text}', html2text(js[i].text));
|
||||
tpl = tpl.replaceAll('{email}', html2text(js[i].email));
|
||||
tpl = tpl.replaceAll('{username}', html2text(js[i].username));
|
||||
tpl = tpl.replaceAll('{ip_address}', html2text(js[i].sign_up_ip));
|
||||
html += tpl;
|
||||
}
|
||||
return html;
|
||||
});
|
||||
console.log(js);
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
load_content: function(content) {
|
||||
switch (content) {
|
||||
case 'home':
|
||||
window.location.hash = '#home';
|
||||
return;
|
||||
case 'settings':
|
||||
return window.view.instance.show_config();
|
||||
default:
|
||||
return window.view.instance
|
||||
.load[content.replaceAll('-','_')]();
|
||||
}
|
||||
console.log(content);
|
||||
},
|
||||
};
|
||||
function title__instance() {}
|
||||
function load__instance(args) {
|
||||
const hargs = parse_hash_arguments(args[1]);
|
||||
const hargs = get_hash_arguments();
|
||||
|
||||
const _error400 = function(msg) {
|
||||
msg = msg || 'Parameters are not correct';
|
||||
|
|
|
@ -41,7 +41,7 @@ window.view.instance_config = {
|
|||
}
|
||||
function title__instance_config() {}
|
||||
function load__instance_config(args) {
|
||||
const hargs = parse_hash_arguments(args[1]);
|
||||
const hargs = get_hash_arguments();
|
||||
|
||||
const _error400 = function(msg) {
|
||||
msg = msg || 'Parameters are not correct';
|
||||
|
|
Loading…
Reference in New Issue