diff --git a/editor/components/commit.ts b/editor/components/commit.ts index 5677f9f..89f024e 100644 --- a/editor/components/commit.ts +++ b/editor/components/commit.ts @@ -75,7 +75,7 @@ export class CommitModal { this.hide(); }, err => { this.committing = false; - this.error_message = `Couldn't commit, cause: '${err}'`; + this.error_message = `Couldn't commit, cause: '${err.json().message}'`; console.log(err); }); } diff --git a/editor/components/login/form.ts b/editor/components/login/form.ts index 134b542..3df4a73 100644 --- a/editor/components/login/form.ts +++ b/editor/components/login/form.ts @@ -29,9 +29,10 @@ export class LoginForm { this.password ).subscribe(res => { if (res.status === 200) { - this.username = ''; - this.password = ''; - this.router.navigate([this.auth.redirectUrl()]); + this.router.navigate([this.auth.redirectUrl()]).then(() => { + this.username = ''; + this.password = ''; + }); } else { this.loginAttemptFailed = true; } diff --git a/editor/components/webgl/simple-surface.ts b/editor/components/webgl/simple-surface.ts index 4c9e9c1..faa9317 100644 --- a/editor/components/webgl/simple-surface.ts +++ b/editor/components/webgl/simple-surface.ts @@ -12,7 +12,6 @@ import {init_gl_default} from './helpers'; selector: 'img-webgl-surface', styles: [ `canvas { width: 100%; height: 100% }`, - `.display-none { display: none; }` ], template: ` diff --git a/editor/components/webgl/surface.ts b/editor/components/webgl/surface.ts index 5a29c7f..5319b56 100644 --- a/editor/components/webgl/surface.ts +++ b/editor/components/webgl/surface.ts @@ -26,7 +26,6 @@ export interface KeyHandler { selector: 'webgl-surface', styles: [ `canvas { width: 100%; height: 100% }`, - `.display-none { display: none; }` ], template: ` { if (map.is_new) { - let observable = this.http.post(`/api/map/new`, { + return this.http.post(`/api/maps/new`, { name: map.name, layers: map.layers.map(l => l.raw.map(c => ({ tiles_id_base64: intoBase64(c.tiles_id), - chipset_id: c.chipset + chipset_id: intoMongoDbId(c) })) ), width: map.width, height: map.height, tile_size: map.tile_size, comment, - } as MapData); - observable.subscribe(res => { + } as MapData) + .do(res => { if (res.status === 200) { map.is_new = false; } }); - return observable; } - return this.http.post(`/api/map/${map.name}/commit`, { + return this.http.post(`/api/maps/${map.name}/commit`, { layers: map.layers.map(l => l.raw.map(c => ({ tiles_id_base64: intoBase64(c.tiles_id), - chipset_id: c.chipset + chipset_id: intoMongoDbId(c) }))), comment, } as MapCommitData); diff --git a/editor/modules/map/editor.html b/editor/modules/map/editor.html index 94d172f..3fcdfd4 100644 --- a/editor/modules/map/editor.html +++ b/editor/modules/map/editor.html @@ -33,13 +33,8 @@

Palette

- - -
- +
+
diff --git a/editor/modules/map/layers-panel.ts b/editor/modules/map/layers-panel.ts index aa6412e..acb61c2 100644 --- a/editor/modules/map/layers-panel.ts +++ b/editor/modules/map/layers-panel.ts @@ -90,7 +90,9 @@ export class LayersPanel implements OnChanges, AfterViewInit, OnDestroy { } private requestLayerPreviews() { - this.current_map.layers + if (this.current_map) { + this.current_map.layers .forEach((_, i) => this.area.layer_index_stream.next(i)); + } } } diff --git a/editor/rxjs-add.ts b/editor/rxjs-add.ts index ad97493..8980ef3 100644 --- a/editor/rxjs-add.ts +++ b/editor/rxjs-add.ts @@ -3,5 +3,7 @@ import 'rxjs/add/operator/mergeMap'; import 'rxjs/add/operator/switchMap'; import 'rxjs/add/operator/filter'; import 'rxjs/add/operator/share'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/delay'; import 'rxjs/add/observable/of'; import 'rxjs/add/observable/fromEvent'; diff --git a/editor/style.scss b/editor/style.scss index 96adfa0..51e831a 100644 --- a/editor/style.scss +++ b/editor/style.scss @@ -81,3 +81,5 @@ header.navbar.navbar-fixed-top.navbar-empty { top: $navbar-height + 12px; height: 56px; // Same for this value } + +.display-none { display: none; } diff --git a/server/apis/chipsets.ts b/server/apis/chipsets.ts index ab35249..206f97d 100644 --- a/server/apis/chipsets.ts +++ b/server/apis/chipsets.ts @@ -38,19 +38,19 @@ app.post('/api/chipset/upload/', reqAuth, upload.single('chipset'), app.get('/api/chipset/', reqAuth, (req, res) => { ChipsetModel.find({}) - .select('name') + .select('id') .exec((err, chipsets) => { if (err) { werr(err); serverError(res, `Couldn't get the list of chipsets.`); } else { - res.status(200).json(chipsets.map(c => c.name)); + res.status(200).json(chipsets.map(c => c.id)); } }); }); -app.get('/api/chipset/:name/metadata', reqAuth, (req, res) => { - ChipsetModel.findOne({ name: req.params.name }, (err, chipset) => { +app.get('/api/chipset/:id/metadata', reqAuth, (req, res) => { + ChipsetModel.findById(req.params.id, (err, chipset) => { if (err || !chipset) { if (err) werr(err); notFound(res, req.user); @@ -60,8 +60,8 @@ app.get('/api/chipset/:name/metadata', reqAuth, (req, res) => { }); }); -app.get('/api/chipset/:name', reqAuth, (req, res) => { - ChipsetModel.findOne({ name: req.params.name }, (err, chipset) => { +app.get('/api/chipset/:id', reqAuth, (req, res) => { + ChipsetModel.findById(req.params.id, (err, chipset) => { if (err || !chipset) { if (err) werr(err); notFound(res, req.user); diff --git a/server/validators/api_map.ts b/server/validators/api_map.ts index 561f5dc..f1b18f8 100644 --- a/server/validators/api_map.ts +++ b/server/validators/api_map.ts @@ -8,7 +8,6 @@ const layerDataSchema = { minItems: 1, items: { type: 'array', - minItems: 1, items: { required: true, type: 'object', @@ -54,7 +53,7 @@ export const validateMapNew = validator({ }, comment: { required: true, - type: 'number' + type: 'string' } } }, {