Merge pull request #4381 from FinnStutzenstein/closSlide

Current list of speaker slide
This commit is contained in:
Finn Stutzenstein 2019-02-22 11:33:45 +01:00 committed by GitHub
commit fc2963f00a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 179 additions and 149 deletions

View File

@ -1,5 +1,6 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { PrivacyPolicyComponent } from './components/privacy-policy/privacy-policy.component';
import { StartComponent } from './components/start/start.component';
import { LegalNoticeComponent } from './components/legal-notice/legal-notice.component';

View File

@ -1,13 +0,0 @@
import { CommonModule } from './common.module';
describe('CommonModule', () => {
let commonModule: CommonModule;
beforeEach(() => {
commonModule = new CommonModule();
});
it('should create an instance', () => {
expect(commonModule).toBeTruthy();
});
});

View File

@ -0,0 +1,13 @@
import { OsCommonModule } from './os-common.module';
describe('OsCommonModule', () => {
let osCommonModule: OsCommonModule;
beforeEach(() => {
osCommonModule = new OsCommonModule();
});
it('should create an instance', () => {
expect(osCommonModule).toBeTruthy();
});
});

View File

@ -1,5 +1,5 @@
import { NgModule } from '@angular/core';
import { CommonModule as AngularCommonModule } from '@angular/common';
import { CommonModule } from '@angular/common';
import { CommonRoutingModule } from './common-routing.module';
import { SharedModule } from '../../shared/shared.module';
@ -10,7 +10,7 @@ import { SearchComponent } from './components/search/search.component';
import { CountUsersComponent } from './components/count-users/count-users.component';
@NgModule({
imports: [AngularCommonModule, CommonRoutingModule, SharedModule],
imports: [CommonModule, CommonRoutingModule, SharedModule],
declarations: [PrivacyPolicyComponent, StartComponent, LegalNoticeComponent, SearchComponent, CountUsersComponent]
})
export class CommonModule {}
export class OsCommonModule {}

View File

@ -7,14 +7,11 @@
<div class="content-container" *ngIf="projector">
<div class="column-left">
<!--<a [routerLink]="['/projector', projector.id]">
<a [routerLink]="['/projector', projector.id]">
<div id="projector">
<os-projector [projector]="projector"></os-projector>
</div>
</a>-->
<div id="projector">
<os-projector [projector]="projector"></os-projector>
</div>
</a>
</div>
<div class="column-right" *osPerms="'core.can_manage_projector'">
<div class="control-group">

View File

