From dc8bc31be517a53e8fbe7100cfe45cd73f596de0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Mar 2016 13:50:19 +0100 Subject: Angular application :first draft --- client/angular/app/app.component.html | 37 ++++++++++++++++++++ client/angular/app/app.component.scss | 28 ++++++++++++++++ client/angular/app/app.component.ts | 63 +++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 client/angular/app/app.component.html create mode 100644 client/angular/app/app.component.scss create mode 100644 client/angular/app/app.component.ts (limited to 'client/angular/app') diff --git a/client/angular/app/app.component.html b/client/angular/app/app.component.html new file mode 100644 index 000000000..590efa0d6 --- /dev/null +++ b/client/angular/app/app.component.html @@ -0,0 +1,37 @@ +
+ +
+ + +
+ + Get videos +
+ + + +
+ + Make friends +
+ +
+ + Quit friends +
+
+ +
+ +
+ +
+ + + +
diff --git a/client/angular/app/app.component.scss b/client/angular/app/app.component.scss new file mode 100644 index 000000000..03ecba8f2 --- /dev/null +++ b/client/angular/app/app.component.scss @@ -0,0 +1,28 @@ +menu { + min-height: 300px; + height: 100%; + margin-right: 20px; + border-right: 1px solid rgba(0, 0, 0, 0.2); + + .panel_button { + margin: 8px; + cursor: pointer; + transition: margin 0.2s; + + &:hover { + margin-left: 15px; + } + + a { + color: #333333; + } + } + + .glyphicon { + margin: 5px; + } +} + +footer { + margin-top: 30px; +} diff --git a/client/angular/app/app.component.ts b/client/angular/app/app.component.ts new file mode 100644 index 000000000..3d41183f2 --- /dev/null +++ b/client/angular/app/app.component.ts @@ -0,0 +1,63 @@ +import { Component, ElementRef } from 'angular2/core'; +import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router'; +import {HTTP_PROVIDERS} from 'angular2/http'; + +import { VideosAddComponent } from '../videos/components/add/videos-add.component'; +import { VideosListComponent } from '../videos/components/list/videos-list.component'; +import { VideosWatchComponent } from '../videos/components/watch/videos-watch.component'; +import { VideosService } from '../videos/services/videos.service'; +import { FriendsService } from '../friends/services/friends.service'; + +@RouteConfig([ + { + path: '/videos/list', + name: 'VideosList', + component: VideosListComponent, + useAsDefault: true + }, + { + path: '/videos/watch/:id', + name: 'VideosWatch', + component: VideosWatchComponent + }, + { + path: '/videos/add', + name: 'VideosAdd', + component: VideosAddComponent + } +]) + +@Component({ + selector: 'my-app', + templateUrl: 'app/angular/app/app.component.html', + styleUrls: [ 'app/angular/app/app.component.css' ], + directives: [ ROUTER_DIRECTIVES ], + providers: [ ROUTER_PROVIDERS, HTTP_PROVIDERS, ElementRef, VideosService, FriendsService ] +}) + +export class AppComponent { + constructor(private _friendsService: FriendsService) {} + + makeFriends() { + this._friendsService.makeFriends().subscribe( + status => { + if (status === 409) { + alert('Already made friends!'); + } + else { + alert('Made friends!'); + } + }, + error => alert(error) + ) + } + + quitFriends() { + this._friendsService.quitFriends().subscribe( + status => { + alert('Quit friends!'); + }, + error => alert(error) + ) + } +} -- cgit v1.2.3