#33 draft gulp

This commit is contained in:
Mario Romano
2016-04-19 11:57:05 +01:00
parent c90fac92a8
commit 88bd8ea345
91 changed files with 52110 additions and 96 deletions

View File

@@ -0,0 +1,85 @@
System.register(['angular2/core', 'angular2/router', './components/login', './services/authentication', './components/AuthRouterOutlet', './components/home.view', './components/page1.view', './components/page2.view', 'ng2-alfresco/components'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1, router_1, login_1, authentication_1, AuthRouterOutlet_1, home_view_1, page1_view_1, page2_view_1, components_1;
var AppComponent;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
},
function (router_1_1) {
router_1 = router_1_1;
},
function (login_1_1) {
login_1 = login_1_1;
},
function (authentication_1_1) {
authentication_1 = authentication_1_1;
},
function (AuthRouterOutlet_1_1) {
AuthRouterOutlet_1 = AuthRouterOutlet_1_1;
},
function (home_view_1_1) {
home_view_1 = home_view_1_1;
},
function (page1_view_1_1) {
page1_view_1 = page1_view_1_1;
},
function (page2_view_1_1) {
page2_view_1 = page2_view_1_1;
},
function (components_1_1) {
components_1 = components_1_1;
}],
execute: function() {
AppComponent = (function () {
function AppComponent(auth, router, alfrescoService) {
this.auth = auth;
this.router = router;
alfrescoService.host = 'http://192.168.99.100:8080';
}
AppComponent.prototype.isActive = function (instruction) {
return this.router.isRouteActive(this.router.generate(instruction));
};
AppComponent.prototype.isLoggedIn = function () {
return this.auth.isLoggedIn();
};
AppComponent.prototype.onLogout = function (event) {
var _this = this;
event.preventDefault();
this.auth.logout()
.subscribe(function () { return _this.router.navigate(['Login']); });
};
AppComponent = __decorate([
core_1.Component({
selector: 'my-app',
templateUrl: 'app/app.component.html',
directives: [router_1.ROUTER_DIRECTIVES, AuthRouterOutlet_1.AuthRouterOutlet]
}),
router_1.RouteConfig([
{ path: '/', name: 'Home', component: home_view_1.HomeView, useAsDefault: true },
{ path: '/login', name: 'Login', component: login_1.Login },
{ path: '/page1', name: 'Page1', component: page1_view_1.Page1View },
{ path: '/page2', name: 'Page2', component: page2_view_1.Page2View }
]),
__metadata('design:paramtypes', [authentication_1.Authentication, router_1.Router, (typeof (_a = typeof components_1.AlfrescoService !== 'undefined' && components_1.AlfrescoService) === 'function' && _a) || Object])
], AppComponent);
return AppComponent;
var _a;
}());
exports_1("AppComponent", AppComponent);
}
}
});
//# sourceMappingURL=app.component.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBA;gBAEI,sBAAmB,IAAmB,EACnB,MAAa,EACpB,eAA+B;oBAFxB,SAAI,GAAJ,IAAI,CAAe;oBACnB,WAAM,GAAN,MAAM,CAAO;oBAE5B,eAAe,CAAC,IAAI,GAAG,4BAA4B,CAAC;gBACxD,CAAC;gBAED,+BAAQ,GAAR,UAAS,WAAiB;oBACtB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;gBACxE,CAAC;gBAED,iCAAU,GAAV;oBACI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;gBAClC,CAAC;gBAED,+BAAQ,GAAR,UAAS,KAAK;oBAAd,iBAMC;oBALG,KAAK,CAAC,cAAc,EAAE,CAAC;oBACvB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;yBACb,SAAS,CACN,cAAM,OAAA,KAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,EAA/B,CAA+B,CACxC,CAAC;gBACV,CAAC;gBAjCL;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,QAAQ;wBAClB,WAAW,EAAE,wBAAwB;wBACrC,UAAU,EAAE,CAAC,0BAAiB,EAAE,mCAAgB,CAAC;qBACpD,CAAC;oBACD,oBAAW,CAAC;wBACT,EAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAQ,EAAE,YAAY,EAAE,IAAI,EAAC;wBAClE,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,aAAK,EAAC;wBACjD,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,sBAAS,EAAC;wBACrD,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,sBAAS,EAAC;qBACxD,CAAC;;gCAAA;gBAwBF,mBAAC;;YAAD,CAvBA,AAuBC,IAAA;YAvBD,uCAuBC,CAAA","file":"app.component.js","sourcesContent":["import {Component} from 'angular2/core';\nimport {Router, RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';\nimport {Login} from './components/login';\nimport {Authentication} from './services/authentication';\nimport {AuthRouterOutlet} from './components/AuthRouterOutlet';\nimport {HomeView} from './components/home.view';\nimport {Page1View} from './components/page1.view';\nimport {Page2View} from './components/page2.view';\nimport {AlfrescoService} from 'ng2-alfresco/components';\n\n@Component({\n selector: 'my-app',\n templateUrl: 'app/app.component.html',\n directives: [ROUTER_DIRECTIVES, AuthRouterOutlet]\n})\n@RouteConfig([\n {path: '/', name: 'Home', component: HomeView, useAsDefault: true},\n {path: '/login', name: 'Login', component: Login},\n {path: '/page1', name: 'Page1', component: Page1View},\n {path: '/page2', name: 'Page2', component: Page2View}\n])\nexport class AppComponent {\n\n constructor(public auth:Authentication,\n public router:Router,\n alfrescoService:AlfrescoService) {\n alfrescoService.host = 'http://192.168.99.100:8080';\n }\n\n isActive(instruction:any[]):boolean {\n return this.router.isRouteActive(this.router.generate(instruction));\n }\n\n isLoggedIn():boolean {\n return this.auth.isLoggedIn();\n }\n\n onLogout(event) {\n event.preventDefault();\n this.auth.logout()\n .subscribe(\n () => this.router.navigate(['Login'])\n );\n }\n}\n"]}

