clean demo project

This commit is contained in:
Mario Romano 2016-04-21 18:46:04 +01:00
parent 32722dfd95
commit d524274d82
10 changed files with 18 additions and 140 deletions

View File

@ -56,9 +56,8 @@
<div class="mdl-layout-spacer"></div> <div class="mdl-layout-spacer"></div>
<!-- Navigation. We hide it in small screens. --> <!-- Navigation. We hide it in small screens. -->
<nav class="mdl-navigation mdl-layout--large-screen-only"> <nav class="mdl-navigation mdl-layout--large-screen-only">
<a class="mdl-navigation__link" href="" [routerLink]="['Home']">Home</a> <a class="mdl-navigation__link" href="" [routerLink]="['Files']">Files</a>
<a class="mdl-navigation__link" href="" [routerLink]="['Page1']">Uploader</a> <a class="mdl-navigation__link" href="" [routerLink]="['Login']">Login</a>
<a class="mdl-navigation__link" href="" [routerLink]="['Page2']">Page 2</a>
</nav> </nav>
<!-- Right aligned menu below button --> <!-- Right aligned menu below button -->
<button id="demo-menu-lower-right" <button id="demo-menu-lower-right"
@ -80,9 +79,8 @@
<div class="mdl-layout__drawer"> <div class="mdl-layout__drawer">
<span class="mdl-layout-title">Alfresco</span> <span class="mdl-layout-title">Alfresco</span>
<nav class="mdl-navigation"> <nav class="mdl-navigation">
<a class="mdl-navigation__link" href="" [routerLink]="['Home']" (click)="hideDrawer()">Home</a> <a class="mdl-navigation__link" href="" [routerLink]="['Files']" (click)="hideDrawer()">Files</a>
<a class="mdl-navigation__link" href="" [routerLink]="['Page1']" (click)="hideDrawer()">Uploader</a> <a class="mdl-navigation__link" href="" [routerLink]="['Login']" (click)="hideDrawer()">Login</a>
<a class="mdl-navigation__link" href="" [routerLink]="['Page2']" (click)="hideDrawer()">Page 2</a>
</nav> </nav>
</div> </div>
<main class="mdl-layout__content"> <main class="mdl-layout__content">

View File

