Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Share model publicly #518

Merged
merged 48 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
dbc67b3
Add Export model button to list of models page
idmarjr Dec 12, 2021
6de196c
Add export model button to Logic model workspace
idmarjr Dec 12, 2021
3b56200
Add export model button to cConceptual model workspace
idmarjr Dec 12, 2021
689952d
Remove aria-hidden from actions in models list
idmarjr Dec 12, 2021
edca2d6
Merge branch 'development' into feature/export-model
idmarjr Dec 12, 2021
8a3ec81
Merge branch 'development' into feature/export-model
idmarjr Dec 13, 2021
7bd3a01
Merge branch 'development' into feature/export-model
idmarjr May 13, 2022
9496040
Merge branch 'development' into feature/export-model
idmarjr Jun 26, 2022
ccea7fa
Merge branch 'main' into feature/export-model
idmarjr Sep 30, 2023
d7ec21d
Create publicview module structure
miltonbsn Apr 20, 2024
818537e
Merge branch 'main' into feature/export-model
idmarjr Apr 20, 2024
39316b3
Update icon and copy frokm "Export" to "Share"
idmarjr Apr 20, 2024
0fb1731
Add Share modal
idmarjr Apr 20, 2024
4334e81
Create load share apis
miltonbsn Apr 20, 2024
857432e
Merge branch 'feature/share-backend' into feature/export-model
miltonbsn Apr 20, 2024
22d2818
Visual adjustments to publicView
idmarjr Apr 20, 2024
3db0424
Avoid layout break for models with long names
idmarjr Apr 20, 2024
5246f1e
Fix: .projectsList layout break
idmarjr Apr 20, 2024
04c7888
Create load config endpoint
miltonbsn Apr 21, 2024
cad5789
Add share into list
miltonbsn Apr 21, 2024
b752178
Remove logs
miltonbsn Apr 21, 2024
583ae4e
Add share into conceptual
miltonbsn Apr 21, 2024
02f72db
Remove logs
miltonbsn Apr 21, 2024
122c125
Short refactoring
miltonbsn Apr 21, 2024
53240f4
Add share into logic
miltonbsn Apr 21, 2024
a095b02
Change load to support always generate link
miltonbsn Apr 21, 2024
bbf3d53
Prevents exit on click outside modal
miltonbsn Apr 21, 2024
f3c83e1
Add new save button and related functions
miltonbsn Apr 21, 2024
84583f9
Disable copy button when url is empty
miltonbsn Apr 21, 2024
37f8e21
Merge pull request #516 from brmodeloweb/feature/public-view-module
miltonbsn Apr 22, 2024
701c855
Fix bug on duplicate model feedback message
idmarjr Apr 22, 2024
9f91e89
Create load shared model api
miltonbsn Apr 22, 2024
98d746a
Load shared model on publicview module
miltonbsn Apr 22, 2024
ebc3263
Merge branch 'feature/export-model' of github.com:brmodeloweb/brmodel…
miltonbsn Apr 22, 2024
f3cccce
Remove unused testes
miltonbsn Apr 22, 2024
2e7d365
Small fixies
miltonbsn Apr 22, 2024
142be07
Merge main features
miltonbsn Apr 23, 2024
3edd0c2
Add sharing feedback on workspace
miltonbsn Apr 23, 2024
6bd0954
Fix sharing config message on conceptual model
miltonbsn Apr 23, 2024
80e6640
Fix sharing config message on logic model
miltonbsn Apr 23, 2024
8c06ea9
Add icon type on publicviem
miltonbsn Apr 23, 2024
2c0a77f
Add panning command into public view
miltonbsn Apr 23, 2024
f24140f
Fix missing translation
idmarjr Apr 23, 2024
560c104
Move publicView styles to it's ow component scss
idmarjr Apr 23, 2024
207f93b
Fix small interface bug on modelSidebar
idmarjr Apr 23, 2024
e9f5a17
Change shared model contract
miltonbsn Apr 23, 2024
bac5c00
Merge branch 'feature/export-model' of github.com:brmodeloweb/brmodel…
idmarjr Apr 23, 2024
c4c78eb
Fix icon loading
miltonbsn Apr 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions app/angular/components/shareModelModal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<div class="modal-header">
<h3 class="modal-title">{{ 'Share model' | translate }}</h3>
</div>

