mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
show json in list instead of alert so we can copy it
This commit is contained in:
parent
6f73d3983f
commit
d34a0c73b5
@ -9,6 +9,7 @@ class SessionItemViewModel extends EventEmitter {
|
|||||||
this._isDeleting = false;
|
this._isDeleting = false;
|
||||||
this._isClearing = false;
|
this._isClearing = false;
|
||||||
this._error = null;
|
this._error = null;
|
||||||
|
this._showJSON = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
get error() {
|
get error() {
|
||||||
@ -32,8 +33,8 @@ class SessionItemViewModel extends EventEmitter {
|
|||||||
|
|
||||||
async clear() {
|
async clear() {
|
||||||
this._isClearing = true;
|
this._isClearing = true;
|
||||||
alert(JSON.stringify(this._sessionInfo, undefined, 2));
|
this._showJSON = true;
|
||||||
this.emit("change", "isClearing");
|
this.emit("change");
|
||||||
try {
|
try {
|
||||||
await this._pickerVM.clear(this.id);
|
await this._pickerVM.clear(this.id);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
@ -65,6 +66,13 @@ class SessionItemViewModel extends EventEmitter {
|
|||||||
get sessionInfo() {
|
get sessionInfo() {
|
||||||
return this._sessionInfo;
|
return this._sessionInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get json() {
|
||||||
|
if (this._showJSON) {
|
||||||
|
return JSON.stringify(this._sessionInfo, undefined, 2);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SessionPickerViewModel {
|
export default class SessionPickerViewModel {
|
||||||
|
@ -41,6 +41,9 @@ body {
|
|||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
background-color: grey;
|
background-color: grey;
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.SessionPickerView .sessionInfo {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,14 @@ class SessionPickerItem extends TemplateView {
|
|||||||
disabled: vm => vm.isClearing,
|
disabled: vm => vm.isClearing,
|
||||||
onClick: this._onClearClick,
|
onClick: this._onClearClick,
|
||||||
}, "Clear");
|
}, "Clear");
|
||||||
|
|
||||||
|
const json = t.if(vm => vm.json, t => {
|
||||||
|
return t.div(t.pre(vm => vm.json));
|
||||||
|
});
|
||||||
|
|
||||||
const userName = t.span({className: "userId"}, vm => vm.userId);
|
const userName = t.span({className: "userId"}, vm => vm.userId);
|
||||||
const errorMessage = t.if(vm => vm.error, t => t.span({className: "error"}, vm => vm.error));
|
const errorMessage = t.if(vm => vm.error, t => t.span({className: "error"}, vm => vm.error));
|
||||||
return t.li([userName, errorMessage, clearButton, deleteButton]);
|
return t.li([t.div({className: "sessionInfo"}, [userName, errorMessage, clearButton, deleteButton]), json]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,8 +46,10 @@ export default class SessionPickerView extends TemplateView {
|
|||||||
mount() {
|
mount() {
|
||||||
this._sessionList = new ListView({
|
this._sessionList = new ListView({
|
||||||
list: this.viewModel.sessions,
|
list: this.viewModel.sessions,
|
||||||
onItemClick: (item) => {
|
onItemClick: (item, event) => {
|
||||||
this.viewModel.pick(item.viewModel.id);
|
if (event.target.closest(".sessionInfo")) {
|
||||||
|
this.viewModel.pick(item.viewModel.id);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}, sessionInfo => {
|
}, sessionInfo => {
|
||||||
return new SessionPickerItem(sessionInfo);
|
return new SessionPickerItem(sessionInfo);
|
||||||
|
Loading…
Reference in New Issue
Block a user