qa: Back to the same situation
This commit is contained in:
parent
00f84e43ca
commit
1aa82bb2ef
27 changed files with 1336 additions and 22 deletions
39
qa/ui/src/lib/themes.js
Normal file
39
qa/ui/src/lib/themes.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
export class Theme {
|
||||
constructor(res) {
|
||||
if (res) {
|
||||
this.update(res);
|
||||
}
|
||||
}
|
||||
|
||||
update({ id, name, urlid, path, authors, intro, headline, image, partner_img, partner_href, partner_txt }) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.urlid = urlid;
|
||||
this.path = path;
|
||||
this.authors = authors;
|
||||
this.intro = intro;
|
||||
this.headline = headline;
|
||||
this.image = image;
|
||||
this.partner_img = partner_img;
|
||||
this.partner_href = partner_href;
|
||||
this.partner_txt = partner_txt;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getThemes() {
|
||||
const res = await fetch(`api/themes`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
return (await res.json()).map((t) => new Theme(t));
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTheme(tid) {
|
||||
const res = await fetch(`api/themes/${tid}`, {headers: {'Accept': 'application/json'}})
|
||||
if (res.status == 200) {
|
||||
return new Theme(await res.json());
|
||||
} else {
|
||||
throw new Error((await res.json()).errmsg);
|
||||
}
|
||||
}
|
||||
Reference in a new issue