cms.component.ts
1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import {StateConfig, Component, Inject, provide} from 'ng-forward';
import {Profile} from "./../models/interfaces";
import {ArticleService} from "../../lib/ng-noosfero-api/http/article.service";
import {ProfileService} from "../../lib/ng-noosfero-api/http/profile.service";
@Component({
selector: 'cms',
templateUrl: "app/cms/cms.html",
providers: [
provide('articleService', { useClass: ArticleService }),
provide('profileService', { useClass: ProfileService })
]
})
@Inject(ArticleService, ProfileService, "$state", "SweetAlert")
export class Cms {
article: any = {};
constructor(private articleService: ArticleService,
private profileService: ProfileService,
private $state: ng.ui.IStateService, private SweetAlert: any) { }
save() {
this.profileService.getCurrentProfile().then((profile: Profile) => {
return this.articleService.create(profile.id, this.article);
}).then((response: restangular.IResponse) => {
this.$state.transitionTo('main.profile.page', { page: response.data.article.path, profile: response.data.article.profile.identifier });
this.SweetAlert.swal({
title: "Good job!",
text: "Article saved!",
type: "success",
timer: 1000
});
});
}
}