Commit 1e865211 by Daniel Lee

WIP: Create new dashboard button in dash search

parent 06a15eec
......@@ -94,9 +94,15 @@
<i class="fa fa-plus"></i>&nbsp; New Dashboard
</a>
<a class="btn btn-inverse" href="dashboard/new/?editview=import" ng-show="ctrl.contextSrv.isEditor" ng-click="ctrl.isOpen = false;">
<i class="fa fa-upload"></i>&nbsp; Import Dashboard
</a>
<a class="btn btn-inverse" ng-click="ctrl.showNewFolderModal()" ng-show="ctrl.contextSrv.isEditor" ng-click="ctrl.isOpen = false;">
<i class="fa fa-plus"></i>
Create New Folder
</a>
<a class="btn btn-inverse" href="dashboard/new/?editview=import" ng-show="ctrl.contextSrv.isEditor" ng-click="ctrl.isOpen = false;">
<i class="fa fa-upload"></i>
>&nbsp; Import Dashboard
</a>
<a class="search-button-row-explore-link" target="_blank" href="https://grafana.com/dashboards?utm_source=grafana_search">
Find <img src="public/img/icn-dashboard-tiny.svg" width="14" /> dashboards on Grafana.com
......
......@@ -158,6 +158,13 @@ export class SearchCtrl {
this.search();
}
showNewFolderModal() {
this.$scope.appEvent('show-modal', {
templateHtml: '<folder-modal></folder-modal>',
modalClass: 'modal--narrow'
});
}
search() {
this.showImport = false;
this.selectedIndex = 0;
......
......@@ -210,6 +210,14 @@ export class BackendSrv {
message: options.message || '',
});
}
saveDashboardFolder(name) {
const dash = {
title: name
};
return this.post('/api/dashboards/db/', {dashboard: dash, isFolder: true, overwrite: false});
}
}
coreModule.service('backendSrv', BackendSrv);
......@@ -37,10 +37,6 @@ export class AclCtrl {
this.get(permission.dashboardId);
});
}
dismiss() {
appEvents.emit('hide-modal');
}
}
export function aclSettings() {
......
......@@ -26,4 +26,5 @@ define([
'./repeat_option/repeat_option',
'./acl/acl',
'./folder_picker/picker',
'./folder_modal/folder'
], function () {});
......@@ -47,15 +47,6 @@ export class DashNavCtrl {
appEvents.emit('show-modal', {templateHtml: '<help-modal></help-modal>'});
}
// $scope.showAclModal = function() {
// var modalScope = $scope.$new();
// modalScope.dashboardId = $scope.dashboard.id;
// $scope.appEvent('show-modal', {
// templateHtml: '<acl-modal></acl-modal>',
// scope: modalScope
// });
// };
starDashboard() {
if (this.dashboard.meta.isStarred) {
return this.backendSrv.delete('/api/user/stars/dashboard/' + this.dashboard.id).then(() => {
......
<div class="modal-body">
<div class="modal-header">
<h2 class="modal-header-title">
<span class="p-l-1">Create Folder</span>
</h2>
<a class="modal-header-close" ng-click="ctrl.dismiss();">
<i class="fa fa-remove"></i>
</a>
</div>
<div class="modal-content folder-modal">
<div class="p-t-2">
<div class="gf-form">
<span class="gf-form-label width-10">Folder Name</span>
<input type="text" ng-model="ctrl.title" required give-focus="true" class="gf-form-input max-width-14" placeholder="Enter folder name" />
</div>
</div>
<div class="gf-form-button-row text-center">
<a type="submit" class="btn btn-success" ng-click="ctrl.create()">Create</a>
<a class="btn-text" ng-click="dismiss();">Cancel</a>
</div>
</div>
</div>
///<reference path="../../../headers/common.d.ts" />
import coreModule from 'app/core/core_module';
import appEvents from 'app/core/app_events';
import _ from 'lodash';
export class FolderCtrl {
title: string;
/** @ngInject */
constructor(private backendSrv, private $scope, $sce) {
}
create() {
if (!this.title || this.title.trim().length === 0) {
return;
}
const title = this.title.trim();
return this.backendSrv.saveDashboardFolder(title).then((result) => {
appEvents.emit('alert-success', ['Dashboard saved', 'Saved as ' + title]);
appEvents.emit('dashboard-saved', result);
this.dismiss();
});
}
dismiss() {
appEvents.emit('hide-modal');
}
}
export function folderModal() {
return {
restrict: 'E',
templateUrl: 'public/app/features/dashboard/folder_modal/folder.html',
controller: FolderCtrl,
bindToController: true,
controllerAs: 'ctrl',
};
}
coreModule.directive('folderModal', folderModal);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment