({ domainId })
| 145 | } |
| 146 | |
| 147 | async get({ domainId }) { |
| 148 | const homepageConfig = this.ctx.setting.get('hydrooj.homepage'); |
| 149 | const info = yaml.load(homepageConfig) as any; |
| 150 | const contents = []; |
| 151 | for (const column of info) { |
| 152 | const tasks = []; |
| 153 | for (const name in column) { |
| 154 | if (name === 'width') continue; |
| 155 | const func = `get${camelCase(name).replace(/^[a-z]/, (i) => i.toUpperCase())}`; |
| 156 | if (!this[func]) tasks.push([name, column[name]]); |
| 157 | else { |
| 158 | tasks.push( |
| 159 | this[func](domainId, column[name]) |
| 160 | .then((res) => [name, res]) |
| 161 | .catch((err) => ['error', err.message]), |
| 162 | ); |
| 163 | } |
| 164 | } |
| 165 | contents.push({ |
| 166 | width: column.width, |
| 167 | // eslint-disable-next-line no-await-in-loop |
| 168 | sections: await Promise.all(tasks), |
| 169 | }); |
| 170 | } |
| 171 | const udict = await user.getList(domainId, Array.from(this.uids)); |
| 172 | this.response.template = 'main.html'; |
| 173 | this.response.body = { |
| 174 | contents, |
| 175 | udict, |
| 176 | domain: this.domain, |
| 177 | }; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | class HomeSecurityHandler extends Handler { |
no test coverage detected