View File

@@ -0,0 +1,67 @@
System.register(['angular2/core', 'angular2/router', '../services/authentication'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var core_1, router_1, authentication_1;
var AuthRouterOutlet;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
},
function (router_1_1) {
router_1 = router_1_1;
},
function (authentication_1_1) {
authentication_1 = authentication_1_1;
}],
execute: function() {
AuthRouterOutlet = (function (_super) {
__extends(AuthRouterOutlet, _super);
function AuthRouterOutlet(_elementRef, _loader, _parentRouter, nameAttr, authentication) {
_super.call(this, _elementRef, _loader, _parentRouter, nameAttr);
this.authentication = authentication;
this.router = _parentRouter;
this.publicRoutes = [
'', 'login', 'signup'
];
}
AuthRouterOutlet.prototype.activate = function (instruction) {
if (this._canActivate(instruction.urlPath)) {
return _super.prototype.activate.call(this, instruction);
}
this.router.navigate(['Login']);
};
AuthRouterOutlet.prototype._canActivate = function (url) {
return this.publicRoutes.indexOf(url) !== -1
|| this.authentication.isLoggedIn();
};
AuthRouterOutlet = __decorate([
core_1.Directive({ selector: 'auth-router-outlet' }),
__param(3, core_1.Attribute('name')),
__metadata('design:paramtypes', [core_1.ElementRef, core_1.DynamicComponentLoader, router_1.Router, String, authentication_1.Authentication])
], AuthRouterOutlet);
return AuthRouterOutlet;
}(router_1.RouterOutlet));
exports_1("AuthRouterOutlet", AuthRouterOutlet);
}
}
});
//# sourceMappingURL=AuthRouterOutlet.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["components/AuthRouterOutlet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAKA;gBAAsC,oCAAY;gBAK9C,0BACI,WAAuB,EAAE,OAA+B,EACxD,aAAqB,EAAqB,QAAgB,EAClD,cAA8B;oBAEtC,kBAAM,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;oBAF7C,mBAAc,GAAd,cAAc,CAAgB;oBAItC,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC;oBAC5B,IAAI,CAAC,YAAY,GAAG;wBAChB,EAAE,EAAE,OAAO,EAAE,QAAQ;qBACxB,CAAC;gBACN,CAAC;gBAED,mCAAQ,GAAR,UAAS,WAAiC;oBACtC,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;wBACzC,MAAM,CAAC,gBAAK,CAAC,QAAQ,YAAC,WAAW,CAAC,CAAC;oBACvC,CAAC;oBAED,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;gBACpC,CAAC;gBAED,uCAAY,GAAZ,UAAa,GAAG;oBACZ,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;2BACrC,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;gBAC5C,CAAC;gBA9BL;oBAAC,gBAAS,CAAC,EAAC,QAAQ,EAAE,oBAAoB,EAAC,CAAC;+BAQZ,gBAAS,CAAC,MAAM,CAAC;;oCARL;gBA+B5C,uBAAC;YAAD,CA9BA,AA8BC,CA9BqC,qBAAY,GA8BjD;YA9BD,+CA8BC,CAAA","file":"AuthRouterOutlet.js","sourcesContent":["import { ElementRef, DynamicComponentLoader, Directive, Attribute } from 'angular2/core';\nimport { Router, RouterOutlet, ComponentInstruction } from 'angular2/router';\nimport {Authentication} from '../services/authentication';\n\n@Directive({selector: 'auth-router-outlet'})\nexport class AuthRouterOutlet extends RouterOutlet {\n\n publicRoutes: Array<string>;\n private router: Router;\n\n constructor(\n _elementRef: ElementRef, _loader: DynamicComponentLoader,\n _parentRouter: Router, @Attribute('name') nameAttr: string,\n private authentication: Authentication\n ) {\n super(_elementRef, _loader, _parentRouter, nameAttr);\n\n this.router = _parentRouter;\n this.publicRoutes = [\n '', 'login', 'signup'\n ];\n }\n\n activate(instruction: ComponentInstruction) {\n if (this._canActivate(instruction.urlPath)) {\n return super.activate(instruction);\n }\n\n this.router.navigate(['Login']);\n }\n\n _canActivate(url) {\n return this.publicRoutes.indexOf(url) !== -1\n || this.authentication.isLoggedIn();\n }\n}\n"]}

