most things work, can't get svg image in avatar component

Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
This commit is contained in:
Julien Veyssier 2020-09-03 11:59:10 +02:00
parent a5e3fc7298
commit 4314e94151
No known key found for this signature in database
GPG key ID: 4141FEE162030638
8 changed files with 164 additions and 292 deletions

View file

@ -1,76 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="512"
height="512"
id="svg2"
version="1.1"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
sodipodi:docname="arobase.svg"
inkscape:export-filename="C:\Documents and Settings\bstawarz\Bureau\Projects\Projet Site\v1.0\arrow.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.9899495"
inkscape:cx="-59.415017"
inkscape:cy="228.38065"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1051"
inkscape:window-x="0"
inkscape:window-y="-37"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-540.3622)">
<path
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#ffffc1;stroke-width:36.64300156;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0;paint-order:stroke fill markers"
id="path816"
sodipodi:type="arc"
sodipodi:cx="257.08383"
sodipodi:cy="795.78345"
sodipodi:rx="246.9823"
sodipodi:ry="247.48737"
sodipodi:start="0"
sodipodi:end="6.2410531"
sodipodi:open="true"
d="M 504.06613,795.78345 A 246.9823,247.48737 0 0 1 259.68526,1043.2571 246.9823,247.48737 0 0 1 10.156333,800.99666 246.9823,247.48737 0 0 1 249.2807,548.41963 246.9823,247.48737 0 0 1 503.84695,785.35934" />
<path
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:20px;line-height:125%;font-family:'Open Sans';-inkscape-font-specification:Sans;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#2b90d9;fill-opacity:1;stroke:none;stroke-width:0.83854532"
d="m 266.77436,619.58325 c -55.49266,-0.20569 -112.46372,24.09818 -144.98003,69.86177 -33.83857,46.93028 -42.368397,108.88511 -31.1669,164.8523 7.867823,37.35501 29.71565,72.65796 63.16221,92.17729 38.15104,23.07175 84.67013,26.52545 128.15034,21.54855 21.82222,-2.6454 43.30556,-8.47556 63.26457,-17.60758 0,-13.79233 0,-27.58465 0,-41.37697 -44.85634,18.5987 -96.13741,27.65991 -143.81052,14.30768 -33.49442,-9.44017 -60.71878,-38.3106 -68.08582,-72.32242 -8.79442,-34.62244 -6.65791,-71.85362 4.4874,-105.63262 11.93584,-33.75723 37.81591,-62.96103 71.79792,-75.24351 33.90802,-13.27321 72.86105,-14.48896 107.46734,-3.02945 30.84313,11.31306 55.97785,37.93904 63.67361,69.85465 8.00028,29.21192 7.0789,61.4834 -4.22183,89.60343 -4.9824,11.84872 -16.24283,23.93361 -30.28612,21.22223 -7.77031,-1.25235 -13.83758,-7.84081 -14.59593,-15.61791 -4.14527,-19.59291 0.94491,-39.62187 0.61636,-59.42594 1.0684,-20.03154 2.13269,-40.06335 3.23571,-60.09297 -31.61968,-9.4676 -65.77433,-15.55694 -98.39805,-7.91377 -33.03041,9.05478 -58.36646,38.77792 -63.89424,72.45056 -4.8269,25.07002 -2.73002,52.14845 8.8647,74.94998 10.72142,19.54451 31.47513,33.45728 53.97834,34.32044 24.82809,2.33067 51.27619,-8.03421 65.38334,-29.00092 9.18485,20.96311 33.76442,32.88753 56.10392,28.64156 26.6497,-3.6567 48.1544,-24.51196 57.54518,-48.97628 15.52565,-36.26916 14.82527,-78.02711 4.0617,-115.50962 -12.83441,-41.37023 -44.77331,-76.76943 -86.00078,-91.17587 -21.11636,-7.94479 -43.78718,-11.30817 -66.35242,-10.86461 z m -2.62045,120.25264 c 8.77532,-0.0282 17.58561,0.68514 26.09972,2.54184 -2.49419,28.58145 0.56322,58.50758 -10.42306,85.58119 -5.25809,11.43471 -16.75106,20.32388 -29.56507,20.15413 -13.41253,1.3148 -28.31176,-6.56758 -31.44484,-20.39775 -5.99328,-18.35143 -4.22465,-38.66323 1.25721,-56.87944 6.14343,-16.7344 21.77771,-30.60503 40.19776,-30.79034 1.28952,-0.11169 2.58413,-0.18249 3.87828,-0.20963 z"
id="text2997"
inkscape:connector-curvature="0" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.7 KiB