@ -1,13 +1,11 @@
import {Component} from 'angular2/core'; import {Component} from 'angular2/core';
import {Router, RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router'; import {Router, RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
import {Login} from './components/login/login';
import {Authentication} from './services/authentication'; import {Authentication} from './services/authentication';
import {AuthRouterOutlet} from './components/AuthRouterOutlet';
import {HomeView} from './components/home.view';
import {Page1View} from './components/page1.view';
import {Page2View} from './components/page2.view';
import {AlfrescoService} from 'ng2-alfresco-documentlist/ng2-alfresco-documentlist'; import {AlfrescoService} from 'ng2-alfresco-documentlist/ng2-alfresco-documentlist';
import {MDL} from './components/MaterialDesignLiteUpgradeElement'; import {MDL} from './components/common/MaterialDesignLiteUpgradeElement';
import {FilesComponent} from './components/files/files.component';
import {LoginComponent} from './components/login/login.component';
import {AuthRouterOutlet} from './components/router/AuthRouterOutlet';
declare var document: any; declare var document: any;
@ -17,10 +15,8 @@ declare var document: any;
directives: [ROUTER_DIRECTIVES, AuthRouterOutlet, MDL] directives: [ROUTER_DIRECTIVES, AuthRouterOutlet, MDL]
}) })
@RouteConfig([ @RouteConfig([
{path: '/', name: 'Home', component: HomeView, useAsDefault: true}, {path: '/', name: 'Files', component: FilesComponent, useAsDefault: true},
{path: '/login', name: 'Login', component: Login}, {path: '/login', name: 'Login', component: LoginComponent}
{path: '/page1', name: 'Page1', component: Page1View},
{path: '/page2', name: 'Page2', component: Page2View}
]) ])
export class AppComponent { export class AppComponent {

View File

@ -1,9 +1,9 @@
import {Component} from 'angular2/core'; import {Component} from 'angular2/core';
import {DocumentList} from 'ng2-alfresco-documentlist/ng2-alfresco-documentlist'; import {DocumentList} from 'ng2-alfresco-documentlist/ng2-alfresco-documentlist';
import {MDL} from './MaterialDesignLiteUpgradeElement'; import {MDL} from '../common/MaterialDesignLiteUpgradeElement';
@Component({ @Component({
selector: 'home-view', selector: 'files-component',
template: ` template: `
<div class="container-fluid p-10"> <div class="container-fluid p-10">
<div class="row"> <div class="row">
@ -42,7 +42,7 @@ import {MDL} from './MaterialDesignLiteUpgradeElement';
</ul> </ul>
</div> </div>
<div class="col-md-10"> <div class="col-md-10">
<alfresco-document-list #list <alfresco-document-list #list
[thumbnails]="thumbnails" [thumbnails]="thumbnails"
[breadcrumb]="breadcrumb" [breadcrumb]="breadcrumb"
[navigate]="navigation" [navigate]="navigation"
@ -55,7 +55,7 @@ import {MDL} from './MaterialDesignLiteUpgradeElement';
`, `,
directives: [DocumentList, MDL] directives: [DocumentList, MDL]
}) })
export class HomeView { export class FilesComponent {
thumbnails: boolean = true; thumbnails: boolean = true;
breadcrumb: boolean = false; breadcrumb: boolean = false;
navigation: boolean = true; navigation: boolean = true;

View File

@ -5,13 +5,13 @@ import {Authentication} from '../../services/authentication';
declare let componentHandler; declare let componentHandler;
@Component({ @Component({
selector: 'login', selector: 'login-component',
moduleId: 'app/components/login/login', moduleId: 'app/components/login/login',
directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES], directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES],
templateUrl: 'login.component.html', templateUrl: 'login.component.html',
styleUrls: ['login.component.css'], styleUrls: ['login.component.css'],
}) })
export class Login { export class LoginComponent {
form:ControlGroup; form:ControlGroup;
error:boolean = false; error:boolean = false;

View File

@ -1,93 +0,0 @@
import {Component, NgZone} from 'angular2/core';
import {UPLOAD_DIRECTIVES} from 'ng2-uploader/ng2-uploader';
@Component({
selector: 'page1-view',
styles: [
`
:host .dropzone {
width: 100%;
height: 100px;
background-color: #f5f5f5;
margin-top: 2px;
margin-bottom: 2px;
box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
text-align: center;
}
`
],
template: `
<div class="container">
<div class="row">
<h2>Upload File</h2>
<input type="file"
[ng-file-select]="options"
(onUpload)="handleUpload($event)">
<div>
Response: {{ uploadFile | json }}
</div>
</div>
<div class="row">
<h2>Drag and Drop file demo</h2>
<div class="col-md-4 col-md-offset-3">
<div [ng-file-drop]="options" (onUpload)="handleDropUpload($event)" class="dropzone">
Drop file here...
</div>
<div class="progress">
<div class="progress-bar" [style.width]="dropProgress + '%'"></div>
<span class="percent">{{ dropProgress }}%</span>
</div>
</div>
</div>
</div>
`,
directives: [UPLOAD_DIRECTIVES]
})
export class Page1View {
uploadFile:any;
options:Object = {
url: 'http://192.168.99.100:8080/alfresco/service/api/upload',
withCredentials: true,
authToken: btoa('admin:admin'),
authTokenPrefix: 'Basic',
fieldName: 'filedata',
formFields: {
siteid: 'swsdp',
containerid: 'documentLibrary'
}
};
zone:NgZone;
dropProgress:number = 0;
dropResp:any[] = [];
constructor() {
this.zone = new NgZone({enableLongStackTrace: false});
}
handleUpload(data):void {
if (data && data.response) {
data = JSON.parse(data.response);
this.uploadFile = data;
}
}
handleDropUpload(data):void {
let index = this.dropResp.findIndex(x => x.id === data.id);
if (index === -1) {
this.dropResp.push(data);
} else {
this.zone.run(() => {
this.dropResp[index] = data;
});
}
let total = 0, uploaded = 0;
this.dropResp.forEach(resp => {
total += resp.progress.total;
uploaded += resp.progress.loaded;
});
this.dropProgress = Math.floor(uploaded / (total / 100));
}
}

View File

@ -1,21 +0,0 @@
import {Component} from 'angular2/core';
import {MDL} from './MaterialDesignLiteUpgradeElement';
@Component({
selector: 'page2-view',
template: `
<div class="container">
<div class="row">
<h2>Page 2</h2>
<label mdl class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-1">
<input type="checkbox" id="checkbox-1" class="mdl-checkbox__input" checked>
<span class="mdl-checkbox__label">Checkbox</span>
</label>
</div>
</div>
`,
directives: [MDL]
})
export class Page2View {
}

View File

@ -1,6 +1,6 @@
import { ElementRef, DynamicComponentLoader, Directive, Attribute } from 'angular2/core'; import { ElementRef, DynamicComponentLoader, Directive, Attribute } from 'angular2/core';
import { Router, RouterOutlet, ComponentInstruction } from 'angular2/router'; import { Router, RouterOutlet, ComponentInstruction } from 'angular2/router';
import {Authentication} from '../services/authentication'; import {Authentication} from '../../services/authentication';
@Directive({selector: 'auth-router-outlet'}) @Directive({selector: 'auth-router-outlet'})
export class AuthRouterOutlet extends RouterOutlet { export class AuthRouterOutlet extends RouterOutlet {

View File

@ -28,9 +28,6 @@
<!--<script src="node_modules/ng2-uploader/bundles/ng2-uploader.js"></script>--> <!--<script src="node_modules/ng2-uploader/bundles/ng2-uploader.js"></script>-->
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/app/js/xml2json.js"></script> <script src="/app/js/xml2json.js"></script>
<!-- 2. Configure SystemJS --> <!-- 2. Configure SystemJS -->

View File

@ -11,6 +11,7 @@
"noImplicitAny": false "noImplicitAny": false
}, },
"files": [ "files": [
"node_modules/angular2/typings/browser.d.ts",
"typings/browser/ambient/jasmine/index.d.ts", "typings/browser/ambient/jasmine/index.d.ts",
"app/**/*.ts" "app/**/*.ts"
], ],