From commits-return-18664-archive-asf-public=cust-asf.ponee.io@brooklyn.apache.org Tue Oct 23 18:43:54 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 0E9B018067B for ; Tue, 23 Oct 2018 18:43:52 +0200 (CEST) Received: (qmail 46590 invoked by uid 500); 23 Oct 2018 16:43:52 -0000 Mailing-List: contact commits-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list commits@brooklyn.apache.org Received: (qmail 46562 invoked by uid 99); 23 Oct 2018 16:43:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Oct 2018 16:43:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A3173DFF85; Tue, 23 Oct 2018 16:43:51 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: heneveld@apache.org To: commits@brooklyn.apache.org Date: Tue, 23 Oct 2018 16:43:52 -0000 Message-Id: In-Reply-To: <8b5715affd4848939c4ea7d76b322e28@git.apache.org> References: <8b5715affd4848939c4ea7d76b322e28@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/4] brooklyn-ui git commit: Add palette service for easy customisation. The template can still be overridden Add palette service for easy customisation. The template can still be overridden Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/a9236f00 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/a9236f00 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/a9236f00 Branch: refs/heads/master Commit: a9236f0070e6813bac5549adfc04bb34a5f076f5 Parents: 38e7c3c Author: Thomas Bouron Authored: Mon Oct 15 09:51:02 2018 +0100 Committer: Thomas Bouron Committed: Mon Oct 15 09:51:02 2018 +0100 ---------------------------------------------------------------------- .../providers/palette-service.provider.js | 75 ++++++++++++++++++++ ui-modules/blueprint-composer/app/index.js | 40 +++++++++-- .../views/main/graphical/graphical.state.html | 20 +++--- .../app/views/main/graphical/graphical.state.js | 29 ++------ .../views/main/graphical/graphical.state.less | 6 +- 5 files changed, 127 insertions(+), 43 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/a9236f00/ui-modules/blueprint-composer/app/components/providers/palette-service.provider.js ---------------------------------------------------------------------- diff --git a/ui-modules/blueprint-composer/app/components/providers/palette-service.provider.js b/ui-modules/blueprint-composer/app/components/providers/palette-service.provider.js new file mode 100644 index 0000000..7fbb4ee --- /dev/null +++ b/ui-modules/blueprint-composer/app/components/providers/palette-service.provider.js @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +import angular from 'angular'; + +const MODULE_NAME = 'brooklyn.composer.service.palette'; + +angular.module(MODULE_NAME, []) + .provider('paletteService', paletteServiceProvider); + +export default MODULE_NAME; + +export function paletteServiceProvider() { + let sections = {}; + + return { + $get: function () { + return new PaletteService(sections); + }, + addSection(id, section) { + sections[id] = section; + }, + deleteSection(id) { + delete sections[id]; + } + } +} + +class PaletteService { + constructor(sectionsToAdd) { + this.sections = {}; + this.fields = ['title', 'type', 'icon']; + + for (const [id, section] of Object.entries(sectionsToAdd)) { + this.addSection(id, section); + } + } + + addSection(id, section) { + if (!section) { + throw 'Section must be an object'; + } + + this.fields.forEach(field => { + if (!section.hasOwnProperty(field)) { + throw `Section must have field "${field}" defined`; + } + }); + + if (!id) { + throw 'Action must have id defined'; + } + this.sections[id] = section; + } + + getSections() { + return this.sections; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/a9236f00/ui-modules/blueprint-composer/app/index.js ---------------------------------------------------------------------- diff --git a/ui-modules/blueprint-composer/app/index.js b/ui-modules/blueprint-composer/app/index.js index 38313af..d7eb860 100755 --- a/ui-modules/blueprint-composer/app/index.js +++ b/ui-modules/blueprint-composer/app/index.js @@ -38,7 +38,8 @@ import brUtils from 'brooklyn-ui-utils/utils/general'; import brSpecEditor from './components/spec-editor/spec-editor.directive'; import brooklynCatalogSaver from './components/catalog-saver/catalog-saver.directive'; -import paletteApiProvider from "./components/providers/palette-api.provider" +import paletteApiProvider from "./components/providers/palette-api.provider"; +import paletteServiceProvider from "./components/providers/palette-service.provider"; import brooklynApi from "brooklyn-ui-utils/brooklyn.api/brooklyn.api"; import {designerDirective} from "./components/designer/designer.directive"; @@ -71,11 +72,12 @@ import {graphicalEditSpecState} from "./views/main/graphical/edit/spec/edit.spec import {graphicalEditDslState, dslParamLabelFilter} from "./views/main/graphical/edit/dsl/edit.dsl.controller"; import bottomSheet from "brooklyn-ui-utils/bottom-sheet/bottom-sheet"; import stackViewer from 'angular-java-stack-viewer'; +import {EntityFamily} from "./components/util/model/entity.model"; -angular.module('app', [ngAnimate, ngResource, ngCookies, ngClipboard, uiRouter, 'ui.router.state.events', brCore, - brServerStatus, brAutoFocus, brIconGenerator, brInterstitialSpinner, brooklynModuleLinks, brooklynUserManagement, - brYamlEditor, brUtils, brSpecEditor, brooklynCatalogSaver, brooklynApi, bottomSheet, stackViewer, brDragndrop, - customActionDirective, customConfigSuggestionDropdown, paletteApiProvider]) +angular.module('app', [ngAnimate, ngResource, ngCookies, ngClipboard, uiRouter, 'ui.router.state.events', brCore, + brServerStatus, brAutoFocus, brIconGenerator, brInterstitialSpinner, brooklynModuleLinks, brooklynUserManagement, + brYamlEditor, brUtils, brSpecEditor, brooklynCatalogSaver, brooklynApi, bottomSheet, stackViewer, brDragndrop, + customActionDirective, customConfigSuggestionDropdown, paletteApiProvider, paletteServiceProvider]) .directive('designer', ['$log', '$state', '$q', 'iconGenerator', 'catalogApi', 'blueprintService', 'brSnackbar', 'paletteDragAndDropService', designerDirective]) .directive('onError', onErrorDirective) .directive('catalogSelector', catalogSelectorDirective) @@ -96,6 +98,7 @@ angular.module('app', [ngAnimate, ngResource, ngCookies, ngClipboard, uiRouter, .filter('dslParamLabel', ['$filter', dslParamLabelFilter]) .config(['$urlRouterProvider', '$stateProvider', '$logProvider', applicationConfig]) .config(['actionServiceProvider', actionConfig]) + .config(['paletteServiceProvider', paletteConfig]) .run(['$rootScope', '$state', 'brSnackbar', errorHandler]) .run(['$http', httpConfig]); @@ -131,8 +134,31 @@ function actionConfig(actionServiceProvider) { actionServiceProvider.addAction("add", {html: ''}); } +function paletteConfig(paletteServiceProvider) { + paletteServiceProvider.addSection('entities', { + title: 'Entities', + type: EntityFamily.ENTITY, + icon: 'fa-square-o' + }); + paletteServiceProvider.addSection('policies', { + title: 'Policies', + type: EntityFamily.POLICY, + icon: 'fa-heartbeat' + }); + paletteServiceProvider.addSection('enrichers', { + title: 'Enrichers', + type: EntityFamily.ENRICHER, + icon: 'fa-puzzle-piece' + }); + paletteServiceProvider.addSection('locations', { + title: 'Locations', + type: EntityFamily.LOCATION, + icon: 'fa-map-pin' + }); +} + function errorHandler($rootScope, $state, brSnackbar) { - $rootScope.$on('$stateChangeError', (event, toState, toParams, fromState, fromParams, error)=> { + $rootScope.$on('$stateChangeError', (event, toState, toParams, fromState, fromParams, error) => { brSnackbar.create(error.detail); if (toState === yamlState) { $state.go(toState); @@ -142,6 +168,6 @@ function errorHandler($rootScope, $state, brSnackbar) { }); } -function httpConfig($http){ +function httpConfig($http) { $http.defaults.headers.common['X-Csrf-Token-Required-For-Requests'] = 'write'; } http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/a9236f00/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.html ---------------------------------------------------------------------- diff --git a/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.html b/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.html index 8b410df..4b0b363 100644 --- a/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.html +++ b/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.html @@ -21,10 +21,10 @@ @@ -32,16 +32,16 @@ -
-
+
+

- {{palette.title}} - + {{section.title}} +

- +
http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/a9236f00/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.js ---------------------------------------------------------------------- diff --git a/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.js b/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.js index e19a4f5..8cd432e 100644 --- a/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.js +++ b/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.js @@ -28,40 +28,19 @@ export const graphicalState = { templateProvider: function(composerOverrides) { return composerOverrides.paletteGraphicalStateTemplate || template; }, - controller: ['$scope', '$state', 'blueprintService', graphicalController], + controller: ['$scope', '$state', 'blueprintService', 'paletteService', graphicalController], controllerAs: 'vm', data: { label: 'Graphical Designer' } }; -function graphicalController($scope, $state, blueprintService) { +function graphicalController($scope, $state, blueprintService, paletteService) { this.EntityFamily = EntityFamily; this.catalogItemsPerPage = 24; - this.palettes = [ - { - title: 'Entities', - type: EntityFamily.ENTITY, - icon: 'fa-square-o' - }, - { - title: 'Policies', - type: EntityFamily.POLICY, - icon: 'fa-heartbeat' - }, - { - title: 'Enrichers', - type: EntityFamily.ENRICHER, - icon: 'fa-puzzle-piece' - }, - { - title: 'Locations', - type: EntityFamily.LOCATION, - icon: 'fa-map-pin' - } - ]; - this.paletteType = EntityFamily.ENTITY; + this.sections = paletteService.getSections(); + this.selectedSection = Object.values(this.sections).find(section => section.type === EntityFamily.ENTITY); this.onTypeSelected = (selectedType)=> { let rootEntity = blueprintService.get(); http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/a9236f00/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.less ---------------------------------------------------------------------- diff --git a/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.less b/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.less index dabfc4f..5649c09 100644 --- a/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.less +++ b/ui-modules/blueprint-composer/app/views/main/graphical/graphical.state.less @@ -39,6 +39,9 @@ } .list-group-item { + @active-border-width: 4px; + padding-top: 10px + @active-border-width; + padding-bottom: 9px + @active-border-width; border-left: none; border-radius: 0; @@ -48,9 +51,10 @@ &.active { border-right: none; border-color: @list-group-border; - border-bottom: 4px solid @brand-primary; + border-bottom: @active-border-width solid @brand-primary; background-color: #fff; color: @list-group-link-color; + padding-bottom: 10px; } } }