Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#44856] Get upload link from StorageFilesResourceService

Andreas Pfohl61e6c616a511
diff --git a/frontend/src/app/core/state/hal-resource.ts b/frontend/src/app/core/state/hal-resource.ts
index 3dbaf983e4d..b29e69e111a 100644
--- a/frontend/src/app/core/state/hal-resource.ts
+++ b/frontend/src/app/core/state/hal-resource.ts
@@ -12,6 +12,10 @@ export interface IHalResourceLinks {
self:IHalResourceLink;
}
+export interface IHalMethodResourceLink extends IHalResourceLink {
+ method:string;
+}
+
export type FormattableFormat = 'markdown'|'custom';
export interface IFormattable {
diff --git a/frontend/src/app/core/state/storage-files/storage-files.service.ts b/frontend/src/app/core/state/storage-files/storage-files.service.ts
index 060d07339c9..5c137f4f86e 100644
--- a/frontend/src/app/core/state/storage-files/storage-files.service.ts
+++ b/frontend/src/app/core/state/storage-files/storage-files.service.ts
@@ -39,6 +39,7 @@ import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';
import { IHalResourceLink } from 'core-app/core/state/hal-resource';
import { StorageFilesStore } from 'core-app/core/state/storage-files/storage-files.store';
import { insertCollectionIntoState } from 'core-app/core/state/collection-store';
+import { IUploadLink } from 'core-app/core/state/storage-files/upload-link.model';
@Injectable()
export class StorageFilesResourceService extends ResourceCollectionService<IStorageFile> {
@@ -61,6 +62,13 @@ export class StorageFilesResourceService extends ResourceCollectionService<IStor
);
}
+ uploadLink(link:IHalResourceLink, fileName:string, parent:string):Observable<IUploadLink> {
+ return this.http.post<IUploadLink>(link.href, {
+ fileName,
+ parent,
+ });
+ }
+
reset():void {
this.store.reset();
}
diff --git a/frontend/src/app/core/state/storage-files/upload-link.model.ts b/frontend/src/app/core/state/storage-files/upload-link.model.ts
new file mode 100644
index 00000000000..3c841f83635
--- /dev/null
+++ b/frontend/src/app/core/state/storage-files/upload-link.model.ts
@@ -0,0 +1,38 @@
+// -- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2022 the OpenProject GmbH
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License version 3.
+//
+// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+// Copyright (C) 2006-2013 Jean-Philippe Lang
+// Copyright (C) 2010-2013 the ChiliProject Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See COPYRIGHT and LICENSE files for more details.
+//++
+
+import { IHalMethodResourceLink, IHalResourceLinks } from 'core-app/core/state/hal-resource';
+
+interface IHalUploadResourceLinks extends IHalResourceLinks {
+ destination:IHalMethodResourceLink
+}
+
+export interface IUploadLink {
+ _type:string;
+ _links:IHalUploadResourceLinks;
+}