<div class="modal-body">
<form class="form-horizontal" role="form" name="modelForm">
<div class="form-group">
<div class="col-sm-offset-3 col-sm-7">
<div class="checkbox">
<label for="share-model">
<input id="share-model" type="checkbox" ng-model="$ctrl.shared" ng-click="$ctrl.toggleShare(!$ctrl.shared)"/>
<span>{{ 'Create public link' | translate }}</span>
</label>
</div>
</div>
</div>
<div class="form-group">
<label for="import-model" class="col-sm-3 control-label">{{ 'URL' | translate }}</label>
<div class="col-sm-6">
<input
class="form-control"
ng-class=""
type="url"
pattern="https://.*"
id="import-model"
autocomplete="off"
readonly
data-ng-model="$ctrl.url"
/>
</div>
<div class="col-sm-3">
<button type="submit" class="btn btn-default" style="margin-left: -24px;" ng-click="$ctrl.copy()" ng-disabled="!$ctrl.url">{{ 'Copy' | translate }}</button>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-7">
<p class="note">{{ 'With this link, people will be able to see but not modify this model' | translate }}</p>
</div>
</div>
</form>
</div>

<div class="modal-footer">
<button class="br-button warning" type="button" ng-click="$ctrl.cancel()">{{ 'Cancel' | translate }}</button>
<button class="br-button" type="button" ng-click="$ctrl.save()">{{ 'Salvar' | translate }}</button>
</div>
54 changes: 54 additions & 0 deletions app/angular/components/shareModelModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import angular from "angular";
import template from "./shareModelModal.html";

const app = angular.module("app.shareModelModal", []);

const Controller = function (ModelAPI) {
const $ctrl = this;
$ctrl.submitted = false;

$ctrl.$onInit = () => {
ModelAPI.loadShareOptions($ctrl.modelId).then(response => {
const shareConfig = response.data;
$ctrl.url = shareConfig.active ? shareConfig.url : "";
$ctrl.shared = shareConfig.active;
$ctrl.backupUrl = shareConfig.url;
$ctrl.backupShared = shareConfig.active;
});
};

$ctrl.toggleShare = (shared) => {
$ctrl.url = shared? $ctrl.backupUrl : "";
}

$ctrl.cancel = () => {
$ctrl.dismiss({reason: "cancel"});
};

$ctrl.save = () => {
if($ctrl.shared != $ctrl.backupShared) {
ModelAPI.toggleShare($ctrl.modelId, $ctrl.shared).then(() => {
$ctrl.close({reason: "model shared"});
}).catch(error => {
console.log(error);
$ctrl.dismiss({reason: "model share error"});
});
} else {
$ctrl.close({reason: "model shared"});
}
};

$ctrl.copy = () => {
navigator.clipboard.writeText($ctrl.url);
};
};

export default app.component("shareModelModal", {
template: template,
bindings: {
close: "&",
dismiss: "&",
modelId: "<",
},
controller: Controller,
}).name;
3 changes: 2 additions & 1 deletion app/angular/conceptual/conceptual.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ <h2 class="h4"><icon-conceptual title="{{'Conceptual model' | translate}}"></ico
<li><a data-ng-click="$ctrl.zoomNone()" title="{{ 'Zoom 100% (Z 0)' | translate }}"><i class="fa fa-search"></i></a></li>
<li class="divider"><a data-ng-click="$ctrl.zoomOut()" title="{{ 'Zoom out (Z -)' | translate }}"><i class="fa fa-search-minus"></i></a></li>
<li><a data-ng-click="$ctrl.duplicateModel($ctrl.model)" title="{{ 'Duplicate model' | translate }}"><i class="fa fa-files-o"></i></a></li>
<li class="divider"><a data-ng-click="$ctrl.convertModel($ctrl.model)" title="{{ 'Generate logical model' | translate }}"><i class="fa fa-table"></i></a></li>
<li><a data-ng-click="$ctrl.convertModel($ctrl.model)" title="{{ 'Generate logical model' | translate }}"><i class="fa fa-table"></i></a></li>
<li class="divider"><a data-ng-click="$ctrl.shareModel($ctrl.model)" title="{{ 'Share' | translate }}"><i class="fa fa-share-alt"></i></a></li>
<li class="divider"><a data-ng-click="$ctrl.print()" title="{{ 'Print (CTRL P)' | translate }}"><i class="fa fa-print"></i></a></li>
</ul>
<aside class="feedback">
Expand Down
23 changes: 22 additions & 1 deletion app/angular/conceptual/conceptual.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import angular from "angular";
import template from "./conceptual.html";

import modelDuplicatorComponent from "../components/duplicateModelModal";
import shareModelModal from "../components/shareModelModal";
import statusBar from "../components/statusBar";
import bugReportButton from "../components/bugReportButton";

Expand All @@ -26,6 +27,7 @@ import EntityExtensor from "./entityExtensor";
import KeyboardController, { types } from "../components/keyboardController";
import ToolsViewService from "../service/toolsViewService";
import preventExitServiceModule from "../service/preventExitService";
import iconConceptual from "../components/icons/conceptual";