View File

@@ -0,0 +1,54 @@
System.register(['angular2/core', 'ng2-alfresco/components'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1, components_1;
var HomeView;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
},
function (components_1_1) {
components_1 = components_1_1;
}],
execute: function() {
HomeView = (function () {
function HomeView() {
this.thumbnails = true;
this.breadcrumb = false;
this.navigation = true;
this.downloads = true;
this.events = [];
}
HomeView.prototype.onItemClick = function ($event) {
console.log($event.value);
this.events.push({
name: 'Item Clicked',
value: $event.value
});
};
HomeView = __decorate([
core_1.Component({
selector: 'home-view',
template: "\n <div class=\"container-fluid\">\n <div class=\"row\">\n <div class=\"col-md-2\">\n <ul class=\"list-unstyled\">\n <li><label><input type=\"checkbox\" [(ngModel)]=\"thumbnails\"> Thumbnails</label></li>\n <li><label><input type=\"checkbox\" [(ngModel)]=\"breadcrumb\"> Breadcrumb</label></li>\n <li><label><input type=\"checkbox\" [(ngModel)]=\"navigation\"> Navigation</label></li>\n <li><label><input type=\"checkbox\" [(ngModel)]=\"downloads\"> Downloads</label></li>\n </ul>\n <hr>\n <ul class=\"list-unstyled\" style=\"font-size: 10px\">\n <li *ngFor=\"#event of events\">\n <strong>{{event.name}}</strong>: {{event.value.displayName}}\n </li>\n </ul>\n </div>\n <div class=\"col-md-10\">\n <alfresco-document-list #list \n [thumbnails]=\"thumbnails\"\n [breadcrumb]=\"breadcrumb\"\n [navigate]=\"navigation\"\n [downloads]=\"downloads\"\n (itemClick)=\"onItemClick($event)\">\n </alfresco-document-list>\n </div>\n </div>\n </div>\n ",
directives: [components_1.DocumentList]
}),
__metadata('design:paramtypes', [])
], HomeView);
return HomeView;
}());
exports_1("HomeView", HomeView);
}
}
});
//# sourceMappingURL=home.view.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["components/home.view.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;YAoCA;gBAAA;oBACI,eAAU,GAAY,IAAI,CAAC;oBAC3B,eAAU,GAAY,KAAK,CAAC;oBAC5B,eAAU,GAAY,IAAI,CAAC;oBAC3B,cAAS,GAAY,IAAI,CAAC;oBAE1B,WAAM,GAAU,EAAE,CAAC;gBASvB,CAAC;gBAPG,8BAAW,GAAX,UAAY,MAAM;oBACd,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;wBACb,IAAI,EAAE,cAAc;wBACpB,KAAK,EAAE,MAAM,CAAC,KAAK;qBACtB,CAAC,CAAC;gBACP,CAAC;gBA/CL;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,WAAW;wBACrB,QAAQ,EAAE,+6CA4BT;wBACD,UAAU,EAAE,CAAC,yBAAY,CAAC;qBAC7B,CAAC;;4BAAA;gBAgBF,eAAC;YAAD,CAfA,AAeC,IAAA;YAfD,+BAeC,CAAA","file":"home.view.js","sourcesContent":["import {Component} from 'angular2/core';\nimport {DocumentList} from 'ng2-alfresco/components';\n\n@Component({\n selector: 'home-view',\n template: `\n <div class=\"container-fluid\">\n <div class=\"row\">\n <div class=\"col-md-2\">\n <ul class=\"list-unstyled\">\n <li><label><input type=\"checkbox\" [(ngModel)]=\"thumbnails\"> Thumbnails</label></li>\n <li><label><input type=\"checkbox\" [(ngModel)]=\"breadcrumb\"> Breadcrumb</label></li>\n <li><label><input type=\"checkbox\" [(ngModel)]=\"navigation\"> Navigation</label></li>\n <li><label><input type=\"checkbox\" [(ngModel)]=\"downloads\"> Downloads</label></li>\n </ul>\n <hr>\n <ul class=\"list-unstyled\" style=\"font-size: 10px\">\n <li *ngFor=\"#event of events\">\n <strong>{{event.name}}</strong>: {{event.value.displayName}}\n </li>\n </ul>\n </div>\n <div class=\"col-md-10\">\n <alfresco-document-list #list \n [thumbnails]=\"thumbnails\"\n [breadcrumb]=\"breadcrumb\"\n [navigate]=\"navigation\"\n [downloads]=\"downloads\"\n (itemClick)=\"onItemClick($event)\">\n </alfresco-document-list>\n </div>\n </div>\n </div>\n `,\n directives: [DocumentList]\n})\nexport class HomeView {\n thumbnails: boolean = true;\n breadcrumb: boolean = false;\n navigation: boolean = true;\n downloads: boolean = true;\n\n events: any[] = [];\n\n onItemClick($event) {\n console.log($event.value);\n this.events.push({\n name: 'Item Clicked',\n value: $event.value\n });\n }\n}\n"]}

