1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-25 02:04:15 +02:00

updating to angular2.rc.1

This commit is contained in:
Braun Patrik 2016-05-04 17:20:21 +02:00
parent ea28a8e5e6
commit ff17089abf
28 changed files with 148 additions and 133 deletions

View File

@ -0,0 +1,10 @@
export enum AutoCompeleteTypes {
image,
directory,
imageTag
}
export class AutoCompleteItem{
constructor(text:string, type:AutoCompeleteTypes){}
}

View File

@ -1,4 +1,4 @@
import {Pipe, PipeTransform} from "angular2/core";
import {Pipe, PipeTransform} from "@angular/core";
import {UserRoles} from "../../../common/entities/User";

View File

@ -1,11 +1,11 @@
///<reference path="../../browser.d.ts"/>
import {Component, OnInit, Pipe, PipeTransform} from "angular2/core";
import {Component, OnInit} from "@angular/core";
import {AuthenticationService} from "../model/network/authentication.service.ts";
import {Router} from "angular2/router";
import {Router} from "@angular/router-deprecated";
import {FrameComponent} from "../frame/frame.component";
import {User, UserRoles} from "../../../common/entities/User";
import {FORM_DIRECTIVES} from "angular2/common";
import {FORM_DIRECTIVES} from "@angular/common";
import {Utils} from "../../../common/Utils";
import {AdminService} from "./admin.service";
import {Message} from "../../../common/entities/Message";
@ -37,16 +37,16 @@ export class AdminComponent implements OnInit {
this.getUsersList();
}
private getUsersList(){
this._adminService.getUsers().then((result:Message<Array<User>>) =>{
private getUsersList() {
this._adminService.getUsers().then((result:Message<Array<User>>) => {
this.users = result.result;
});
}
canModifyUser(user:User):boolean{
let currentUser = this._authService.getUser();
if(!currentUser){
canModifyUser(user:User):boolean {
let currentUser = this._authService.getUser();
if (!currentUser) {
return false;
}
@ -58,20 +58,20 @@ export class AdminComponent implements OnInit {
this.newUser.role = UserRoles.User;
}
addNewUser(){
this._adminService.createUser(this.newUser).then(() =>{
addNewUser() {
this._adminService.createUser(this.newUser).then(() => {
this.getUsersList();
});
}
updateRole(user:User){
this._adminService.updateRole(user).then(() =>{
updateRole(user:User) {
this._adminService.updateRole(user).then(() => {
this.getUsersList();
});
}
deleteUser(user:User){
this._adminService.deleteUser(user).then(() =>{
deleteUser(user:User) {
this._adminService.deleteUser(user).then(() => {
this.getUsersList();
});
}

View File

@ -1,8 +1,8 @@
///<reference path="../../browser.d.ts"/>
import {Injectable} from 'angular2/core';
import {Injectable} from '@angular/core';
import {NetworkService} from "../model/network/network.service.ts";
import {Http} from "angular2/http";
import {Http} from "@angular/http";
import {Message} from "../../../common/entities/Message";
import {User} from "../../../common/entities/User";

View File

@ -1,14 +0,0 @@
import {Component} from 'angular2/core';
@Component({
selector: 'admin-new-user',
templateUrl: 'app/admin/newuser/new.user.admin.component.html',
styleUrls:['app/admin/newuser/new.user.admin.component.css']
})
export class NewUserComponent{
constructor() {
}
}

View File

@ -1,14 +1,12 @@
///<reference path="../browser.d.ts"/>
import { Component } from 'angular2/core';
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouterLink} from 'angular2/router';
import { Component,OnInit } from '@angular/core';
import {LoginComponent} from "./login/login.component";
import {AuthenticationService} from "./model/network/authentication.service.ts";
import {GalleryComponent} from "./gallery/gallery.component";
import {OnInit} from "angular2/core";
import {User} from "../../common/entities/User";
import {Router} from "angular2/router";
import {HTTP_PROVIDERS} from "angular2/http";
import {Router, RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from "@angular/router-deprecated";
import {HTTP_PROVIDERS} from "@angular/http";
import {UserService} from "./model/network/user.service.ts";
import {GalleryService} from "./gallery/gallery.service";
import {AdminComponent} from "./admin/admin.component";
@ -17,7 +15,7 @@ import {AdminComponent} from "./admin/admin.component";
@Component({
selector: 'pi-gallery2-app',
template: `<router-outlet></router-outlet>`,
directives: [ROUTER_DIRECTIVES, RouterLink],
directives: [ROUTER_DIRECTIVES],
providers: [
HTTP_PROVIDERS,
ROUTER_PROVIDERS,

View File

@ -1,7 +1,7 @@
///<reference path="../../browser.d.ts"/>
import {Component, ViewEncapsulation} from 'angular2/core';
import {RouterLink} from "angular2/router";
import {Component, ViewEncapsulation} from '@angular/core';
import {RouterLink} from "@angular/router-deprecated";
@Component({
selector: 'app-frame',

View File

@ -1,8 +1,8 @@
///<reference path="../../../browser.d.ts"/>
import {Component, Input, OnInit} from 'angular2/core';
import {Component, Input} from '@angular/core';
import {Directory} from "../../../../common/entities/Directory";
import {RouterLink} from "angular2/router";
import {RouterLink} from "@angular/router-deprecated";
import {Utils} from "../../../../common/Utils";
@Component({

View File

@ -1,8 +1,8 @@
///<reference path="../../browser.d.ts"/>
import {Component, OnInit, QueryList, ViewChild, AfterViewInit} from 'angular2/core';
import {Component, OnInit, QueryList, ViewChild, AfterViewInit} from '@angular/core';
import {AuthenticationService} from "../model/network/authentication.service.ts";
import {Router, RouteParams} from "angular2/router";
import {Router, RouteParams} from "@angular/router-deprecated";
import {GalleryService} from "./gallery.service";
import {Directory} from "../../../common/entities/Directory";
import {Message} from "../../../common/entities/Message";

View File

@ -1,8 +1,8 @@
///<reference path="../../browser.d.ts"/>
import {Injectable} from 'angular2/core';
import {Injectable} from '@angular/core';
import {NetworkService} from "../model/network/network.service.ts";
import {Http} from "angular2/http";
import {Http} from "@angular/http";
import {Message} from "../../../common/entities/Message";
import {Directory} from "../../../common/entities/Directory";

View File

@ -1,23 +1,28 @@
///<reference path="../../../browser.d.ts"/>
import {
Component, Input, ElementRef, OnChanges, ViewChild, ViewChildren, QueryList, Output, AfterViewInit, EventEmitter
} from 'angular2/core';
Component,
Input,
ElementRef,
OnChanges,
ViewChild,
ViewChildren,
QueryList,
AfterViewInit
} from "@angular/core";
import {Directory} from "../../../../common/entities/Directory";
import {Photo} from "../../../../common/entities/Photo";
import {GalleryPhotoComponent} from "../photo/photo.gallery.component";
import {GridRowBuilder} from "./GridRowBuilder";
import {AnimationBuilder} from "angular2/animate";
import {Utils} from "../../../../common/Utils";
import {GalleryLightboxComponent} from "../lightbox/lightbox.gallery.component";
import {Observable} from "rxjs/Observable";
@Component({
selector: 'gallery-grid',
templateUrl: 'app/gallery/grid/grid.gallery.component.html',
styleUrls: ['app/gallery/grid/grid.gallery.component.css'],
directives:[GalleryPhotoComponent]
directives: [GalleryPhotoComponent]
})
export class GalleryGridComponent implements OnChanges,AfterViewInit{
export class GalleryGridComponent implements OnChanges,AfterViewInit {
@ViewChild('gridContainer') gridContainer:ElementRef;
@ViewChildren(GalleryPhotoComponent) gridPhotoQL:QueryList<GalleryPhotoComponent>;
@ -35,18 +40,18 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit{
constructor() {
}
ngOnChanges(){
ngOnChanges() {
this.renderPhotos();
}
ngAfterViewInit(){
ngAfterViewInit() {
this.lightbox.gridPhotoQL = this.gridPhotoQL;
this.gridPhotoQL.changes.subscribe(
this.gridPhotoQL.changes.subscribe(
(x)=> {
if(this.gridPhotoQL.length < this.photosToRender.length){
if (this.gridPhotoQL.length < this.photosToRender.length) {
return;
}
if(this.renderedConteinerWidth != this.getContainerWidth()){
if (this.renderedConteinerWidth != this.getContainerWidth()) {
this.renderPhotos();
}
});
@ -54,53 +59,51 @@ export class GalleryGridComponent implements OnChanges,AfterViewInit{
}
private renderedConteinerWidth = 0;
private renderPhotos() {
let maxRowHeight = window.innerHeight / this.MIN_ROW_COUNT;
let minRowHeight = window.innerHeight / this.MAX_ROW_COUNT;
let containerWidth = this.getContainerWidth();
this.renderedConteinerWidth = containerWidth;
this.photosToRender = [];
let i = 0;
private renderPhotos() {
let maxRowHeight = window.innerHeight / this.MIN_ROW_COUNT;
let minRowHeight = window.innerHeight / this.MAX_ROW_COUNT;
let containerWidth = this.getContainerWidth();
this.renderedConteinerWidth = containerWidth;
while (i < this.directory.photos.length ) {
this.photosToRender = [];
let i = 0;
let photoRowBuilder = new GridRowBuilder(this.directory.photos,i,this.IMAGE_MARGIN,this.getContainerWidth());
photoRowBuilder.addPhotos(this.TARGET_COL_COUNT);
photoRowBuilder.adjustRowHeightBetween(minRowHeight,maxRowHeight);
while (i < this.directory.photos.length) {
let rowHeight = photoRowBuilder.calcRowHeight();
let imageHeight = rowHeight - (this.IMAGE_MARGIN * 2);
let photoRowBuilder = new GridRowBuilder(this.directory.photos, i, this.IMAGE_MARGIN, this.getContainerWidth());
photoRowBuilder.addPhotos(this.TARGET_COL_COUNT);
photoRowBuilder.adjustRowHeightBetween(minRowHeight, maxRowHeight);
photoRowBuilder.getPhotoRow().forEach((photo) => {
let imageWidth = imageHeight * (photo.width / photo.height);
this.photosToRender.push(new GridPhoto(photo,imageWidth,imageHeight));
});
let rowHeight = photoRowBuilder.calcRowHeight();
let imageHeight = rowHeight - (this.IMAGE_MARGIN * 2);
i+= photoRowBuilder.getPhotoRow().length;
}
}
photoRowBuilder.getPhotoRow().forEach((photo) => {
let imageWidth = imageHeight * (photo.width / photo.height);
this.photosToRender.push(new GridPhoto(photo, imageWidth, imageHeight));
});
i += photoRowBuilder.getPhotoRow().length;
}
}
onResize() {
this.renderPhotos();
}
private getContainerWidth(): number{
if(!this.gridContainer){
private getContainerWidth():number {
if (!this.gridContainer) {
return 0;
}
return this.gridContainer.nativeElement.clientWidth;
}
}
class GridPhoto {
constructor(public photo:Photo, public renderWidth:number, public renderHeight:number){
constructor(public photo:Photo, public renderWidth:number, public renderHeight:number) {
}
}

View File

@ -1,10 +1,10 @@
///<reference path="../../../browser.d.ts"/>
import {Component, ElementRef, ViewChild, QueryList} from "angular2/core";
import {Component, ElementRef, ViewChild, QueryList} from "@angular/core";
import {Photo} from "../../../../common/entities/Photo";
import {GalleryPhotoComponent} from "../photo/photo.gallery.component";
import {AnimationBuilder} from "angular2/animate";
import {BrowserDomAdapter} from "angular2/src/platform/browser/browser_adapter";
import {AnimationBuilder} from "@angular/platform-browser/src/animate/animation_builder";
import {BrowserDomAdapter} from "@angular/platform-browser/src/browser_common";
import {Dimension} from "../../model/IRenderable";
@Component({

View File

@ -1,6 +1,6 @@
///<reference path="../../../browser.d.ts"/>
import {Component, Input, ElementRef, ViewChild} from 'angular2/core';
import {Component, Input, ElementRef, ViewChild} from '@angular/core';
import {Photo} from "../../../../common/entities/Photo";
import {Directory} from "../../../../common/entities/Directory";
import {Utils} from "../../../../common/Utils";

View File

@ -1,7 +1,7 @@
///<reference path="../../../browser.d.ts"/>
import {Injectable} from "angular2/core";
import {Http} from "angular2/http";
import {Injectable} from "@angular/core";
import {Http} from "@angular/http";
import {NetworkService} from "../../model/network/network.service";
@Injectable()

View File

@ -1,6 +1,6 @@
///<reference path="../../../browser.d.ts"/>
import {Component} from "angular2/core";
import {Component} from "@angular/core";
import {AutoCompleteService} from "./autocomplete.service";
@Component({

View File

@ -1,10 +1,10 @@
///<reference path="../../browser.d.ts"/>
import {Component, OnInit} from 'angular2/core';
import {Component, OnInit} from '@angular/core';
import {LoginCredential} from '../../../common/entities/LoginCredential';
import {AuthenticationService} from "../model/network/authentication.service.ts";
import {Router} from "angular2/router";
import {FORM_DIRECTIVES} from "angular2/common";
import {Router} from "@angular/router-deprecated";
import {FORM_DIRECTIVES} from "@angular/common";
@Component({
selector: 'login',

View File

@ -4,11 +4,11 @@ import {
it,
inject,
injectAsync,
beforeEachProviders,
TestComponentBuilder
} from 'angular2/testing';
beforeEachProviders
} from '@angular/core/testing';
import {provide} from 'angular2/core';
import {provide} from '@angular/core';
import {AuthenticationService} from "./authentication.service.ts";
import {UserService} from "./user.service.ts";
import {User} from "../../../../common/entities/User";

View File

@ -1,6 +1,6 @@
///<reference path="../../../browser.d.ts"/>
import {Injectable} from 'angular2/core';
import {Injectable} from '@angular/core';
import {User} from "../../../../common/entities/User";
import {Event} from "../../../../common/event/Event";
import {UserService} from "./user.service.ts";

View File

@ -1,9 +1,8 @@
///<reference path="../../../browser.d.ts"/>
import {Http, Headers, RequestOptions, Response} from "angular2/http";
import {Http, Headers, RequestOptions} from "@angular/http";
import {Message} from "../../../../common/entities/Message";
import "rxjs/Rx";
import {Utils} from "../../../../common/Utils";
export class NetworkService{

View File

@ -1,8 +1,8 @@
///<reference path="../../../browser.d.ts"/>
import {Injectable} from 'angular2/core';
import {Injectable} from '@angular/core';
import {LoginCredential} from "../../../../common/entities/LoginCredential";
import {Http} from "angular2/http";
import {Http} from "@angular/http";
import {NetworkService} from "./network.service.ts";
import {User} from "../../../../common/entities/User";
import {Message} from "../../../../common/entities/Message";

View File

@ -1,6 +1,9 @@
/// <reference path="../typings/browser.d.ts"/>
/// <reference path="../common/common-classes.d.ts" />
/// <reference path="../node_modules/angular2/typings/browser.d.ts" />
/// <reference path="../node_modules/tslint/lib/tslint.d.ts" />
/// <reference path="../node_modules/@angular/core/index.d.ts" />
/// <reference path="../node_modules/@angular/common/index.d.ts" />
/// <reference path="../node_modules/@angular/router/index.d.ts" />
/// <reference path="../node_modules/@angular/router-deprecated/index.d.ts" />
/// <reference path="../node_modules/zone.js/dist/zone.js.d.ts"/>

View File

@ -1,6 +1,8 @@
///<reference path="../typings/browser.d.ts"/>
import { bootstrap } from 'angular2/platform/browser';
import { bootstrap } from '@angular/platform-browser-dynamic';
import {AppComponent} from "./app/app.component.ts";
bootstrap(AppComponent);
bootstrap(AppComponent)
.catch(err => console.error(err));

View File

@ -8,6 +8,7 @@
},
"exclude": [
"node_modules",
"typings"
"typings/main.d.ts",
"typings/main"
]
}

View File

@ -22,7 +22,15 @@
"url": "https://github.com/bpatrik/PiGallery2/issues"
},
"dependencies": {
"angular2": "^2.0.0-beta.17",
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/platform-server": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.1",
"body-parser": "^1.15.0",
"core-js": "^2.3.0",
"debug": "^2.2.0",
@ -38,7 +46,7 @@
"optimist": "^0.6.1",
"rxjs": "5.0.0-beta.6",
"ts-loader": "^0.8.2",
"tslint": "^3.8.1",
"tslint": "^3.9.0",
"typescript": "^1.8.10",
"typings": "^0.8.1",
"webpack": "^1.13.0",

View File

@ -8,6 +8,7 @@
},
"exclude": [
"node_modules",
"typings"
"typings/main.d.ts",
"typings/main"
]
}

View File

@ -8,6 +8,7 @@
},
"exclude": [
"node_modules",
"typings"
"typings/main.d.ts",
"typings/main"
]
}

View File

@ -3,6 +3,7 @@
"version": false,
"ambientDependencies": {
"body-parser": "registry:dt/body-parser#0.0.0+20160317120654",
"core-js": "registry:dt/core-js#0.0.0+20160317120654",
"debug": "github:DefinitelyTyped/DefinitelyTyped/debug/debug.d.ts#0d622d857f97d44ea7dcad2b3edec1f23c48fe9e",
"express": "github:DefinitelyTyped/DefinitelyTyped/express/express.d.ts#0d622d857f97d44ea7dcad2b3edec1f23c48fe9e",
"express-session": "registry:dt/express-session#0.0.0+20160331200931",
@ -13,5 +14,8 @@
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#0d622d857f97d44ea7dcad2b3edec1f23c48fe9e",
"optimist": "registry:dt/optimist#0.0.0+20160316171810",
"serve-static": "github:DefinitelyTyped/DefinitelyTyped/serve-static/serve-static.d.ts#0d622d857f97d44ea7dcad2b3edec1f23c48fe9e"
},
"dependencies": {
"es6-promise": "registry:npm/es6-promise#3.0.0+20160211003958"
}
}