UNPKG

32.5 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4<meta charset="utf-8"/>
5<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover"/>
6
7<link rel="stylesheet" href="../assets/css/style.css"/>
8<!-- Copyright 1998-2021 by Northwoods Software Corporation. --> <title> GoJS Storage -- Northwoods Software </title>
9 <link rel="stylesheet" href="../assets/css/prism.css" />
10 </head>
11 <script>
12
13 window.diagrams = [];
14 window.goCode = function(pre, w, h, parentid, animation) {
15 window.diagrams.push([pre, w, h, parentid, animation]);
16 }
17 </script>
18 <body>
19 <nav id="navTop" class="w-full z-30 top-0 text-white bg-nwoods-primary">
20 <div class="w-full container max-w-screen-lg mx-auto flex flex-wrap sm:flex-nowrap items-center justify-between mt-0 py-2">
21 <div class="md:pl-4">
22 <a class="text-white hover:text-white no-underline hover:no-underline
23 font-bold text-2xl lg:text-4xl rounded-lg hover:bg-nwoods-secondary " href="../">
24 <h1 class="mb-0 p-1 ">GoJS</h1>
25 </a>
26 </div>
27 <button id="topnavButton" class="rounded-lg sm:hidden focus:outline-none focus:ring" aria-label="Navigation">
28 <svg fill="currentColor" viewBox="0 0 20 20" class="w-6 h-6">
29 <path id="topnavOpen" fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM9 15a1 1 0 011-1h6a1 1 0 110 2h-6a1 1 0 01-1-1z" clip-rule="evenodd"></path>
30 <path id="topnavClosed" class="hidden" fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path>
31 </svg>
32 </button>
33 <div id="topnavList" class="hidden sm:block items-center w-auto mt-0 text-white p-0 z-20">
34 <ul class="list-reset list-none font-semibold flex justify-end flex-wrap sm:flex-nowrap items-center px-0 pb-0">
35 <li class="p-1 sm:p-0"><a class="topnav-link" href="../learn/">Learn</a></li>
36 <li class="p-1 sm:p-0"><a class="topnav-link" href="../samples/">Samples</a></li>
37 <li class="p-1 sm:p-0"><a class="topnav-link" href="../intro/">Intro</a></li>
38 <li class="p-1 sm:p-0"><a class="topnav-link" href="../api/">API</a></li>
39 <li class="p-1 sm:p-0"><a class="topnav-link" href="https://www.nwoods.com/products/register.html">Register</a></li>
40 <li class="p-1 sm:p-0"><a class="topnav-link" href="../download.html">Download</a></li>
41 <li class="p-1 sm:p-0"><a class="topnav-link" href="https://forum.nwoods.com/c/gojs/11">Forum</a></li>
42 <li class="p-1 sm:p-0"><a class="topnav-link" href="https://www.nwoods.com/contact.html"
43 target="_blank" rel="noopener" onclick="getOutboundLink('https://www.nwoods.com/contact.html', 'contact');">Contact</a></li>
44 <li class="p-1 sm:p-0"><a class="topnav-link" href="https://www.nwoods.com/sales/index.html"
45 target="_blank" rel="noopener" onclick="getOutboundLink('https://www.nwoods.com/sales/index.html', 'buy');">Buy</a></li>
46 </ul>
47 </div>
48 </div>
49 <hr class="border-b border-gray-600 opacity-50 my-0 py-0" />
50 </nav>
51
52 <div class="md:flex flex-col md:flex-row md:min-h-screen w-full max-w-screen-xl mx-auto">
53
54 <div id="navSide" class="flex flex-col w-full md:w-40 lg:w-48 text-gray-700 bg-white flex-shrink-0">
55 <div class="flex-shrink-0 px-8 py-4">
56 <button id="navButton" class="rounded-lg md:hidden focus:outline-none focus:ring" aria-label="Navigation">
57 <svg fill="currentColor" viewBox="0 0 20 20" class="w-6 h-6">
58 <path id="navOpen" fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM9 15a1 1 0 011-1h6a1 1 0 110 2h-6a1 1 0 01-1-1z" clip-rule="evenodd"></path>
59 <path id="navClosed" class="hidden" fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path>
60 </svg>
61 </button>
62 </div>
63 <nav id="navList" class="min-h-screen hidden md:block sidebar-nav flex-grow px-1 lg:px-4 pb-4 md:pb-0 md:overflow-y-auto break-words">
64 <a href="index.html">Basics</a>
65 <a href="buildingObjects.html">Building Parts</a>
66 <a href="usingModels.html">Using Models</a>
67 <a href="dataBinding.html">Data Binding</a>
68 <a href="react.html">GoJS with React</a>
69 <a href="angular.html">GoJS with Angular</a>
70 <a href="textBlocks.html">TextBlocks</a>
71 <a href="shapes.html">Shapes</a>
72 <a href="pictures.html">Pictures</a>
73 <a href="panels.html">Panels</a>
74 <a href="tablePanels.html">Table Panels</a>
75 <a href="brush.html">Brushes</a>
76 <a href="sizing.html">Sizing Objects</a>
77 <a href="itemArrays.html">Item Arrays</a>
78 <a href="changedEvents.html">Changed Events</a>
79 <a href="transactions.html">Transactions</a>
80 <a href="viewport.html">Coordinates</a>
81 <a href="initialView.html">Initial View</a>
82 <a href="collections.html">Collections</a>
83 <a href="links.html">Links</a>
84 <a href="linkLabels.html">Link Labels</a>
85 <a href="connectionPoints.html">Link Points</a>
86 <a href="ports.html">Ports</a>
87 <a href="nodes.html">Nodes</a>
88 <a href="debugging.html">Debugging</a>
89 <a href="layouts.html">Layouts</a>
90 <a href="trees.html">Trees</a>
91 <a href="subtrees.html">SubTrees</a>
92 <a href="groups.html">Groups</a>
93 <a href="subgraphs.html">SubGraphs</a>
94 <a href="sizedGroups.html">Sized Groups</a>
95 <a href="selection.html">Selection</a>
96 <a href="highlighting.html">Highlighting</a>
97 <a href="animation.html">Animation</a>
98 <a href="toolTips.html">ToolTips</a>
99 <a href="contextmenus.html">Context Menus</a>
100 <a href="events.html">Diagram Events</a>
101 <a href="tools.html">Tools</a>
102 <a href="commands.html">Commands</a>
103 <a href="permissions.html">Permissions</a>
104 <a href="validation.html">Validation</a>
105 <a href="HTMLInteraction.html">HTML Interaction</a>
106 <a href="layers.html">Layers &amp; Z-ordering</a>
107 <a href="palette.html">Palette</a>
108 <a href="overview.html">Overview</a>
109 <a href="resizing.html">Resizing Diagrams</a>
110 <a href="replacingDeleting.html">Replacing and Deleting</a>
111 <a href="buttons.html">Buttons</a>
112 <a href="templateMaps.html">Template Maps</a>
113 <a href="legends.html">Legends and Titles</a>
114 <a href="extensions.html">Extensions</a>
115 <a href="geometry.html">Geometry Strings</a>
116 <a href="grids.html">Grid Patterns</a>
117 <a href="graduatedPanels.html">Graduated Panels</a>
118 <a href="makingImages.html">Diagram Images</a>
119 <a href="makingSVG.html">Diagram SVG</a>
120 <a href="printing.html">Printing</a>
121 <a href="serverSideImages.html">Server-side Images</a>
122 <a href="nodeScript.html">GoJS in Node.js</a>
123 <a href="testing.html">Testing</a>
124 <a href="storage.html">Storage</a>
125 <a href="performance.html">Performance</a>
126 <a href="source.html">Building from Source</a>
127 <a href="platforms.html">Platforms</a>
128 <a href="deployment.html">Deployment</a>
129 </nav>
130 </div>
131 <div class="pt-4 px-2 md:px-0 lg:px-4 pb-16 w-full overflow-hidden">
132
133
134
135
136<h1>Storage</h1>
137
138<p>
139 Storing GoJS model data in cloud storage is an excellent way to save, load, create, and delete diagram data files without worrying about local system concerns.
140 Interfacing with popular cloud storage services is made easy with the GoCloudStorage library.
141</p>
142<p>
143 The GoCloudStorage library is not pre-packaged with GoJS. You can find the GoCloudStorage library <a href="../projects/storage/lib/gcs.js">here</a>.
144</p>
145<p>
146 The GoCloudStorage class system lets developers easily store their GoJS diagram model data to popular cloud storage services. The
147 <a href="../api/symbols/GoCloudStorage.html">GoCloudStorage class</a> itself is an abstract class, never to be instantiated.
148 Instead, its subclasses are used, each interfacing with a different cloud storage service. Currently, the GoCloudStorage system supports Dropbox,
149 Google Drive, Microsoft OneDrive, and Local Storage. Class names are:
150 <ul>
151 <li><a href="../api/symbols/GoDropBox.html">GoDropBox</a></li>
152 <li><a href="../api/symbols/GoGoogleDrive.html">GoGoogleDrive</a></li>
153 <li><a href="../api/symbols/GoOneDrive.html">GoOneDrive</a></li>
154 <li><a href="../api/symbols/GoLocalStorage.html">GoLocalStorage</a></li>
155 </ul>
156</p>
157
158<h3 id="GoCloudStorageSubclassConstruction">GoCloudStorage Subclass Construction</h3>
159
160<p>
161 This section provides a description of how to create an instance of a specific GoCloudStorage subclass, GoGoogleDrive. Due to the variable nature of
162 cloud storage service APIs, GoCloudStorage subclass constructor parameters and behavior vary. It is recommended you read the full
163 <a href="../api/index.html">documentation</a> for any GoCloudStorage subclass you wish to use.
164</p>
165<p>
166 First, ensure you have a <code>script</code> tag with the path to your <code>gcs.js</code> library. All GoCloudStorage
167 subclasses are defined in the namespace <code>gcs</code>.
168</p>
169<p>
170 <strong>Note</strong>: To use any GoCloudStorage subclass (except for <a href="../api/symbols/GoLocalStorage.html">GoLocalStorage</a>), you must
171 also include a <code>script</code> tag referencing the storage service provider JS library. For each subclass, these could be something like:
172 <ul>
173 <li><a href="../api/symbols/GoDropBox.html">GoDropBox</a>: https://unpkg.com/dropbox@2.5.13/dist/DropboxTeam-sdk.min.js </li>
174 <li><a href="../api/symbols/GoGoogleDrive.html">GoGoogleDrive</a>: https://apis.google.com/js/api.js</li>
175 <li><a href="../api/symbols/GoOneDrive.html">GoOneDrive</a>: https://js.live.net/v7.2/OneDrive.js </li>
176 </ul>
177</p>
178<p>
179 Here is a valid constructor call for GoGoogleDrive.
180</p>
181<pre class="lang-js" id="simple"><code>
182 // Create a valid GoGoogleDrive instance
183 var ggd = new gcs.GoGoogleDrive(
184 diagrams, // managedDiagrams parameter
185 "16225356139-n64vtg7konuetna3of3mfcaj2iffhgmg.apps.googleusercontent.com", // clientId parameter
186 "AIzaSydBje3lBL67MMVKw467_pvuRg7_XMVGf18", // pickerApiKey parameter
187 defaultModel, // defaultModel parameter
188 "../projects/storage/goCloudStorageIcons/" // iconsRelativeDirectory parameter
189 );
190</code></pre>
191<p>
192 <strong>Note</strong>: All client ID's / API keys on this page are fabricated, and for example purposes only.
193</p>
194<p>
195 What are all these parameters? We'll step through them, one by one.
196</p>
197
198<h4 id="ManagedDiagrams">Managed Diagrams </h4>
199<p>
200 The first parameter passed to the GoGoogleDrive constructor is something called <code>diagrams</code>. This is the parameter known to all GoCloudStorage subclasses
201 as <code><a href="../api/symbols/GoCloudStorage.html#managedDiagrams">managedDiagrams</a></code>. It is either an Array of
202 GoJS Diagrams or a single GoJS Diagram that this instance of GoCloudStorage (in this case, GoGoogleDrive) will manage data storage for.
203 This parameter is required.
204</p>
205
206<h4 id="ClientID">Client ID</h4>
207<p>
208 The second parameter passed to the GoGoogleDrive constructor is a long string. This is the <code>
209 <a href="../api/symbols/GoCloudStorage.html#clientId">clientId</a></code> parameter, required by all GoCloudStorage subclasses (except
210 <a href="../api/symbols/GoLocalStorage.html">GoLocalStorage</a>). This ID tells the cloud storage provider (in this case, Google) and the user
211 what application is asking to manipulate stored file data (in this case, Google Drive file data).
212</p>
213<p>
214 This is usually given by the cloud storage provider's developer console or similar.
215 You will need to register an application with the storage provider (in this case, Google) to obtain this ID.
216 Read more below at <a href="#ObtainingClientIDs">Obtaining Client IDs</a>.
217</p>
218
219<h4 id="GooglePickerAPIKey">Google Picker API Key</h4>
220<p>
221 This is a GoGoogleDrive-specific parameter. Some GoCloudStorage subclasses require parameters that others do not.
222 Again, it is recommended you read the full <a href="../api/index.html">documentation</a> for any GoCloudStorage subclass you wish to use.
223</p>
224<p>
225 GoGoogleDrive requires this key to allow for the familiar, Google Drive file picker interface during graphical file manipulation. Read more about this special parameter
226 in the full <code><a href="../api/symbols/GoGoogleDrive.html#pickerApiKey">GoGoogleDrive.pickerApiKey</a></code> documentation.
227</p>
228
229<h4 id="DefaultModel">Default Model </h4>
230<p>
231 It is the default model data assigned to newly created diagrams with calls to
232 <code><a href="../api/symbols/GoCloudStorage.html#create">create</a></code>. Generally, this value is obtained with a call to
233 <a href="../api/symbols/Model.html#toJson">Diagram.model.toJson()</a>.
234</p>
235<p>
236 This is an optional parameter for all GoCloudStorage subclasses.
237 If no value is supplied during construction, this defaults to a new <a href="../api/symbols/GraphLinksModel.html">GraphLinksModel</a>.
238</p>
239
240<h4 id="IconsRelativeDirectory">Icons Relative Directory</h4>
241<p>
242 To use commands that call a GoCloudStorage subclass' custom <code><a href="../api/symbols/GoCloudStorage.html#ui">ui</a></code>,
243 you must specify the directory in which the icons for storage services reside, relative to the directory your application page is. This is provided
244 by the optional <code><a href="../api/symbols/GoCloudStorage.html#iconsRelativeDirectory">iconsRelativeDirectory</a></code> parameter. The default value is
245 "../goCloudStorageIcons/".
246</p>
247<p>
248 Exactly what the UI looks like varies between GoCloudStorage subclasses, though it certainly contains references to storage service icons. Without providing this
249 parameter, it's likely the space where these images go will appear blank.
250</p>
251<p>
252 Please refer to the full <a href="../api/index.html">documentation</a> for details on class-specific UIs.
253</p>
254
255<h3 id="ObtainingClientIDs">Obtaining Client IDs</h3>
256<p>
257 All GoCloudStorage subclasses (except <a href="../api/symbols/GoLocalStorage.html">GoLocalStorage</a>) require a client ID as a parameter during construction.
258 This lets the storage service provider (i.e. Google, Dropbox...) and the user know the identity of the application trying to manipulate their remote filesystems.
259 Therefore, obtaining a client ID for the storage service you wish to use is a requirement to using the corresponding GoCloudStorage subclass.
260</p>
261<p>
262 The process for this varies from service to service, though the general steps are the same.
263</p>
264<ol>
265 <li><strong>Register an account</strong></li>
266 <p>
267 If you do not already have an account with the storage service provider, make one.
268 </p>
269 <li><strong>Register a web application</strong></li>
270 <p>
271 This step varies most from service to service. Create and register an application with the storage service provider.
272 </p>
273 <li><strong>Locate your new application's Client ID</strong></li>
274 <p>
275 Your newly registered application has a Client ID -- a long string like the one we saw in <a href="#GoCloudStorageSubclassConstruction">GoCloudStorage
276 Subclass Construction</a>. Use this string as the <code><a href="../api/symbols/GoCloudStorage.html#clientId">clientId</a></code> parameter for your
277 instance of GoCloudStorage.
278 </p>
279</ol>
280<p>
281 These storage-specific pages can help walk you through the process of creating / registering an application with their service.
282 <ul>
283 <li><a href="https://developers.google.com/drive/v3/web/quickstart/js">GoGoogleDrive</a></li>
284 <li><a href="https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/app-registration">Microsoft OneDrive (Graph)</a></li>
285 <li><a href="https://www.dropbox.com/developers">Dropbox</a></li>
286 </ul>
287</p>
288
289<h3 id="SavingLoadingData">Saving / Loading Data </h3>
290<p>
291 Now that you have a working instance of a GoCloudStorage subclass, let's start saving and loading GoJS Diagram model data. We will continue with our
292 GoGoogleDrive example from <a href="#GoCloudStorageSubclassConstruction">GoCloudStorage Subclass Construction</a>, referring to our specific GoGoogleDrive instance as
293 <code>ggd</code>.
294</p>
295<p>
296 We can save the model data of <code>ggd.managedDiagrams</code> to Google Drive in a variety of ways.
297</p>
298
299<h4 id="SaveVsSaveWithUI">Save vs. Save With UI</h4>
300<p>
301 All GoCloudStorage subclasses have the functions <code>save()</code> and <code>saveWithUI()</code>. What's the difference?
302</p>
303<p>
304 <code>saveWithUI()</code> shows the <a href="../api/symbols/GoCloudStorage.html#ui">ui</a> element of the invoking instance of
305 GoCloudStorage, letting the user graphically specify a file name and/or save location.
306</p>
307<p>
308 <code>save()</code> is more nuanced. There are three cases. Let's return to our GoGoogleDrive example and explore them.
309</p>
310<ol>
311 <li><strong>Saving With a Specified Path</strong></li>
312 <p>
313 A call to <code>ggd.save(&#60;valid path string&#62;)</code> will save to that specific path in Google Drive, without showing any UI.
314 </p>
315 <p>
316 <strong>Note</strong>: What constitutes a valid path string parameter varies from service to service. See
317 <a href="../api/symbols/GoCloudStorage.html#getFile"> documentation</a> for more details.
318 </p>
319 <li><strong>Saving With a Valid Current Diagram File</strong></li>
320 <p>
321 If no path is supplied, but <code>ggd</code> has a valid <code><a href="../api/symbols/GoCloudStorage.html#currentDiagramFile">currentDiagramFile</a></code>
322 (a representation of the file from Google Drive <code>ggd</code> has currently open, and whose contents are loaded in <code>ggd.managedDiagrams</code>' models),
323 then the diagram file content at the path in Google Drive corresponding to <code>ggd.currentDiagramFile.path</code> is updated with the model contents of
324 <code>ggd.managedDiagrams</code>.
325 </p>
326 <li><strong>Saving With Neither</strong></li>
327 <p>
328 If no path is supplied and <code>ggd.currentDiagramFile</code> is not valid, <code>ggd.saveWithUI()</code> is called, prompting the user for a save name / location.
329 </p>
330</ol>
331<h4 id="Loading">Loading</h4>
332 <p>
333 Loading file data is more straightforward.
334 </p>
335 <p>
336 <code><a href="../api/symbols/GoCloudStorage.html#load">load(&#60;valid path string&#62;)</a></code> loads file contents from the cloud storage service and
337 into each of <code>managedDiagrams</code>' models. No UI appears.
338 <br />
339 <strong>Example</strong>: <code>ggd.load('ahjdhe^3n4dlKd4r')</code>
340 </p>
341 <p>
342 <code><a href="../api/symbols/GoCloudStorage.html#loadWithUI">loadWithUI()</a></code> displays the
343 <a href="../api/symbols/GoCloudStorage.html#ui">ui</a> and lets the user graphically choose which file to load.
344 <br />
345 <strong>Example</strong>: <code>ggd.loadWithUI()</code>
346 </p>
347 <p>
348 <strong>Note 1</strong>: The file being loaded must have been saved to storage from a page with GoJS Diagrams whose DIV IDs correspond with the DIV IDs of
349 <code><a href="../api/symbols/GoCloudStorage.html#managedDiagrams">managedDiagrams</a></code>. Otherwise, it will not be clear to the GoCloudStorage subclass
350 where to load model data to.
351 <br />
352 <strong>Note 2</strong>: Model data loaded into <code>managedDiagrams</code> from storage must be processed appropriately within the
353 application containing the invoking instance of GoCloudStorage (via <a href="templateMaps.html">node / link templates</a> or some other method). The GoCloudStorage
354 class system does not store any information other than model data.
355 </p>
356</p>
357
358<h3 id="CreatingRemovingData">Creating / Removing Data </h3>
359<h4 id="CreatingFiles">Creating Files</h4>
360<p>
361 Continuing with our GoGoogleDrive example, how would you create a new file in storage to save <code>ggd.managedDiagrams</code> to? Call the <code>create</code> function.
362</p>
363<p>
364 <code>create()</code> sets each of <code>ggd.managedDiagrams</code> to <code>ggd.defaultModel</code> (assigned at construction, back in
365 <a href="#GoCloudStorageSubclassConstruction">GoCloudStorage Subclass Construction</a>). If
366 <code><a href="../api/symbols/GoCloudStorage.html#isAutoSaving">ggd.isAutoSaving</a></code> is true, you will be prompted to
367 save your newly refreshed <code>managedDiagrams</code> to Google Drive via an automatic call to <code>saveWithUI()</code>.
368</p>
369<p>
370 Optionally, the <code>create</code> function can accept a path parameter, just as the <code>save()</code> and <code>load()</code> functions described in
371 <a href="#savingLoadingData">Saving / Loading Data</a>. If supplied, once each of <code>ggd.managedDiagrams</code> is reset to <code>defaultModel</code>,
372 their model data is saved to the given path in Google Drive, and no UI appears.
373</p>
374
375<h4 id="RemovingFiles">Removing Files</h4>
376<p>
377 To remove a file from Google Drive, simply call <code>ggd.remove(&#60;some valid path string&#62;)</code>. The file at the given path in Google Drive will be removed,
378 without showing any UI.
379</p>
380<p>
381 To remove a file from Google Drive with the <a href="../api/symbols/GoCloudStorage.html#ui">ui</a> element, call <code>ggd.removeWithUI()</code>.
382</p>
383
384<h3 id="GoCloudStorageManager">Go Cloud Storage Manager </h3>
385<p>
386 What if you wanted to be able to save / load the diagrams on your page to / from many different cloud storage services? Say, Google Drive and Microsoft OneDrive?
387 Or Microsoft OneDrive, Dropbox, and Google Drive? Or any combination of the currently supported GoCloudStorage subclasses? That's what the
388 <a href="../api/symbols/GoCloudStorageManager.html">Go Cloud Storage Manager</a> is for.
389</p>
390
391<h4 id="ConstructingGoCloudStorageManager">Constructing the GoCloudStorageManager</h4>
392<p>
393 Observe the standard GoCloudStorageManager construction process:
394 <pre class="lang-js"><code>
395 // Construct the CloudStorage subclasses you wish to manage
396 gls = new gcs.GoLocalStorage(myDiagram, defaultModel);
397 god = new gcs.GoOneDrive(myDiagram, 'f9b171a6-a12e-48c1-b86c-814ed40fcdd1', defaultModel);
398 ggd = new gcs.GoGoogleDrive(myDiagram, '16225373139-n24vtg7konuetna3ofbmfcaj2infhgmg.apps.googleusercontent.com',
399 'AIzaSyDBj43lBLpYMMVKw4aN_pvuRg7_XMVGf18', defaultModel);
400 gdb = new gcs.GoDropBox(myDiagram, '3sm2ko6q7u1gbix', defaultModel);
401 storages = [gls, god, ggd, gdb];
402
403 // Create the GoCloudStorageManager instance
404 storageManager = new gcs.GoCloudStorageManager(storages, "../projects/storage/goCloudStorageIcons/");
405 </code></pre>
406 Despite all that code, there are only two parameters GoCloudStorageManager takes.
407</p>
408<ul>
409 <li><strong><a href="../api/symbols/GoCloudStorageManager.html#storages">Storages</a></strong></li>
410 <p>
411 The first parameter, <code>storages</code>, is a either an Array or <a href="../api/Set.html">Set</a> of GoCloudStorage subclasses.
412 This tells the GoCloudStorageManager instance, <code>storageManager</code>, what storage services are being managed and how those services are managing their diagrams.
413 </p>
414 <li><strong><a href="../api/symbols/GoCloudStorageManager.html#iconsRelativeDirectory">Icons Relative Directory</a></strong></li>
415 <p>
416 The second parameter is a string, and corresponds to the
417 <code><a href="../api/symbols/GoCloudStorageManager.html#iconsRelativeDirectory">iconsRelativeDirectory</a></code> property of GoCloudStorageManager. This
418 is analogous to the <code>iconsRelativeDirectory</code> discussed in <a href="#GoCloudStorageSubclassConstruction">GoCloudStorage Subclass Construction</a>. The only
419 difference is the GoCloudStorageManager applies this property to each of the GoCloudStorage subclasses' <code>iconsRelativeDirectory</code> properties. This parameter
420 is optional, but not supplying it may mean there are blank spaces in the <a href="../api/symbols/GoCloudStorageManager.html#ui">ui</a> where the storage service
421 icons are supposed to be.
422 </p>
423</ul>
424
425
426
427<h4 id="UsingGoCloudStorageManager">Using the GoCloudStorageManager</h4>
428
429<div style="text-align: center; padding: 20px;">
430 <figure >
431 <img src="images/gcsmSelectStorageService.png" />
432 <figcaption>The UI the appears after calling selectStorageService()</figcaption>
433 </figure>
434</div>
435<p>
436 First, set the GoCloudStorage subclass you want to use at the moment. This is done through a UI, which is brought up with a
437 call to <code><a href="../api/symbols/GoCloudStorageManager.html#selectStorageService">storageManager.selectStorageService()</a></code>.
438 <code><a href="../api/symbols/GoCloudStorageManager.html#currentStorageService">storageManager.currentStorageService</a></code> is set
439 to the GoCloudStorage subclass managing the storage service selected in the resultant UI.
440
441</p>
442
443<p>
444 The GoCloudStorageManager assumes a desire for mainly graphical manipulation of data, so calls to <code>save()</code>, <code>load()</code>, <code>create()</code>, and
445 <code>remove()</code> do not take any parameters and all launch the proper <a href="../api/symbols/GoCloudStorage.html#ui">ui</a> for
446 <code>storageManager.currentStorageService</code> (set by the the previous step).
447</p>
448
449<p>
450 You may want to update your page display or perform some other actions based on the saving / loading / removal / creation of data using GoCloudStorageManager.
451 All GoCloudStorageManager core methods (<code>save()</code>, <code>load()</code>, <code>create()</code>, and <code>remove()</code>) return Promises that resolve with
452 a <a href="../api/symbols/DiagramFile.html">DiagramFile</a>, representing the recently saved / loaded / created / removed file. With this data, you may update your
453 page display or perform any other action upon Promise resolution. Such as:
454 <pre class="lang-js"><code>
455 // resolving the Promise returned after the Load action
456 storageManager.load().then(function(fileData){
457 // the fileData is a DiagramFile object
458 alert(fileData.name + " (file ID " + fileData.id + ") loaded from path " + fileData.path);
459 });
460 </code></pre>
461 <strong>Note</strong>: There are three guaranteed fields in any DiagramFile object: the <a href="../api/symbols/DiagramFile.html#name">name</a>,
462 <a href="../api/symbols/DiagramFile.html#id">id</a>, and <a href="../api/symbols/DiagramFile.html#path">path</a> of the represented file.
463</p>
464
465 </div>
466 </div>
467
468 <div class="bg-nwoods-primary">
469 <section class="max-w-screen-lg text-white container mx-auto py-2 px-12">
470 <p id="version" class="leading-none mb-2 my-4">GoJS</p>
471 </section>
472 </div><footer class="bg-nwoods-primary text-white">
473 <div class="container max-w-screen-lg mx-auto px-8">
474 <div class="w-full py-6">
475
476 <div class="max-w-screen-lg xl:max-w-screen-xl mx-auto px-4 sm:px-6 md:px-8">
477 <ul class="text-sm font-medium pb-14 sm:pb-20 grid grid-cols-1 sm:grid-cols-3 gap-y-10">
478 <li class="list-none row-span-2">
479 <h2 class="text-base font-semibold tracking-wide">GoJS</h2>
480 <ul class="list-none space-y-4 md:space-y-1 px-0">
481 <li>
482 <a href="../samples/index.html">Samples</a>
483 </li>
484 <li>
485 <a href="../learn/index.html">Learn</a>
486 </li>
487 <li>
488 <a href="../intro/index.html">Intro</a>
489 </li>
490 <li>
491 <a href="../api/index.html">API</a>
492 </li>
493 <li>
494 <a href="../changelog.html">Changelog</a>
495 </li>
496 <li>
497 <a href="https://github.com/NorthwoodsSoftware/GoJS">GitHub</a>
498 </li>
499 </ul>
500 </li>
501 <li class="list-none row-span-2">
502 <h2 class="text-base font-semibold tracking-wide">Support</h2>
503 <ul class="list-none space-y-4 md:space-y-1 px-0">
504 <li>
505 <a href="https://www.nwoods.com/contact.html"
506 target="_blank" rel="noopener" onclick="getOutboundLink('https://www.nwoods.com/contact.html', 'contact');">Contact</a>
507 </li>
508 <li>
509 <a href="https://forum.nwoods.com/c/gojs">Forum</a>
510 </li>
511 <li>
512 <a href="https://www.nwoods.com/app/activate.aspx?sku=gojs">Activate</a>
513 </li>
514 <li>
515 <a href="https://www.nwoods.com/sales/index.html"
516 target="_blank" rel="noopener" onclick="getOutboundLink('https://www.nwoods.com/sales/index.html', 'buy');">Buy</a>
517 </li>
518 <li>
519 <a href="https://www.youtube.com/channel/UC9We8EoX596-6XFjJDtZIDg">Videos</a>
520 </li>
521 </ul>
522 </li>
523 <li class="list-none row-span-2">
524 <h2 class="text-base font-semibold tracking-wide">Company</h2>
525 <ul class="list-none space-y-4 md:space-y-1 px-0">
526 <li>
527 <a href="https://www.nwoods.com">Northwoods</a>
528 </li>
529 <li>
530 <a href="https://www.nwoods.com/about.html">About Us</a>
531 </li>
532 <li>
533 <a href="https://www.nwoods.com/contact.html">Contact Us</a>
534 </li>
535 <li>
536 <a href="https://twitter.com/northwoodsgo">Twitter</a>
537 </li>
538
539 </ul>
540 </li>
541 </ul>
542
543
544 <p class="text-sm text-gray-100 md:mb-6">
545 Copyright 1998-2021 <a class="text-white" href="https://www.nwoods.com">Northwoods Software</a>
546 </p>
547 </div>
548 </div>
549</footer> </body>
550
551<script async src="https://www.googletagmanager.com/gtag/js?id=UA-1506307-5"></script>
552<script>
553 window.dataLayer = window.dataLayer || [];
554 function gtag(){dataLayer.push(arguments);}
555 gtag('js', new Date()); gtag('config', 'UA-1506307-5');
556 var getOutboundLink = function(url, label) {
557 gtag('event', 'click', {
558 'event_category': 'outbound',
559 'event_label': label,
560 'transport_type': 'beacon'
561 });
562 }
563
564 // topnav
565 var topButton = document.getElementById("topnavButton");
566 var topnavList = document.getElementById("topnavList");
567 topButton.addEventListener("click", function() {
568 this.classList.toggle("active");
569 topnavList.classList.toggle("hidden");
570 document.getElementById("topnavOpen").classList.toggle("hidden");
571 document.getElementById("topnavClosed").classList.toggle("hidden");
572 });
573</script>
574 <script src="../assets/js/prism.js"></script>
575 <script src="../release/go.js"></script>
576 <script src="../assets/js/goDoc.js"></script>
577 <script>
578 document.addEventListener("DOMContentLoaded", function() {
579 if (window.go) document.getElementById('version').textContent = "GoJS version " + go.version;
580 if (window.goDoc) window.goDoc();
581 var d = window.diagrams;
582 for (var i = 0; i < d.length; i++) {
583 var dargs = d[i];
584 goCodeExecute(dargs[0], dargs[1], dargs[2], dargs[3], dargs[4]);
585 }
586 if (window.extra) window.extra();
587 });
588 </script>
589</html>