-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c5d744
commit d64c3c7
Showing
22 changed files
with
481 additions
and
23 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface Student { | ||
name: string; | ||
image: string; | ||
imageData: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!-- | ||
Generated template for the HomePage page. | ||
See http://ionicframework.com/docs/components/#navigation for more info on | ||
Ionic pages and navigation. | ||
--> | ||
<ion-header> | ||
|
||
<ion-navbar color="primary"> | ||
<ion-title>Add Student</ion-title> | ||
<ion-buttons end> | ||
<button ion-button>Save</button> | ||
</ion-buttons> | ||
|
||
<ion-buttons start> | ||
<button ion-button (click)="dismiss()" >Cancel</button> | ||
</ion-buttons> | ||
</ion-navbar> | ||
|
||
</ion-header> | ||
|
||
|
||
<ion-content> | ||
|
||
<ion-item> | ||
<ion-input placeholder="Student Full Name" [(ngModel)]="student.name"></ion-input> | ||
</ion-item> | ||
|
||
<ion-card style="margin-top: 5%;"> | ||
<div *ngIf="imageData; else upload"> | ||
<img class="image1" [src]="domSanitizer.bypassSecurityTrustUrl(imageData)" alt="image source"> | ||
</div> | ||
<ng-template #upload> | ||
<div class="upload" (click)="takePhoto()"> | ||
<ion-icon name="camera"></ion-icon> | ||
</div> | ||
</ng-template> | ||
</ion-card> | ||
|
||
<div padding> | ||
<button color="primary" ion-button block (click)="submit()">Submit</button> | ||
<button *ngIf="imageData" color="danger" ion-button block (click)="delete()">Delete</button> | ||
</div> | ||
</ion-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { IonicPageModule } from 'ionic-angular'; | ||
import { AddStudentPage } from './add-student'; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
AddStudentPage, | ||
], | ||
imports: [ | ||
IonicPageModule.forChild(AddStudentPage), | ||
], | ||
}) | ||
export class AddStudentPageModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
page-add-student { | ||
.upload { | ||
//height: 90px; | ||
line-height: 400px; | ||
text-align: center; | ||
border: 2px maroon; | ||
border-style: inset; | ||
font-size: 60px; | ||
background-color: transparentize($color: gray, $amount: 0.9); | ||
font-weight: bold; | ||
//border-style: outset; | ||
} | ||
|
||
.item { | ||
background-color: transparentize($color: white, $amount: 0.25); | ||
margin-bottom: 15px; | ||
} | ||
|
||
span { | ||
display: inline-block; | ||
vertical-align: middle; | ||
line-height: normal; | ||
} | ||
|
||
.image1 { | ||
line-height: 400px; | ||
text-align: center; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Course } from './../../models/course'; | ||
import { ImageDataServiceProvider } from './../../providers/data-service/image-data-service'; | ||
import { UtilitiesProvider } from './../../providers/utilities/utilities'; | ||
import { CameraServiceProvider } from './../../providers/camera-service/camera-service'; | ||
import { Student } from './../../models/student'; | ||
import { Component } from '@angular/core'; | ||
import { IonicPage, NavController, NavParams, ViewController } from 'ionic-angular'; | ||
import { DomSanitizer } from '@angular/platform-browser'; | ||
|
||
/** | ||
* Generated class for the AddStudentPage page. | ||
* | ||
* See https://ionicframework.com/docs/components/#navigation for more info on | ||
* Ionic pages and navigation. | ||
*/ | ||
|
||
@IonicPage() | ||
@Component({ | ||
selector: 'page-add-student', | ||
templateUrl: 'add-student.html', | ||
}) | ||
export class AddStudentPage { | ||
|
||
imageData: string; | ||
nonNormalized: string; | ||
student = {} as Student; | ||
courseId: string; | ||
|
||
constructor(public navCtrl: NavController, public navParams: NavParams, | ||
private cam: CameraServiceProvider, public domSanitizer: DomSanitizer, | ||
private view: ViewController, private utilities: UtilitiesProvider, | ||
private data: ImageDataServiceProvider) { | ||
} | ||
|
||
ionViewDidLoad() { | ||
console.log('ionViewDidLoad HomePage'); | ||
this.courseId = this.navParams.get('courseId'); | ||
} | ||
|
||
async takePhoto() { | ||
try { | ||
this.imageData = await this.cam.takePicture(); | ||
} catch (e) { | ||
this.utilities.createToast(e, 3000).present(); | ||
} | ||
} | ||
|
||
async submit() { | ||
this.student.image = `stu-${this.courseId}-${this.student.name.replace(/\s/g, '')}`; | ||
if (this.student.name != '' && this.imageData != null && this.student.image != '') { | ||
this.student.imageData = this.imageData; | ||
this.utilities.createToast('Added student!', 2000).present(); | ||
this.view.dismiss({student: this.student, added: true}); | ||
} else { | ||
this.utilities.createToast('Complete missing fields.', 3000).present(); | ||
} | ||
} | ||
|
||
delete() { | ||
this.imageData = null; | ||
} | ||
|
||
dismiss() { | ||
this.view.dismiss({added: false}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,13 @@ page-courses { | |
|
||
} | ||
|
||
.no-courses { | ||
top: 50%; | ||
position: relative; | ||
color: gray; | ||
text-align: center; | ||
} | ||
|
||
|
||
|
||
} | ||
|
Oops, something went wrong.