Skip to content

Commit

Permalink
Add ability to switch between file sync method rsync/scp
Browse files Browse the repository at this point in the history
(reference #118)
  • Loading branch information
piotrzarzycki21 committed Jan 13, 2025
1 parent 5d5133d commit 1d6c065
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 7 deletions.
7 changes: 6 additions & 1 deletion Assets/text/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
"button":"Manage",
"tooltip":"Click to locate your Notes Safe ID"
},
"syncmethod": {
"text": "File synchronization method",
"warning": "File synchronization requires rsync version higher than 2.6.9. Please upgrade rsync using MacPorts or Homebrew package managers. \nAlternatively, you can use the SCP plugin, though it may result in slower transfer speeds compared to rsync.",
"rsync": "Rsync",
"scp": "SCP"
},
"provisioner":{
"text":"Vagrant Provisioner"
},
Expand Down Expand Up @@ -388,7 +394,6 @@
"browsername": "Browser name",
"executablebrowserpath": "Executable Browser path",
"locatebrowser": "Locate Browser",
"defaultbrowser": "Default Browser",
"browserlisthint": "Select default Browser",
"browsernotdetected": "%1 not detected",
"configurebrowser": "Configure"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class GenesisApplicationTheme extends ClassVariantTheme {
public static final LABEL_SMALL_CENTERED:String = "label-small-centered";
public static final LABEL_TITLE:String = "label-title";
public static final LABEL_ERROR:String = "label-error";
public static final LABEL_JUSTIFY:String = "label-fustify";
public static final LAYOUT_GROUP_CREATE_ACCOUNT:String = "layout-group-create-account";
public static final LAYOUT_GROUP_FOOTER:String = "layout-group-footer";
public static final LAYOUT_GROUP_HEADER:String = "layout-group-header";
Expand Down Expand Up @@ -323,6 +324,7 @@ class GenesisApplicationTheme extends ClassVariantTheme {
this.styleProvider.setStyleFunction( Label, LABEL_SMALL_CENTERED, _setLabelSmallCenteredStyles );
this.styleProvider.setStyleFunction( Label, LABEL_TITLE, _setLabelTitleStyles );
this.styleProvider.setStyleFunction( Label, LABEL_ERROR, _setLabelErrorStyles );
this.styleProvider.setStyleFunction( Label, LABEL_JUSTIFY, _setLabelJustifyStyles );
this.styleProvider.setStyleFunction( Label, null, _setLabelStyles );
this.styleProvider.setStyleFunction( LayoutGroup, APPLICATION, _setApplicationLayoutGroupStyles );
this.styleProvider.setStyleFunction( LayoutGroup, LAYOUT_GROUP_CREATE_ACCOUNT, _setLayoutGroupCreateAccountStyles );
Expand Down Expand Up @@ -643,6 +645,12 @@ class GenesisApplicationTheme extends ClassVariantTheme {

}

function _setLabelJustifyStyles(label:Label) {
var textLayout = _themeTypography.Default;
textLayout.align = TextFormatAlign.JUSTIFY;
label.textFormat = textLayout;
}

function _setLayoutGroupCreateAccountStyles( group:LayoutGroup ) {

var layout = new VerticalLayout();
Expand Down
55 changes: 54 additions & 1 deletion Source/superhuman/components/ConfigPage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

package superhuman.components;

import superhuman.server.SyncMethod;
import feathers.controls.Button;
import feathers.controls.Check;
import feathers.layout.VerticalLayout;
import feathers.controls.Label;
import feathers.controls.LayoutGroup;
import feathers.events.TriggerEvent;
Expand Down Expand Up @@ -68,6 +72,8 @@ class ConfigPage extends Page {
var _buttonSafeId:GenesisFormButton;
var _buttonSave:GenesisFormButton;
var _dropdownCoreComponentVersion:GenesisFormPupUpListView;
var _syncMethodCheck:Check;

var _form:GenesisForm;
var _inputHostname:GenesisFormTextInput;
var _inputOrganization:GenesisFormTextInput;
Expand All @@ -80,8 +86,11 @@ class ConfigPage extends Page {
var _rowHostname:GenesisFormRow;
var _rowOrganization:GenesisFormRow;
var _rowPreviousSafeId:GenesisFormRow;
var _rowRoles:GenesisFormRow;
var _rowSafeId:GenesisFormRow;
var _rowRoles:GenesisFormRow;
var _rowSyncMethod:GenesisFormRow;
var _rowWarningSync:GenesisFormRow;

var _server:Server;
var _titleGroup:LayoutGroup;

Expand Down Expand Up @@ -213,6 +222,45 @@ class ConfigPage extends Page {
_rowRoles.content.addChild( _buttonRoles );
_form.addChild( _rowRoles );

_rowSyncMethod = new GenesisFormRow();

_rowSyncMethod.text = LanguageManager.getInstance().getString( 'serverconfigpage.form.syncmethod.text' );

_syncMethodCheck = new Check( LanguageManager.getInstance().getString( 'serverconfigpage.form.syncmethod.check' ) );
_syncMethodCheck.text = _server.syncMethod;
_syncMethodCheck.selected = _server.syncMethod == SyncMethod.Rsync;
_syncMethodCheck.variant = GenesisApplicationTheme.CHECK_MEDIUM;
_syncMethodCheck.addEventListener(TriggerEvent.TRIGGER, _syncMethodCheckTriggered);

_rowSyncMethod.content.addChild( _syncMethodCheck );
_form.addChild( _rowSyncMethod );

#if mac
_rowWarningSync = new GenesisFormRow();

var warningHorizontalGroupLayout:HorizontalLayout = new HorizontalLayout();
warningHorizontalGroupLayout.verticalAlign = MIDDLE;
warningHorizontalGroupLayout.gap = GenesisApplicationTheme.GRID;

var warningGroup:LayoutGroup = new LayoutGroup();
warningGroup.layout = warningHorizontalGroupLayout;

var buttonWarningSync:Button = new Button();
buttonWarningSync.variant = GenesisApplicationTheme.BUTTON_BROWSER_WARNING;
buttonWarningSync.icon = new AdvancedAssetLoader( GenesisApplicationTheme.getAssetPath( GenesisApplicationTheme.ICON_WARNING ) );
warningGroup.addChild(buttonWarningSync);

var labelWarningSync:Label = new Label();
labelWarningSync.layoutData = new HorizontalLayoutData(100);
labelWarningSync.variant = GenesisApplicationTheme.LABEL_JUSTIFY;
labelWarningSync.wordWrap = true;
labelWarningSync.text = LanguageManager.getInstance().getString( 'serverconfigpage.form.syncmethod.warning' );
warningGroup.addChild(labelWarningSync);

_rowWarningSync.content.addChild(warningGroup);
_form.addChild( _rowWarningSync );
#end

var line = new HLine();
line.width = _w;
this.addChild( line );
Expand Down Expand Up @@ -329,6 +377,11 @@ class ConfigPage extends Page {

}

function _syncMethodCheckTriggered( e:TriggerEvent ) {
_syncMethodCheck.text = _syncMethodCheck.selected ? SyncMethod.Rsync : SyncMethod.SCP;
_server.syncMethod = _syncMethodCheck.selected ? SyncMethod.Rsync : SyncMethod.SCP;
}

function _inputHostnameChanged( e:Event ) {

var a = Server.getComputedName( _inputHostname.text, _inputOrganization.text );
Expand Down
7 changes: 6 additions & 1 deletion Source/superhuman/server/Server.hx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ class Server {
var _vagrantUpExecutor:AbstractExecutor;
var _vagrantUpExecutorElapsedTimer:Timer;
var _vagrantUpExecutorStopTimer:Timer;

var _syncMethod:SyncMethod = SyncMethod.Rsync;

public var busy( get, never ):Bool;
function get_busy() return _busy.value;

Expand Down Expand Up @@ -350,6 +351,10 @@ class Server {
public var webAddress( get, never ):String;
function get_webAddress() return _getWebAddress();

public var syncMethod(get, set):SyncMethod;
function get_syncMethod() return _syncMethod;
function set_syncMethod( value:SyncMethod ):SyncMethod { _syncMethod = value; return _syncMethod; }

function new() {

_id = Math.floor( Math.random() * 9000 ) + 1000;
Expand Down
38 changes: 38 additions & 0 deletions Source/superhuman/server/SyncMethod.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2016-present Prominic.NET, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
*
* http://www.mongodb.com/licensing/server-side-public-license
*
* As a special exception, the copyright holders give permission to link the
* code of portions of this program with the OpenSSL library under certain
* conditions as described in each individual source file and distribute
* linked combinations including the program with the OpenSSL library. You
* must comply with the Server Side Public License in all respects for
* all of the code used other than as permitted herein. If you modify file(s)
* with this exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do so,
* delete this exception statement from your version. If you delete this
* exception statement from all source files in the program, then also delete
* it in the license file.
*/

package superhuman.server;

enum abstract SyncMethod( String ) to String {

var Rsync = "rsync";
var SCP = "scp";

}
5 changes: 1 addition & 4 deletions Source/superhuman/server/provisioners/DemoTasks.hx
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,7 @@ class HostsFileGenerator {
var defaultProvisionerFieldValue:String = versionGreaterThan22 ? null : "";
var defaultRoleFieldValue:Dynamic = versionGreaterThan22 ? false : "";

var syncMethod = "rsync";
#if mac
syncMethod = "scp";
#end
var syncMethod = provisioner.server.syncMethod;

var replace = {

Expand Down

0 comments on commit 1d6c065

Please sign in to comment.