Skip to content

Commit

Permalink
GSOC project : Updater for LibreEHR using github API (#1122)
Browse files Browse the repository at this point in the history
* updater icon added

* administration panel - step one

* review changes

* user control panel added

* loader added to load templates

* saving the changes

* Updater settings Module Implemented

* bug fix in updater setting

* backup the local changes to branch

* progress towards user mode

* fix

* saving the progress

* saving progress  - downloading files

* downloading and backup files - progress

* backup, download functions added

* replacement function progress

* enabling backup functions

* clearing backup as well as download directory before updating

* user mode almost ready

* ui for user mode

* preparing for review

* db changes for review

* db patch

* db mistake correction

* add download and backup directory

* fix for updater : show when repo is already up to date

* developer mode ui added

* bug fix during file addition

* loader icon added

* missed comma

* fix

* prevent deletion of readme.md

* sql bindings done

* copyright information - done

* send notification on update

* developer mode initialisation

* developer mode  - progress save

* missed semicolon

* clearing errors

* developer mode - experimental

* validation for developer mode

* prevent developer mode to sync from start

* show progress when developer mode is running

* progress showing in developer mode

* adding restore button to the developer mode

* wrong button id -fixed

* error in sql statement fixed

* review system from client was added

* error in sql statement - fixed

* fix the broken features

* settings.json PR number changed

* translating text - stage one

* translations - second phase

* Updater icon toggle

* pr number showing on developer mode
  • Loading branch information
naveen17797 authored and aethelwulffe committed Jul 13, 2018
1 parent e2e17f4 commit cacaa71
Show file tree
Hide file tree
Showing 27 changed files with 2,354 additions and 5 deletions.
161 changes: 159 additions & 2 deletions interface/main/tabs/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/* for getPnotesByUser(). */
require_once($GLOBALS['srcdir'] . '/pnotes.inc');
$esignApi = new Api();

require '../../../updater/lib/updater_functions.php';
?>
<!DOCTYPE html>
<title><?php echo $GLOBALS['libreehr_name'];?></title>
Expand Down Expand Up @@ -58,7 +58,7 @@ function isEncounterLocked( encounterId ) {

<?php
/* Include Bootstrap, Knockout Libraries and Font Awesome library */
call_required_libraries(array("jquery-min-3-1-1","bootstrap","knockout", "font-awesome"));
call_required_libraries(array("jquery-min-3-1-1","bootstrap","knockout", "font-awesome", "iziModalToast"));
?>

<script type="text/javascript" src="js/custom_bindings.js"></script>
Expand Down Expand Up @@ -243,5 +243,162 @@ function isEncounterLocked( encounterId ) {


</script>
<?php

$userAuthorized = $_SESSION['userauthorized'];
$authUserId = $_SESSION['authUserID'];
$sql = sqlQuery("SELECT gl_value FROM globals WHERE gl_name = ?", array("updater_icon_visibility") );
$updater_icon_visibility = $sql['gl_value'];
if ($updater_icon_visibility == 1) {
$show_icon = true;
}
else {
$show_icon = false;
}
if(checkAdmin($userAuthorized, $authUserId) && $show_icon) {
//only admin can use the updater
echo "<div id='developer-mode' title='Developer Mode' style='display: none;'><i class='fa fa-code'></i></div>
<div id='updater-options' style='display: none;' title='updater settings'><i class='fa fa-gear'></i></div><div id='updater-icon'>
<i class='fa fa-refresh'></i>
</div>
<div id='updater-iframe'></div>
<div id='updater-settings-iframe'></div>
<div id='developer-mode-iframe'></div>";
}
?>
<?php do_action( 'after_main_box' ); ?>
<style type="text/css">
#updater-icon, #updater-options, #developer-mode {
position: fixed; /* Fixed/sticky position */
bottom: 20px; /* Place the button at the bottom of the page */
right: 30px; /* Place the button 30px from the right */
z-index: 99; /* Make sure it does not overlap */
border: none; /* Remove borders */
outline: none; /* Remove outline */
background-color: #F69600; /* Set a background color */
color: white; /* Text color */
cursor: pointer; /* Add a mouse pointer on hover */
padding: 15px; /* Some padding */
border-radius: 40px; /* Rounded corners */
font-size: 18px; /* Increase font size */
}
#updater-options, #developer-mode {
border: 2px solid #000;
background-color: #F69600;
padding: 5px;
border-radius: 40%;
bottom: 90px; /* Place the button at the bottom of the page */
right: 30px; /* Place the button 30px from the right */
}

#developer-mode {
right: 70px;
font-size: 15px;
bottom: 70px;
}
</style>
<script>
$("#updater-settings-iframe").iziModal({
title: '<i class="fa fa-refresh"></i> <?php echo xlt("Settings for Updater"); ?>',
subtitle: '<?php echo xlt("Configuration settings for updater"); ?>',
headerColor: '#F69600',
closeOnEscape: true,
fullscreen:true,
overlayClose: false,
closeButton: true,
theme: 'dark', // light
iframe: true,
width:900,
focusInput: true,
padding:5,
iframeHeight: 400,
iframeURL: "<?php echo $GLOBALS['webroot']; ?>/updater/index.php"
});