View File

@@ -0,0 +1,72 @@
System.register(['angular2/core', 'angular2/router', 'angular2/common', '../services/authentication'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1, router_1, common_1, authentication_1;
var Login;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
},
function (router_1_1) {
router_1 = router_1_1;
},
function (common_1_1) {
common_1 = common_1_1;
},
function (authentication_1_1) {
authentication_1 = authentication_1_1;
}],
execute: function() {
Login = (function () {
function Login(fb, auth, router) {
this.auth = auth;
this.router = router;
this.error = false;
this.form = fb.group({
username: ['', common_1.Validators.compose([common_1.Validators.required, common_1.Validators.minLength(4)])],
password: ['', common_1.Validators.required]
});
}
Login.prototype.isErrorStyle = function (field) {
if (field.valid) {
return false;
}
else {
return true;
}
};
Login.prototype.onSubmit = function (value, event) {
var _this = this;
event.preventDefault();
this.auth.login('POST', value.username, value.password)
.subscribe(function (token) { return _this.router.navigate(['Home']); }, function () {
_this.error = true;
});
};
Login = __decorate([
core_1.Component({
selector: 'login',
directives: [router_1.ROUTER_DIRECTIVES, common_1.FORM_DIRECTIVES],
templateUrl: 'app/template/login.component.html',
styleUrls: ['app/style/login.component.css'],
}),
__metadata('design:paramtypes', [common_1.FormBuilder, authentication_1.Authentication, router_1.Router])
], Login);
return Login;
}());
exports_1("Login", Login);
}
}
});
//# sourceMappingURL=login.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["components/login.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAWA;gBAYI,eAAY,EAAc,EAAS,IAAmB,EAAS,MAAa;oBAAzC,SAAI,GAAJ,IAAI,CAAe;oBAAS,WAAM,GAAN,MAAM,CAAO;oBAV5E,UAAK,GAAW,KAAK,CAAC;oBAWlB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC;wBACjB,QAAQ,EAAE,CAAC,EAAE,EAAE,mBAAU,CAAC,OAAO,CAAC,CAAC,mBAAU,CAAC,QAAQ,EAAE,mBAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;wBAClF,QAAQ,EAAE,CAAC,EAAE,EAAE,mBAAU,CAAC,QAAQ,CAAC;qBACtC,CAAC,CAAC;gBACP,CAAC;gBAbD,4BAAY,GAAZ,UAAa,KAAkB;oBAC3B,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;wBACd,MAAM,CAAC,KAAK,CAAC;oBACjB,CAAC;oBAAC,IAAI,CAAC,CAAC;wBACJ,MAAM,CAAC,IAAI,CAAC;oBAChB,CAAC;gBACL,CAAC;gBASD,wBAAQ,GAAR,UAAS,KAAS,EAAE,KAAK;oBAAzB,iBASC;oBARG,KAAK,CAAC,cAAc,EAAE,CAAC;oBACvB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC;yBAClD,SAAS,CACN,UAAC,KAAS,IAAK,OAAA,KAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,EAA9B,CAA8B,EAC7C;wBACI,KAAI,CAAC,KAAK,GAAG,IAAI,CAAC;oBACtB,CAAC,CACJ,CAAC;gBACV,CAAC;gBAlCL;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,OAAO;wBACjB,UAAU,EAAE,CAAC,0BAAiB,EAAE,wBAAe,CAAC;wBAChD,WAAW,EAAE,mCAAmC;wBAChD,SAAS,EAAE,CAAC,+BAA+B,CAAC;qBAC/C,CAAC;;yBAAA;gBA8BF,YAAC;YAAD,CA7BA,AA6BC,IAAA;YA7BD,yBA6BC,CAAA","file":"login.js","sourcesContent":["import {Component} from 'angular2/core';\nimport {Router, ROUTER_DIRECTIVES} from 'angular2/router';\nimport {FORM_DIRECTIVES, ControlGroup, FormBuilder, Validators} from 'angular2/common';\nimport {Authentication} from '../services/authentication';\n\n@Component({\n selector: 'login',\n directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES],\n templateUrl: 'app/template/login.component.html',\n styleUrls: ['app/style/login.component.css'],\n})\nexport class Login {\n form:ControlGroup;\n error:boolean = false;\n\n isErrorStyle(field:ControlGroup) {\n if (field.valid) {\n return false;\n } else {\n return true;\n }\n }\n\n constructor(fb:FormBuilder, public auth:Authentication, public router:Router) {\n this.form = fb.group({\n username: ['', Validators.compose([Validators.required, Validators.minLength(4)])],\n password: ['', Validators.required]\n });\n }\n\n onSubmit(value:any, event) {\n event.preventDefault();\n this.auth.login('POST', value.username, value.password)\n .subscribe(\n (token:any) => this.router.navigate(['Home']),\n () => {\n this.error = true;\n }\n );\n }\n}\n"]}