const controller = function (ModelAPI, $stateParams, $rootScope, $timeout, $uibModal, $state, $transitions, preventExitService, $filter) {
const ctrl = this;
Expand Down Expand Up @@ -146,6 +148,25 @@ const controller = function (ModelAPI, $stateParams, $rootScope, $timeout, $uibM
});
}

ctrl.shareModel = (model) => {
const modalInstance = $uibModal.open({
animation: true,
backdrop: 'static',
keyboard: false,
template: '<share-model-modal close="$close(result)" dismiss="$dismiss()" model-id="$ctrl.modelId"></share-model-modal>',
controller: function() {
const $ctrl = this;
$ctrl.modelId = model._id;
},
controllerAs: '$ctrl',
}).result;
modalInstance.then(() => {
ctrl.showFeedback(true, $filter('translate')("Sharing configuration has been updated successfully!"));
}).catch((reason) => {
console.log("Modal dismissed with reason", reason);
});
};

ctrl.unselectAll = () => {
ctrl.showFeedback(false, "");
ctrl.onSelectElement(null);
Expand Down Expand Up @@ -546,7 +567,7 @@ const controller = function (ModelAPI, $stateParams, $rootScope, $timeout, $uibM
};

export default angular
.module("app.workspace.conceptual", [modelDuplicatorComponent, preventExitServiceModule, bugReportButton, statusBar])
.module("app.workspace.conceptual", [modelDuplicatorComponent, preventExitServiceModule, bugReportButton, statusBar, shareModelModal, iconConceptual])
.component("editorConceptual", {
template,
controller,
Expand Down
16 changes: 16 additions & 0 deletions app/angular/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ app.config([
},
});

$stateProvider.state("publicview", {
title: "PublicView - BRMW",
url: "/publicview/{modelshareid}",
component: "publicview",
data: {
requireLogin: false,
},
lazyLoad($transition$) {
const $ocLazyLoad = $transition$.injector().get("$ocLazyLoad");
return import("./publicview/publicview.js").then((mod) =>
$ocLazyLoad.inject(mod.default)
);
},
});


$stateProvider.state("register", {
title: "Register - BRMW",
url: "/register",
Expand Down
3 changes: 2 additions & 1 deletion app/angular/logic/logic.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ <h2 class="h4"><icon-logic title="{{'Logic model' | translate}}"></icon-logic> {
<li><a data-ng-click="$ctrl.zoomNone()" title="{{ 'Zoom 100% (Z 0)' | translate }}"><i class="fa fa-search"></i></a></li>
<li class="divider"><a data-ng-click="$ctrl.zoomOut()" title="{{ 'Zoom out (Z -)' | translate }}"><i class="fa fa-search-minus"></i></a></li>
<li><a data-ng-click="$ctrl.duplicateModel()" title="{{ 'Duplicate model' | translate }}"><i class="fa fa-files-o"></i></a></li>
<li class="divider"><a data-ng-click="$ctrl.generateSQL()" title="{{ 'Generate SQL' | translate }}"><i class="fa fa-database"></i></a></li>
<li><a data-ng-click="$ctrl.generateSQL()" title="{{ 'Generate SQL' | translate }}"><i class="fa fa-database"></i></a></li>
<li class="divider"><a data-ng-click="$ctrl.shareModel($ctrl.model)" title="{{ 'Share' | translate }}"><i class="fa fa-share-alt"></i></a></li>
<li class="divider"><a data-ng-click="$ctrl.print()" title="{{ 'Print (CTRL P)' | translate }}"><i class="fa fa-print"></i></a></li>
</ul>
<aside class="feedback">
Expand Down
25 changes: 23 additions & 2 deletions app/angular/logic/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import template from "./logic.html";
import sqlGeneratorService from "../service/sqlGeneratorService";
import sqlGeneratorModal from "../components/sqlGeneratorModal";
import duplicateModelModal from "../components/duplicateModelModal";
import shareModelModal from "../components/shareModelModal";
import queryExpressionModal from "../components/queryExpressionModal";
import sqlComparasionDropdown from "../components/sqlComparasionDropdown";
import bugReportButton from "../components/bugReportButton";
Expand All @@ -12,6 +13,7 @@ import view from "../view/view";
import columnForm from "./columnForm";
import checkConstraint from "./checkConstraint";
import sidebarControlLogical from "./sidebarControl";
import iconLogic from "../components/icons/logic";

const controller = function (
$rootScope,
Expand Down Expand Up @@ -223,12 +225,31 @@ const controller = function (
};
ModelAPI.saveModel(duplicatedModel).then((newModel) => {
window.open($state.href('logic', { references: { 'modelid': newModel._id } }));
ctrl.showFeedback("Successfully duplicated!", true);
ctrl.showFeedback("Successfully duplicated!", true, 'success');
ctrl.setLoading(false);
});
});
};

ctrl.shareModel = (model) => {
const modalInstance = $uibModal.open({
animation: true,
backdrop: 'static',
keyboard: false,
template: '<share-model-modal close="$close(result)" dismiss="$dismiss()" model-id="$ctrl.modelId"></share-model-modal>',
controller: function() {
const $ctrl = this;
$ctrl.modelId = model.id;
},
controllerAs: '$ctrl',
}).result;
modalInstance.then(() => {
ctrl.showFeedback($filter('translate')("Sharing configuration has been updated successfully!"), true, "success");
}).catch((reason) => {
console.log("Modal dismissed with reason", reason);
});
};

window.onbeforeunload = preventExitService.handleBeforeUnload(ctrl);

const onBeforeDeregister = $transitions.onBefore({},
Expand All @@ -246,7 +267,7 @@ const controller = function (
};

export default angular
.module("app.workspace.logic", [sqlGeneratorService, sqlGeneratorModal, duplicateModelModal, preventExitServiceModule, bugReportButton, statusBar, view, columnForm, sidebarControlLogical, checkConstraint, queryExpressionModal, sqlComparasionDropdown])
.module("app.workspace.logic", [sqlGeneratorService, sqlGeneratorModal, duplicateModelModal, preventExitServiceModule, bugReportButton, statusBar, view, columnForm, sidebarControlLogical, checkConstraint, queryExpressionModal, sqlComparasionDropdown, shareModelModal, iconLogic])
.component("editorLogic", {
template,
controller,
Expand Down
34 changes: 34 additions & 0 deletions app/angular/publicview/publicView.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
////////////////////////////////////////////////////////////////////////////////
// .publicView
////////////////////////////////////////////////////////////////////////////////
.publicView > .navbar {
height: 54px;
background-color: #fff;
}

.publicView .navbar .br-loader {
top: 63px;
}

.publicView .document-info {
margin-left: 150px;
}

.publicView .document-info h2 {
margin-top: 5px;
margin-bottom: 15px;
}

.publicView .model-area {
left: 0;
}

.publicView .workspace-header .nav li:first-child {
margin-left: 149px;
border-left: 1px solid var(--border-default);
}

.publicView .workspace-header .header-actions {
position: relative;
top: -3px;
}
44 changes: 44 additions & 0 deletions app/angular/publicview/publicview.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<section class="view modelWorkspace publicView">
<header class="navbar navbar-default navbar-fixed-top">
<div class="navbar-header">
<strong class="navbar-brand">{{ 'BRMW' | translate }}</strong>
</div>

<img
src="../../img/loading-dots.gif"
alt="Loading"
class="br-loader"
ng-class="{'loading': $ctrl.loading}"
/>
</header>

<div class="mainContent">

<section id="content" class="model-area">
<header class="workspace-header">
<div class="page-header clearfix">
<div class="document-info pull-left">
<h2 class="h4" ng-if="$ctrl.model.type === 'conceptual'"><icon-conceptual title="{{'Conceptual model' | translate}}" aria-hidden="true"></icon-conceptual> {{$ctrl.model.name}}</h2>
<h2 class="h4" ng-if="$ctrl.model.type === 'logic'"><icon-logic title="{{'Logic model' | translate}}" aria-hidden="true"></icon-logic> {{$ctrl.model.name}}</h2>
</div>
<aside class="header-actions pull-right">
<a class="docs-icon" href="https://docs.brmodeloweb.com" target="_blank" rel="noopener noreferrer" title="{{ 'Documentation' | translate }}"><i class="fa fa-book"></i></a>
<a class="br-button" href="https://app.brmodeloweb.com/#!/register" target="_blank" rel="noopener noreferrer">{{'Create account' | translate}}</a>
</aside>
</div>
<ul class="nav navbar-nav tool-icons">
<li><a data-ng-click="$ctrl.zoomIn()" title="{{ 'Zoom in (Z +)' | translate }}"><i class="fa fa-search-plus"></i></a></li>
<li><a data-ng-click="$ctrl.zoomNone()" title="{{ 'Zoom 100% (Z 0)' | translate }}"><i class="fa fa-search"></i></a></li>
<li><a data-ng-click="$ctrl.zoomOut()" title="{{ 'Zoom out (Z -)' | translate }}"><i class="fa fa-search-minus"></i></a></li>
<li class="divider"><a data-ng-click="$ctrl.print()" title="{{ 'Print (CTRL P)' | translate }}"><i class="fa fa-print"></i></a></li>
</ul>
<aside class="feedback">
<div class="alert alert-success" role="alert" data-ng-class="{'hide': !$ctrl.feedback.showing}">
<p>{{ $ctrl.feedback.message }}</p>
</div>
</aside>
</header><!-- End .workspace-header -->
</section><!-- End .model-area -->
<bug-report-button></bug-report-button>
</div><!-- End .mainContent -->
</section><!-- End .view -->
Loading