$("#developer-mode-iframe").iziModal({
title: '<i class="fa fa-code"></i> <?php echo xlt("Developer Options"); ?>',
subtitle: '<?php echo xlt("Developer Mode in the Updater"); ?>',
headerColor: '#F69600',
closeOnEscape: true,
fullscreen:true,
overlayClose: false,
closeButton: true,
theme: 'dark', // light
iframe: true,
width:900,
focusInput: true,
padding:5,
iframeHeight: 400,
onOpening: function () {
var imageURL = "../../../updater/updater_loading.gif";
$('.iziModal-content').css("background-image", "url("+imageURL+")");
},
iframeURL: "<?php echo $GLOBALS['webroot']; ?>/updater/developer_mode.php"
});
$("#updater-iframe").iziModal({
title: '<i class="fa fa-refresh"></i> <?php echo xlt("Updater"); ?>',
subtitle: '<?php echo xlt("Updater for entire application"); ?>',
headerColor: '#F69600',
closeOnEscape: true,
fullscreen:true,
overlayClose: false,
closeButton: true,
theme: 'dark', // light
iframe: true,
width:900,
focusInput: true,
padding:5,
iframeHeight: 400,
iframeURL: "<?php echo $GLOBALS['webroot']; ?>/updater/updater.php",
onOpening: function () {
var imageURL = "../../../updater/updater_loading.gif";
$('.iziModal-content').css("background-image", "url("+imageURL+")");
}
});
$('#developer-mode').click(function () {
$("#developer-mode-iframe").iziModal('open');
});
$('#updater-options').click(function () {
$('#updater-settings-iframe').iziModal('open');
});

