diff --git a/angular.json b/angular.json
index 7903cdf..8ff5a41 100644
--- a/angular.json
+++ b/angular.json
@@ -6,7 +6,7 @@
"version": 1,
"newProjectRoot": "projects",
"projects": {
- "sell4zec": {
+ "zgo": {
"projectType": "application",
"schematics": {
"@schematics/angular:application": {
@@ -20,7 +20,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
- "outputPath": "dist/sell4zec",
+ "outputPath": "dist/zgo",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
@@ -71,10 +71,10 @@
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
- "browserTarget": "sell4zec:build:production"
+ "browserTarget": "zgo:build:production"
},
"development": {
- "browserTarget": "sell4zec:build:development"
+ "browserTarget": "zgo:build:development"
}
},
"defaultConfiguration": "development"
@@ -82,7 +82,7 @@
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
- "browserTarget": "sell4zec:build"
+ "browserTarget": "zgo:build"
}
},
"test": {
@@ -106,5 +106,5 @@
}
}
},
- "defaultProject": "sell4zec"
+ "defaultProject": "zgo"
}
diff --git a/backend/app.js b/backend/app.js
index 8b952c7..c4e83bb 100644
--- a/backend/app.js
+++ b/backend/app.js
@@ -169,15 +169,19 @@ app.post('/api/addowner', (req, res, next) => {
});
});
-app.post('/api/addownername', (req, res, next) => {
- console.log('Post: /api/addownername');
- const owner = ownermodel.findOne({address: req.body.address});
-
- owner.name = req.body.name;
- owner.save();
- res.status(201).json({
- message: 'Ownername added successfully'
- });
+app.post('/api/updateowner', (req, res, next) => {
+ console.log('Post: /api/updateowner');
+ ownermodel.findByIdAndUpdate(req.body.owner._id, req.body.owner,
+ function(err, docs) {
+ if (err) {
+ console.log(err);
+ } else {
+ res.status(201).json({
+ message: 'Owner updated',
+ owner: docs
+ });
+ }
+ });
});
app.get('/api/getitems', (req, res, next) => {
diff --git a/karma.conf.js b/karma.conf.js
index ace1b75..f0a43fa 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -25,7 +25,7 @@ module.exports = function (config) {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
- dir: require('path').join(__dirname, './coverage/sell4zec'),
+ dir: require('path').join(__dirname, './coverage/zgo'),
subdir: '.',
reporters: [
{ type: 'html' },
diff --git a/package.json b/package.json
index 3ff93ef..21efbb3 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
{
- "name": "sell4zec",
+ "name": "zgo",
"version": "0.0.0",
"scripts": {
"ng": "ng",
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 42658f2..549dd14 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -22,6 +22,7 @@ import { ItemAddComponent} from './items/item-add/item-add.component';
import { OrderComponent } from './order/order.component';
import { CancelComponent } from './cancel/cancel.component';
import { CheckoutComponent } from './checkout/checkout.component';
+import { SettingsComponent } from './settings/settings.component';
//import { NameDialogComponent } from './namedialog/namedialog.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@@ -37,7 +38,8 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
ItemDeleteComponent,
ItemAddComponent,
CancelComponent,
- CheckoutComponent
+ CheckoutComponent,
+ SettingsComponent
],
imports: [
BrowserModule,
@@ -59,6 +61,13 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
],
providers: [],
bootstrap: [AppComponent],
- entryComponents: [ItemCreateComponent, ItemDeleteComponent, ItemAddComponent, CancelComponent, CheckoutComponent]
+ entryComponents: [
+ ItemCreateComponent,
+ ItemDeleteComponent,
+ ItemAddComponent,
+ CancelComponent,
+ CheckoutComponent,
+ SettingsComponent
+ ]
})
export class AppModule { }
diff --git a/src/app/header/header.component.css b/src/app/header/header.component.css
index 9d41a83..548904e 100644
--- a/src/app/header/header.component.css
+++ b/src/app/header/header.component.css
@@ -1,5 +1,5 @@
-* {
- font-family: 'Roboto Mono', monospace;
+.text {
+ font-family: 'Roboto-Mono', monospace;
}
a{
@@ -21,3 +21,6 @@ ul{
font-size: 9px;
line-height: 0.8;
}
+.icon {
+ font-family: "Material Icons";
+}
diff --git a/src/app/header/header.component.html b/src/app/header/header.component.html
index 7b0ed93..6ea406e 100644
--- a/src/app/header/header.component.html
+++ b/src/app/header/header.component.html
@@ -1,12 +1,14 @@
-
-
+
+
Z Go!
- Last block seen: {{heightUpdate | async}}
+ Last block seen: {{heightUpdate | async}}
- {{ shortenZaddr((ownerUpdate | async)!.address) }}
+
diff --git a/src/app/header/header.component.ts b/src/app/header/header.component.ts
index f5ca8ef..7d828cf 100644
--- a/src/app/header/header.component.ts
+++ b/src/app/header/header.component.ts
@@ -1,7 +1,9 @@
import {Component, OnInit, OnDestroy} from '@angular/core';
+import { MatDialog, MatDialogConfig} from '@angular/material/dialog';
import {FullnodeService} from '../fullnode.service';
import { UserService } from '../user.service';
import {Subscription, Observable} from 'rxjs';
+import { SettingsComponent } from '../settings/settings.component';
import {Owner} from '../owner.model';
@@ -22,11 +24,15 @@ export class HeaderComponent implements OnInit, OnDestroy {
constructor(
public fullnodeService: FullnodeService,
- public userService: UserService
+ public userService: UserService,
+ private dialog: MatDialog
){
this.heightUpdate = fullnodeService.heightUpdate;
this.uZaddrUpdate = userService.uZaddrUpdate;
this.ownerUpdate = userService.ownerUpdate;
+ this.ownerUpdate.subscribe((owner) => {
+ this.owner = owner;
+ });
}
@@ -43,4 +49,21 @@ export class HeaderComponent implements OnInit, OnDestroy {
return addr.substring(0,5).concat('...').concat(addr.substring(last, end));
}
+ openSettings() {
+
+ const dialogConfig = new MatDialogConfig();
+
+ dialogConfig.disableClose = true;
+ dialogConfig.autoFocus = true;
+ dialogConfig.data = this.owner;
+
+ const dialogRef = this.dialog.open(SettingsComponent, dialogConfig);
+ dialogRef.afterClosed().subscribe((val) => {
+ if (val != null) {
+ console.log('Saving settings');
+ this.userService.updateOwner(val);
+ }
+ });
+ }
+
}
diff --git a/src/app/namedialog/namedialog.component.html b/src/app/namedialog/namedialog.component.html
deleted file mode 100644
index 5e537b4..0000000
--- a/src/app/namedialog/namedialog.component.html
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
Set the name of your business
-
-
-
diff --git a/src/app/namedialog/namedialog.component.ts b/src/app/namedialog/namedialog.component.ts
deleted file mode 100644
index 70cef1c..0000000
--- a/src/app/namedialog/namedialog.component.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import { Inject, Component, OnInit, OnDestroy } from '@angular/core';
-import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
-import { NgForm } from '@angular/forms';
-
-@Component({
- selector: 'name-dialog',
- templateUrl: './namedialog.component.html'
-})
-
-export class NameDialogComponent implements OnInit{
- bizname: string = '';
-
- constructor(
- private dialogRef: MatDialogRef
- ) {
- }
-
- ngOnInit() {
- }
-
- save(form: NgForm) {
- if (form.invalid) {
- return;
- }
- this.dialogRef.close(form.value.bizname);
- //console.log(`Saving name ${form.value.bizname}`);
- }
-
- close() {
- this.dialogRef.close();
- }
-}
diff --git a/src/app/settings/settings.component.css b/src/app/settings/settings.component.css
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html
new file mode 100644
index 0000000..4235f47
--- /dev/null
+++ b/src/app/settings/settings.component.html
@@ -0,0 +1,12 @@
+Settings
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts
new file mode 100644
index 0000000..b6512fa
--- /dev/null
+++ b/src/app/settings/settings.component.ts
@@ -0,0 +1,40 @@
+import { Inject, Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
+import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+import { FormBuilder, Validators, FormGroup, FormControl } from '@angular/forms';
+import {User} from '../user.model';
+import {Owner} from '../owner.model';
+
+@Component({
+ selector: 'app-settings',
+ templateUrl: './settings.component.html',
+ styleUrls: ['/settings.component.css']
+})
+
+export class SettingsComponent implements OnInit {
+
+ settingsForm: FormGroup;
+ owner: Owner;
+
+ constructor(
+ private fb: FormBuilder,
+ private dialogRef: MatDialogRef,
+ @Inject(MAT_DIALOG_DATA) public data: Owner
+ ) {
+ this.settingsForm = fb.group({
+ name: [data.name, Validators.required]
+ });
+ this.owner = data;
+ }
+
+ ngOnInit() {
+ }
+
+ close() {
+ this.dialogRef.close();
+ }
+
+ save() {
+ this.owner.name = this.settingsForm.value.name;
+ this.dialogRef.close(this.owner);
+ }
+}
diff --git a/src/app/user.service.ts b/src/app/user.service.ts
index 5b15492..32766c4 100644
--- a/src/app/user.service.ts
+++ b/src/app/user.service.ts
@@ -82,10 +82,12 @@ export class UserService{
return obs;
}
- addOwnerName(address: string, name: string) {
- this.http.post<{message: string}>('http://localhost:3000/api/addownername', {address, name}).
+ updateOwner(owner: Owner) {
+ this.http.post<{message: string, owner: Owner}>('http://localhost:3000/api/updateowner', {owner: owner}).
subscribe((responseData) => {
console.log(responseData.message);
+ //this.dataStore.owner = responseData.owner;
+ //this._ownerUpdated.next(Object.assign({},this.dataStore).owner);
});
}
@@ -114,40 +116,9 @@ export class UserService{
return this.uZaddr === this.oZaddr;
}
- //getUser(session: string) {
- //const params = new HttpParams().append('session', session);
- //console.log(`US: Searching for session ${session} `);
- //this.http.get<{message: string, user: any}>('http://localhost:3000/api/getuser', { headers:{}, params: params, observe: 'response'}).
- //subscribe((UserDataResponse) => {
- //console.log(UserDataResponse.status);
- //if (UserDataResponse.status == 200){
- //this.uZaddr = UserDataResponse.body!.user[0].address;
- //console.log(`US: Found user, returning zaddr ${this.uZaddr}`);
- //this._uZaddrUpdated.next(this.uZaddr);
- //} else {
- //console.log('US: Did not find user');
- //this._uZaddrUpdated.next('');
- //}
- //});
-
- //}
-
- //getName() {
- //if (this.session != null) {
- //this.getUser(this.session);
- //this._uZaddrUpdated.subscribe((addr: string) => {
- //console.log(` US: ${addr}`);
- //this.getOwner(addr);
- //});
- //}
- //}
-
getNameUpdateListener() {
return this.uNameUpdated;
}
- //getZaddrUpdateListener() {
- //return this.uZaddrUpdated;
- //}
}
diff --git a/src/app/viewer/viewer.component.css b/src/app/viewer/viewer.component.css
index f6d0e97..0676c66 100644
--- a/src/app/viewer/viewer.component.css
+++ b/src/app/viewer/viewer.component.css
@@ -1,3 +1,3 @@
* {
- font-family: 'Roboto Mono', monospace;
+ font-family: 'Roboto-Mono', monospace;
}
diff --git a/src/app/viewer/viewer.component.html b/src/app/viewer/viewer.component.html
index 09706f2..4452d98 100644
--- a/src/app/viewer/viewer.component.html
+++ b/src/app/viewer/viewer.component.html
@@ -1,6 +1,6 @@
-
{{message}}
+ {{(ownerUpdate | async)!.name}}
diff --git a/src/app/viewer/viewer.component.ts b/src/app/viewer/viewer.component.ts
index d745e33..60ce54f 100644
--- a/src/app/viewer/viewer.component.ts
+++ b/src/app/viewer/viewer.component.ts
@@ -44,20 +44,4 @@ export class ViewerComponent implements OnInit {
ngOnDestroy(){
}
- //openDialog(address: string) {
- //const dialogConfig = new MatDialogConfig();
-
- //dialogConfig.autoFocus = true;
-
- /*
- *dialogConfig.data = {
- * id: 1,
- * title: 'Whee!'
- *}
- */
-
- //const dialogRef = this.dialog.open(NameDialogComponent, dialogConfig);
-
- //dialogRef.afterClosed().subscribe(name => this.userService.addOwnerName(address, name) );
- //}
}