/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
frontend/src/model/service.js
84 строки
2 KB
Michael Mayer
Settings: Save service password and API key on edit #5558
16 май 2026, 19:20
16 май 2026, 19:20
ee89d73
Код
Авторство
О чём код?
import RestModel from "model/rest"; import $api from "common/api"; import { $gettext } from "common/gettext"; import { $config } from "app/session"; // Service captures external service connections (WebDAV, S3, etc.). export class Service extends RestModel { getDefaults() { return { ID: 0, AccName: "", AccOwner: "", AccURL: "", AccType: "", AccKey: "", AccUser: "", AccPass: "", AccTimeout: "", AccError: "", AccErrors: 0, AccShare: true, AccSync: false, RetryLimit: 3, SharePath: "/", ShareSize: "", ShareExpires: 0, SyncPath: "/", SyncStatus: "", SyncInterval: 86400, SyncDate: null, SyncFilenames: true, SyncUpload: false, SyncDownload: !$config.get("readonly"), SyncRaw: true, CreatedAt: "", UpdatedAt: "", DeletedAt: null, }; } // AccPass and AccKey are tagged `json:"-"` on the backend, so they never // arrive in GET responses. Seeded here so the change-diff in update() // picks up user edits in the service edit dialog. getWriteOnly() { return { AccPass: "", AccKey: "", }; } getEntityName() { return this.AccName; } getId() { return this.ID ? this.ID : false; } Folders() { return $api.get(this.getEntityResource() + "/folders").then((response) => Promise.resolve(response.data)); } Upload(selection, folder) { if (!selection) { return; } if (Array.isArray(selection)) { selection = { Photos: selection }; } return $api.post(this.getEntityResource() + "/upload", { selection, folder }).then((response) => Promise.resolve(response.data)); } static getCollectionResource() { return "services"; } static getModelName() { return $gettext("Account"); } } export default Service;