Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

corrected some bugs with icons and table byLocation #21

Merged
merged 3 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<name>Where am I ?</name>
<summary><![CDATA[Is a simple application to locate everybody in your company.]]></summary>
<description><![CDATA[Is a simple application to locate everybody in your company.]]></description>
<version>0.0.18</version>
<version>0.0.19</version>
<licence>agpl</licence>
<author mail="contact@adacis.net" homepage="https://www.adacis.net">ADACIS</author>
<namespace>Whereami</namespace>
Expand Down
3 changes: 2 additions & 1 deletion js/adminSection.app.js

Large diffs are not rendered by default.

47 changes: 7 additions & 40 deletions js/adminSection.app.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,8 @@
/*!
* Sizzle CSS Selector Engine v2.3.6
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
*
* Date: 2021-02-16
*/

/*!
* jQuery JavaScript Library v3.6.0
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2021-03-02T17:08Z
*/

/*!
DataTables Bootstrap 3 integration
©2011-2015 SpryMedia Ltd - datatables.net/license
*/

/*! DataTables 1.12.1
* ©2008-2022 SpryMedia Ltd - datatables.net/license
*/

/*! FixedColumns 4.1.0
* 2019-2022 SpryMedia Ltd - datatables.net/license
*/

/*! FixedColumns 4.1.0
* 2019-2022 SpryMedia Ltd - datatables.net/license
/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
2 changes: 1 addition & 1 deletion js/main.app.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions js/main.app.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@
/*! FixedColumns 4.1.0
* 2019-2022 SpryMedia Ltd - datatables.net/license
*/

/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
4 changes: 2 additions & 2 deletions lib/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function deleteTag(String $tag)
}

/**
* @AdminRequired
* @NoAdminRequired
* @param string usage
*/
public function getTags(String $usage)
Expand Down Expand Up @@ -118,7 +118,7 @@ public function deleteIcon(String $person, String $prefix, String $label)
}

/**
* @AdminRequired
* @NoAdminRequired
*/
public function getAllIcons()
{
Expand Down
2 changes: 2 additions & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public function search(String $dtStart, String $dtEnd)
{
$from = new DateTime($dtStart);
$to = new DateTime($dtEnd);
// It looks like search does not include the upper bound
$to->modify('+1 day');
$searchResults = $this->calendarManager->search("@", ['SUMMARY'], ['timerange' => ['start' => $from, 'end' => $to]]);

return $searchResults;
Expand Down
9 changes: 7 additions & 2 deletions src/js/class/ListEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ export class ListEvents {
*
* @param {*} from
* @param {*} icons
* @param {*} exluded_places
* @returns
*/
eventsAtDayCount(from, icons) {
eventsAtDayCount(from, icons, placeIsExcluded) {
const myCell = document.createElement('td')
let found = false
let res = 0
Expand All @@ -70,13 +71,17 @@ export class ListEvents {
if (e.inInterval(from)) {
let userTetra = Events.compute_tetragraph(e.nextcloud_users)
res += 1
if (groupedIcons[userTetra])
if (placeIsExcluded)
isSomeoneThere = true

else if (groupedIcons[userTetra])
for (let dic of groupedIcons[userTetra]) {
if (e.place === dic.label.toLowerCase()) {
title += dic.prefix + "(" + dic.label + ") "
isSomeoneThere = true
}
}

title += e.nextcloud_users + '\n'
found = true
}
Expand Down
17 changes: 12 additions & 5 deletions src/js/module/xhr.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { showError, showSuccess } from '@nextcloud/dialogs'
import { generateUrl } from '@nextcloud/router'
import { map } from 'lodash'
import { groupBy } from 'lodash/collection'
import { Events } from '../class/Event'
import { daysFr, ListEvents } from '../class/ListEvents'
Expand Down Expand Up @@ -120,7 +121,7 @@ export function getIcons(person, label = "") {
function setTitleWithIcons(element, icons) {
for (let dic of icons) {
element.title = dic.prefix + "(" + dic.label + ")\n" + element.title;
element.innerText = dic.prefix + element.innerText;
element.innerText = element.innerText + dic.prefix;
}
}

Expand Down Expand Up @@ -221,11 +222,15 @@ function newTablePersonne(response, dtStart, dtEnd, tablename) {
const to = new Date(dtEnd)
const res = JSON.parse(response)
let icons = getAllIcons().onload()
let excludedPlaces
if (tablename === 'summary')
excludedPlaces = getTags("excluded_places").onload().map(element => element.word.toLowerCase())

Object.keys(res).forEach(element => {
let from = new Date(dtStart)
const userListEvents = new ListEvents(element, res[element])
if (tablename === 'summary') {
tbody = getContent(tbody, from, to, userListEvents, icons, true)
tbody = getContent(tbody, from, to, userListEvents, icons, excludedPlaces, true)
} else {
tbody = getContent(tbody, from, to, userListEvents, icons, false)
}
Expand Down Expand Up @@ -306,23 +311,25 @@ function getHeader(from, to) {
* @param {*} count
* @returns
*/
function getContent(tbody, from, to, userListEvents, icons, count = false) {
function getContent(tbody, from, to, userListEvents, icons, excludedPlaces = null, count = false) {
const line = document.createElement('tr')
let td = newCell('td', userListEvents.id)
line.appendChild(td)
let placeIsExcluded
if (!count) {
icons = groupBy(icons, "person")
let tetra = Events.compute_tetragraph(userListEvents.id)
if (icons[tetra] != undefined)
setTitleWithIcons(td, icons[tetra])

}
else
placeIsExcluded = excludedPlaces.includes(userListEvents.id)

while (from <= to) {
if (!count) {
line.appendChild(userListEvents.eventsAtDay(from))
} else {
line.appendChild(userListEvents.eventsAtDayCount(from, icons))
line.appendChild(userListEvents.eventsAtDayCount(from, icons, placeIsExcluded))
}

from.setDate(from.getDate() + 1)
Expand Down
4 changes: 2 additions & 2 deletions templates/navigation/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul class="app-navigation">
<li class="app-navigation-entry"><span class="navmarg"></span><b>Where am I V 0.0.18</b></li>
<li class="app-navigation-entry"><span class="navmarg"></span><b>Where am I V 0.0.19</b></li>
<li class="app-navigation-entry">
<ul class="app-navigation">
<li class="app-navigation-entry"><span class="navmarg icon-contacts-dark"></span><a class="a-entry" href="<?php echo ($_['url']['index']); ?>"><?php p($l->t('Employees')); ?></a>
Expand All @@ -10,4 +10,4 @@
</li>
</ul>
</li>
</ul>
</ul>