View File

@@ -0,0 +1,83 @@
System.register(['angular2/core', 'ng2-uploader/ng2-uploader'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1, ng2_uploader_1;
var Page1View;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
},
function (ng2_uploader_1_1) {
ng2_uploader_1 = ng2_uploader_1_1;
}],
execute: function() {
Page1View = (function () {
function Page1View() {
this.options = {
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'
}
};
this.dropProgress = 0;
this.dropResp = [];
this.zone = new core_1.NgZone({ enableLongStackTrace: false });
}
Page1View.prototype.handleUpload = function (data) {
if (data && data.response) {
data = JSON.parse(data.response);
this.uploadFile = data;
}
};
Page1View.prototype.handleDropUpload = function (data) {
var _this = this;
var index = this.dropResp.findIndex(function (x) { return x.id === data.id; });
if (index === -1) {
this.dropResp.push(data);
}
else {
this.zone.run(function () {
_this.dropResp[index] = data;
});
}
var total = 0, uploaded = 0;
this.dropResp.forEach(function (resp) {
total += resp.progress.total;
uploaded += resp.progress.loaded;
});
this.dropProgress = Math.floor(uploaded / (total / 100));
};
Page1View = __decorate([
core_1.Component({
selector: 'page1-view',
styles: [
"\n :host .dropzone {\n width: 100%;\n height: 100px;\n background-color: #f5f5f5;\n margin-top: 2px;\n margin-bottom: 2px;\n box-shadow: inset 0 1px 2px rgba(0,0,0,.1);\n text-align: center;\n }\n "
],
template: "\n <div class=\"container\">\n <div class=\"row\">\n <h2>Upload File</h2>\n <input type=\"file\" \n [ng-file-select]=\"options\"\n (onUpload)=\"handleUpload($event)\">\n <div>\n Response: {{ uploadFile | json }}\n </div>\n </div>\n <div class=\"row\">\n <h2>Drag and Drop file demo</h2>\n <div class=\"col-md-4 col-md-offset-3\">\n <div [ng-file-drop]=\"options\" (onUpload)=\"handleDropUpload($event)\" class=\"dropzone\">\n Drop file here...\n </div>\n <div class=\"progress\">\n <div class=\"progress-bar\" [style.width]=\"dropProgress + '%'\"></div>\n <span class=\"percent\">{{ dropProgress }}%</span>\n </div>\n </div>\n </div>\n </div>\n ",
directives: [ng2_uploader_1.UPLOAD_DIRECTIVES]
}),
__metadata('design:paramtypes', [])
], Page1View);
return Page1View;
}());
exports_1("Page1View", Page1View);
}
}
});
//# sourceMappingURL=page1.view.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["components/page1.view.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;YA6CA;gBAkBI;oBAhBA,YAAO,GAAU;wBACb,GAAG,EAAE,wDAAwD;wBAC7D,eAAe,EAAE,IAAI;wBACrB,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC;wBAC9B,eAAe,EAAE,OAAO;wBACxB,SAAS,EAAE,UAAU;wBACrB,UAAU,EAAE;4BACR,MAAM,EAAE,OAAO;4BACf,WAAW,EAAE,iBAAiB;yBACjC;qBACJ,CAAC;oBAGF,iBAAY,GAAU,CAAC,CAAC;oBACxB,aAAQ,GAAS,EAAE,CAAC;oBAGhB,IAAI,CAAC,IAAI,GAAG,IAAI,aAAM,CAAC,EAAC,oBAAoB,EAAE,KAAK,EAAC,CAAC,CAAC;gBAC1D,CAAC;gBAED,gCAAY,GAAZ,UAAa,IAAI;oBACb,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;wBACxB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;wBACjC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;oBAC3B,CAAC;gBACL,CAAC;gBAED,oCAAgB,GAAhB,UAAiB,IAAI;oBAArB,iBAiBC;oBAhBG,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAhB,CAAgB,CAAC,CAAC;oBAC3D,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;wBACf,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBAC7B,CAAC;oBAAC,IAAI,CAAC,CAAC;wBACJ,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;4BACV,KAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;wBAChC,CAAC,CAAC,CAAC;oBACP,CAAC;oBAED,IAAI,KAAK,GAAG,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC;oBAC5B,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAA,IAAI;wBACtB,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;wBAC7B,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;oBACrC,CAAC,CAAC,CAAC;oBAEH,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;gBAC7D,CAAC;gBAxFL;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,YAAY;wBACtB,MAAM,EAAE;4BACJ,ySAUC;yBACJ;wBACD,QAAQ,EAAE,6/BAwBT;wBACD,UAAU,EAAE,CAAC,gCAAiB,CAAC;qBAClC,CAAC;;6BAAA;gBAgDF,gBAAC;YAAD,CA/CA,AA+CC,IAAA;YA/CD,iCA+CC,CAAA","file":"page1.view.js","sourcesContent":["import {Component, NgZone} from 'angular2/core';\nimport {UPLOAD_DIRECTIVES} from 'ng2-uploader/ng2-uploader';\n\n@Component({\n selector: 'page1-view',\n styles: [\n `\n :host .dropzone {\n width: 100%;\n height: 100px;\n background-color: #f5f5f5;\n margin-top: 2px;\n margin-bottom: 2px;\n box-shadow: inset 0 1px 2px rgba(0,0,0,.1);\n text-align: center;\n }\n `\n ],\n template: `\n <div class=\"container\">\n <div class=\"row\">\n <h2>Upload File</h2>\n <input type=\"file\" \n [ng-file-select]=\"options\"\n (onUpload)=\"handleUpload($event)\">\n <div>\n Response: {{ uploadFile | json }}\n </div>\n </div>\n <div class=\"row\">\n <h2>Drag and Drop file demo</h2>\n <div class=\"col-md-4 col-md-offset-3\">\n <div [ng-file-drop]=\"options\" (onUpload)=\"handleDropUpload($event)\" class=\"dropzone\">\n Drop file here...\n </div>\n <div class=\"progress\">\n <div class=\"progress-bar\" [style.width]=\"dropProgress + '%'\"></div>\n <span class=\"percent\">{{ dropProgress }}%</span>\n </div>\n </div>\n </div>\n </div>\n `,\n directives: [UPLOAD_DIRECTIVES]\n})\nexport class Page1View {\n uploadFile:any;\n options:Object = {\n url: 'http://192.168.99.100:8080/alfresco/service/api/upload',\n withCredentials: true,\n authToken: btoa('admin:admin'),\n authTokenPrefix: 'Basic',\n fieldName: 'filedata',\n formFields: {\n siteid: 'swsdp',\n containerid: 'documentLibrary'\n }\n };\n\n zone:NgZone;\n dropProgress:number = 0;\n dropResp:any[] = [];\n\n constructor() {\n this.zone = new NgZone({enableLongStackTrace: false});\n }\n\n handleUpload(data):void {\n if (data && data.response) {\n data = JSON.parse(data.response);\n this.uploadFile = data;\n }\n }\n\n handleDropUpload(data):void {\n let index = this.dropResp.findIndex(x => x.id === data.id);\n if (index === -1) {\n this.dropResp.push(data);\n } else {\n this.zone.run(() => {\n this.dropResp[index] = data;\n });\n }\n\n let total = 0, uploaded = 0;\n this.dropResp.forEach(resp => {\n total += resp.progress.total;\n uploaded += resp.progress.loaded;\n });\n\n this.dropProgress = Math.floor(uploaded / (total / 100));\n }\n}\n"]}

