diff --git a/src/app/app.module.ts b/src/app/app.module.ts index ffe8b4705..2a824241a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -60,6 +60,7 @@ import { CoreSharedFilesModule } from '../core/sharedfiles/sharedfiles.module'; import { CoreCourseModule } from '../core/course/course.module'; import { CoreSiteHomeModule } from '../core/sitehome/sitehome.module'; import { CoreContentLinksModule } from '../core/contentlinks/contentlinks.module'; +import { CoreUserModule } from '../core/user/user.module'; // Addon modules. import { AddonCalendarModule } from '../addon/calendar/calendar.module'; @@ -97,6 +98,7 @@ export function createTranslateLoader(http: HttpClient) { CoreCourseModule, CoreSiteHomeModule, CoreContentLinksModule, + CoreUserModule, AddonCalendarModule ], bootstrap: [IonicApp], diff --git a/src/core/mainmenu/pages/more/more.html b/src/core/mainmenu/pages/more/more.html index e2044e6b9..089e4ad3c 100644 --- a/src/core/mainmenu/pages/more/more.html +++ b/src/core/mainmenu/pages/more/more.html @@ -5,7 +5,7 @@ - + {{ 'core.pictureof' | translate:{$a: siteInfo.fullname} }} diff --git a/src/core/user/lang/en.json b/src/core/user/lang/en.json new file mode 100644 index 000000000..0e0dcd235 --- /dev/null +++ b/src/core/user/lang/en.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/src/core/user/pages/profile/profile.html b/src/core/user/pages/profile/profile.html new file mode 100644 index 000000000..d3bf591b3 --- /dev/null +++ b/src/core/user/pages/profile/profile.html @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/core/user/pages/profile/profile.module.ts b/src/core/user/pages/profile/profile.module.ts new file mode 100644 index 000000000..0e0780fee --- /dev/null +++ b/src/core/user/pages/profile/profile.module.ts @@ -0,0 +1,29 @@ +// (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 { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { CoreUserProfilePage } from './profile'; +import { CoreDirectivesModule } from '../../../../directives/directives.module'; + +@NgModule({ + declarations: [ + CoreUserProfilePage, + ], + imports: [ + CoreDirectivesModule, + IonicPageModule.forChild(CoreUserProfilePage), + ], +}) +export class CoreUserProfilePageModule {} diff --git a/src/core/user/pages/profile/profile.scss b/src/core/user/pages/profile/profile.scss new file mode 100644 index 000000000..76f53dc77 --- /dev/null +++ b/src/core/user/pages/profile/profile.scss @@ -0,0 +1,3 @@ +page-core-user-profile { + +} \ No newline at end of file diff --git a/src/core/user/pages/profile/profile.ts b/src/core/user/pages/profile/profile.ts new file mode 100644 index 000000000..983092276 --- /dev/null +++ b/src/core/user/pages/profile/profile.ts @@ -0,0 +1,28 @@ +// (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 } from '@angular/core'; +import { IonicPage } from 'ionic-angular'; +import { CoreUserProvider } from '../../providers/user'; + +/** + * Page that displays an user profile page. + */ +@IonicPage({segment: "core-user-profile"}) +@Component({ + selector: 'page-core-user-profile', + templateUrl: 'profile.html', +}) +export class CoreUserProfilePage { +} \ No newline at end of file diff --git a/src/core/user/providers/delegate.ts b/src/core/user/providers/delegate.ts new file mode 100644 index 000000000..b2ea852eb --- /dev/null +++ b/src/core/user/providers/delegate.ts @@ -0,0 +1,30 @@ +// (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 { Injectable } from '@angular/core'; +import { CoreLoggerProvider } from '../../../providers/logger'; + +/** + * Service to interact with plugins to be shown in user profile. Provides functions to register a plugin + * and notify an update in the data. + */ +@Injectable() +export class CoreUserDelegate { + protected logger; + + constructor(logger: CoreLoggerProvider) { + this.logger = logger.getInstance('CoreUserDelegate'); + } + +} diff --git a/src/core/user/providers/user.ts b/src/core/user/providers/user.ts new file mode 100644 index 000000000..772ade7eb --- /dev/null +++ b/src/core/user/providers/user.ts @@ -0,0 +1,24 @@ +// (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 { Injectable } from '@angular/core'; + +/** + * Service to provide user functionalities. + */ +@Injectable() +export class CoreUserProvider { + + constructor() {} +} diff --git a/src/core/user/user.module.ts b/src/core/user/user.module.ts new file mode 100644 index 000000000..18296d3ef --- /dev/null +++ b/src/core/user/user.module.ts @@ -0,0 +1,29 @@ +// (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 { NgModule } from '@angular/core'; +import { CoreUserDelegate } from './providers/delegate'; +import { CoreUserProvider } from './providers/user'; + +@NgModule({ + declarations: [ + ], + imports: [ + ], + providers: [ + CoreUserDelegate, + CoreUserProvider + ] +}) +export class CoreUserModule {} diff --git a/src/directives/directives.module.ts b/src/directives/directives.module.ts index 105f6565b..11d708992 100644 --- a/src/directives/directives.module.ts +++ b/src/directives/directives.module.ts @@ -18,6 +18,7 @@ import { CoreExternalContentDirective } from './external-content'; import { CoreFormatTextDirective } from './format-text'; import { CoreLinkDirective } from './link'; import { CoreKeepKeyboardDirective } from './keep-keyboard'; +import { CoreUserLinkDirective } from './user-link'; @NgModule({ declarations: [ @@ -25,7 +26,8 @@ import { CoreKeepKeyboardDirective } from './keep-keyboard'; CoreExternalContentDirective, CoreFormatTextDirective, CoreKeepKeyboardDirective, - CoreLinkDirective + CoreLinkDirective, + CoreUserLinkDirective ], imports: [], exports: [ @@ -33,7 +35,8 @@ import { CoreKeepKeyboardDirective } from './keep-keyboard'; CoreExternalContentDirective, CoreFormatTextDirective, CoreKeepKeyboardDirective, - CoreLinkDirective + CoreLinkDirective, + CoreUserLinkDirective ] }) export class CoreDirectivesModule {} diff --git a/src/directives/user-link.ts b/src/directives/user-link.ts new file mode 100644 index 000000000..0dcd85862 --- /dev/null +++ b/src/directives/user-link.ts @@ -0,0 +1,47 @@ +// (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 { Directive, Input, OnInit, ElementRef } from '@angular/core'; +import { NavController } from 'ionic-angular'; +/** + * Directive to open a link in external browser. + */ +@Directive({ + selector: '[core-user-link]' +}) +export class CoreUserLinkDirective implements OnInit { + @Input() userId: number; // User id to open the profile. + @Input() courseId?: number; // If set, course id to show the user info related to that course. + + protected element: HTMLElement; + + constructor(element: ElementRef, private navCtrl: NavController) { + // This directive can be added dynamically. In that case, the first param is the anchor HTMLElement. + this.element = element.nativeElement || element; + } + + /** + * Function executed when the component is initialized. + */ + ngOnInit() { + this.element.addEventListener('click', (event) => { + // If the event prevented default action, do nothing. + if (!event.defaultPrevented) { + event.preventDefault(); + event.stopPropagation(); + this.navCtrl.push('CoreUserProfilePage', {userId: this.userId, courseId: this.courseId}); + } + }); + } +} \ No newline at end of file