$('#updater-icon').hover(function () {
$(this).css("border", "2px solid #000");
$('#developer-mode').fadeIn(100);
$('#updater-options').fadeIn(100);
});
$('#updater-icon').click(function () {
$('#updater-iframe').iziModal('open');
});
$('body').hover(function () {
$('#developer-mode').css("display", "none");
$('#updater-options').css("display", "none");
$(this).css("border", "0px solid #000");
});
function showUpdaterNotifications(type, title, message) {
if (type == "warning") {
iziToast.warning({
title: title,
message: message,
});
}
if (type == "success") {
iziToast.success({
title: title,
message: message,
});
}
if (type == "info") {
iziToast.info({
title: title,
message: message,
});
}
if (type == "error") {
iziToast.error({
title: title,
message: message,
});
}
}
</script>
10 changes: 7 additions & 3 deletions interface/super/edit_globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ function checkBackgroundServices(){
$boolean = false;
}
}
elseif ($fldid == "updater_icon_visibility") {
//updater icon visibility
$boolean = true;
}
elseif ($fldid == "primary_color" || $fldid == "primary_font_color" || $fldid == "secondary_color" || $fldid == "secondary_font_color" ) {
if (strlen($_POST["form_$i"]) == 7 && substr($_POST["form_$i"], 0,1) == "#") {
$boolean = true;
Expand All @@ -155,9 +159,9 @@ function checkBackgroundServices(){
}
}
if ($boolean) {
$label = "global:".$fldid;
$fldvalue = trim(strip_escape_custom($_POST["form_$i"]));
setUserSetting($label,$fldvalue,$_SESSION['authId'],FALSE);
$label = "global:".$fldid;
$fldvalue = trim(strip_escape_custom($_POST["form_$i"]));
setUserSetting($label,$fldvalue,$_SESSION['authId'],FALSE);
}
if ( $_POST["toggle_$i"] == "YES" ) {
removeUserSetting($label);
Expand Down
8 changes: 8 additions & 0 deletions library/globals.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,14 @@
xl('EDI History (under Fees) for storing and interpreting EDI claim response files')
),

//SHOW UPDATER ICON
'updater_icon_visibility' => array(
xl('Show updater floating action button'),
'bool', // data type
'1', // default = true
xl('The Updater Floating Action Button at the bottom of the screen')
),

'online_support_link' => array(
xl('Online Forum Support Link'),
'text', // data type
Expand Down
41 changes: 41 additions & 0 deletions sql/2_0_0-to-2_0_1_upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,46 @@ DROP TABLE IF EXISTS `menu_trees`;

DROP TABLE IF EXISTS `menu_entries`;

#IfNotTable updater_users
CREATE TABLE `updater_users` (
`authUserId` int(11) NOT NULL,
`date` datetime NOT NULL
) ENGINE=InnoDB;
#EndIf

#IfNotTable updater_settings
CREATE TABLE `updater_settings` (
`name` varchar(255) NOT NULL,
`value` varchar(255) NOT NULL
) ENGINE=InnoDB;
#EndIf

#IfNotTable updater_user_mode_download_entry
--
-- Table structure for table `updater_user_mode_download_entry`
--

CREATE TABLE `updater_user_mode_download_entry` (
`filename` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
`original_name` varchar(255) NOT NULL,
`old_name` varchar(255) NOT NULL
) ENGINE=InnoDB;
#Endif

#IfNotTable updater_user_mode_backup_entry
--
-- Table structure for table `updater_user_mode_download_entry`
--

CREATE TABLE `updater_user_mode_backup_entry` (
`filename` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
`original_name` varchar(255) NOT NULL,
`old_name` varchar(255) NOT NULL
) ENGINE=InnoDB;
#Endif

#IfMissingColumn form_misc_billing_options onset_date
ALTER TABLE `form_misc_billing_options` ADD `onset_date` DATE NOT NULL ;
#EndIf
Expand Down Expand Up @@ -147,3 +187,4 @@ INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`
#IfMissingColumn libreehr_postcalendar_events cancel_reason
ALTER TABLE `libreehr_postcalendar_events` ADD `cancel_reason` text NOT NULL ;
#EndIf

42 changes: 42 additions & 0 deletions sql/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7654,3 +7654,45 @@ CREATE TABLE `form_clinical_instructions` (
`activity` TINYINT DEFAULT 1 NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB;

--
-- Table structure for table `updater_users`
--
DROP TABLE IF EXISTS `updater_users`;
CREATE TABLE `updater_users` (
`authUserId` int(11) NOT NULL,
`date` datetime NOT NULL
) ENGINE=InnoDB;


--
-- Table structure for table `updater_settings`
--
DROP TABLE IF EXISTS `updater_settings`;
CREATE TABLE `updater_settings` (
`name` varchar(255) NOT NULL,
`value` varchar(255) NOT NULL
) ENGINE=InnoDB;


--
-- Table structure for table `updater_user_mode_download_entry`
--
DROP TABLE IF EXISTS `updater_user_mode_download_entry`;
CREATE TABLE `updater_user_mode_download_entry` (
`filename` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
`original_name` varchar(255) NOT NULL,
`old_name` varchar(255) NOT NULL
) ENGINE=InnoDB;

--
-- Table structure for table `updater_user_mode_backup_entry`
--
DROP TABLE IF EXISTS `updater_user_mode_backup_entry`;
CREATE TABLE `updater_user_mode_backup_entry` (
`filename` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
`original_name` varchar(255) NOT NULL,
`old_name` varchar(255) NOT NULL
) ENGINE=InnoDB;
Loading

0 comments on commit cacaa71

Please sign in to comment.