Skip to content

Commit fb645c2

Browse files
committed
Bug Fixes
1 parent c7cf880 commit fb645c2

File tree

5 files changed

+103
-33
lines changed

5 files changed

+103
-33
lines changed

both/collections/course_record.collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
this.observable = new MongoObservable.Collection(this);
2727

2828
// Permissions
29-
const allowed_fields = [];
29+
const allowed_fields = ["labs"];
3030
super.allow({
3131
update: function(user_id, course_record : CourseRecord, fields) {
3232
return _.reject(fields, key => _.includes(allowed_fields, key)).length === 0 &&

client/imports/account/dashboard.component.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
<div class="tuxlab-dashboard">
22

3+
<h1> Welcome to TuxLab! </h1>
4+
35
<div class="featured_courses">
46
<h2> Featured Courses </h2>
57
<tuxlab-course-list type="featured_courses"></tuxlab-course-list>
6-
78
</div>
89

910

1011
<div class="split_courses" fxLayout="row">
1112
<div fxFlex="1 0 auto">
12-
<h3> My Sessions </h3>
13+
<h2> My Sessions </h2>
1314
</div>
1415
<div fxFlex="1 0 auto">
15-
<h3> My Courses </h3>
16+
<h2> My Courses </h2>
1617

1718
<tuxlab-course-list type="my_courses"></tuxlab-course-list>
1819
</div>

client/imports/account/dashboard.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ div.tuxlab-dashboard{
44

55
margin:0 auto;
66

7-
h2, h3 {
7+
h1, h2, h3 {
88
font-weight: 300;
99
}
1010

client/imports/admin/admin_user_list.component.ts

Lines changed: 96 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,25 @@
100100
<!-- Session Record -->
101101
<h5> Session Record: </h5>
102102
<br>
103-
<textarea [ngModel]="getCourseRecordJSON((course_record | async))" [disabled]="!edit_mode"></textarea>
103+
<textarea mdInput mdTextareaAutosize [(ngModel)]="session_record" [disabled]="!edit_mode"></textarea>
104+
105+
<!-- Actions -->
106+
<br>
107+
<div class="actions" fxLayout="row" fxLayoutAlign="end center">
108+
109+
<!-- Edit Mode -->
110+
<ng-container *ngIf="(course_record | async)?._id as id"[ngSwitch]="edit_mode">
111+
<button md-raised-button (click)="edit_mode = true" *ngSwitchCase="false">
112+
<md-icon>edit</md-icon>
113+
Edit
114+
</button>
115+
<button md-raised-button (click)="update(id)" *ngSwitchCase="true">
116+
<md-icon>save</md-icon>
117+
Save
118+
</button>
119+
</ng-container>
120+
121+
</div>
104122
</div>
105123
106124
</div>
@@ -146,25 +164,29 @@
146164
147165
textarea{
148166
width: 100%;
149-
min-height: 300px;
150167
border: none;
151168
background-color: transparent;
152169
color: #000 !important;
170+
font-family: "Courier New", courier, monospace;
153171
}
154172
173+
155174
` ],
156175
changeDetection: ChangeDetectionStrategy.OnPush
157176
})
158177

159178
export class UserSessionItem extends MeteorComponent {
179+
@Input('user') user : User;
180+
@Input('course') course : Course;
160181
@Input('course_record') course_record : Observable<CourseRecord>;
161-
162182
@Input('session') session : Session;
163183
private SessionStatus = SessionStatus;
164-
private container_index = 0;
165184

185+
private container_index = 0;
166186
private lab : Lab;
167187

188+
private session_record;
189+
168190
private expand : boolean = false;
169191
private edit_mode : boolean = false;
170192

@@ -173,19 +195,42 @@
173195
}
174196

175197
ngOnInit(){
198+
176199
// Get Lab
177-
Meteor.subscribe('labs.course', this.session.course_id, () => {
178-
this.zone.run(() => {
179-
this.lab = Labs.findOne({ "_id" : this.session.lab_id });
180-
this.ref.markForCheck();
200+
new Promise((resolve, reject) => {
201+
Meteor.subscribe('labs.course', this.session.course_id, () => {
202+
this.zone.run(() => {
203+
this.lab = Labs.findOne({ "_id" : this.session.lab_id });
204+
this.ref.markForCheck();
205+
resolve();
206+
})
181207
});
182-
});
208+
})
209+
210+
// Get Course Record for Lab
211+
.then(() => {
212+
new Promise((resolve, reject) => {
213+
this.course_record.subscribe((record) => {
214+
if(record && _.has(record, "labs."+this.lab._id+"."+this.session._id)){
215+
this.session_record = JSON.stringify(record.labs[this.lab._id][this.session._id],null,2);
216+
this.ref.markForCheck();
217+
resolve();
218+
}
219+
})
220+
})
221+
})
222+
183223
}
184224

185-
private getCourseRecordJSON(record){
186-
if(record && _.has(record, "labs."+this.lab._id+"."+this.session._id)){
187-
return JSON.stringify(record.labs[this.lab._id][this.session._id],null,2);
188-
}
225+
update(id){
226+
CourseRecords.update({
227+
"_id" : id
228+
},{
229+
"$set" : {
230+
["labs."+this.lab._id+"."+this.session._id] : JSON.parse(this.session_record)
231+
}
232+
})
233+
this.edit_mode = false;
189234
}
190235
}
191236

@@ -208,14 +253,15 @@
208253
<div class="expand_container" *ngIf="expand" fxLayout="column">
209254
210255
<!-- Actions -->
211-
<br>
212-
<h5> Role: </h5>
213-
<div fxLayout="row">
214-
<md-select class="role_select">
215-
<md-option [value]="Role.student">Student</md-option>
216-
<md-option [value]="Role.instructor">Instructor</md-option>
217-
<md-option [value]="Role.course_admin">Course Admin</md-option>
218-
</md-select>
256+
<div class="actions" fxLayout="row">
257+
<div *ngIf="role < Role.global_admin && role > Role.guest" class="mat-raised-button" fxLayout="row" fxLayoutAlign="space-evenly center">
258+
Role: &nbsp;
259+
<md-select class="role_select" [(ngModel)]="role" (ngModelChanges)="update()">
260+
<md-option [value]="Role.student">Student</md-option>
261+
<md-option [value]="Role.instructor">Instructor</md-option>
262+
<md-option [value]="Role.course_admin">Course Admin</md-option>
263+
</md-select>
264+
</div>
219265
</div>
220266
221267
<!-- Sessions -->
@@ -230,7 +276,7 @@
230276
231277
<ul fxLayout="column" class="sessions">
232278
<li *ngFor="let session of (sessions | async);">
233-
<tuxlab-user-session-item [session]="session" [course_record]="course_record"></tuxlab-user-session-item>
279+
<tuxlab-user-session-item [user]="user" [course]="course" [course_record]="course_record" [session]="session"></tuxlab-user-session-item>
234280
</li>
235281
</ul>
236282
</ng-container>
@@ -266,6 +312,21 @@
266312
padding: 10px !important;
267313
}
268314
315+
div.actions{
316+
padding: 4px;
317+
318+
font-weight: 500;
319+
background-color: #ddd;
320+
321+
mat-raised-button{
322+
padding: 4px;
323+
324+
md-select{
325+
font-size: 14px !important;
326+
}
327+
}
328+
}
329+
269330
` ],
270331
changeDetection: ChangeDetectionStrategy.OnPush
271332
})
@@ -275,6 +336,7 @@
275336
@Input('course') course : Course;
276337

277338
private Role = Role;
339+
private role : Role;
278340

279341
private sessions : ObservableCursor<Session>;
280342
private course_record : Observable<CourseRecord>;
@@ -300,6 +362,7 @@
300362
// Get Course
301363
.then(() => {
302364
this.course = Courses.findOne({ _id : this.course._id });
365+
this.role = Users.getRoleFor(this.course._id, this.user._id);
303366
})
304367

305368
// Get Sub-Items
@@ -311,6 +374,7 @@
311374
Meteor.subscribe('course_records.id', this.course._id, this.user._id, () => {
312375
resolve();
313376
});
377+
314378
}).then(() => {
315379
this.course_record = CourseRecords.observable.find({
316380
user_id: this.user._id,
@@ -334,8 +398,12 @@
334398
});
335399
})
336400
])
337-
})
338-
})
401+
});
402+
});
403+
}
404+
405+
update(){
406+
Users.setRoleFor(this.course._id, this.user._id, this.role);
339407
}
340408
}
341409

