<!DOCTYPE html>
<html>
<head>
<base href="." />
<title>angular2 playground</title>
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.blue-orange.min.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
<script src="https://unpkg.com/zone.js/dist/long-stack-trace-zone.js"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.8"></script>
<script src="https://unpkg.com/systemjs@0.19.31/dist/system.js"></script>
<script src="config.js"></script>
<script>
System.import('app')
.catch(console.error.bind(console));
</script>
</head>
<body>
<my-app>
loading...
</my-app>
</body>
</html>
/* Styles go here */
.p-10 {
padding: 10px;
}
### Angular Starter Plunker - Typescript
System.config({
//use typescript for compilation
transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
emitDecoratorMetadata: true
},
paths: {
'npm:': 'https://unpkg.com/'
},
//map tells the System loader where to look for things
map: {
'app': './src',
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js',
'@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js',
'@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js',
'rxjs': 'npm:rxjs',
'typescript': 'npm:typescript@2.0.2/lib/typescript.js',
'ng2-translate': 'npm:ng2-translate@2.5.0',
'alfresco-js-api': 'npm:alfresco-js-api@1.0.0/dist/alfresco-js-api.min.js',
'ng2-alfresco-core': 'npm:ng2-alfresco-core@1.0.0/bundles/ng2-alfresco-core.js',
'ng2-alfresco-datatable': 'npm:ng2-alfresco-datatable@1.0.0/bundles/ng2-alfresco-datatable.js'
},
//packages defines our app package
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
},
rxjs: {
defaultExtension: 'js'
},
'ng2-translate': { defaultExtension: 'js' }
}
});
//main entry point
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app';
platformBrowserDynamic().bootstrapModule(AppModule)
//our root app component
import { Component, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { CoreModule } from 'ng2-alfresco-core';
import {
DataTableModule,
ObjectDataTableAdapter,
DataSorting,
ObjectDataRow,
ObjectDataColumn
} from 'ng2-alfresco-datatable';
@Component({
selector: 'my-app',
template: `
<div class="container">
<div class="p-10">
<alfresco-datatable [data]="data" [multiselect]="multiselect"></alfresco-datatable>
</div>
<div class="p-10">
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-1">
<input type="checkbox" id="checkbox-1" class="mdl-checkbox__input" [(ngModel)]="multiselect">
<span class="mdl-checkbox__label">Multiselect</span>
</label>
</div>
<div class="p-10">
<button
class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"
(click)="reset()">
Reset to default
</button>
<button
class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"
(click)="addRow()">
Add row
</button>
<button
class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"
(click)="replaceRows()">
Replace rows
</button>
<button
class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"
(click)="replaceColumns()">
Replace columns
</button>
</div>
</div>
`,
})
export class App {
name:string;
multiselect: boolean = false;
data: ObjectDataTableAdapter;
private _imageUrl: string = 'http://placehold.it/140x100';
private _createdBy: any = {
name: 'Denys Vuika',
email: 'denys.vuika@alfresco.com'
};
constructor() {
this.name = 'Alfresco DataTable Demo';
this.reset();
}
reset() {
this.data = new ObjectDataTableAdapter(
[
{id: 1, name: 'Name 1', createdBy: this._createdBy, icon: 'material-icons://folder_open'},
{id: 2, name: 'Name 2', createdBy: this._createdBy, icon: 'material-icons://accessibility'},
{id: 3, name: 'Name 3', createdBy: this._createdBy, icon: 'material-icons://alarm'},
{id: 4, name: 'Image 1', createdBy: this._createdBy, icon: this._imageUrl}
],
[
{type: 'image', key: 'icon', title: '', srTitle: 'Thumbnail'},
{type: 'text', key: 'id', title: 'Id', sortable: true},
{type: 'text', key: 'name', title: 'Name', cssClass: 'full-width name-column', sortable: true},
{type: 'text', key: 'createdBy.name', title: 'Created By', sortable: true}
]
);
this.data.setSorting(new DataSorting('id', 'asc'));
}
addRow() {
let id = this.data.getRows().length + 1;
let row = new ObjectDataRow({
id: id,
name: 'Name ' + id,
icon: 'material-icons://extension',
createdBy: this._createdBy
});
this.data.getRows().push(row);
this.data.sort();
}
replaceRows() {
let objects = [
{id: 10, name: 'Name 10', createdBy: this._createdBy, icon: 'material-icons://face'},
{id: 11, name: 'Name 11', createdBy: this._createdBy, icon: 'material-icons://language'},
{id: 12, name: 'Name 12', createdBy: this._createdBy, icon: 'material-icons://pets'},
{id: 13, name: 'Image 13', createdBy: this._createdBy, icon: this._imageUrl}
];
let rows = objects.map(obj => new ObjectDataRow(obj));
this.data.setRows(rows);
}
replaceColumns() {
let schema = [
{ type: 'text', key: 'id', title: 'Id', sortable: true },
{ type: 'text', key: 'name', title: 'Name', sortable: true, cssClass: 'full-width name-column' }
];
let columns = schema.map(col => new ObjectDataColumn(col));
this.data.setColumns(columns);
}
}
@NgModule({
imports: [
BrowserModule,
CoreModule.forRoot(),
DataTableModule
],
declarations: [ App ],
bootstrap: [ App ]
})
export class AppModule {}