1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

ics sources configuration interface

This commit is contained in:
Sylvain 2019-11-27 16:17:32 +01:00
parent bb777227d6
commit 9e2134c9cf
11 changed files with 191 additions and 12 deletions

View File

@ -755,3 +755,57 @@ Application.Controllers.controller('DeleteRecurrentAvailabilityController', ['$s
}
}
]);
/**
* Controller used in the iCalendar (ICS) imports management page
*/
Application.Controllers.controller('AdminICalendarController', ['$scope',
function ($scope) {
// list of ICS sources
$scope.calendars = [];
// configuration of a new ICS source
$scope.newCalendar = {
color: undefined,
textColor: undefined,
url: undefined,
textHidden: false
};
/**
* Save the new iCalendar in database
*/
$scope.save = function () {
$scope.calendars.push(Object.assign({}, $scope.newCalendar));
$scope.newCalendar.url = undefined;
$scope.newCalendar.color = null;
$scope.newCalendar.textColor = null;
$scope.newCalendar.textHidden = false;
}
/**
* Return a CSS-like style of the given calendar configuration
* @param calendar
*/
$scope.calendarStyle = function (calendar) {
return {
'border-color': calendar.color,
'color': calendar.textColor,
'width': calendar.textHidden ? '50px' : 'auto',
'height': calendar.textHidden ? '21px' : 'auto'
};
}
/**
* Delete the given calendar from the database
* @param calendar
*/
$scope.delete = function (calendar) {
const idx = $scope.calendars.indexOf(calendar);
$scope.calendars.splice(idx, 1);
}
}
]);

View File

