/* * Copyright (C) 1998-2018 by Northwoods Software Corporation * All Rights Reserved. * * Go Local Storage */ import * as go from "../../release/go"; import * as gcs from "./GoCloudStorage"; import {Promise} from "es6-promise"; /** *
Class for saving / loading Diagram models * to / from Local Storage. GoLocalStorage is the only {@link GoCloudStorage} subclass than can be used in a local page; that is, one not served by a web server.
*Note: that this class will not work with browsers that do not have Local Storage support (like some old versions of Internet Explorer).
* @category Storage */ export class GoNetCore extends gcs.GoCloudStorage { /** * The number of files to display in {@link ui} before loading more */ private static _MIN_FILES_IN_UI = 100; private _rootEndpoint: string; /** * @constructor * @param {go.Diagram|go.Diagram[]} managedDiagrams An array of GoJS Diagrams whose model(s) will be saved to * / loaded from Local Storage. Can also be a single Diagram. * @param {string} defaultModel String representation of the default model data for new diagrams. If this is null, default new * diagrams will be empty. Usually a value given by calling .toJson() on a GoJS Diagram's Model. * @param {string} iconsRelativeDirectory The directory path relative to the page in which this instance of GoLocalStorage exists, in which * the storage service brand icons can be found. The default value is "../goCloudStorageIcons/". */ constructor(managedDiagrams: go.Diagram|go.Diagram[], rootEndpoint: string, defaultModel?: string, iconsRelativeDirectory?: string) { super(managedDiagrams, defaultModel); this._rootEndpoint = rootEndpoint; this.ui.id = "goNetCoreCustomFilepicker"; this._serviceName = "Microsoft ASP .NET Core Web API"; } get rootEndpoint(): string { return this._rootEndpoint } /** * Check if Local Storage is supported by the current browser. * @param {boolean} refreshToken This parameter can be ignored. It exists only to maintain GoCloudStorage system structure * @return {PromiseThere may be more diagram files not shown. Click here to try loading more.
" document.getElementById("netCoreLoadMoreFiles").onclick = function () { storage.showUI(action, num); } } ui.appendChild(filesDiv); // italicize currently open file, if a file is currently open if (storage.currentDiagramFile.id) { let el: HTMLElement = document.getElementById(storage.currentDiagramFile.id + '-label'); if (el) el.style.fontStyle = "italic"; } // user input div (only for save) if (action === 'Save') { const userInputDiv = document.createElement('div'); userInputDiv.id = 'userInputDiv'; userInputDiv.innerHTML += 'Save Diagram As '; ui.appendChild(userInputDiv); } const submitDiv = document.createElement('div'); submitDiv.id = "submitDiv"; const actionButton = document.createElement('button'); actionButton.textContent = action; actionButton.id = 'actionButton'; actionButton.onclick = function () { storage.processUIResult(action); } submitDiv.appendChild(actionButton); ui.appendChild(submitDiv); const cancelDiv = document.createElement('div'); const cancelButton = document.createElement('button'); cancelButton.id = 'cancelButton'; cancelButton.textContent = 'Cancel'; cancelButton.onclick = function () { storage.hideUI(true); } cancelDiv.appendChild(cancelButton); ui.appendChild(cancelDiv); }); return storage._deferredPromise['promise']; // will not resolve until action (save, load, delete) completes } /** * TODO TODO TODO * @private * @hidden * Process the result of pressing the action button on the custom GoLocalStorage filepicker {@link ui}. * @param {string} action The action being done. Acceptable values: *Get information about a diagram file saved to .NET Core database. This data includes:
*Note: Id, name, and path are all provided (despite being the same). They are requisite for creating valid {@link DiagramFile}s.
* @param {string} path A valid id corresponding to a saved diagram file in the .NET Core database * @return {Promise