Initial beta admin portal. Development depends on user interest, we may not need to switch to a separated administration vs user experience.

This commit is contained in:
xevidos 2019-02-09 16:31:40 -05:00
parent 4c46d82f03
commit e4f83699e0
4 changed files with 434 additions and 0 deletions

150
admin.php Normal file
View file

@ -0,0 +1,150 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once( 'common.php' );
if( ! isset( $_SESSION["token"] ) || ! isset( $_SESSION["user"] ) ) {
header( 'Location: index.php' );
exit();
}
checkSession();
if( ! checkAccess() ) {
?>
<p>
Error, you do not have access to the administration page.
</p>
<?php
return;
}
// Read Components, Plugins, Themes
$admin_components = Common::readDirectory( __DIR__ . "/admin/components" );
$components = Common::readDirectory(COMPONENTS);
$plugins = Common::readDirectory( PLUGINS );
$themes = Common::readDirectory( THEMES );
// Theme
$theme = THEME;
if( isset( $_SESSION['theme'] ) ) {
$theme = $_SESSION['theme'];
}
// Get Site name if set
if( defined( "SITE_NAME" ) && ! ( SITE_NAME === "" || SITE_NAME === null ) ) {
$site_name = SITE_NAME;
} else {
$site_name = "Codiad";
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo htmlentities( $site_name ); ?></title>
<?php
// Load System CSS Files
$stylesheets = array(
"jquery.toastmessage.css",
"reset.css",
"fonts.css",
"screen.css"
);
foreach( $stylesheets as $sheet ) {
if( file_exists( THEMES . "/" . $theme . "/" . $sheet ) ) {
echo( '<link rel="stylesheet" href="themes/' . $theme . '/' . $sheet . '">' );
} else {
echo( '<link rel="stylesheet" href="themes/default/' . $sheet . '">' );
}
}
$admin_stylesheets = array(
"admin/screen.css"
);
foreach( $admin_stylesheets as $sheet ) {
if( file_exists( THEMES . "/" . $theme . "/" . $sheet ) ) {
echo( '<link rel="stylesheet" href="themes/' . $theme . '/' . $sheet . '">' );
} else {
echo( '<link rel="stylesheet" href="themes/default/' . $sheet . '">' );
}
}
?>
<script>
codiad = {};
</script>
</head>
<body>
<script>
var i18n = (function(lang) {
return function(word,args) {
var x;
var returnw = (word in lang) ? lang[word] : word;
for(x in args){
returnw=returnw.replace("%{"+x+"}%",args[x]);
}
return returnw;
}
})(<?php echo json_encode($lang); ?>)
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/jquery-1.7.2.min.js"%3E%3C/script%3E'));</script>
<script src="js/jquery-ui-1.8.23.custom.min.js"></script>
<script src="js/jquery.css3.min.js"></script>
<script src="js/jquery.easing.js"></script>
<script src="js/jquery.toastmessage.js"></script>
<script src="js/jquery.ui.touch-punch.min.js"></script>
<script src="js/amplify.min.js"></script>
<script src="js/localstorage.js"></script>
<script src="js/jquery.hoverIntent.min.js"></script>
<script src="js/system.js"></script>
<script src="js/sidebars.js"></script>
<script src="js/modal.js"></script>
<script src="js/message.js"></script>
<script src="js/jsend.js"></script>
<script src="js/instance.js?v=<?php echo time(); ?>"></script>
<script src="admin/js/admin.js"></script>
<div id="message"></div>
<a class="mobile_menu_trigger">&#9776;</a>
<section class="container">
<div class="sidebar" id="sidebar">
<div class="sidebar_menu">
<div class="mobile_menu_close"><a class="sidebar_option" style="text-align: right;padding-right: 5%;">&times;</a></div>
<div class="sidebar_option option_selected"><a class="sidebar_option">Dashboard</a></div>
</div>
</div>
<div class="content">
<p>testig</p>
</div>
</section>
<?php
// JS
foreach( $admin_components as $component ) {
if( file_exists( __DIR__ . "/admin/components" . "/" . $component . "/init.js" ) ) {
echo( '<script src="admin/components/' . $component . '/init.js"></script>"' );
}
}
?>
</body>
</html>

View file

@ -0,0 +1,58 @@
( function( global, $ ) {
// Define core
let codiad = global.codiad,
scripts = document.getElementsByTagName( 'script' ),
path = scripts[scripts.length-1].src.split( '?' )[0],
curpath = path.split( '/' ).slice( 0, -1 ).join( '/' ) + '/';
$( function() {
codiad.admin.navigation.init();
});
codiad.admin.navigation = {
path: curpath,
init() {
this.add_listeners();
},
add_listeners() {
let _this = codiad.admin.navigation;
$( ".mobile_menu_close" ).on( "click", _this.close_nav );
$( ".mobile_menu_trigger" ).on( "click", _this.trigger_nav );
},
close_nav() {
$( "#sidebar" ).css( "width", "0px" );
$( ".container .content" ).off( "click", _this.close_nav );
},
open_nav() {
$( "#sidebar" ).css( "width", "250px" );
$( ".container .content" ).on( "click", _this.close_nav );
},
trigger_nav() {
let _this = codiad.admin.navigation;
let width = $( "#sidebar" ).width();
$( ".content" ).html( width )
if( width > 0 ) {
_this.close_nav();
} else {
_this.open_nav();
}
}
};
})( this, jQuery );

22
admin/js/admin.js Normal file
View file

@ -0,0 +1,22 @@
( function( global, $ ) {
// Define core
let codiad = global.codiad,
scripts = document.getElementsByTagName( 'script' ),
path = scripts[scripts.length-1].src.split( '?' )[0],
curpath = path.split( '/' ).slice( 0, -1 ).join( '/' ) + '/';
$( function() {
codiad.admin.init();
});
codiad.admin = {
path: curpath,
init: function() {
},
};
})( this, jQuery );

View file

@ -0,0 +1,204 @@
div.sidebar {
border-right: groove;
display: block;
float: left;
height: 100%;
left: 0px;
margin: 0px 0px 0px 0px;
overflow-x: hidden;
overflow-y: scroll;
position: fixed;
top: 0px;
width: 250px;
}
div.sidebar::-webkit-scrollbar {
display: none;
}
.mobile_menu_close {
display: none;
}
.mobile_menu_trigger {
display: block;
float: right;
margin: 10px 10px 0 0;
}
div.sidebar_menu {
padding-top: 20px;
display: block;
width: auto;
}
.sidebar_icon {
display: inline-block;
height: 30px;
margin-right: 5px;
width: auto;
vertical-align: middle;
}
.sidebar_option_text {
display: inline-block;
margin: 0px;
vertical-align: middle;
}
div.sidebar_option {
border: none;
float: none;
outline: none;
padding: 0px;
text-align: left;
white-space: normal;
width: 100%;
}
div.sidebar_option:hover {
background: #555;
-webkit-transition: background .5s; /* Safari */
transition: background .5s;
}
a.sidebar_option {
color: #FFFFFF;
display: block;
margin: 5px 20px 5px 20px;
padding: 10px 0px 10px 0px;
text-decoration: none;
width: 100%;
}
.option_selected {
background: #555;
}
li.menu_option:hover {
background: #555;
-webkit-transition: background 1s; /* Safari */
transition: background 1s;
}
section.container {
display: block;
padding: 25px 0px 0px 22%;
}
@media only screen and (max-width: 1080px) {
div.dashboard_card {
width: 90%;
}
}
@media only screen and (max-width: 750px) {
header {
min-height: 50px;
right: 0px;
max-width: 100%;
}
nav.fixed_header {
width: 1000%;
height: 60px;
background: #292f36;
position: fixed;
}
section.container {
display: block;
padding: 25px 0px 0px 5%;
}
.mobile_menu_trigger {
display: block;
}
.mobile_menu_close {
border: none;
display: flex !important;
float: none;
outline: none;
padding: 0px;
text-align: left;
white-space: normal;
width: 100%;
}
div.sidebar {
background: #333333;
height: 100%;
left: 0;
overflow-x: hidden;
padding-top: 0px;
position: fixed;
top: 0;
transition: 0.5s;
width: 0px;
z-index: 1;
}
div.sidebar::-webkit-scrollbar {
display: none;
}
div.sidebar_menu {
padding-top: 0px;
display: block;
width: auto;
}
a.sidebar_option {
display: block;
margin: 0px 0px 10px 0px;
padding: 8px 8px 8px 32px;
text-decoration: none;
transition: 0.3s;
width: 80%;
}
section.footer {
background-color: #292f36;
bottom: 0px;
display: block;
margin-left: 10px;
margin-top: 10px;
position: fixed;
right: 0px;
width: 100%;
}
}
@media only screen and (max-width: 500px) {
td {
display: block;
}
}