|
|
@@ -1068,462 +1068,6 @@ from desktop.views import _ko
|
|
|
|
|
|
(function () {
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * @param {Object} options
|
|
|
- * @param {string} options.user
|
|
|
- * @constructor
|
|
|
- **/
|
|
|
- function AssistDocumentsPanel (options) {
|
|
|
- var self = this;
|
|
|
- self.user = options.user;
|
|
|
-
|
|
|
- self.activeEntry = ko.observable();
|
|
|
- self.activeSort = ko.observable('defaultAsc');
|
|
|
- self.typeFilter = ko.observable(DOCUMENT_TYPES[0]); // all is first
|
|
|
-
|
|
|
- self.highlightTypeFilter = ko.observable(false);
|
|
|
-
|
|
|
- var lastOpenedUuid = window.apiHelper.getFromTotalStorage('assist', 'last.opened.assist.doc.uuid');
|
|
|
-
|
|
|
- if (lastOpenedUuid) {
|
|
|
- self.activeEntry(new HueFileEntry({
|
|
|
- activeEntry: self.activeEntry,
|
|
|
- trashEntry: ko.observable(),
|
|
|
- app: 'documents',
|
|
|
- user: self.user,
|
|
|
- activeSort: self.activeSort,
|
|
|
- typeFilter: self.typeFilter,
|
|
|
- definition: {
|
|
|
- uuid: lastOpenedUuid,
|
|
|
- type: 'directory'
|
|
|
- }
|
|
|
- }))
|
|
|
- } else {
|
|
|
- self.fallbackToRoot();
|
|
|
- }
|
|
|
-
|
|
|
- self.activeEntry.subscribe(function (newEntry) {
|
|
|
- if (!newEntry.loaded()) {
|
|
|
- var loadedSub = newEntry.loaded.subscribe(function (loaded) {
|
|
|
- if (loaded && !newEntry.hasErrors() && newEntry.definition() && newEntry.definition().uuid) {
|
|
|
- window.apiHelper.setInTotalStorage('assist', 'last.opened.assist.doc.uuid', newEntry.definition().uuid);
|
|
|
- }
|
|
|
- loadedSub.dispose();
|
|
|
- })
|
|
|
- } else if (!newEntry.hasErrors() && newEntry.definition() && newEntry.definition().uuid) {
|
|
|
- window.apiHelper.setInTotalStorage('assist', 'last.opened.assist.doc.uuid', newEntry.definition().uuid);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- self.reload = function () {
|
|
|
- self.activeEntry().load(function () {}, function () {
|
|
|
- self.fallbackToRoot();
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.document.refresh', function () {
|
|
|
- huePubSub.publish('assist.clear.document.cache');
|
|
|
- self.reload();
|
|
|
- });
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.doc.highlight', function (details) {
|
|
|
- huePubSub.publish('assist.show.documents');
|
|
|
- huePubSub.publish('context.popover.hide');
|
|
|
- var whenLoaded = $.Deferred().done(function () {
|
|
|
- self.activeEntry().highlightInside(details.docUuid);
|
|
|
- });
|
|
|
- if (self.activeEntry() && self.activeEntry().definition() && self.activeEntry().definition().uuid === details.parentUuid) {
|
|
|
- if (self.activeEntry().loaded() && !self.activeEntry().hasErrors()) {
|
|
|
- whenLoaded.resolve();
|
|
|
- } else {
|
|
|
- var loadedSub = self.activeEntry().loaded.subscribe(function (newVal) {
|
|
|
- if (newVal) {
|
|
|
- if (!self.activeEntry().hasErrors()) {
|
|
|
- whenLoaded.resolve();
|
|
|
- }
|
|
|
- whenLoaded.reject();
|
|
|
- loadedSub.remove();
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- self.activeEntry().highlight(details.docUuid);
|
|
|
- } else {
|
|
|
- self.activeEntry(new HueFileEntry({
|
|
|
- activeEntry: self.activeEntry,
|
|
|
- trashEntry: ko.observable(),
|
|
|
- app: 'documents',
|
|
|
- user: self.user,
|
|
|
- activeSort: self.activeSort,
|
|
|
- typeFilter: self.typeFilter,
|
|
|
- definition: {
|
|
|
- uuid: details.parentUuid,
|
|
|
- type: 'directory'
|
|
|
- }
|
|
|
- }));
|
|
|
- self.activeEntry().load(function() {
|
|
|
- whenLoaded.resolve();
|
|
|
- }, function () {
|
|
|
- whenLoaded.reject();
|
|
|
- self.fallbackToRoot();
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- AssistDocumentsPanel.prototype.setTypeFilter = function (newType) {
|
|
|
- var self = this;
|
|
|
- DOCUMENT_TYPES.some(function (docType) {
|
|
|
- if (docType.type === newType) {
|
|
|
- self.typeFilter(docType);
|
|
|
- return true;
|
|
|
- }
|
|
|
- });
|
|
|
- self.highlightTypeFilter(true);
|
|
|
- window.setTimeout(function () {
|
|
|
- self.highlightTypeFilter(false);
|
|
|
- }, 600)
|
|
|
- };
|
|
|
-
|
|
|
- AssistDocumentsPanel.prototype.fallbackToRoot = function () {
|
|
|
- var self = this;
|
|
|
- if (!self.activeEntry() || self.activeEntry().definition() && (self.activeEntry().definition().path !== '/' || self.activeEntry().definition().uuid)) {
|
|
|
- window.apiHelper.setInTotalStorage('assist', 'last.opened.assist.doc.uuid', null);
|
|
|
- self.activeEntry(new HueFileEntry({
|
|
|
- activeEntry: self.activeEntry,
|
|
|
- trashEntry: ko.observable(),
|
|
|
- app: 'documents',
|
|
|
- user: self.user,
|
|
|
- activeSort: self.activeSort,
|
|
|
- typeFilter: self.typeFilter,
|
|
|
- definition: {
|
|
|
- name: '/',
|
|
|
- type: 'directory'
|
|
|
- }
|
|
|
- }));
|
|
|
- self.activeEntry().load();
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- AssistDocumentsPanel.prototype.init = function () {
|
|
|
- var self = this;
|
|
|
- if (! self.activeEntry().loaded()) {
|
|
|
- self.activeEntry().load(function () {}, function () {
|
|
|
- self.fallbackToRoot();
|
|
|
- }, true);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * @param {Object} options
|
|
|
- * @constructor
|
|
|
- **/
|
|
|
- function AssistHdfsPanel (options) {
|
|
|
- var self = this;
|
|
|
- self.selectedHdfsEntry = ko.observable();
|
|
|
- self.loading = ko.observable();
|
|
|
- self.initialized = false;
|
|
|
-
|
|
|
- var loadPath = function (path) {
|
|
|
- self.loading(true);
|
|
|
- var parts = path.split('/');
|
|
|
- parts.shift();
|
|
|
-
|
|
|
- var currentEntry = new AssistStorageEntry({
|
|
|
- type: 'hdfs',
|
|
|
- definition: {
|
|
|
- name: '/',
|
|
|
- type: 'dir'
|
|
|
- },
|
|
|
- parent: null
|
|
|
- });
|
|
|
-
|
|
|
- currentEntry.loadDeep(parts, function (entry) {
|
|
|
- self.selectedHdfsEntry(entry);
|
|
|
- entry.open(true);
|
|
|
- self.loading(false);
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- self.reload = function () {
|
|
|
- loadPath(window.apiHelper.getFromTotalStorage('assist', 'currentHdfsPath', window.USER_HOME_DIR));
|
|
|
- };
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.hdfs.go.home', function () {
|
|
|
- loadPath(window.USER_HOME_DIR);
|
|
|
- window.apiHelper.setInTotalStorage('assist', 'currentHdfsPath', window.USER_HOME_DIR);
|
|
|
- });
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.selectHdfsEntry', function (entry) {
|
|
|
- self.selectedHdfsEntry(entry);
|
|
|
- window.apiHelper.setInTotalStorage('assist', 'currentHdfsPath', entry.path);
|
|
|
- });
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.hdfs.refresh', function () {
|
|
|
- huePubSub.publish('assist.clear.hdfs.cache');
|
|
|
- self.reload();
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- AssistHdfsPanel.prototype.init = function () {
|
|
|
- var self = this;
|
|
|
- if (self.initialized) {
|
|
|
- return;
|
|
|
- }
|
|
|
- self.reload();
|
|
|
- self.initialized = true;
|
|
|
- };
|
|
|
-
|
|
|
- function AssistAdlsPanel (options) {
|
|
|
- var self = this;
|
|
|
- self.selectedAdlsEntry = ko.observable();
|
|
|
- self.loading = ko.observable();
|
|
|
- self.initialized = false;
|
|
|
-
|
|
|
- var loadPath = function (path) {
|
|
|
- self.loading(true);
|
|
|
- var parts = path.split('/');
|
|
|
- parts.shift();
|
|
|
-
|
|
|
- var currentEntry = new AssistStorageEntry({
|
|
|
- type: 'adls',
|
|
|
- definition: {
|
|
|
- name: '/',
|
|
|
- type: 'dir'
|
|
|
- },
|
|
|
- parent: null
|
|
|
- });
|
|
|
-
|
|
|
- currentEntry.loadDeep(parts, function (entry) {
|
|
|
- self.selectedAdlsEntry(entry);
|
|
|
- entry.open(true);
|
|
|
- self.loading(false);
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- self.reload = function () {
|
|
|
- loadPath(window.apiHelper.getFromTotalStorage('assist', 'currentAdlsPath', '/'));
|
|
|
- };
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.adls.go.home', function () {
|
|
|
- loadPath(window.USER_HOME_DIR);
|
|
|
- window.apiHelper.setInTotalStorage('assist', 'currentAdlsPath', window.USER_HOME_DIR);
|
|
|
- });
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.selectAdlsEntry', function (entry) {
|
|
|
- self.selectedAdlsEntry(entry);
|
|
|
- window.apiHelper.setInTotalStorage('assist', 'currentAdlsPath', entry.path);
|
|
|
- });
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.adls.refresh', function () {
|
|
|
- huePubSub.publish('assist.clear.adls.cache');
|
|
|
- self.reload();
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- AssistAdlsPanel.prototype.init = function () {
|
|
|
- var self = this;
|
|
|
- if (self.initialized) {
|
|
|
- return;
|
|
|
- }
|
|
|
- self.reload();
|
|
|
- self.initialized = true;
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * @param {Object} options
|
|
|
- * @constructor
|
|
|
- **/
|
|
|
- function AssistGitPanel (options) {
|
|
|
- var self = this;
|
|
|
-
|
|
|
- self.selectedGitEntry = ko.observable();
|
|
|
- self.reload = function () {
|
|
|
- var lastKnownPath = window.apiHelper.getFromTotalStorage('assist', 'currentGitPath', window.USER_HOME_DIR);
|
|
|
- var parts = lastKnownPath.split('/');
|
|
|
- parts.shift();
|
|
|
-
|
|
|
- var currentEntry = new AssistGitEntry({
|
|
|
- definition: {
|
|
|
- name: '/',
|
|
|
- type: 'dir'
|
|
|
- },
|
|
|
- parent: null
|
|
|
- });
|
|
|
-
|
|
|
- currentEntry.loadDeep(parts, function (entry) {
|
|
|
- self.selectedGitEntry(entry);
|
|
|
- entry.open(true);
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.selectGitEntry', function (entry) {
|
|
|
- self.selectedGitEntry(entry);
|
|
|
- window.apiHelper.setInTotalStorage('assist', 'currentGitPath', entry.path);
|
|
|
- });
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.git.refresh', function () {
|
|
|
- huePubSub.publish('assist.clear.git.cache');
|
|
|
- self.reload();
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- AssistGitPanel.prototype.init = function () {
|
|
|
- this.reload();
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * @param {Object} options
|
|
|
- * @constructor
|
|
|
- **/
|
|
|
- function AssistS3Panel (options) {
|
|
|
- var self = this;
|
|
|
-
|
|
|
- self.selectedS3Entry = ko.observable();
|
|
|
- self.loading = ko.observable();
|
|
|
- self.initialized = false;
|
|
|
-
|
|
|
- self.reload = function () {
|
|
|
- self.loading(true);
|
|
|
- var lastKnownPath = window.apiHelper.getFromTotalStorage('assist', 'currentS3Path', '/');
|
|
|
- var parts = lastKnownPath.split('/');
|
|
|
- parts.shift();
|
|
|
-
|
|
|
- var currentEntry = new AssistStorageEntry({
|
|
|
- type: 's3',
|
|
|
- definition: {
|
|
|
- name: '/',
|
|
|
- type: 'dir'
|
|
|
- },
|
|
|
- parent: null
|
|
|
- });
|
|
|
-
|
|
|
- currentEntry.loadDeep(parts, function (entry) {
|
|
|
- self.selectedS3Entry(entry);
|
|
|
- entry.open(true);
|
|
|
- self.loading(false);
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.selectS3Entry', function (entry) {
|
|
|
- self.selectedS3Entry(entry);
|
|
|
- window.apiHelper.setInTotalStorage('assist', 'currentS3Path', entry.path);
|
|
|
- });
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.s3.refresh', function () {
|
|
|
- huePubSub.publish('assist.clear.s3.cache');
|
|
|
- self.reload();
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- AssistS3Panel.prototype.init = function () {
|
|
|
- var self = this;
|
|
|
- if (self.initialized) {
|
|
|
- return;
|
|
|
- }
|
|
|
- self.reload();
|
|
|
- self.initialized = true;
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * @param {Object} options
|
|
|
- * @constructor
|
|
|
- **/
|
|
|
- function AssistHBasePanel(options) {
|
|
|
- var self = this;
|
|
|
- self.initialized = false;
|
|
|
-
|
|
|
- var root = new AssistHBaseEntry({
|
|
|
- definition: {
|
|
|
- host: '',
|
|
|
- name: '',
|
|
|
- port: 0
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- self.selectedHBaseEntry = ko.observable();
|
|
|
- self.reload = function () {
|
|
|
- self.selectedHBaseEntry(root);
|
|
|
- root.loadEntries(function () {
|
|
|
- var lastOpenendPath = window.apiHelper.getFromTotalStorage('assist', 'last.opened.hbase.entry', null);
|
|
|
- if (lastOpenendPath) {
|
|
|
- root.entries().every(function (entry) {
|
|
|
- if (entry.path === lastOpenendPath) {
|
|
|
- entry.open();
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- })
|
|
|
- }
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- self.selectedHBaseEntry.subscribe(function (newEntry) {
|
|
|
- if (newEntry !== root || (newEntry === root && newEntry.loaded)) {
|
|
|
- window.apiHelper.setInTotalStorage('assist', 'last.opened.hbase.entry', newEntry.path);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.clickHBaseItem', function (entry) {
|
|
|
- if (entry.definition.host) {
|
|
|
- entry.loadEntries();
|
|
|
- self.selectedHBaseEntry(entry);
|
|
|
- }
|
|
|
- else {
|
|
|
- huePubSub.publish('assist.dblClickHBaseItem', entry);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.clickHBaseRootItem', function (entry) {
|
|
|
- self.reload();
|
|
|
- });
|
|
|
-
|
|
|
- var delayChangeHash = function (hash) {
|
|
|
- window.setTimeout(function () {
|
|
|
- window.location.hash = hash;
|
|
|
- }, 0);
|
|
|
- };
|
|
|
-
|
|
|
- self.lastClickeHBaseEntry = null;
|
|
|
- self.HBaseLoaded = false;
|
|
|
-
|
|
|
- huePubSub.subscribeOnce('hbase.app.loaded', function() {
|
|
|
- if (self.selectedHBaseEntry() && self.lastClickeHBaseEntry) {
|
|
|
- delayChangeHash(self.selectedHBaseEntry().definition.name + '/' + self.lastClickeHBaseEntry.definition.name);
|
|
|
- }
|
|
|
- self.HBaseLoaded = true;
|
|
|
- });
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.dblClickHBaseItem', function (entry) {
|
|
|
- var hash = self.selectedHBaseEntry().definition.name + '/' + entry.definition.name;
|
|
|
- if (window.location.pathname.startsWith('/hue/hbase')) {
|
|
|
- window.location.hash = hash;
|
|
|
- } else {
|
|
|
- self.lastClickeHBaseEntry = entry;
|
|
|
- huePubSub.subscribeOnce('app.gained.focus', function (app) {
|
|
|
- if (app === 'hbase' && self.HBaseLoaded) {
|
|
|
- delayChangeHash(hash);
|
|
|
- }
|
|
|
- });
|
|
|
- huePubSub.publish('open.link', '/hbase');
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- huePubSub.subscribe('assist.hbase.refresh', function () {
|
|
|
- huePubSub.publish('assist.clear.hbase.cache');
|
|
|
- self.reload();
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- AssistHBasePanel.prototype.init = function () {
|
|
|
- var self = this;
|
|
|
- if (self.initialized) {
|
|
|
- return;
|
|
|
- }
|
|
|
- self.reload();
|
|
|
- self.initialized = true;
|
|
|
- };
|
|
|
-
|
|
|
var NAV_FACET_ICON = 'fa-tags';
|
|
|
var NAV_TYPE_ICONS = {
|
|
|
'DATABASE': 'fa-database',
|