Convert admin page to Vue
This commit is contained in:
@@ -75,7 +75,7 @@ export default class Spot {
|
||||
if(oData.desc.substr(0, this.consts.lang_prefix.length)==this.consts.lang_prefix) oData.desc = this.lang(oData.desc.substr(5));
|
||||
|
||||
if(oData.result==this.consts.error) fOnError(oData.desc);
|
||||
else fOnSuccess(oData.data, oData.desc);
|
||||
else if(fOnSuccess) fOnSuccess(oData.data, oData.desc);
|
||||
})
|
||||
.fail((jqXHR, textStatus, errorThrown) => {
|
||||
fonProgress('fail');
|
||||
@@ -83,6 +83,32 @@ export default class Spot {
|
||||
});
|
||||
}
|
||||
|
||||
async get2(sAction, oVars) {
|
||||
oVars = oVars || {};
|
||||
oVars['a'] = sAction;
|
||||
oVars['t'] = this.consts.timezone;
|
||||
|
||||
let oUrl = new URL(this.consts.server+this.consts.process_page);
|
||||
oUrl.search = new URLSearchParams(oVars).toString();
|
||||
|
||||
try {
|
||||
let oUrl = new URL(this.consts.server+this.consts.process_page);
|
||||
oUrl.search = new URLSearchParams(oVars).toString();
|
||||
const oRequest = await fetch(oUrl, {method: 'GET', /*body: JSON.stringify(oVars),*/ headers: {"Content-Type": "application/json"}});
|
||||
if(!oRequest.ok) throw new Error('Error HTTP '+oRequest.status+': '+oRequest.statusText);
|
||||
else {
|
||||
let oResponse = await oRequest.json();
|
||||
if(oResponse.desc.substr(0, this.consts.lang_prefix.length)==this.consts.lang_prefix) oResponse.desc = this.lang(oData.desc.substr(this.consts.lang_prefix.length));
|
||||
|
||||
if(oResponse.result == this.consts.error) return Promise.reject(oResponse.desc);
|
||||
else return Promise.resolve(oResponse.data, oResponse.desc);
|
||||
}
|
||||
}
|
||||
catch(oError) {
|
||||
throw oError;
|
||||
}
|
||||
}
|
||||
|
||||
lang(sKey, asParams) {
|
||||
asParams = asParams || [];
|
||||
if(typeof asParams == 'string') asParams = [asParams];
|
||||
@@ -176,6 +202,7 @@ export default class Spot {
|
||||
asContext = asContext || {};
|
||||
let sPage = this.vars('page');
|
||||
if(this.pages[sPage].onFeedback) this.pages[sPage].onFeedback(sType, sMsg, asContext);
|
||||
else console.log({type:sType, msg:sMsg, context:asContext});
|
||||
}
|
||||
|
||||
onKeydown(oEvent) {
|
||||
|
||||
Reference in New Issue
Block a user