View File

@@ -0,0 +1,42 @@
System.register(['angular2/core', 'ng2-alfresco/components'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1, components_1;
var Page2View;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
},
function (components_1_1) {
components_1 = components_1_1;
}],
execute: function() {
Page2View = (function () {
function Page2View() {
}
Page2View = __decorate([
core_1.Component({
selector: 'page2-view',
template: "\n <div class=\"container\">\n <div class=\"row\">\n <h2>Page 2</h2>\n <hello-world></hello-world>\n </div>\n </div>\n ",
directives: [components_1.HelloWorld]
}),
__metadata('design:paramtypes', [])
], Page2View);
return Page2View;
}());
exports_1("Page2View", Page2View);
}
}
});
//# sourceMappingURL=page2.view.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["components/page2.view.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;YAeA;gBAAA;gBAEA,CAAC;gBAdD;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,YAAY;wBACtB,QAAQ,EAAE,8LAOT;wBACD,UAAU,EAAE,CAAC,uBAAU,CAAC;qBAC3B,CAAC;;6BAAA;gBAGF,gBAAC;YAAD,CAFA,AAEC,IAAA;YAFD,iCAEC,CAAA","file":"page2.view.js","sourcesContent":["import {Component} from 'angular2/core';\nimport {HelloWorld} from 'ng2-alfresco/components';\n\n@Component({\n selector: 'page2-view',\n template: `\n <div class=\"container\">\n <div class=\"row\">\n <h2>Page 2</h2>\n <hello-world></hello-world>\n </div>\n </div>\n `,\n directives: [HelloWorld]\n})\nexport class Page2View {\n\n}\n"]}