@ -16,7 +16,7 @@ const routes: Routes = [
children: [
{
path: '',
loadChildren: './common/common.module#CommonModule',
loadChildren: './common/os-common.module#OsCommonModule',
data: { preload: true }
},
{

View File

@ -1,3 +0,0 @@
export interface CurrentListOfSpeakersSlideData {
error: string;
}

View File

@ -3,7 +3,7 @@ interface SlideSpeaker {
marked: boolean;
}
export interface ListOfSpeakersSlideData {
export interface CommonListOfSpeakersSlideData {
waiting: SlideSpeaker[];
current: SlideSpeaker;
finished: SlideSpeaker[];

View File

@ -18,7 +18,7 @@
</div>
<!-- Next speakers -->
<div *ngIf="data.data.finished.length">
<div *ngIf="data.data.waiting.length">
<ol class="nextSpeakers">
<li *ngFor="let speaker of data.data.waiting">
{{ speaker.user }}

View File

@ -1,21 +1,21 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ListOfSpeakersSlideComponent } from './list-of-speakers-slide.component';
import { CommonListOfSpeakersSlideComponent } from './common-list-of-speakers-slide.component';
import { E2EImportsModule } from '../../../../e2e-imports.module';
describe('ListOfSpeakersSlideComponent', () => {
let component: ListOfSpeakersSlideComponent;
let fixture: ComponentFixture<ListOfSpeakersSlideComponent>;
let component: CommonListOfSpeakersSlideComponent;
let fixture: ComponentFixture<CommonListOfSpeakersSlideComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [E2EImportsModule],
declarations: [ListOfSpeakersSlideComponent]
declarations: [CommonListOfSpeakersSlideComponent]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListOfSpeakersSlideComponent);
fixture = TestBed.createComponent(CommonListOfSpeakersSlideComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

View File

@ -1,16 +1,16 @@
import { Component } from '@angular/core';
import { BaseSlideComponent } from 'app/slides/base-slide-component';
import { ListOfSpeakersSlideData } from './list-of-speakers-slide-data';
import { CommonListOfSpeakersSlideData } from './common-list-of-speakers-slide-data';
import { CollectionStringMapperService } from 'app/core/core-services/collectionStringMapper.service';
import { isBaseAgendaContentObjectRepository } from 'app/core/repositories/base-agenda-content-object-repository';
@Component({
selector: 'os-list-of-speakers-slide',
templateUrl: './list-of-speakers-slide.component.html',
styleUrls: ['./list-of-speakers-slide.component.scss']
selector: 'os-common-list-of-speakers-slide',
templateUrl: './common-list-of-speakers-slide.component.html',
styleUrls: ['./common-list-of-speakers-slide.component.scss']
})
export class ListOfSpeakersSlideComponent extends BaseSlideComponent<ListOfSpeakersSlideData> {
export class CommonListOfSpeakersSlideComponent extends BaseSlideComponent<CommonListOfSpeakersSlideData> {
public constructor(private collectionStringMapperService: CollectionStringMapperService) {
super();
}

View File

@ -0,0 +1,13 @@
import { CommonListOfSpeakersSlideModule } from './common-list-of-speakers-slide.module';
describe('CommonListOfSpeakersSlideModule', () => {
let commonListOfSpeakersSlideModule: CommonListOfSpeakersSlideModule;
beforeEach(() => {
commonListOfSpeakersSlideModule = new CommonListOfSpeakersSlideModule();
});
it('should create an instance', () => {
expect(commonListOfSpeakersSlideModule).toBeTruthy();
});
});

View File

@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CommonListOfSpeakersSlideComponent } from './common-list-of-speakers-slide.component';
import { SharedModule } from '../../../shared/shared.module';
@NgModule({
declarations: [CommonListOfSpeakersSlideComponent],
entryComponents: [CommonListOfSpeakersSlideComponent],
imports: [CommonModule, SharedModule],
exports: [CommonListOfSpeakersSlideComponent]
})
export class CommonListOfSpeakersSlideModule {}

View File

@ -1,3 +1,3 @@
<div id="overlay">
Current list of speakers overlay
<div id="overlay" *ngIf="data">
TODO
</div>

View File

@ -1,14 +1,20 @@
import { Component } from '@angular/core';
import { Component, Input } from '@angular/core';
import { BaseSlideComponent } from 'app/slides/base-slide-component';
import { CurrentListOfSpeakersSlideData } from '../base/current-list-of-speakers-slide-data';
import { CommonListOfSpeakersSlideData } from '../common/common-list-of-speakers-slide-data';
@Component({
selector: 'os-current-list-of-speakers-overlay-slide',
templateUrl: './current-list-of-speakers-overlay-slide.component.html',
styleUrls: ['./current-list-of-speakers-overlay-slide.component.scss']
})
export class CurrentListOfSpeakersOverlaySlideComponent extends BaseSlideComponent<CurrentListOfSpeakersSlideData> {
export class CurrentListOfSpeakersOverlaySlideComponent extends BaseSlideComponent<CommonListOfSpeakersSlideData> {
// TODO: remove to access data in the template
@Input()
public set data(value: any) {
console.log(value.data);
}
public constructor() {
super();
}

View File

@ -1,3 +0,0 @@
<div>
Current list of speakers slide
</div>

View File

@ -1,26 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CurrentListOfSpeakersSlideComponent } from './current-list-of-speakers-slide.component';
import { E2EImportsModule } from '../../../../e2e-imports.module';
describe('CurrentListOfSpeakersSlideComponent', () => {
let component: CurrentListOfSpeakersSlideComponent;
let fixture: ComponentFixture<CurrentListOfSpeakersSlideComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [E2EImportsModule],
declarations: [CurrentListOfSpeakersSlideComponent]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CurrentListOfSpeakersSlideComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -1,18 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { BaseSlideComponent } from 'app/slides/base-slide-component';
import { CurrentListOfSpeakersSlideData } from '../base/current-list-of-speakers-slide-data';
@Component({
selector: 'os-current-list-of-speakers-slide',
templateUrl: './current-list-of-speakers-slide.component.html',
styleUrls: ['./current-list-of-speakers-slide.component.scss']
})
export class CurrentListOfSpeakersSlideComponent extends BaseSlideComponent<CurrentListOfSpeakersSlideData>
implements OnInit {
public constructor() {
super();
}
public ngOnInit(): void {}
}

View File

@ -1,13 +0,0 @@
import { CurrentListOfSpeakersSlideModule } from './current-list-of-speakers-slide.module';
describe('CurrentListOfSpeakersSlideModule', () => {
let currentListOfSpeakersSlideModule: CurrentListOfSpeakersSlideModule;
beforeEach(() => {
currentListOfSpeakersSlideModule = new CurrentListOfSpeakersSlideModule();
});
it('should create an instance', () => {
expect(currentListOfSpeakersSlideModule).toBeTruthy();
});
});

View File

@ -1,7 +1,13 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { makeSlideModule } from 'app/slides/base-slide-module';
import { CurrentListOfSpeakersSlideComponent } from './current-list-of-speakers-slide.component';
import { SLIDE } from '../../slide-token';
import { SharedModule } from 'app/shared/shared.module';
import { CommonListOfSpeakersSlideModule } from '../common/common-list-of-speakers-slide.module';
import { CommonListOfSpeakersSlideComponent } from '../common/common-list-of-speakers-slide.component';
@NgModule(makeSlideModule(CurrentListOfSpeakersSlideComponent))
@NgModule({
imports: [CommonModule, SharedModule, CommonListOfSpeakersSlideModule],
providers: [{ provide: SLIDE, useValue: CommonListOfSpeakersSlideComponent }]
})
export class CurrentListOfSpeakersSlideModule {}

View File

@ -1,13 +0,0 @@
import { ListOfSpeakersSlideModule } from './list-of-speakers-slide.module';
describe('ListOfSpeakersSlideModule', () => {
let listOfSpeakersSlideModule: ListOfSpeakersSlideModule;
beforeEach(() => {
listOfSpeakersSlideModule = new ListOfSpeakersSlideModule();
});
it('should create an instance', () => {
expect(listOfSpeakersSlideModule).toBeTruthy();
});
});

View File

@ -1,7 +1,13 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { makeSlideModule } from 'app/slides/base-slide-module';
import { ListOfSpeakersSlideComponent } from './list-of-speakers-slide.component';
import { SLIDE } from '../../slide-token';
import { SharedModule } from 'app/shared/shared.module';
import { CommonListOfSpeakersSlideModule } from '../common/common-list-of-speakers-slide.module';
import { CommonListOfSpeakersSlideComponent } from '../common/common-list-of-speakers-slide.component';
@NgModule(makeSlideModule(ListOfSpeakersSlideComponent))
@NgModule({
imports: [CommonModule, SharedModule, CommonListOfSpeakersSlideModule],
providers: [{ provide: SLIDE, useValue: CommonListOfSpeakersSlideComponent }]
})
export class ListOfSpeakersSlideModule {}

View File

@ -56,7 +56,9 @@ def get_flat_tree(all_data: AllData, parent_id: int = 0) -> List[Dict[str, Any]]
return tree
def item_list_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
def item_list_slide(
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
"""
Item list slide.
@ -84,7 +86,7 @@ def item_list_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any
def list_of_speakers_slide(
all_data: AllData, element: Dict[str, Any]
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
"""
List of speakers slide.
@ -96,6 +98,10 @@ def list_of_speakers_slide(
if item_id is None:
raise ProjectorElementException("id is required for list of speakers slide")
return get_list_of_speakers_slide_data(all_data, item_id)
def get_list_of_speakers_slide_data(all_data: AllData, item_id: int) -> Dict[str, Any]:
try:
item = all_data["agenda/item"][item_id]
except KeyError:
@ -144,17 +150,53 @@ def list_of_speakers_slide(
def current_list_of_speakers_slide(
all_data: AllData, element: Dict[str, Any]
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
"""
TODO
Note: This data is for all projectors showing this slide, so we cannot give projector-
specific data. The work-around is to make a dict with projector-ids as keys and the
data-per-projector as values. This is not a security concern, because if a person can
see one projector, he is able to see all others, too. Maybe a bit more data..
The current list of speakers slide. Creates the data for the given projector.
"""
return {"error": "TODO"}
try:
this_projector = all_data["core/projector"][projector_id]
except KeyError:
raise ProjectorElementException(f"Projector {projector_id} does not exist")
reference_projector_id = this_projector["reference_projector_id"] or projector_id
try:
reference_projector = all_data["core/projector"][reference_projector_id]
except KeyError:
raise ProjectorElementException(
f"Projector {reference_projector_id} does not exist"
)
# Search for elements, that do have an agenda item:
# Try to get a model by the collection and id in the element. This
# model needs to have a 'agenda_item_id'. This item must exist. The first
# matching element is taken.
elements = reference_projector["elements"]
item_id = None
for element in elements:
if "id" not in element:
continue
collection = element["name"]
id = element["id"]
if collection not in all_data or id not in all_data[collection]:
continue
model = all_data[collection][id]
if "agenda_item_id" not in model:
continue
if not model["agenda_item_id"] in all_data["agenda/item"]:
continue
item_id = model["agenda_item_id"]
break
if item_id is None: # no element found
return {}
return get_list_of_speakers_slide_data(all_data, item_id)
def register_projector_slides() -> None:

View File

@ -9,7 +9,9 @@ from ..utils.projector import AllData, register_projector_slide
# to be fast!
def assignment_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
def assignment_slide(
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
"""
Assignment slide.
"""

View File

@ -14,7 +14,9 @@ from ..utils.projector import (
# to be fast!
def countdown_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
def countdown_slide(
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
"""
Countdown slide.
@ -40,7 +42,9 @@ def countdown_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any
}
def message_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
def message_slide(
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
"""
Message slide.
@ -59,7 +63,9 @@ def message_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
raise ProjectorElementException(f"Message {message_id} does not exist")
def clock_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
def clock_slide(
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
return {}

View File

@ -13,7 +13,9 @@ from ..utils.projector import (
# to be fast!
def mediafile_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
def mediafile_slide(
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
"""
Slide for Mediafile.
"""

View File

@ -97,7 +97,9 @@ def get_amendment_base_statute(amendment, all_data):
return {"title": statute["title"], "text": statute["text"]}
def motion_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
def motion_slide(
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
"""
Motion slide.
@ -204,7 +206,9 @@ def motion_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
return return_value
def motion_block_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
def motion_block_slide(
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
"""
Motion block slide.
"""

View File

@ -13,7 +13,9 @@ from ..utils.projector import (
# to be fast!
def topic_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
def topic_slide(
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
"""
Topic slide.

View File

@ -13,7 +13,9 @@ from ..utils.projector import (
# to be fast!
def user_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
def user_slide(
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
"""
User slide.

View File

@ -11,7 +11,7 @@ from .cache import element_cache
AllData = Dict[str, Dict[int, Dict[str, Any]]]
ProjectorSlide = Callable[[AllData, Dict[str, Any]], Dict[str, Any]]
ProjectorSlide = Callable[[AllData, Dict[str, Any], int], Dict[str, Any]]
projector_slides: Dict[str, ProjectorSlide] = {}
@ -83,7 +83,7 @@ async def get_projector_data(
for element in projector["elements"]:
projector_slide = projector_slides[element["name"]]
try:
data = projector_slide(all_data, element)
data = projector_slide(all_data, element, projector_id)
except ProjectorElementException as err:
data = {"error": str(err)}
projector_data[projector_id].append({"data": data, "element": element})

View File

@ -90,14 +90,18 @@ class TProjector:
return elements
def slide1(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
def slide1(
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
"""
Slide that shows the general_event_name.
"""
return {"name": "slide1", "event_name": get_config(all_data, "general_event_name")}
def slide2(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
def slide2(
all_data: AllData, element: Dict[str, Any], projector_id: int
) -> Dict[str, Any]:
return {"name": "slide2"}

View File

@ -88,7 +88,7 @@ def all_data():
def test_main_items(all_data):
element: Dict[str, Any] = {}
data = projector.item_list_slide(all_data, element)
data = projector.item_list_slide(all_data, element, 1)
assert data == {
"items": [
@ -109,7 +109,7 @@ def test_main_items(all_data):
def test_all_items(all_data):
element: Dict[str, Any] = {"only_main_items": False}
data = projector.item_list_slide(all_data, element)
data = projector.item_list_slide(all_data, element, 1)
assert data == {
"items": [

View File

@ -256,7 +256,7 @@ def all_data():
def test_motion_slide(all_data):
element: Dict[str, Any] = {"id": 1}
data = projector.motion_slide(all_data, element)
data = projector.motion_slide(all_data, element, 1)
assert data == {
"identifier": "4",
@ -301,7 +301,7 @@ def test_motion_slide(all_data):
def test_amendment_slide(all_data):
element: Dict[str, Any] = {"id": 2}
data = projector.motion_slide(all_data, element)
data = projector.motion_slide(all_data, element, 1)
assert data == {
"identifier": "Ä1",
@ -325,7 +325,7 @@ def test_amendment_slide(all_data):
def test_statute_amendment_slide(all_data):
element: Dict[str, Any] = {"id": 3}
data = projector.motion_slide(all_data, element)
data = projector.motion_slide(all_data, element, 1)
assert data == {
"identifier": None,