1
img/calendar.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -256 1850 1850"><path d="M269.398 1390.771h271.993V1118.78H269.398zm332.436 0h302.214V1118.78H601.834zm-332.436-332.435h271.993V756.122H269.398zm332.436 0h302.214V756.122H601.834zM269.398 695.679h271.993V423.686H269.398zm695.092 695.092h302.214V1118.78H964.49zM601.834 695.68h302.214V423.686H601.834zm725.313 695.092h271.993V1118.78h-271.993zM964.49 1058.336h302.214V756.122H964.49zM632.055 242.358V-29.634q0-12.278-8.972-21.25t-21.25-8.972h-60.442q-12.277 0-21.25 8.972-8.971 8.972-8.971 21.25v271.992q0 12.278 8.972 21.25t21.249 8.972h60.443q12.277 0 21.25-8.972 8.971-8.972 8.971-21.25zm695.092 815.978h271.993V756.122h-271.993zM964.49 695.679h302.214V423.686H964.49zm362.657 0h271.993V423.686h-271.993zm30.222-453.32V-29.635q0-12.278-8.972-21.25t-21.25-8.972h-60.443q-12.277 0-21.249 8.972t-8.972 21.25v271.992q0 12.278 8.972 21.25t21.25 8.972h60.442q12.278 0 21.25-8.972t8.972-21.25zm362.656-60.444v1208.856q0 49.11-35.888 84.998-35.887 35.888-84.997 35.888H269.398q-49.11 0-84.997-35.888-35.888-35.888-35.888-84.998V181.915q0-49.11 35.888-84.997 35.888-35.888 84.997-35.888h120.886v-90.664q0-62.332 44.388-106.72 44.387-44.387 106.719-44.387h60.443q62.331 0 106.72 44.387 44.387 44.388 44.387 106.72V61.03h362.656v-90.664q0-62.332 44.388-106.72 44.388-44.387 106.72-44.387h60.442q62.332 0 106.72 44.387 44.387 44.388 44.387 106.72V61.03h120.886q49.11 0 84.997 35.888 35.888 35.888 35.888 84.997z" stroke="#fffffd" stroke-width="173.89699902" paint-order="stroke fill markers"/></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -1,72 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
viewBox="0 -256 1930 1930"
id="svg3037"
version="1.1"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
width="100%"
height="100%"
sodipodi:docname="retweet.svg">
<metadata
id="metadata3047">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs3045" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1051"
id="namedview3043"
showgrid="false"
inkscape:zoom="0.26339286"
inkscape:cx="597.44282"
inkscape:cy="1052.1978"
inkscape:window-x="0"
inkscape:window-y="-37"
inkscape:window-maximized="1"
inkscape:current-layer="svg3037" />
<path
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2.16400003;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
id="path816"
sodipodi:type="arc"
sodipodi:cx="964.33899"
sodipodi:cy="709.66101"
sodipodi:rx="956.74579"
sodipodi:ry="956.74579"
sodipodi:start="0"
sodipodi:end="6.2410531"
sodipodi:open="true"
d="M 1921.0848,709.66101 A 956.74579,956.74579 0 0 1 974.41626,1666.3537 956.74579,956.74579 0 0 1 7.8054855,729.81443 956.74579,956.74579 0 0 1 934.11166,-246.60716 956.74579,956.74579 0 0 1 1920.2357,669.36312" />
<g
transform="matrix(0.83587571,0,0,-0.83587571,170.84746,1226)"
id="g3039"
style="fill:#2b90d9;fill-opacity:1">
<path
d="M 1280,32 Q 1280,19 1270.5,9.5 1261,0 1248,0 H 288 q -8,0 -13.5,2 -5.5,2 -9,7 -3.5,5 -5.5,8 -2,3 -3,11.5 -1,8.5 -1,11.5 V 53 64 224 640 H 64 q -26,0 -45,19 -19,19 -19,45 0,24 15,41 l 320,384 q 19,22 49,22 30,0 49,-22 L 753,745 q 15,-17 15,-41 0,-26 -19,-45 -19,-19 -45,-19 H 512 V 256 h 576 q 16,0 25,-11 L 1273,53 q 7,-11 7,-21 z m 640,416 q 0,-24 -15,-41 L 1585,23 q -20,-23 -49,-23 -29,0 -49,23 l -320,384 q -15,17 -15,41 0,26 19,45 19,19 45,19 h 192 V 896 H 832 q -16,0 -25,12 l -160,192 q -7,9 -7,20 0,13 9.5,22.5 9.5,9.5 22.5,9.5 h 960 q 8,0 13.5,-2 5.5,-2 9,-7 3.5,-5 5.5,-8 2,-3 3,-11.5 1,-8.5 1,-11.5 v -13 -11 -160 -416 h 192 q 26,0 45,-19 19,-19 19,-45 z"
id="path3041"
inkscape:connector-curvature="0"
style="fill:#2b90d9;fill-opacity:1" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3 KiB

