diff --git a/src/core/sitehome/components/all-course-list/all-course-list.html b/src/core/sitehome/components/all-course-list/all-course-list.html
new file mode 100644
index 000000000..9aa7dd581
--- /dev/null
+++ b/src/core/sitehome/components/all-course-list/all-course-list.html
@@ -0,0 +1,4 @@
+
+
+ {{ 'core.courses.availablecourses' | translate}}
+
diff --git a/src/core/sitehome/components/all-course-list/all-course-list.ts b/src/core/sitehome/components/all-course-list/all-course-list.ts
new file mode 100644
index 000000000..71ea79d22
--- /dev/null
+++ b/src/core/sitehome/components/all-course-list/all-course-list.ts
@@ -0,0 +1,32 @@
+// (C) Copyright 2015 Martin Dougiamas
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { Component, Input } from '@angular/core';
+import { IonicPage } from 'ionic-angular';
+import { CoreCoursesProvider } from '../../../courses/providers/courses';
+
+/**
+ * Component to open the page to view the list of all courses.
+ */
+@Component({
+ selector: 'core-sitehome-all-course-list',
+ templateUrl: 'all-course-list.html',
+})
+export class CoreSiteHomeAllCourseListComponent {
+ show: boolean;
+
+ constructor(coursesProvider: CoreCoursesProvider) {
+ this.show = coursesProvider.isGetCoursesByFieldAvailable();
+ }
+}
diff --git a/src/core/sitehome/components/categories/categories.html b/src/core/sitehome/components/categories/categories.html
new file mode 100644
index 000000000..9ecbba6da
--- /dev/null
+++ b/src/core/sitehome/components/categories/categories.html
@@ -0,0 +1,4 @@
+
+
+ {{ 'core.courses.categories' | translate}}
+
diff --git a/src/core/sitehome/components/categories/categories.ts b/src/core/sitehome/components/categories/categories.ts
new file mode 100644
index 000000000..6cfa1b25d
--- /dev/null
+++ b/src/core/sitehome/components/categories/categories.ts
@@ -0,0 +1,32 @@
+// (C) Copyright 2015 Martin Dougiamas
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { Component, Input } from '@angular/core';
+import { IonicPage } from 'ionic-angular';
+import { CoreCoursesProvider } from '../../../courses/providers/courses';
+
+/**
+ * Component to open the page to view the list of categories.
+ */
+@Component({
+ selector: 'core-sitehome-categories',
+ templateUrl: 'categories.html',
+})
+export class CoreSiteHomeCategoriesComponent {
+ show: boolean;
+
+ constructor(coursesProvider: CoreCoursesProvider) {
+ this.show = coursesProvider.isGetCoursesByFieldAvailable();
+ }
+}
diff --git a/src/core/sitehome/components/components.module.ts b/src/core/sitehome/components/components.module.ts
index 558bc272d..044a2fa01 100644
--- a/src/core/sitehome/components/components.module.ts
+++ b/src/core/sitehome/components/components.module.ts
@@ -20,10 +20,20 @@ import { CoreComponentsModule } from '../../../components/components.module';
import { CoreDirectivesModule } from '../../../directives/directives.module';
import { CoreCourseComponentsModule } from '../../course/components/components.module';
import { CoreSiteHomeIndexComponent } from './index/index';
+import { CoreSiteHomeAllCourseListComponent } from './all-course-list/all-course-list';
+import { CoreSiteHomeCategoriesComponent } from './categories/categories';
+import { CoreSiteHomeCourseSearchComponent } from './course-search/course-search';
+import { CoreSiteHomeEnrolledCourseListComponent } from './enrolled-course-list/enrolled-course-list';
+import { CoreSiteHomeNewsComponent } from './news/news';
@NgModule({
declarations: [
- CoreSiteHomeIndexComponent
+ CoreSiteHomeIndexComponent,
+ CoreSiteHomeAllCourseListComponent,
+ CoreSiteHomeCategoriesComponent,
+ CoreSiteHomeCourseSearchComponent,
+ CoreSiteHomeEnrolledCourseListComponent,
+ CoreSiteHomeNewsComponent
],
imports: [
CommonModule,
@@ -34,7 +44,12 @@ import { CoreSiteHomeIndexComponent } from './index/index';
CoreCourseComponentsModule
],
exports: [
- CoreSiteHomeIndexComponent
+ CoreSiteHomeIndexComponent,
+ CoreSiteHomeAllCourseListComponent,
+ CoreSiteHomeCategoriesComponent,
+ CoreSiteHomeCourseSearchComponent,
+ CoreSiteHomeEnrolledCourseListComponent,
+ CoreSiteHomeNewsComponent
]
})
export class CoreSiteHomeComponentsModule {}
diff --git a/src/core/sitehome/components/course-search/course-search.html b/src/core/sitehome/components/course-search/course-search.html
new file mode 100644
index 000000000..e67ae19ee
--- /dev/null
+++ b/src/core/sitehome/components/course-search/course-search.html
@@ -0,0 +1,4 @@
+
+
+ {{ 'core.courses.searchcourses' | translate}}
+
diff --git a/src/core/sitehome/components/course-search/course-search.ts b/src/core/sitehome/components/course-search/course-search.ts
new file mode 100644
index 000000000..8a74bfad5
--- /dev/null
+++ b/src/core/sitehome/components/course-search/course-search.ts
@@ -0,0 +1,32 @@
+// (C) Copyright 2015 Martin Dougiamas
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { Component, Input } from '@angular/core';
+import { IonicPage } from 'ionic-angular';
+import { CoreCoursesProvider } from '../../../courses/providers/courses';
+
+/**
+ * Component to open the page to search courses.
+ */
+@Component({
+ selector: 'core-sitehome-course-search',
+ templateUrl: 'course-search.html',
+})
+export class CoreSiteHomeCourseSearchComponent {
+ show: boolean;
+
+ constructor(coursesProvider: CoreCoursesProvider) {
+ this.show = !coursesProvider.isSearchCoursesDisabledInSite();
+ }
+}
diff --git a/src/core/sitehome/components/enrolled-course-list/enrolled-course-list.html b/src/core/sitehome/components/enrolled-course-list/enrolled-course-list.html
new file mode 100644
index 000000000..88c5c83c2
--- /dev/null
+++ b/src/core/sitehome/components/enrolled-course-list/enrolled-course-list.html
@@ -0,0 +1,4 @@
+
+
+ {{ 'core.courses.mycourses' | translate}}
+
diff --git a/src/core/sitehome/components/enrolled-course-list/enrolled-course-list.ts b/src/core/sitehome/components/enrolled-course-list/enrolled-course-list.ts
new file mode 100644
index 000000000..ab05eeb73
--- /dev/null
+++ b/src/core/sitehome/components/enrolled-course-list/enrolled-course-list.ts
@@ -0,0 +1,43 @@
+// (C) Copyright 2015 Martin Dougiamas
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { Component, Input, OnInit } from '@angular/core';
+import { IonicPage } from 'ionic-angular';
+import { CoreCoursesProvider } from '../../../courses/providers/courses';
+
+/**
+ * Component to open the page to view the list of courses the user is enrolled in.
+ */
+@Component({
+ selector: 'core-sitehome-enrolled-course-list',
+ templateUrl: 'enrolled-course-list.html',
+})
+export class CoreSiteHomeEnrolledCourseListComponent implements OnInit {
+ show: boolean;
+
+ constructor(private coursesProvider: CoreCoursesProvider) {}
+
+ /**
+ * Component being initialized.
+ */
+ ngOnInit() {
+ if (this.coursesProvider.isMyCoursesDisabledInSite()) {
+ this.show = false;
+ } else {
+ return this.coursesProvider.getUserCourses().then((courses) => {
+ this.show = courses.length > 0;
+ });
+ }
+ }
+}
diff --git a/src/core/sitehome/components/index/index.html b/src/core/sitehome/components/index/index.html
index 742d1f24d..0c7c4ed3f 100644
--- a/src/core/sitehome/components/index/index.html
+++ b/src/core/sitehome/components/index/index.html
@@ -5,6 +5,7 @@
+
@@ -13,9 +14,18 @@
-
-
+
+ 0">
+
+
+
+
+
+
+
+
+
diff --git a/src/core/sitehome/components/index/index.ts b/src/core/sitehome/components/index/index.ts
index f15d090bb..2f677e15c 100644
--- a/src/core/sitehome/components/index/index.ts
+++ b/src/core/sitehome/components/index/index.ts
@@ -60,10 +60,16 @@ export class CoreSiteHomeIndexComponent implements OnInit {
* @param {any} refresher Refresher.
*/
doRefresh(refresher: any) {
- const promises = [];
+ const promises = [],
+ currentSite = this.sitesProvider.getCurrentSite();
promises.push(this.courseProvider.invalidateSections(this.siteHomeId));
- promises.push(this.sitesProvider.getCurrentSite().invalidateConfig());
+ promises.push(currentSite.invalidateConfig().then(() => {
+ // Config invalidated, fetch it again.
+ return currentSite.getConfig().then((config) => {
+ currentSite.setConfig(config);
+ });
+ }));
if (this.sectionsLoaded) {
// Invalidate modules prefetch data.
@@ -89,21 +95,21 @@ export class CoreSiteHomeIndexComponent implements OnInit {
if (config.frontpageloggedin) {
// Items with index 1 and 3 were removed on 2.5 and not being supported in the app.
let frontpageItems = [
- 'mma-frontpage-item-news', // News items.
+ 'news', // News items.
false,
- 'mma-frontpage-item-categories', // List of categories.
+ 'categories', // List of categories.
false,
- 'mma-frontpage-item-categories', // Combo list.
- 'mma-frontpage-item-enrolled-course-list', // Enrolled courses.
- 'mma-frontpage-item-all-course-list', // List of courses.
- 'mma-frontpage-item-course-search' // Course search box.
+ 'categories', // Combo list.
+ 'enrolled-course-list', // Enrolled courses.
+ 'all-course-list', // List of courses.
+ 'course-search' // Course search box.
],
items = config.frontpageloggedin.split(',');
this.items = [];
items.forEach((itemNumber) => {
- // Get the frontpage item directive to render itself.
+ // Get the frontpage item "name".
const item = frontpageItems[parseInt(itemNumber, 10)];
if (!item || this.items.indexOf(item) >= 0) {
return;
@@ -112,7 +118,6 @@ export class CoreSiteHomeIndexComponent implements OnInit {
this.hasContent = true;
this.items.push(item);
});
-
}
return this.courseProvider.getSections(this.siteHomeId, false, true).then((sections) => {
diff --git a/src/core/sitehome/components/news/news.html b/src/core/sitehome/components/news/news.html
new file mode 100644
index 000000000..1469eb616
--- /dev/null
+++ b/src/core/sitehome/components/news/news.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/core/sitehome/components/news/news.ts b/src/core/sitehome/components/news/news.ts
new file mode 100644
index 000000000..32519d767
--- /dev/null
+++ b/src/core/sitehome/components/news/news.ts
@@ -0,0 +1,67 @@
+// (C) Copyright 2015 Martin Dougiamas
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { Component, OnInit, Input } from '@angular/core';
+import { IonicPage } from 'ionic-angular';
+import { CoreSitesProvider } from '../../../../providers/sites';
+
+/**
+ * Component that displays site home news.
+ */
+@Component({
+ selector: 'core-sitehome-news',
+ templateUrl: 'news.html',
+})
+export class CoreSiteHomeNewsComponent implements OnInit {
+ module: any;
+ show: boolean;
+ siteHomeId: number;
+
+ constructor(private sitesProvider: CoreSitesProvider) {
+ this.siteHomeId = sitesProvider.getCurrentSite().getSiteHomeId();
+ }
+
+ /**
+ * Component being initialized.
+ */
+ ngOnInit() {
+ // Get number of news items to show.
+ const newsItems = this.sitesProvider.getCurrentSite().getStoredConfig('newsitems') || 0;
+ if (!newsItems) {
+ return;
+ }
+
+ // @todo: Implement it once forum is supported.
+ // $mmaModForum = $mmAddonManager.get('$mmaModForum');
+ // if ($mmaModForum) {
+ // return $mmaModForum.getCourseForums(courseId).then(function(forums) {
+ // for (var x in forums) {
+ // if (forums[x].type == 'news') {
+ // return forums[x];
+ // }
+ // }
+ // }).then(function(forum) {
+ // if (forum) {
+ // return $mmCourse.getModuleBasicInfo(forum.cmid).then(function(module) {
+ // scope.show = true;
+ // scope.module = module;
+ // scope.module._controller =
+ // $mmCourseDelegate.getContentHandlerControllerFor(module.modname, module, courseId,
+ // module.section);
+ // });
+ // }
+ // });
+ // }
+ }
+}