36
demo-shell-ng2/dist/app/app/main.js vendored Normal file
View File

@@ -0,0 +1,36 @@
System.register(['angular2/platform/browser', './app.component', 'angular2/router', 'angular2/http', './services/authentication', 'ng2-alfresco/components'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var browser_1, app_component_1, router_1, http_1, authentication_1, components_1;
return {
setters:[
function (browser_1_1) {
browser_1 = browser_1_1;
},
function (app_component_1_1) {
app_component_1 = app_component_1_1;
},
function (router_1_1) {
router_1 = router_1_1;
},
function (http_1_1) {
http_1 = http_1_1;
},
function (authentication_1_1) {
authentication_1 = authentication_1_1;
},
function (components_1_1) {
components_1 = components_1_1;
}],
execute: function() {
browser_1.bootstrap(app_component_1.AppComponent, [
router_1.ROUTER_PROVIDERS,
http_1.HTTP_PROVIDERS,
authentication_1.Authentication,
components_1.ALFRESCO_PROVIDERS
]);
}
}
});
//# sourceMappingURL=main.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;YAOA,mBAAS,CAAC,4BAAY,EAAE;gBACpB,yBAAgB;gBAChB,qBAAc;gBACd,+BAAc;gBACd,+BAAkB;aACrB,CAAC,CAAC","file":"main.js","sourcesContent":["import {bootstrap} from 'angular2/platform/browser';\nimport {AppComponent} from './app.component';\nimport {ROUTER_PROVIDERS} from 'angular2/router';\nimport {HTTP_PROVIDERS} from 'angular2/http';\nimport {Authentication} from './services/authentication';\nimport {ALFRESCO_PROVIDERS} from 'ng2-alfresco/components';\n\nbootstrap(AppComponent, [\n ROUTER_PROVIDERS,\n HTTP_PROVIDERS,\n Authentication,\n ALFRESCO_PROVIDERS\n]);\n"]}

View File

