From c8493d4940ac11d242caddcf41ff06013ce9f856 Mon Sep 17 00:00:00 2001 From: dejande <159643@gmail.com> Date: Fri, 21 Nov 2014 14:29:47 +0100 Subject: [PATCH] In log details view I added the print log button. By clicking on it new window opens and in it there are all log's details including attachments --- Olog/public_html/index.html | 11 +- Olog/public_html/modify_log.html | 7 +- Olog/public_html/new_log.html | 7 +- Olog/public_html/print_log.html | 81 +++++ Olog/public_html/static/css/print_style.css | 22 ++ Olog/public_html/static/css/style.css | 2 +- Olog/public_html/static/js/common.js | 227 +------------ Olog/public_html/static/js/configuration.js | 334 ++++++++++---------- Olog/public_html/static/js/helper.js | 287 +++++++++++++++++ Olog/public_html/static/js/index.js | 2 +- Olog/public_html/static/js/multilist.js | 56 ---- Olog/public_html/static/js/print_log.js | 24 ++ Olog/public_html/static/js/rest.js | 22 +- 13 files changed, 614 insertions(+), 468 deletions(-) create mode 100644 Olog/public_html/print_log.html create mode 100644 Olog/public_html/static/css/print_style.css create mode 100644 Olog/public_html/static/js/helper.js create mode 100644 Olog/public_html/static/js/print_log.js diff --git a/Olog/public_html/index.html b/Olog/public_html/index.html index d2182de..ca11068 100644 --- a/Olog/public_html/index.html +++ b/Olog/public_html/index.html @@ -32,14 +32,14 @@
  • -
    - +
    +
    @@ -118,7 +118,7 @@
    Filter Log Entries
    @@ -227,6 +227,7 @@
    , + diff --git a/Olog/public_html/modify_log.html b/Olog/public_html/modify_log.html index c8d0861..473f24b 100644 --- a/Olog/public_html/modify_log.html +++ b/Olog/public_html/modify_log.html @@ -39,13 +39,13 @@ @@ -170,6 +170,7 @@
    Quickly add or remove + diff --git a/Olog/public_html/new_log.html b/Olog/public_html/new_log.html index 94d08f0..f727cc2 100644 --- a/Olog/public_html/new_log.html +++ b/Olog/public_html/new_log.html @@ -39,13 +39,13 @@ @@ -175,6 +175,7 @@
    Quickly add + diff --git a/Olog/public_html/print_log.html b/Olog/public_html/print_log.html new file mode 100644 index 0000000..4fb4719 --- /dev/null +++ b/Olog/public_html/print_log.html @@ -0,0 +1,81 @@ + + + + Olog + + + + + + + + + + + + + + + +
    +
    +

    Log id: , Log version:

    +
    +
    +

    Owner:

    +
    +
    +

    Log created:

    +
    +
    +

    Level:

    +
    +
    +

    Logbooks:

    +
    +
    +

    Tags:

    +
    +
    +

    + Description: +
    + +

    +
    +
    + Attachments: +
    + +
    +
    +
    +

    Date printed:

    +
    +
    + + +
    + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Olog/public_html/static/css/print_style.css b/Olog/public_html/static/css/print_style.css new file mode 100644 index 0000000..de7b779 --- /dev/null +++ b/Olog/public_html/static/css/print_style.css @@ -0,0 +1,22 @@ +/* + * Common styles used in all files + * + * @author: Dejan Dežman + * @created: 2014-11-21 + */ + +html, body { + margin: 0; + padding: 0; + height: 100%; + width: 100%; +} + +.container { + margin-top: 20px; + margin-bottom: 20px; +} + +.bold { + font-weight: bold; +} \ No newline at end of file diff --git a/Olog/public_html/static/css/style.css b/Olog/public_html/static/css/style.css index fdf1c86..5d788ec 100644 --- a/Olog/public_html/static/css/style.css +++ b/Olog/public_html/static/css/style.css @@ -1,7 +1,7 @@ /* * Common styles used in all files * - * @author: Dejan Dežman + * @author: Dejan Dežman */ html, body { diff --git a/Olog/public_html/static/js/common.js b/Olog/public_html/static/js/common.js index 85e39c0..a7bce06 100644 --- a/Olog/public_html/static/js/common.js +++ b/Olog/public_html/static/js/common.js @@ -97,223 +97,6 @@ $(document).ready(function(){ startListeningForToggleFilterClicks(); }); -/** - * Write logs to Chrome or Firefox console - * @param input input string - */ -function l(input) { - - if(writeLogs === true) { - console.log(input); - } -} - -/** - * Make the first letter in every word uppercase - * @param {type} input input string - * @returns {string} output string - */ -function firstLetterToUppercase(input) { - input = input.toLowerCase().replace(/\b[a-z]/g, function(letter) { - return letter.toUpperCase(); - }); - - return input; -} - -/** - * Trim spaces from the start and the end of the string - * @param {type} str input string - * @returns {unresolved} string without spaces in the start and at the end of string - */ -function trim(str) { - str = str.replace(/^\s+/, ''); - for (var i = str.length - 1; i >= 0; i--) { - if (/\S/.test(str.charAt(i))) { - str = str.substring(0, i + 1); - break; - } - } - return str; -} - -/** - * Convert time filter from the left pane to the actual time - * @param {type} from from time filter group - * @param {type} to to time filter group - */ -function returnTimeFilterTimestamp(from, to) { - var reg = null; - var searchParts = [""]; - var fromSeconds = 0; - var toSeconds = 0; - var currentSeconds = Math.round((new Date().getTime())/1000); - - // Check if from is defined - if(from !== undefined) { - reg = new RegExp('last (\\d+) (\\w+).*', "i"); - searchParts = reg.exec(from); - - if(searchParts !== null) { - - if(searchParts[0] !== "") { - fromSeconds = parseInt(searchParts[1] * eval(timeFilter[searchParts[2]])); - } - - } else { - var parseFrom = moment(from, datePickerDateFormatMometParseString); - from = Math.round((parseFrom.toDate().getTime())/1000); - fromSeconds = currentSeconds - from; - } - } - - // Check if to is defined - if(to !== undefined) { - reg = new RegExp('(\\d+) (\\w+) ago.*', "i"); - searchParts = reg.exec(to); - - if(searchParts !== null) { - - if(searchParts[0] !== "") { - toSeconds = parseInt(searchParts[1] * eval(timeFilter[searchParts[2]])); - } - - } else { - var parseTo = moment(to, datePickerDateFormatMometParseString); - to = Math.round((parseTo.toDate().getTime())/1000); - toSeconds = currentSeconds - to; - } - } - - return [currentSeconds - fromSeconds, currentSeconds - toSeconds]; -} - -/* - * Retun first X words from the string. - * @param {type} string input string - * @param {type} count how many of words do we want to return - * @returns {String} First X words - */ -function returnFirstXWords(string, count){ - var words = string.split(" "); - var summary = ""; - var append = ""; - - if (count > words.length) { - count = words.length; - - } else { - append = " ..."; - } - - if(words.length > 0){ - summary = words[0]; - - if(words.length > 1){ - for(i=1; i"; - } - return lines.join('\r\n'); -} - -/** - * Convert string from html to text - * @param {type} value input value - * @returns textual presentation of html - */ -function htmlEncode(value) { - return $('
    ').text(value).html(); -} - -/** - * Is file we want to upload image or not - * @param {type} type MIME type string - * @returns {Boolean} is mimetype an image or not - */ -function isImage(type) { - typeParts = type.split("/"); - - if(typeParts.length === 2 && typeParts[0] === "image") { - return true; - - } else { - return false; - } -} - -/** - * Check if elements is present in the current DOM or not - * @returns {Boolean} - */ -jQuery.fn.doesExist = function(){ - return jQuery(this).length > 0; -}; - -/** - * Show error in specific error block - * @param {type} string string that describes an error - * @param {type} blockId id of the error block - * @param {type} blockBody id of the error block body - * @param {type} errorX id of the error block body close icon - * @returns {undefined} - */ -function showError(string, blockId, blockBody, errorX) { - var errorBlock = $(blockId); - var errorBody = $(blockBody); - var errorX = $(errorX); - - errorBody.html(string); - errorBlock.show("fast"); - - errorX.click(function(e) { - errorBlock.hide("fast"); - }); -} - -/** - * If input string looks like a link, surround it with tag - * @param {type} input input strig that is checked if it looks like a real link. - * @returns {String|checkIfLink.input} - */ -function checkIfLink(input) { - - if(input.toLowerCase().indexOf("http") === 0) { - return '' + input + ''; - - } else { - return input; - } -} - /** * Initialize pans resize listener. * @@ -532,6 +315,7 @@ function removeHtmlTags(input) { * Disable creating new Logs, Logbooks, Tags and mofidying them */ function disableCreatingNewAndModifying() { + $('#add_btn_group').css("z-index", "-1"); $('#new_log').addClass("disabled"); $('#new_log').attr("disabled", true); $('#new_logbook_and_tag').addClass("disabled"); @@ -543,6 +327,7 @@ function disableCreatingNewAndModifying() { * Enable creating Logs, Logbooks, Tags and modifying them */ function enableCreatingAndModifying() { + $('#add_btn_group').css("z-index", "5"); $('#new_log').removeClass("disabled"); $('#new_log').attr("disabled", false); $('#new_logbook_and_tag').removeClass("disabled"); @@ -567,14 +352,6 @@ function deleteFilterData() { $.removeCookie(filtersCookieName); } -/** - * Save settings data to a cookie - * @param {type} dataToBeSaved data to be saved into a cookie - */ -function saveOlogSettingsData(dataToBeSaved) { - $.cookie(settingsCookieName, JSON.stringify(dataToBeSaved)); -} - /** * * @param {type} rawId id of the first child element diff --git a/Olog/public_html/static/js/configuration.js b/Olog/public_html/static/js/configuration.js index 0fde6e0..e7dfbab 100644 --- a/Olog/public_html/static/js/configuration.js +++ b/Olog/public_html/static/js/configuration.js @@ -1,167 +1,167 @@ -/* - * Configuration file for setting global variables - * - * @author: Dejan Dežman - */ - -/** - * Variables that can be and should be configured by user - */ - - -// Version number -var version = "0.4"; - -// For accessing the REST service -var serviceurl = window.location.protocol + "//" + window.location.host + "/Olog/resources/"; - -// For all the dates shown in client -// Format docs can be found at http://momentjs.com/docs/#/displaying/format/ -var dateFormat = "M/D/YY, h:mm a"; - -// jQuery datepicker plugin has its onw date format so it is defined separately. -// Format switches can be found at http://api.jqueryui.com/datepicker/ -var datePickerDateFormat = "mm/dd/yy"; - -// jQuery timepicker plugin has its onw date format so it is defined separately. -// Format switches can be found at http://trentrichardson.com/examples/timepicker/ -var datePickerTimeFormat = "hh:mm"; - -// Date from the datepicker is put in the search input but need to be parsed -// to build a REST service query. Format documentation can be found at -// http://momentjs.com/docs/#/parsing/ -var datePickerDateFormatMometParseString = "MM/DD/YYYY hh:mm"; - -// Start of the week in the jQuery datepicker: 0: Sunday, 1: Monday, ... -var datePickerFirstName = 1; - -// How many logs do you want to load per request? -var numberOfLogsPerLoad = 20; - -// Set the name of the cookie that holds selected filters -var filtersCookieName = "filters"; - -// Set the name of the cookie that holds the user data -var sessionCookieName = "SESSION"; - -// Write logs to console -var writeLogs = true; - -// First page name -var firstPageName = "index.html"; - -// Search key map. Function will extract value from search input, try to find -// keyMap keys in it and it will generate search query by replacing keyMap keys -// with keyMap values. -var keyMap = { - 'tag:': 'tag=', - 'logbook:': 'logbook=', - 'from:': 'start=', - 'start:': 'start=', - 'end:': 'end=', - 'to:': 'end=', - 'search:': 'search=' -}; - -// Convert time filters to seconds. Forulas are evaluated and added or substracted from -// current time. -var timeFilter = { - 'min': '60', - 'mins': '60', - 'hour': '60*60', - 'hours': '60*60', - 'day': '24*60*60', - 'days': '24*60*60', - 'week': '7*24*60*60', - 'weeks': '7*24*60*60' -}; - -// Create From filter definition array. Other values can be added in this array to -// extend the functionality. -// @param name name of the filter which will be visibla by the user -// @param value value of the filter that can be parsed with the regular expression -var createdFromFilterDefinition = [ - {name:"Last min", value:"last 1 min"}, - {name:"Last hour", value:"last 1 hour"}, - {name:"Last day", value:"last 1 day"}, - {name:"Last week", value:"last 1 week"} -]; - -// Available sizes for Log attachments. These sites will be displayed in the -// Image size dropdown list. -// list: -// @param name is the name of the size that will be displayed as a list item -// @param scale is a scale, attachment will be resized to -// @param correction is a parameter that can be set to correct image sizes so they -// fit in the right pane in all browsers -// selected: -// represents the default selected size -// current: -// represents the current selected size -var imageSizes = { - list:[ - {name:'small', scale:'0.25', correction:'15'}, - {name:'medium', scale:'0.5', correction:'25'}, - {name:'large', scale:'1', correction:'0'} - ], - defaultSize:1, - current:-1 -}; - -// Map size names to list item array position -var backwardImageSizesMap = { - small:0, - medium:1, - large:2 -}; - -// Update interval in seconds. After this time has elapsed system will check if -// new Log entries were created. If updateInterval is set to -1, checking will -// be disabled. -var updateInterval = 60; - -// Settings cookie name -var settingsCookieName = "olog"; - -// Maximum width of small resolution. If Olog will be displayed in smaller -// width, panes will be stacked one upon each other and filters will be closed. -// If this constant is changes, constant should also be changed in style.css -// file. -var smallScreenResolutionWidth = 1024; - -// Available Levels -var levels = ["Info", "Problem", "Request", "Suggestion", "Urgent"]; - -/** - * Global variables needed by more than one page. SHOULD NOT BE CONFIGURED BY THE USER! - */ - -// Current Log search url -var searchURL = ""; - -// Current Log displayed -var selectedLog = ""; - -// Html file that contain modal windows -var modalWindows = "static/html/modal_windows.html"; - -// Html file that contain templates -var templates = "static/html/templates.html"; - -// Selected filter elements are saved into an object -var selectedElements = {}; - -// Olog settings that are saved in Olog settings cookie -var ologSettings = {}; - -// Should history be included by default -var includeHistory = true; - -// URL parameter for displaying log's history -var historyParameter = "history"; - -// URL parameter for displaying particular version of log entry -var versionParameter = "version"; - -// Default version order -var logVersionOrder = true; +/* + * Configuration file for setting global variables + * + * @author: Dejan Dežman + */ + +/** + * Variables that can be and should be configured by user + */ + + +// Version number +var version = "0.5"; + +// For accessing the REST service +var serviceurl = window.location.protocol + "//" + window.location.host + "/Olog/resources/"; + +// For all the dates shown in client +// Format docs can be found at http://momentjs.com/docs/#/displaying/format/ +var dateFormat = "M/D/YY, h:mm a"; + +// jQuery datepicker plugin has its onw date format so it is defined separately. +// Format switches can be found at http://api.jqueryui.com/datepicker/ +var datePickerDateFormat = "mm/dd/yy"; + +// jQuery timepicker plugin has its onw date format so it is defined separately. +// Format switches can be found at http://trentrichardson.com/examples/timepicker/ +var datePickerTimeFormat = "hh:mm"; + +// Date from the datepicker is put in the search input but need to be parsed +// to build a REST service query. Format documentation can be found at +// http://momentjs.com/docs/#/parsing/ +var datePickerDateFormatMometParseString = "MM/DD/YYYY hh:mm"; + +// Start of the week in the jQuery datepicker: 0: Sunday, 1: Monday, ... +var datePickerFirstName = 1; + +// How many logs do you want to load per request? +var numberOfLogsPerLoad = 20; + +// Set the name of the cookie that holds selected filters +var filtersCookieName = "filters"; + +// Set the name of the cookie that holds the user data +var sessionCookieName = "SESSION"; + +// Write logs to console +var writeLogs = true; + +// First page name +var firstPageName = "index.html"; + +// Search key map. Function will extract value from search input, try to find +// keyMap keys in it and it will generate search query by replacing keyMap keys +// with keyMap values. +var keyMap = { + 'tag:': 'tag=', + 'logbook:': 'logbook=', + 'from:': 'start=', + 'start:': 'start=', + 'end:': 'end=', + 'to:': 'end=', + 'search:': 'search=' +}; + +// Convert time filters to seconds. Forulas are evaluated and added or substracted from +// current time. +var timeFilter = { + 'min': '60', + 'mins': '60', + 'hour': '60*60', + 'hours': '60*60', + 'day': '24*60*60', + 'days': '24*60*60', + 'week': '7*24*60*60', + 'weeks': '7*24*60*60' +}; + +// Create From filter definition array. Other values can be added in this array to +// extend the functionality. +// @param name name of the filter which will be visibla by the user +// @param value value of the filter that can be parsed with the regular expression +var createdFromFilterDefinition = [ + {name:"Last min", value:"last 1 min"}, + {name:"Last hour", value:"last 1 hour"}, + {name:"Last day", value:"last 1 day"}, + {name:"Last week", value:"last 1 week"} +]; + +// Available sizes for Log attachments. These sites will be displayed in the +// Image size dropdown list. +// list: +// @param name is the name of the size that will be displayed as a list item +// @param scale is a scale, attachment will be resized to +// @param correction is a parameter that can be set to correct image sizes so they +// fit in the right pane in all browsers +// selected: +// represents the default selected size +// current: +// represents the current selected size +var imageSizes = { + list:[ + {name:'small', scale:'0.25', correction:'15'}, + {name:'medium', scale:'0.5', correction:'25'}, + {name:'large', scale:'1', correction:'0'} + ], + defaultSize:1, + current:-1 +}; + +// Map size names to list item array position +var backwardImageSizesMap = { + small:0, + medium:1, + large:2 +}; + +// Update interval in seconds. After this time has elapsed system will check if +// new Log entries were created. If updateInterval is set to -1, checking will +// be disabled. +var updateInterval = 60; + +// Settings cookie name +var settingsCookieName = "olog"; + +// Maximum width of small resolution. If Olog will be displayed in smaller +// width, panes will be stacked one upon each other and filters will be closed. +// If this constant is changes, constant should also be changed in style.css +// file. +var smallScreenResolutionWidth = 1024; + +// Available Levels +var levels = ["Info", "Problem", "Request", "Suggestion", "Urgent"]; + +/** + * Global variables needed by more than one page. SHOULD NOT BE CONFIGURED BY THE USER! + */ + +// Current Log search url +var searchURL = ""; + +// Current Log displayed +var selectedLog = ""; + +// Html file that contain modal windows +var modalWindows = "static/html/modal_windows.html"; + +// Html file that contain templates +var templates = "static/html/templates.html"; + +// Selected filter elements are saved into an object +var selectedElements = {}; + +// Olog settings that are saved in Olog settings cookie +var ologSettings = {}; + +// Should history be included by default +var includeHistory = true; + +// URL parameter for displaying log's history +var historyParameter = "history"; + +// URL parameter for displaying particular version of log entry +var versionParameter = "version"; + +// Default version order +var logVersionOrder = true; diff --git a/Olog/public_html/static/js/helper.js b/Olog/public_html/static/js/helper.js new file mode 100644 index 0000000..3c615d5 --- /dev/null +++ b/Olog/public_html/static/js/helper.js @@ -0,0 +1,287 @@ +/* + * Helper functions + * + * @author: Dejan Dežman + * @created: 2014-11-17 + */ + +/** + * Write logs to Chrome or Firefox console + * @param input input string + */ +function l(input) { + + if(writeLogs === true) { + console.log(input); + } +} + +/** + * Make the first letter in every word uppercase + * @param {type} input input string + * @returns {string} output string + */ +function firstLetterToUppercase(input) { + input = input.toLowerCase().replace(/\b[a-z]/g, function(letter) { + return letter.toUpperCase(); + }); + + return input; +} + +/** + * Trim spaces from the start and the end of the string + * @param {type} str input string + * @returns {unresolved} string without spaces in the start and at the end of string + */ +function trim(str) { + str = str.replace(/^\s+/, ''); + for (var i = str.length - 1; i >= 0; i--) { + if (/\S/.test(str.charAt(i))) { + str = str.substring(0, i + 1); + break; + } + } + return str; +} + +/** + * Convert time filter from the left pane to the actual time + * @param {type} from from time filter group + * @param {type} to to time filter group + */ +function returnTimeFilterTimestamp(from, to) { + var reg = null; + var searchParts = [""]; + var fromSeconds = 0; + var toSeconds = 0; + var currentSeconds = Math.round((new Date().getTime())/1000); + + // Check if from is defined + if(from !== undefined) { + reg = new RegExp('last (\\d+) (\\w+).*', "i"); + searchParts = reg.exec(from); + + if(searchParts !== null) { + + if(searchParts[0] !== "") { + fromSeconds = parseInt(searchParts[1] * eval(timeFilter[searchParts[2]])); + } + + } else { + var parseFrom = moment(from, datePickerDateFormatMometParseString); + from = Math.round((parseFrom.toDate().getTime())/1000); + fromSeconds = currentSeconds - from; + } + } + + // Check if to is defined + if(to !== undefined) { + reg = new RegExp('(\\d+) (\\w+) ago.*', "i"); + searchParts = reg.exec(to); + + if(searchParts !== null) { + + if(searchParts[0] !== "") { + toSeconds = parseInt(searchParts[1] * eval(timeFilter[searchParts[2]])); + } + + } else { + var parseTo = moment(to, datePickerDateFormatMometParseString); + to = Math.round((parseTo.toDate().getTime())/1000); + toSeconds = currentSeconds - to; + } + } + + return [currentSeconds - fromSeconds, currentSeconds - toSeconds]; +} + +/* + * Retun first X words from the string. + * @param {type} string input string + * @param {type} count how many of words do we want to return + * @returns {String} First X words + */ +function returnFirstXWords(string, count){ + var words = string.split(" "); + var summary = ""; + var append = ""; + + if (count > words.length) { + count = words.length; + + } else { + append = " ..."; + } + + if(words.length > 0){ + summary = words[0]; + + if(words.length > 1){ + for(i=1; i"; + } + return lines.join('\r\n'); +} + +/** + * Convert string from html to text + * @param {type} value input value + * @returns textual presentation of html + */ +function htmlEncode(value) { + return $('
    ').text(value).html(); +} + +/** + * Is file we want to upload image or not + * @param {type} type MIME type string + * @returns {Boolean} is mimetype an image or not + */ +function isImage(type) { + typeParts = type.split("/"); + + if(typeParts.length === 2 && typeParts[0] === "image") { + return true; + + } else { + return false; + } +} + +/** + * Check if elements is present in the current DOM or not + * @returns {Boolean} + */ +jQuery.fn.doesExist = function(){ + return jQuery(this).length > 0; +}; + +/** + * Show error in specific error block + * @param {type} string string that describes an error + * @param {type} blockId id of the error block + * @param {type} blockBody id of the error block body + * @param {type} errorX id of the error block body close icon + * @returns {undefined} + */ +function showError(string, blockId, blockBody, errorX) { + var errorBlock = $(blockId); + var errorBody = $(blockBody); + var errorX = $(errorX); + + errorBody.html(string); + errorBlock.show("fast"); + + errorX.click(function(e) { + errorBlock.hide("fast"); + }); +} + +/** + * If input string looks like a link, surround it with tag + * @param {type} input input strig that is checked if it looks like a real link. + * @returns {String|checkIfLink.input} + */ +function checkIfLink(input) { + + if(input.toLowerCase().indexOf("http") === 0) { + return '' + input + ''; + + } else { + return input; + } +} + +/** + * Close filter group and leave selected items visible + * @param {type} groupContainer container object that holds filters + */ +function closeFilterGroup(groupContainer) { + groupContainer.find('li:gt(0)').addClass('display_none'); + + // Style attribute is added when filter items are being filtered + groupContainer.find('li:gt(0)').removeAttr("style"); + groupContainer.find('li:gt(0) .multilist_clicked').parent().removeClass('display_none'); + + var arrow = groupContainer.find('li i.toggle-from'); + toggleChevron(arrow, false); + + // Check if filtersOpened is defined + if(ologSettings.filtersOpened === undefined) { + ologSettings.filtersOpened = {}; + } + + ologSettings.filtersOpened[groupContainer.attr('id')] = false; + + // Save settings into a cookie + saveOlogSettingsData(ologSettings); +} + +/** + * Toggle chevron on an element + * @param {type} element element that contains chevron + * @param openGroup define this argument if you want to enforce open/close group + */ +function toggleChevron(element, openGroup) { + + if(openGroup === undefined) { + + if($(element).hasClass('icon-chevron-down')) { + $(element).removeClass('icon-chevron-down'); + $(element).addClass('icon-chevron-right'); + + } else { + $(element).removeClass('icon-chevron-right'); + $(element).addClass('icon-chevron-down'); + } + + } else { + + if(openGroup === false) { + $(element).removeClass('icon-chevron-down'); + $(element).addClass('icon-chevron-right'); + + } else { + $(element).removeClass('icon-chevron-right'); + $(element).addClass('icon-chevron-down'); + } + } +} + +/** + * Save settings data to a cookie + * @param {type} dataToBeSaved data to be saved into a cookie + */ +function saveOlogSettingsData(dataToBeSaved) { + $.cookie(settingsCookieName, JSON.stringify(dataToBeSaved)); +} \ No newline at end of file diff --git a/Olog/public_html/static/js/index.js b/Olog/public_html/static/js/index.js index f5a41dd..0623f64 100644 --- a/Olog/public_html/static/js/index.js +++ b/Olog/public_html/static/js/index.js @@ -113,7 +113,7 @@ $(document).ready(function(){ // Show sign in form var template = getTemplate('template_logged_out'); - var html = Mustache.to_html(template, {"user": "User"}); + var html = Mustache.to_html(template, {"user": "Guest"}); $('#top_container').html(html); login(); disableCreatingNewAndModifying(); diff --git a/Olog/public_html/static/js/multilist.js b/Olog/public_html/static/js/multilist.js index fcfd452..8da727b 100644 --- a/Olog/public_html/static/js/multilist.js +++ b/Olog/public_html/static/js/multilist.js @@ -262,31 +262,6 @@ function startListeningForToggleFilterClicks() { }); } -/** - * Close filter group and leave selected items visible - * @param {type} groupContainer container object that holds filters - */ -function closeFilterGroup(groupContainer) { - groupContainer.find('li:gt(0)').addClass('display_none'); - - // Style attribute is added when filter items are being filtered - groupContainer.find('li:gt(0)').removeAttr("style"); - groupContainer.find('li:gt(0) .multilist_clicked').parent().removeClass('display_none'); - - var arrow = groupContainer.find('li i.toggle-from'); - toggleChevron(arrow, false); - - // Check if filtersOpened is defined - if(ologSettings.filtersOpened === undefined) { - ologSettings.filtersOpened = {}; - } - - ologSettings.filtersOpened[groupContainer.attr('id')] = false; - - // Save settings into a cookie - saveOlogSettingsData(ologSettings); -} - /** * Open filter group * @param {type} groupContainer container that holds filters @@ -306,35 +281,4 @@ function openFilterGroup(groupContainer) { // Save settings into a cookie saveOlogSettingsData(ologSettings); -} - -/** - * Toggle chevron on an element - * @param {type} element element that contains chevron - * @param openGroup define this argument if you want to enforce open/close group - */ -function toggleChevron(element, openGroup) { - - if(openGroup === undefined) { - - if($(element).hasClass('icon-chevron-down')) { - $(element).removeClass('icon-chevron-down'); - $(element).addClass('icon-chevron-right'); - - } else { - $(element).removeClass('icon-chevron-right'); - $(element).addClass('icon-chevron-down'); - } - - } else { - - if(openGroup === false) { - $(element).removeClass('icon-chevron-down'); - $(element).addClass('icon-chevron-right'); - - } else { - $(element).removeClass('icon-chevron-right'); - $(element).addClass('icon-chevron-down'); - } - } } \ No newline at end of file diff --git a/Olog/public_html/static/js/print_log.js b/Olog/public_html/static/js/print_log.js new file mode 100644 index 0000000..cfb3938 --- /dev/null +++ b/Olog/public_html/static/js/print_log.js @@ -0,0 +1,24 @@ +/* + * Javascript functions for displaying log in print view + * + * @author: Dejan Dežman + * @created: 2014-11-17 + */ + +$(document).ready(function(){ + var urlObject = $.url(); + var id = urlObject.param("id"); + + if(id !== undefined) { + var log = getLog(id); + + if(log[0] !== null) { + $('#log_id').html(log[1].split('_')[0]); + $('#log_version').html(log[1].split('_')[1]); + $('#date_printed').html(new Date()); + showLog(log[0], log[1]); + l(log[0]); + window.print(); + } + } +}); \ No newline at end of file diff --git a/Olog/public_html/static/js/rest.js b/Olog/public_html/static/js/rest.js index e9f6cd8..f01c394 100644 --- a/Olog/public_html/static/js/rest.js +++ b/Olog/public_html/static/js/rest.js @@ -137,7 +137,7 @@ function loadLogsAutomatically(){ $('#load_logs').scroll(function(e){ var scrollDiv = $('#load_logs'); - if((scrollDiv.scrollTop() + scrollDiv.innerHeight() >= scrollDiv.prop('scrollHeight')) && limit === true){ + if((scrollDiv.scrollTop() + scrollDiv.innerHeight() >= scrollDiv.prop('scrollHeight') - 2) && limit === true){ l('scroll locked? ' + scrollLock); if(!scrollLock) { @@ -173,8 +173,6 @@ function getLog(id){ url += '&' + historyParameter + '=&'; } - l(url); - // Get log/logs data $.getJSON(url, function(logs) { $.each(logs, function(i, log) { @@ -230,7 +228,6 @@ function getLogNew(id, myFunction){ */ function showLog(log, id){ $('#load_log').show("fast"); - //l(log); var desc = log.description; @@ -242,6 +239,7 @@ function showLog(log, id){ $("#log_level").html(log.level); $("#modify_log_link").attr("href", "modify_log.html?id=" + id); + $("#print_log_link").attr("href", "print_log.html?id=" + id); var item = undefined; var html = ""; @@ -456,7 +454,6 @@ function repeat(source_id, target_id, data, property, showByDefault, showSelecte } html = Mustache.to_html(template, customItem); - $('#'+target_id).append(html); }); @@ -483,10 +480,17 @@ function prepareParentAndChildren(i, children, prepend, logOwners) { var item = children[0]; + // Original owner + var originalOwner = logOwners[item.id + '_1']; + + if(originalOwner === undefined) { + originalOwner = item.owner; + } + // Build customized Log object var newItem = { description: returnFirstXWords(item.description, 40), - owner: logOwners[item.id + '_1'], + owner: originalOwner, modifiedOwner: item.owner, createdDate: formatDate(item.createdDate), modifiedDate: formatDate(item.modifiedDate), @@ -616,11 +620,13 @@ function repeatLogs(data, prepend){ var logId = ""; var logIndex = 0; var logOwners = {}; + l(data); // HACK: Get owner of the first version of log entry $.each(data, function(i, item) { logOwners[item.id + "_" + item.version] = item.owner; }); + l(logOwners); // If we are prepending new data, reverse the order of logs so the will be prepended correctly if(prepend) { @@ -755,13 +761,15 @@ function repeatProperties(properties) { * @returns template as a string */ var templateCache = {}; + function getTemplate(id){ - $.ajaxSetup({async:false}); var template = ""; if(id in templateCache) { return templateCache[id]; + } else { + $.ajaxSetup({async:false}); $('#template_container').load(templates + ' #' + id, function(response, status, xhr){ template = $('#' + id).html();