View file

@ -1,56 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
viewBox="0 0 16 16"
width="16"
height="16"
id="svg4"
sodipodi:docname="starred.svg"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
<metadata
id="metadata10">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1051"
id="namedview6"
showgrid="false"
inkscape:zoom="29.5"
inkscape:cx="4.5871328"
inkscape:cy="8.6335754"
inkscape:window-x="0"
inkscape:window-y="-37"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" />
<path
d="M 7.9785158,2.5370783 9.9726171,6.1246448 14.098253,6.9356396 11.33011,9.9079906 11.803352,14.011587 7.9785158,12.262534 4.1536799,14.011587 4.6787845,9.9598527 1.8587784,6.9356396 5.8806906,6.1246448 Z"
id="path2"
inkscape:connector-curvature="0"
style="fill:#ffcc00;stroke:#000000;stroke-width:1.9150579;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
sodipodi:nodetypes="ccccccccccc" />
</svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

65
img/time.svg Normal file
View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="40"
height="40"
version="1.0"
id="svg8"
sodipodi:docname="time.svg"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
<metadata
id="metadata14">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs12" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1051"
id="namedview10"
showgrid="false"
inkscape:zoom="11.8"
inkscape:cx="5.4661017"
inkscape:cy="24.661017"
inkscape:window-x="0"
inkscape:window-y="-37"
inkscape:window-maximized="1"
inkscape:current-layer="svg8" />
<g
id="g6"
style="fill:#000000;fill-opacity:1;stroke:#ffffff;stroke-width:3.79999995;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.98400005;paint-order:stroke fill markers"
transform="translate(-5,0.08474576)">
<path
d="M 25,2 C 15.086,2 7,10.086 7,20 7,29.914 15.086,38 25,38 34.914,38 43,29.914 43,20 43,10.086 34.914,2 25,2 Z m 0,4 c 7.75,0 14,6.25 14,14 0,7.75 -6.25,14 -14,14 C 17.25,34 11,27.75 11,20 11,12.25 17.25,6 25,6 Z"
style="color:#000000;overflow:visible;fill:#000000;fill-opacity:1;stroke:#ffffff;stroke-width:3.79999995;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.98400005;marker:none"
overflow="visible"
id="path2"
inkscape:connector-curvature="0" />
<path
d="m 25.25,6.755 a 2,2 0 0 0 -1.969,2.032 v 13.718 a 2,2 0 0 0 3.063,1.72 l 7.281,-4.47 a 2,2 0 1 0 -2.094,-3.406 l -4.25,2.594 V 8.787 A 2,2 0 0 0 25.25,6.755 Z"
id="path4"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:3.79999995;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.98400005"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -97,7 +97,9 @@ class MoodleAPIController extends Controller {
* @NoCSRFRequired
*/
public function getMoodleAvatar($url) {
$response = new DataDisplayResponse($this->moodleAPIService->getMoodleAvatar($url));
$content = $this->moodleAPIService->getMoodleAvatar($url);
//return new DataResponse($content);
$response = new DataDisplayResponse($content);
$response->cacheFor(60*60*24);
return $response;
}

View file