@@ -0,0 +1,100 @@
System.register(['angular2/core', 'rxjs/Rx', 'angular2/http'], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1, Rx_1, http_1;
var Authentication;
return {
setters:[
function (core_1_1) {
core_1 = core_1_1;
},
function (Rx_1_1) {
Rx_1 = Rx_1_1;
},
function (http_1_1) {
http_1 = http_1_1;
}],
execute: function() {
Authentication = (function () {
function Authentication(http) {
this.http = http;
this._host = 'http://192.168.99.100:8080';
this._baseUrl = this._host + '/alfresco/service/api/';
this.token = localStorage.getItem('token');
}
Authentication.prototype.isLoggedIn = function () {
return !!localStorage.getItem('token');
};
Authentication.prototype.login = function (method, username, password) {
if (method === 'GET') {
return this.loginGet(username, password);
}
else {
return this.loginPost(username, password);
}
};
Authentication.prototype.loginGet = function (username, password) {
var _this = this;
var searchParams = new http_1.URLSearchParams();
searchParams.set('u', username);
searchParams.set('pw', password);
return this.http.get(this._baseUrl + 'login', { search: searchParams })
.map(function (res) {
var data = JSON.parse(xml2json(res.text(), ' '));
_this.token = data.ticket;
_this.saveJwt(_this.token);
})
.catch(this.handleError);
};
Authentication.prototype.loginPost = function (username, password) {
var _this = this;
var credentials = '{ username: ' + username + ', password: ' + password + ' }';
var headers = new http_1.Headers();
headers.append('Content-Type', 'application/json');
return this.http.post(this._baseUrl + 'login', credentials, {
headers: headers
})
.map(function (res) {
var response = res.json();
_this.token = response.data.ticket;
_this.saveJwt(_this.token);
})
.catch(this.handleError);
};
Authentication.prototype.saveJwt = function (jwt) {
if (jwt) {
localStorage.setItem('token', jwt);
}
};
Authentication.prototype.logout = function () {
this.token = undefined;
localStorage.removeItem('token');
return Rx_1.Observable.of(true);
};
Authentication.prototype.handleError = function (error) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.error(error);
return Rx_1.Observable.throw(error.json().error || 'Server error');
};
Authentication = __decorate([
core_1.Injectable(),
__metadata('design:paramtypes', [http_1.Http])
], Authentication);
return Authentication;
}());
exports_1("Authentication", Authentication);
}
}
});
//# sourceMappingURL=authentication.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["services/authentication.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAOA;gBAMI,wBAAmB,IAAS;oBAAT,SAAI,GAAJ,IAAI,CAAK;oBAHpB,UAAK,GAAU,4BAA4B,CAAC;oBAC5C,aAAQ,GAAU,IAAI,CAAC,KAAK,GAAG,wBAAwB,CAAC;oBAG5D,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC/C,CAAC;gBAED,mCAAU,GAAV;oBACI,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC3C,CAAC;gBAED,8BAAK,GAAL,UAAM,MAAa,EAAE,QAAe,EAAE,QAAe;oBACjD,EAAE,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC;wBACnB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;oBAC7C,CAAC;oBAAC,IAAI,CAAC,CAAC;wBACJ,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;oBAC9C,CAAC;gBACL,CAAC;gBAED,iCAAQ,GAAR,UAAS,QAAe,EAAE,QAAe;oBAAzC,iBAYC;oBAXG,IAAM,YAAY,GAAG,IAAI,sBAAe,EAAE,CAAC;oBAC3C,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;oBAChC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;oBAEjC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,EAAC,MAAM,EAAE,YAAY,EAAC,CAAC;yBAChE,GAAG,CAAC,UAAC,GAAO;wBACT,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;wBAClD,KAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;wBACzB,KAAI,CAAC,OAAO,CAAC,KAAI,CAAC,KAAK,CAAC,CAAC;oBAC7B,CAAC,CAAC;yBACD,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACjC,CAAC;gBAED,kCAAS,GAAT,UAAU,QAAe,EAAE,QAAe;oBAA1C,iBAeC;oBAdG,IAAI,WAAW,GAAG,cAAc,GAAG,QAAQ,GAAG,cAAc,GAAG,QAAQ,GAAG,IAAI,CAAC;oBAE/E,IAAI,OAAO,GAAG,IAAI,cAAO,EAAE,CAAC;oBAC5B,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;oBAEnD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,WAAW,EAAE;wBACpD,OAAO,EAAE,OAAO;qBACnB,CAAC;yBACD,GAAG,CAAC,UAAC,GAAO;wBACT,IAAI,QAAQ,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;wBAC1B,KAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;wBAClC,KAAI,CAAC,OAAO,CAAC,KAAI,CAAC,KAAK,CAAC,CAAC;oBAC7B,CAAC,CAAC;yBACD,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACjC,CAAC;gBAED,gCAAO,GAAP,UAAQ,GAAG;oBACP,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;wBACN,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;oBACvC,CAAC;gBACL,CAAC;gBAED,+BAAM,GAAN;oBACI,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;oBACvB,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;oBAEjC,MAAM,CAAC,eAAU,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBAC/B,CAAC;gBAEO,oCAAW,GAAnB,UAAoB,KAAc;oBAC9B,mFAAmF;oBACnF,4CAA4C;oBAC5C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBACrB,MAAM,CAAC,eAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,cAAc,CAAC,CAAC;gBAClE,CAAC;gBAxEL;oBAAC,iBAAU,EAAE;;kCAAA;gBAyEb,qBAAC;YAAD,CAxEA,AAwEC,IAAA;YAxED,2CAwEC,CAAA","file":"authentication.js","sourcesContent":["import {Injectable} from 'angular2/core';\nimport {Observable} from 'rxjs/Rx';\nimport {Http, Headers, URLSearchParams, Response} from 'angular2/http';\n\ndeclare var xml2json:any;\n\n@Injectable()\nexport class Authentication {\n token:string;\n\n private _host:string = 'http://192.168.99.100:8080';\n private _baseUrl:string = this._host + '/alfresco/service/api/';\n\n constructor(public http:Http) {\n this.token = localStorage.getItem('token');\n }\n\n isLoggedIn() {\n return !!localStorage.getItem('token');\n }\n\n login(method:string, username:string, password:string) {\n if (method === 'GET') {\n return this.loginGet(username, password);\n } else {\n return this.loginPost(username, password);\n }\n }\n\n loginGet(username:string, password:string) {\n const searchParams = new URLSearchParams();\n searchParams.set('u', username);\n searchParams.set('pw', password);\n\n return this.http.get(this._baseUrl + 'login', {search: searchParams})\n .map((res:any) => {\n let data = JSON.parse(xml2json(res.text(), ' '));\n this.token = data.ticket;\n this.saveJwt(this.token);\n })\n .catch(this.handleError);\n }\n\n loginPost(username:string, password:string) {\n let credentials = '{ username: ' + username + ', password: ' + password + ' }';\n\n let headers = new Headers();\n headers.append('Content-Type', 'application/json');\n\n return this.http.post(this._baseUrl + 'login', credentials, {\n headers: headers\n })\n .map((res:any) => {\n let response = res.json();\n this.token = response.data.ticket;\n this.saveJwt(this.token);\n })\n .catch(this.handleError);\n }\n\n saveJwt(jwt) {\n if (jwt) {\n localStorage.setItem('token', jwt);\n }\n }\n\n logout() {\n this.token = undefined;\n localStorage.removeItem('token');\n\n return Observable.of(true);\n }\n\n private handleError(error:Response) {\n // in a real world app, we may send the error to some remote logging infrastructure\n // instead of just logging it to the console\n console.error(error);\n return Observable.throw(error.json().error || 'Server error');\n }\n}\n"]}