Browse Source

Add ConfigTemplate API

pull/1206/head
Hironsan 3 years ago
parent
commit
8d0ba53bc4
2 changed files with 24 additions and 1 deletions
  1. 2
      frontend/repositories/config/api.ts
  2. 23
      frontend/repositories/template/api.ts

2
frontend/repositories/config/api.ts

@ -2,7 +2,7 @@ import ApiService from '@/services/api.service'
import { ConfigItemListRepository } from '@/repositories/config/interface' import { ConfigItemListRepository } from '@/repositories/config/interface'
import { ConfigItemList, ConfigItem } from '@/models/config/config-item-list' import { ConfigItemList, ConfigItem } from '@/models/config/config-item-list'
interface ConfigItemResponse {
export interface ConfigItemResponse {
id: number, id: number,
model_name: string, model_name: string,
model_attrs: object, model_attrs: object,

23
frontend/repositories/template/api.ts

@ -0,0 +1,23 @@
import ApiService from '@/services/api.service'
import { TemplateRepository } from '@/repositories/template/interface'
import { ConfigTemplateItem, ConfigResponse } from '@/models/config/config-template'
export class FromApiTemplateRepository implements TemplateRepository {
constructor(
private readonly request = ApiService
) {}
async list(projectId: string): Promise<string[]> {
const url = `/projects/${projectId}/auto-labeling-templates`
const response = await this.request.get(url)
const responseItems: string[] = response.data
return responseItems
}
async find(projectId: string, optionName: string): Promise<ConfigTemplateItem> {
const url = `/projects/${projectId}/auto-labeling-templates/${optionName}`
const response = await this.request.get(url)
const responseItem: ConfigResponse = response.data
return ConfigTemplateItem.valueOf(responseItem)
}
}
Loading…
Cancel
Save