@ -49,42 +49,75 @@ class MoodleAPIService {
if (isset($recentItems['error'])) {
return $recentItems;
}
$courseIds = [];
foreach ($recentItems as $recentItem) {
if (isset($recentItem['courseid']) && !in_array($recentItem['courseid'], $courseIds)) {
array_push($courseIds, $recentItem['courseid']);
}
}
//$upcomingEvents = [];
//foreach ($courseIds as $courseId) {
// $params['wsfunction'] = 'core_calendar_get_calendar_upcoming_view';
// $params['courseid'] = $courseId;
// $upcomingEvents = array_merge($upcomingEvents, $this->request($url, 'webservice/rest/server.php', $params));
//}
$results = $recentItems;
// filter by date
if (!is_null($since)) {
$results = array_filter($results, function($elem) use ($since) {
$ts = intval($elem['timeaccess']);
return $ts > $since;
});
}
// sort results by date
$a = usort($results, function($a, $b) {
// sort recent items by date DESC
$a = usort($recentItems, function($a, $b) {
$ta = $a['timeaccess'];
$tb = $b['timeaccess'];
return ($ta > $tb) ? -1 : 1;
});
// get courses and set 'time'
$courseIds = [];
foreach ($recentItems as $k => $recentItem) {
if (isset($recentItem['courseid']) && !in_array($recentItem['courseid'], $courseIds)) {
array_push($courseIds, $recentItem['courseid']);
}
$recentItems[$k]['time'] = $recentItem['timeaccess'];
$recentItems[$k]['type'] = 'recent';
}
// get upcoming events
$upcomingEvents = [];
foreach ($courseIds as $courseId) {
$params['wsfunction'] = 'core_calendar_get_calendar_upcoming_view';
$params['courseid'] = $courseId;
$oneRes = $this->request($url, 'webservice/rest/server.php', $params);
if (!isset($oneRes['error']) && isset($oneRes['events'])) {
$upcomingEvents = array_merge($upcomingEvents, $oneRes['events']);
}
}
// sort upcoming events by date ASC
$a = usort($upcomingEvents, function($a, $b) {
$ta = $a['timestart'];
$tb = $b['timestart'];
return ($ta < $tb) ? -1 : 1;
});
foreach ($upcomingEvents as $k => $upcomingEvent) {
$upcomingEvents[$k]['time'] = $upcomingEvent['timestart'];
$upcomingEvents[$k]['type'] = 'event';
}
$results = array_merge($upcomingEvents, $recentItems);
// filter by date
if (!is_null($since)) {
$results = array_filter($results, function($elem) use ($since) {
$ts = intval($elem['time']);
return $ts > $since;
});
}
return $results;
}
public function getMoodleAvatar($url) {
return $this->client->get($url)->getBody();
$rawResult = $this->client->get($url)->getBody();
$success = preg_match('/<svg.*/', $rawResult, $matches);
//$result = $success === 1 ? $this->getBase64Svg($matches[0]) : $rawResult;
if ($success === 1) {
$result = '<?xml version="1.0"?>' . $matches[0];
//$result = $this->getBase64Svg($result);
} else {
$result = $rawResult;
}
error_log('RESult['.$success.'] '.$result);
return $result;
}
private function getBase64Svg(string $svgString): string {
return 'data:image/svg+xml;base64,' . base64_encode($svgString);
}
public function request(string $url, string $endPoint, array $params = [], string $method = 'GET'): array {

View file

@ -28,7 +28,6 @@ import { generateUrl } from '@nextcloud/router'
import { DashboardWidget } from '@nextcloud/vue-dashboard'
import { showError } from '@nextcloud/dialogs'
import moment from '@nextcloud/moment'
// eslint-disable-next-line
import { getLocale } from '@nextcloud/l10n'
export default {
@ -74,13 +73,14 @@ export default {
}
})
},
lastId() {
const nbNotif = this.notifications.length
return (nbNotif > 0) ? this.notifications[0].id : null
},
lastDate() {
const nbNotif = this.notifications.length
return (nbNotif > 0) ? this.notifications[0].created_at : null
lastTimestamp() {
let maxTs = 0
this.notifications.forEach((n) => {
if (n.time > maxTs) {
maxTs = n.time
}
})
return (maxTs === 0) ? null : maxTs
},
lastMoment() {
return moment(this.lastDate)
@ -110,7 +110,7 @@ export default {
fetchNotifications() {
const req = {}
req.params = {
since: this.lastId,
since: this.lastTimestamp,
}
axios.get(generateUrl('/apps/integration_moodle/notifications'), req).then((response) => {
this.processNotifications(response.data)
@ -129,55 +129,32 @@ export default {
})
},
processNotifications(newNotifications) {
if (this.lastId) {
// just add those which are more recent than our most recent one
let i = 0
while (i < newNotifications.length && this.lastMoment.isBefore(newNotifications[i].created_at)) {
i++
}
if (i > 0) {
const toAdd = this.filter(newNotifications.slice(0, i))
this.notifications = toAdd.concat(this.notifications)
}
} else {
// first time we don't check the date
this.notifications = this.filter(newNotifications)
}
const toAdd = this.filter(newNotifications)
this.notifications = toAdd.concat(this.notifications)
},
filter(notifications) {
// no filtering for the moment
return notifications
},
getNotificationTarget(n) {
if (['favourite', 'mention', 'reblog'].includes(n.type)) {
return n.status.url
} else if (['follow'].includes(n.type)) {
return n.account.url
} else if (['follow_request'].includes(n.type)) {
return this.moodleUrl + '/web/follow_requests'
if (['event', 'recent'].includes(n.type)) {
return n.viewurl
}
return ''
},
getMainText(n) {
if (['favourite', 'mention', 'reblog'].includes(n.type)) {
return this.html2text(n.status.content)
} else if (n.type === 'follow') {
return t('integration_moodle', 'is following you')
} else if (n.type === 'follow_request') {
return t('integration_moodle', 'wants to follow you')
if (['recent'].includes(n.type)) {
return n.name
} else if (['event'].includes(n.type)) {
return n.name
}
return ''
},
getSubline(n) {
return this.getAuthorNameAndID(n)
},
getNotificationContent(n) {
if (['favourite', 'mention', 'reblog'].includes(n.type)) {
return this.html2text(n.status.content)
} else if (n.type === 'follow') {
return t('integration_moodle', '{name} is following you', { name: this.getAuthorNameAndID(n) })
} else if (n.type === 'follow_request') {
return t('integration_moodle', '{name} wants to follow you', { name: this.getAuthorNameAndID(n) })
if (['recent'].includes(n.type)) {
return n.coursename
} else if (['event'].includes(n.type)) {
return n.course.fullname
}
return ''
},
@ -191,33 +168,31 @@ export default {
return temp.content.firstChild.textContent
},
getUniqueKey(n) {
return n.id
return n.type + n.id
},
getAuthorAvatarUrl(n) {
return (n.account && n.account.avatar)
? generateUrl('/apps/integration_moodle/avatar?') + encodeURIComponent('url') + '=' + encodeURIComponent(n.account.avatar)
: ''
if (['event'].includes(n.type)) {
console.debug(n.course.courseimage)
return n.course.courseimage
} else if (['recent'].includes(n.type)) {
const el = document.createElement('img')
el.innerHTML = n.icon
const realUrl = el.firstChild.getAttribute('src')
return generateUrl('/apps/integration_moodle/avatar?') + encodeURIComponent('url') + '=' + encodeURIComponent(realUrl)
}
return ''
},
getNotificationTypeImage(n) {
if (n.type === 'mention') {
return generateUrl('/svg/integration_moodle/arobase?color=777777')
} else if (['follow', 'follow_request'].includes(n.type)) {
return generateUrl('/svg/integration_moodle/add_user?color=ffffff')
} else if (['favourite'].includes(n.type)) {
return generateUrl('/svg/integration_moodle/starred?color=ffffff')
} else if (['reblog'].includes(n.type)) {
return generateUrl('/svg/integration_moodle/retweet?color=ffffff')
if (n.type === 'event') {
return generateUrl('/svg/integration_moodle/calendar?color=ffffff')
} else if (['recent'].includes(n.type)) {
return generateUrl('/svg/integration_moodle/time?color=ffffff')
}
return ''
},
getFormattedDate(n) {
return moment(n.created_at).locale(this.locale).format('LLL')
},
getAuthorNameAndID(n) {
return n.account.display_name
? n.account.display_name + ' (' + n.account.acct + ')'
: n.account.acct
},
},
}
</script>