@@ -359,7 +427,6 @@
359427
<br>
360428
361429
<!-- Actions -->
362-
<h5> Actions: </h5>
363430
<div class="actions" fxLayout="row" style="margin-bottom:10px;">
364431
365432
<!-- Global Admin -->
@@ -517,12 +584,14 @@
517584
private user_query : string;
518585
private course_query : Course;
519586

520-
constructor( private zone : NgZone ) {
587+
constructor( private zone : NgZone, private ref : ChangeDetectorRef ) {
521588
super();
522589
}
523590

524591
ngOnInit(){
525-
Meteor.subscribe('users.all');
592+
Meteor.subscribe('users.all', () => {
593+
this.ref.markForCheck();
594+
});
526595
Meteor.subscribe('courses.all');
527596
this.courses = Courses.observable.find({});
528597
this.onSearch();

client/imports/course/course_list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h1 *ngIf="title">{{ title }}</h1>
3131
</md-card-header>
3232

3333
<!-- Action Buttons -->
34-
<md-card-actions fxLayout="row" fxLayoutAlign="start">
34+
<md-card-actions fxLayout="row" fxLayoutAlign="space-evenly">
3535

3636
<!-- View -->
3737
<a [routerLink]="['/courses', course._id ]" md-button>

0 commit comments

Comments
 (0)