@ -170,7 +170,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$
};
const eventRenderCb = function (event, element) {
if (event.tags.length > 0) {
if (event.tags && event.tags.length > 0) {
let html = '';
for (let tag of Array.from(event.tags)) {
html += `<span class='label label-success text-white'>${tag.name}</span> `;

View File

@ -659,6 +659,18 @@ angular.module('application.router', ['ui.router'])
translations: ['Translations', function (Translations) { return Translations.query('app.admin.calendar').$promise; }]
}
})
.state('app.admin.calendar.icalendar', {
url: '/admin/calendar/icalendar',
views: {
'main@': {
templateUrl: '<%= asset_path "admin/calendar/icalendar.html" %>',
controller: 'AdminICalendarController'
}
},
resolve: {
translations: ['Translations', function (Translations) { return Translations.query('app.admin.icalendar').$promise; }]
}
})
// project's elements
.state('app.admin.project_elements', {

View File

@ -670,5 +670,6 @@ padding: 10px;
font-size: 10px;
padding: 2px;
margin-left: 10px;
display: inline-block;
}
}

View File

@ -102,6 +102,7 @@ p, .widget p {
.text-italic { font-style: italic; }
.text-left { text-align: left !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }

View File

@ -32,11 +32,7 @@
@import "app.buttons";
@import "app.components";
@import "app.plugins";
@import "modules/invoice";
@import "modules/signup";
@import "modules/abuses";
@import "modules/cookies";
@import "modules/stripe";
@import "modules/*";
@import "app.responsive";

View File

@ -0,0 +1,10 @@
.calendar-form {
margin : 2em;
border: 1px solid #ddd;
border-radius: 3px;
padding: 1em;
& > .input-group, & > .minicolors {
margin-top: 1em;
}
}

View File

@ -5,15 +5,17 @@
<a href="#" ng-click="backPrevLocation($event)"><i class="fa fa-long-arrow-left "></i></a>
</section>
</div>
<div class="col-xs-10 col-sm-10 col-md-8 b-l b-r-md">
<div class="col-xs-10 b-l b-r-md">
<section class="heading-title">
<h1 translate>{{ 'admin_calendar.calendar_management' }}</h1>
</section>
</div>
<div class="col-xs-12 col-sm-12 col-md-3 b-t hide-b-md">
<section class="heading-actions wrapper" ng-class="{'p-s': !fablabWithoutSpaces}">
<div class="col-xs-1">
<section class="heading-actions wrapper">
<a role="button" ui-sref="app.admin.calendar.icalendar" class="btn btn-default b-2x rounded pointer m-t-sm">
<i class="fa fa-exchange" aria-hidden="true"></i>
</a>
</section>
</div>
@ -28,7 +30,7 @@
<div class="calendar-legend-block">
<h4 translate>{{ 'admin_calendar.legend' }}</h4>
<div class="legends">
<span class="calendar-legend text-sm border-formation" ng-class="{'m-t-sm': fablabWithoutSpaces}" translate>{{ 'admin_calendar.trainings' }}</span><br>
<span class="calendar-legend text-sm border-formation" translate>{{ 'admin_calendar.trainings' }}</span><br>
<span class="calendar-legend text-sm border-machine" translate>{{ 'admin_calendar.machines' }}</span><br>
<span class="calendar-legend text-sm border-space" ng-hide="fablabWithoutSpaces" translate>{{ 'admin_calendar.spaces' }}</span>
<span class="calendar-legend text-sm border-event" ng-show="eventsInCalendar" translate>{{ 'admin_calendar.events' }}</span>

View File

@ -0,0 +1,87 @@
<section class="heading b-b">
<div class="row no-gutter">
<div class="col-xs-2 col-sm-2 col-md-1">
<section class="heading-btn">
<a role="button" ng-click="backPrevLocation($event)"><i class="fa fa-long-arrow-left "></i></a>
</section>
</div>
<div class="col-md-8 b-l b-r-md">
<section class="heading-title">
<h1 translate>{{ 'icalendar.icalendar_import' }}</h1>
</section>
</div>
<div class="col-md-3">
<section class="heading-actions wrapper">
</section>
</div>
</div>
</section>
<section class="row no-gutter">
<div class="col-sm-12 col-md-12 col-lg-9">
<div class="alert alert-info m-lg" translate>
{{ 'icalendar.intro' }}
</div>
<div class="wrapper-lg">
<table class="table" ng-show="calendars.length > 0">
<thead>
<tr>
<th style="width: 75%;" translate>{{ 'icalendar.url' }}</th>
<th translate>{{ 'icalendar.display' }}</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="calendar in calendars">
<td class="calendar-url">{{calendar.url}}</td>
<td class="calendar-legend-block text-left"><span class="calendar-legend" ng-style="calendarStyle(calendar)" translate> {{ calendar.textHidden ? '' : 'icalendar.example' }}</span>
<td class="calendar-actions">
<button class="btn btn-danger" ng-click="delete(calendar)"><i class="fa fa-trash"></i></button>
</td>
</tr>
</tbody>
</table>
<form class="calendar-form" name="newImportForm">
<h4 translate>{{ 'icalendar.new_import' }}</h4>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-link"></i>
</div>
<input type="url" ng-model="newCalendar.url" class="form-control" placeholder="{{ 'icalendar.url' | translate }}" required>
</div>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-paint-brush"></i>
</div>
<input type="text" minicolors ng-model="newCalendar.color" class="form-control" placeholder="{{ 'icalendar.color' | translate}}" required/>
</div>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-paint-brush"></i>
</div>
<input type="text" minicolors ng-model="newCalendar.textColor" class="form-control" placeholder="{{ 'icalendar.text_color' | translate}}" required/>
</div>
<div class="input-group">
<label for="hideText" class="control-label m-r" translate>{{ 'icalendar.hide_text' }}</label>
<input bs-switch
ng-model="newCalendar.textHidden"
id="hideText"
type="checkbox"
class="form-control"
switch-on-text="{{ 'icalendar.hidden' | translate }}"
switch-off-text="{{ 'icalendar.shown' | translate }}"
switch-animate="true"/>
</div>
<div class="m-t text-right">
<button role="button" class="btn btn-warning" ng-click="save()" ng-disabled="newImportForm.$invalid" translate>
{{ 'confirm' }}
</button>
</div>
</form>
</div>
</div>
</section>

View File

@ -341,7 +341,9 @@
</select>
<button name="button" class="btn btn-warning m-t" ng-click="save(machinesSortBy)" translate>{{ 'save' }}</button>
</div>
<div class="col-md-4">
<div class="col-md-4">
</div>
</div>
</div>
</div>
</div>

View File

@ -88,6 +88,20 @@ fr:
view_reservations: "Voir les réservations"
legend: "Légende"
icalendar:
icalendar:
icalendar_import: "Import iCalendar"
intro: "Fab-manager vous permet d'importer automatiquement des évènements de calendrier, au format iCalendar RFC 5545, depuis des URL externes. Ces URL seront synchronisée toutes les nuits et les évènements seront affichés dans le calendrier publique."
new_import: "Nouvel import ICS"
color: "Couleur"
text_color: "Couleur du texte"
url: "URL"
example: "Exemple"
display: "Affichage"
hide_text: "Cacher le texte"
hidden: "Caché"
shown: "Affiché"
project_elements:
# gestion des éléments constituant les projets
project_elements: