Skip to content

Commit 00aa66b

Browse files
authored
Merge pull request #80 from UnstableDesign/op-extensions
Op extensions
2 parents 3c8da82 + 733538d commit 00aa66b

File tree

10 files changed

+327
-134
lines changed

10 files changed

+327
-134
lines changed

src/app/app-routing.module.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@ import { NgModule } from '@angular/core';
22
import { Routes, RouterModule } from '@angular/router';
33
import { WeaverComponent } from './weaver/weaver.component';
44
import { MixerComponent } from './mixer/mixer.component';
5-
import { LoginComponent } from './core/login/login.component';
6-
import { ProfileComponent } from './core/profile/profile.component';
7-
import { SignupComponent } from './core/signup/signup.component';
8-
import { EmailComponent } from './core/email/email.component';
5+
96

107
const routes: Routes = [
11-
// { path: '', redirectTo: 'login', pathMatch: 'full' },
12-
// { path: 'login', component: LoginComponent },
13-
// { path: 'email-login', component: EmailComponent },
14-
// { path: 'signup', component: SignupComponent },
15-
// { path: 'profile', component: ProfileComponent },
168
{
179
path: '',
1810
component: MixerComponent,

src/app/core/modal/init/init.modal.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ <h2 mat-dialog-title *ngIf="source === 'import'">Import Into Block</h2>
1111
<mat-label>Where would you like to begin?</mat-label>
1212
<mat-select [(value)]="selected" (selectionChange)="selectionMade(selected)">
1313

14-
<mat-option *ngIf="auth.isLoggedIn" value="recover">
14+
<!-- <mat-option *ngIf="auth.isLoggedIn" value="recover">
1515
Recover Previous Workspace
16-
</mat-option>
16+
</mat-option> -->
1717

1818
<mat-option *ngFor="let opt of opts" [value]="opt.value">
1919
{{opt.viewValue}}

src/app/core/modal/init/init.modal.ts

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export class InitModal implements OnInit {
4545

4646

4747
constructor(
48-
private auth: AuthService,
4948
private fls: FileService,
49+
private auth: AuthService,
5050
private dm: DesignmodesService,
5151
private http: HttpClient,
5252
private dialogRef: MatDialogRef<InitModal>,
@@ -91,11 +91,11 @@ export class InitModal implements OnInit {
9191

9292
}
9393

94-
selectionMade(selection: any){
95-
if(selection === 'recover'){
96-
this.loadSavedFile();
97-
}
98-
}
94+
// selectionMade(selection: any){
95+
// if(selection === 'recover'){
96+
// this.loadSavedFile();
97+
// }
98+
// }
9999

100100
loadExample(filename: string){
101101
console.log("loading example: ", filename);
@@ -108,28 +108,7 @@ export class InitModal implements OnInit {
108108
});
109109
}
110110

111-
loadSavedFile(){
112-
this.auth.user.subscribe(user => {
113-
if(user !== null){
114-
115-
const db = fbref(getDatabase());
116-
117-
118-
fbget(child(db, `users/${this.auth.uid}/ada`)).then((snapshot) => {
119-
if (snapshot.exists()) {
120-
this.fls.loader.ada("recovered draft", snapshot.val()).then(lr => {
121-
this.dialogRef.close(lr)
122-
});
123-
}
124-
}).catch((error) => {
125-
console.error(error);
126-
});
127-
128-
}
129-
130-
});
131-
132-
}
111+
133112

134113

135114

src/app/mixer/mixer.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
(onLoadNewFile)="loadNewFile($event);"
88
(onClearScreen)="clearAll();"
99
(onSave)="onSave($event);">
10+
1011
</app-topbar>
1112

1213
<mat-drawer-container #container class="mat-drawer-container" cdkScrollable>
@@ -97,3 +98,4 @@
9798

9899

99100
</mat-drawer-container>
101+

src/app/mixer/mixer.component.ts

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { SystemsService } from '../core/provider/systems.service';
2020
import { HttpClient } from '@angular/common/http';
2121
import { InitModal } from '../core/modal/init/init.modal';
2222
import { MatDialog } from '@angular/material/dialog';
23+
import { AuthService } from '../core/provider/auth.service';
24+
import {getDatabase, ref as fbref, get as fbget, child} from '@angular/fire/database'
2325

2426

2527
//disables some angular checking mechanisms
@@ -70,6 +72,7 @@ export class MixerComponent implements OnInit {
7072
* dialog - Anglar Material dialog module. Used to control the popup modals.
7173
*/
7274
constructor(public dm: DesignmodesService,
75+
private auth: AuthService,
7376
private ms: MaterialsService,
7477
private sys: SystemsService,
7578
private ps: PatternService,
@@ -158,7 +161,6 @@ export class MixerComponent implements OnInit {
158161
*/
159162
importNewFile(result: LoadResponse){
160163

161-
console.log("imported new file", result, result.data);
162164
this.processFileData(result.data).then(
163165
this.palette.changeDesignmode('move')
164166
);
@@ -291,7 +293,6 @@ export class MixerComponent implements OnInit {
291293
}
292294
});
293295

294-
console.log("seed nodes mapped ", seeds);
295296

296297

297298

@@ -309,7 +310,7 @@ export class MixerComponent implements OnInit {
309310
return this.tree.validateNodes();
310311
})
311312
.then(el => {
312-
console.log("performing top level ops");
313+
//console.log("performing top level ops");
313314

314315
return this.tree.performTopLevelOps();
315316
})
@@ -321,7 +322,7 @@ export class MixerComponent implements OnInit {
321322
if(this.tree.hasParent(el.id)){
322323
el.draft = new Draft({warps: 1, wefts: 1, pattern: [[new Cell(false)]]});
323324
} else{
324-
console.log("removing node ", el.id, el.type, this.tree.hasParent(el.id));
325+
// console.log("removing node ", el.id, el.type, this.tree.hasParent(el.id));
325326
this.tree.removeNode(el.id);
326327
}
327328
})
@@ -388,14 +389,72 @@ export class MixerComponent implements OnInit {
388389

389390
ngAfterViewInit() {
390391

391-
const dialogRef = this.dialog.open(InitModal, {
392-
data: {source: 'mixer'}
393-
});
394392

395-
dialogRef.afterClosed().subscribe(loadResponse => {
396-
if(loadResponse !== undefined) this.loadNewFile(loadResponse);
393+
this.auth.user.subscribe(user => {
394+
395+
if(user === null){
396+
397+
const dialogRef = this.dialog.open(InitModal, {
398+
data: {source: 'mixer'}
399+
});
400+
401+
402+
dialogRef.afterClosed().subscribe(loadResponse => {
403+
if(loadResponse !== undefined) this.loadNewFile(loadResponse);
404+
405+
});
406+
}else{
407+
408+
//in the case someone logs in mid way through, don't replace their work.
409+
if(this.tree.nodes.length > 0) return;
410+
411+
412+
const db = fbref(getDatabase());
413+
414+
415+
fbget(child(db, `users/${this.auth.uid}/ada`)).then((snapshot) => {
416+
if (snapshot.exists()) {
417+
this.fs.loader.ada("recovered draft", snapshot.val()).then(lr => {
418+
this.loadNewFile(lr);
419+
});
420+
}
421+
}).catch((error) => {
422+
console.error(error);
423+
});
424+
425+
}
426+
});
427+
428+
console.log(this.auth, this.auth.isLoggedIn);
429+
430+
431+
432+
433+
434+
435+
}
436+
437+
438+
loadSavedFile(){
439+
// this.auth.user.subscribe(user => {
440+
// if(user !== null){
441+
442+
// const db = fbref(getDatabase());
397443

398-
});
444+
445+
// fbget(child(db, `users/${this.auth.uid}/ada`)).then((snapshot) => {
446+
// if (snapshot.exists()) {
447+
// this.fls.loader.ada("recovered draft", snapshot.val()).then(lr => {
448+
// this.dialogRef.close(lr)
449+
// });
450+
// }
451+
// }).catch((error) => {
452+
// console.error(error);
453+
// });
454+
455+
// }
456+
457+
// });
399458

400459
}
401460

src/app/mixer/palette/operation/operation.component.html

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@
8080

8181
<div class="param-name">{{param.name}}</div>
8282

83-
84-
<div *ngIf="param.max > 1" class="param-slider">
83+
<ng-container *ngIf="param.type == 'number'">
84+
<div class="param-slider">
85+
86+
8587
<mat-slider
8688
thumbLabel
8789
tickInterval="1"
@@ -96,7 +98,7 @@
9698
</div>
9799

98100

99-
<div *ngIf="param.max > 1" class='param-label'>
101+
<div class='param-label'>
100102
<input
101103
[formControl]="op_inputs[i]"
102104
[matTooltip]=param.dx
@@ -110,16 +112,38 @@
110112
>
111113

112114
</div>
113-
114-
<div *ngIf="param.max === 1" class="param-checkbox">
115-
<mat-checkbox
116-
[formControl]="op_inputs[i]"
117-
[matTooltip]=param.dx
118-
value="op_inputs[i].value"
119-
(change)= "onCheckboxParamChange(i, op_inputs[i].value)">
120-
</mat-checkbox>
121-
</div>
122-
115+
</ng-container>
116+
117+
<ng-container *ngIf="param.type == 'boolean'">
118+
119+
<div class="param-checkbox">
120+
<mat-checkbox
121+
[formControl]="op_inputs[i]"
122+
[matTooltip]=param.dx
123+
value="op_inputs[i].value"
124+
(change)= "onCheckboxParamChange(i, op_inputs[i].value)">
125+
</mat-checkbox>
126+
</div>
127+
</ng-container>
128+
129+
<ng-container *ngIf="param.type == 'string'">
130+
131+
132+
<div class='param-label'>
133+
<input
134+
[formControl]="op_inputs[i]"
135+
[matTooltip]=param.dx
136+
type = "text"
137+
[name]=param.name
138+
[min]=param.min
139+
[max]=param.max
140+
step = 1
141+
value = op_inputs[i].value
142+
(change)= "onParamChange(i, op_inputs[i].value)"
143+
>
144+
145+
</div>
146+
</ng-container>
123147
</div>
124148
</ng-container>
125149
</div>

src/app/mixer/palette/subdraft/subdraft.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,14 @@
102102

103103

104104
<div class='dims_and_name'>
105-
<div><input matInput [(ngModel)]="tree.getDraft(id).ud_name" [placeholder]="tree.getDraft(id).gen_name" (focusout)="nameFocusOut($event)"> </div>
105+
<div><input matInput [(ngModel)]="tree.getDraft(id).ud_name"
106+
[placeholder]="tree.getDraft(id).gen_name"
107+
(focusout)="nameFocusOut($event)">
108+
</div>
106109
<div class="dims">{{tree.getDraft(id).warps}} x {{tree.getDraft(id).wefts}} </div>
107110
<div *ngIf="gl.type === 'frame' && (gl.min_frames < tree.getLoom(id).num_frames || gl.min_treadles < tree.getLoom(id).num_treadles) "class="frame">
108111
<span class="error">
109112
<i matTooltip="This draft requires more than the {{gl.min_frames}} frames or {{gl.min_treadles}} treadles than you have specified for your loom" class="fas fa-exclamation-circle"></i>
110-
111113
{{tree.getLoom(id).num_frames}} frames, {{tree.getLoom(id).num_treadles}} treadles</span></div>
112114

113115

src/app/mixer/palette/subdraft/subdraft.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export class SubdraftComponent implements OnInit {
174174
this.canvas = <HTMLCanvasElement> document.getElementById(this.id.toString());
175175
this.cx = this.canvas.getContext("2d");
176176
this.drawDraft(this.draft); //force call here because it likely didn't render previously.
177+
177178
this.rescale();
178179
this.updateViewport(this.bounds);
179180

0 commit comments

Comments
 (0)