mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
16 lines
482 KiB
JavaScript
16 lines
482 KiB
JavaScript
|
/**
|
||
|
* Copyright JS Foundation and other contributors, http://js.foundation
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
**/
|
||
|
var RED=function(){function s(e,i){i=i||function(){};var t,n=/<!-- --- \[red-module:(\S+)\] --- -->/.exec(e.trim());t=n?n[1]:"unknown";try{var a=!1,s=$("<div>"+e+"</div>");s.find("script").each(function(e,t){var n=$(t).attr("src");if(n&&!/^\s*(https?:|\/|\.)/.test(n)){$(t).remove();var o=document.createElement("script");o.onload=function(){$("body").append(s),i()},$("body").append(o),o.src=RED.settings.apiRootUrl+n,a=!0}}),a||($("body").append(s),i())}catch(e){RED.notify(RED._("notification.errors.failedToAppendNode",{module:t,error:e.toString()}),{type:"error",timeout:1e4}),console.log("["+t+"] "+e.toString()),i()}}function r(t){$.ajax({headers:{Accept:"application/json"},cache:!1,url:"icons",success:function(e){RED.nodes.setIconSets(e),t&&t()}})}function t(){$.ajax({headers:{Accept:"text/html"},cache:!1,url:"nodes",success:function(e){var t=e.trim().split(/(?=<!-- --- \[red-module:\S+\] --- -->)/),n=function(){0===t.length?($("body").i18n(),$("#palette > .palette-spinner").hide(),$(".palette-scroll").removeClass("hide"),$("#palette-search").removeClass("hide"),d(function(){RED.settings.theme("projects.enabled",!1)?RED.projects.refresh(function(e){RED.sidebar.info.refresh(),e||(RED.menu.setDisabled("menu-item-projects-open",!0),RED.menu.setDisabled("menu-item-projects-settings",!0),!1===e||RED.projects.showStartup()),o()}):(RED.sidebar.info.refresh(),o())})):s(t.shift(),n)};n()}})}function d(n){$.ajax({headers:{Accept:"application/json"},cache:!1,url:"flows",success:function(e){if(e){var t=window.location.hash;RED.nodes.version(e.rev),RED.nodes.import(e.flows),RED.nodes.dirty(!1),RED.view.redraw(!0),/^#flow\/.+$/.test(t)&&RED.workspaces.show(t.substring(6))}n()}})}function o(){var a={};RED.comms.subscribe("notification/#",function(e,n){var t=e.split("/")[1];if("runtime-deploy"!==t&&"node"!==t){if("project-update"===t)return RED.nodes.clear(),RED.history.clear(),RED.view.redraw(!0),void RED.projects.refresh(function(){d(function(){var e=RED.projects.getActiveProject(),t={"change-branch":RED._("notification.project.change-branch",{project:e.git.branches.local}),"merge-abort":RED._("notification.project.merge-abort"),loaded:RED._("notification.project.loaded",{project:n.project}),updated:RED._("notification.project.updated",{project:n.project}),pull:RED._("notification.project.pull",{project:n.project}),revert:RED._("notification.project.revert",{project:n.project}),"merge-complete":RED._("notification.project.merge-complete")}[n.action];RED.notify("<p>"+t+"</p>"),RED.sidebar.info.refresh()})});if(n.text){n.default=n.text;var o=RED._(n.text,n),i={type:n.type,fixed:void 0===n.timeout,timeout:n.timeout,id:t};"runtime-state"===t&&("missing-types"===n.error?(o+="<ul><li>"+n.types.join("</li><li>")+"</li></ul>",RED.projects.getActiveProject()?i.buttons=[{text:RED._("notification.label.manage-project-dep"),click:function(){a[t].hideNotification(),RED.projects.settings.show("deps")}}]:i.buttons=[{text:RED._("common.label.close"),click:function(){a[t].hideNotification()}}]):"credentials_load_failed"===n.error?RED.settings.theme("projects.enabled",!1)?RED.user.hasPermission("projects.write")&&(i.buttons=[{text:"Setup credentials",click:function(){a[t].hideNotification(),RED.projects.showCredentialsPrompt()}}]):i.buttons=[{text:"Close",click:function(){a[t].hideNotification()}}]:"missing_flow_file"===n.error?RED.user.hasPermission("projects.write")&&(i.buttons=[{text:"Setup project files",click:function(){a[t].hideNotification(),RED.projects.showFilesPrompt()}}]):"missing_package_file"===n.error?RED.user.hasPermission("projects.write")&&(i.buttons=[{text:"Create default package file",click:function(){a[t].hideNotification(),RED.projects.createDefaultPackageFile()}}]):"project_empty"===n.error?RED.user.hasPermission("projects.write")&&(i.buttons=[{text:"No thanks",click:function(){a[t].hideNotification()}},{text:"Create default project files",click:function(){a[t].hideNotification(),RED.projects.createDefaultFileSet()}}]):"git_merge_conflict"===n.error&&(RED.nodes.clear(),RED.sidebar.versionControl.refresh(!0),RED.user.hasPermission
|