Merge pull request #4349 from FinnStutzenstein/mediafileSlide

Basic mediafile slide
This commit is contained in:
Emanuel Schütze 2019-02-15 14:55:55 +01:00 committed by GitHub
commit a3f9d46a6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 136 additions and 6 deletions

View File

@ -67,6 +67,14 @@
</mat-cell> </mat-cell>
</ng-container> </ng-container>
<!-- Projector column -->
<ng-container matColumnDef="projector">
<mat-header-cell *matHeaderCellDef mat-sort-header>Projector</mat-header-cell>
<mat-cell *matCellDef="let file">
<os-projector-button [object]="file"></os-projector-button>
</mat-cell>
</ng-container>
<!-- Filename --> <!-- Filename -->
<ng-container matColumnDef="title"> <ng-container matColumnDef="title">
<mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header>Name</mat-header-cell>

View File

@ -278,9 +278,12 @@ export class MediafileListComponent extends ListViewBaseComponent<ViewMediafile>
* @returns the column definition for the screen size * @returns the column definition for the screen size
*/ */
public getColumnDefinition(): string[] { public getColumnDefinition(): string[] {
const columns = this.vp.isMobile ? this.displayedColumnsMobile : this.displayedColumnsDesktop; let columns = this.vp.isMobile ? this.displayedColumnsMobile : this.displayedColumnsDesktop;
if (this.operator.hasPerms('core.can_manage_projector')) {
columns = ['projector'].concat(columns);
}
if (this.isMultiSelect) { if (this.isMultiSelect) {
return ['selector'].concat(columns); columns = ['selector'].concat(columns);
} }
return columns; return columns;
} }

View File

@ -3,8 +3,10 @@ import { Mediafile } from 'app/shared/models/mediafiles/mediafile';
import { Searchable } from 'app/site/base/searchable'; import { Searchable } from 'app/site/base/searchable';
import { SearchRepresentation } from 'app/core/ui-services/search.service'; import { SearchRepresentation } from 'app/core/ui-services/search.service';
import { ViewUser } from 'app/site/users/models/view-user'; import { ViewUser } from 'app/site/users/models/view-user';
import { BaseProjectableViewModel } from 'app/site/base/base-projectable-view-model';
import { ProjectorElementBuildDeskriptor } from 'app/site/base/projectable';
export class ViewMediafile extends BaseViewModel implements Searchable { export class ViewMediafile extends BaseProjectableViewModel implements Searchable {
public static COLLECTIONSTRING = Mediafile.COLLECTIONSTRING; public static COLLECTIONSTRING = Mediafile.COLLECTIONSTRING;
private _mediafile: Mediafile; private _mediafile: Mediafile;
@ -86,6 +88,19 @@ export class ViewMediafile extends BaseViewModel implements Searchable {
throw new Error('TODO'); throw new Error('TODO');
} }
public getSlide(): ProjectorElementBuildDeskriptor {
return {
getBasicProjectorElement: () => ({
name: Mediafile.COLLECTIONSTRING,
id: this.id,
getIdentifiers: () => ['name', 'id']
}),
slideOptions: [],
projectionDefaultName: 'mediafiles',
getTitle: () => this.getTitle()
};
}
/** /**
* Determine if the file is an image * Determine if the file is an image
* *

View File

@ -45,5 +45,10 @@ export const allSlidesDynamicConfiguration: (SlideDynamicConfiguration & Slide)[
slide: 'assignments/assignment', slide: 'assignments/assignment',
scaleable: true, scaleable: true,
scrollable: true scrollable: true
},
{
slide: 'mediafiles/mediafile',
scaleable: true,
scrollable: true
} }
]; ];

View File

@ -81,5 +81,13 @@ export const allSlides: SlideManifest[] = [
verboseName: 'Election', verboseName: 'Election',
elementIdentifiers: ['name', 'id'], elementIdentifiers: ['name', 'id'],
canBeMappedToModel: true canBeMappedToModel: true
},
{
slide: 'mediafiles/mediafile',
path: 'mediafiles/mediafile',
loadChildren: './slides/mediafiles/mediafile/mediafile-slide.module#MediafileSlideModule',
verboseName: 'File',
elementIdentifiers: ['name', 'id'],
canBeMappedToModel: true
} }
]; ];

View File

@ -0,0 +1,5 @@
export interface MediafileSlideData {
path: string;
type: string;
media_url_prefix: string;
}

View File

@ -0,0 +1,5 @@
<div *ngIf="data">
<p>{{ data.data.path }}</p>
<p>{{ data.data.type }}</p>
<p>{{ data.data.media_url_prefix }}</p>
</div>

View File

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

View File

@ -0,0 +1,15 @@
import { Component } from '@angular/core';
import { BaseSlideComponent } from 'app/slides/base-slide-component';
import { MediafileSlideData } from './mediafile-slide-data';
@Component({
selector: 'os-mediafile-slide',
templateUrl: './mediafile-slide.component.html',
styleUrls: ['./mediafile-slide.component.scss']
})
export class MediafileSlideComponent extends BaseSlideComponent<MediafileSlideData> {
public constructor() {
super();
}
}

View File

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

View File

@ -0,0 +1,7 @@
import { NgModule } from '@angular/core';
import { makeSlideModule } from 'app/slides/base-slide-module';
import { MediafileSlideComponent } from './mediafile-slide.component';
@NgModule(makeSlideModule(MediafileSlideComponent))
export class MediafileSlideModule {}

View File

@ -1,6 +1,10 @@
from typing import Any, Dict from typing import Any, Dict
from ..utils.projector import AllData, register_projector_slide from ..utils.projector import (
AllData,
ProjectorElementException,
register_projector_slide,
)
# Important: All functions have to be prune. This means, that thay can only # Important: All functions have to be prune. This means, that thay can only
@ -13,7 +17,23 @@ def mediafile_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any
""" """
Slide for Mediafile. Slide for Mediafile.
""" """
return {"error": "TODO"} mediafile_id = element.get("id")
if mediafile_id is None:
raise ProjectorElementException("id is required for mediafile slide")
try:
mediafile = all_data["mediafiles/mediafile"][mediafile_id]
except KeyError:
raise ProjectorElementException(
f"mediafile with id {mediafile_id} does not exist"
)
return {
"path": mediafile["mediafile"]["name"],
"type": mediafile["mediafile"]["type"],
"media_url_prefix": mediafile["media_url_prefix"],
}
def register_projector_slides() -> None: def register_projector_slides() -> None:

View File

@ -55,7 +55,7 @@ def motion_slide(all_data: AllData, element: Dict[str, Any]) -> Dict[str, Any]:
motion_id = element.get("id") motion_id = element.get("id")
if motion_id is None: if motion_id is None:
return {"error": "id is required for motion slide"} raise ProjectorElementException("id is required for motion slide")
try: try:
motion = all_data["motions/motion"][motion_id] motion = all_data["motions/motion"][motion_id]