1<mn-element-cargo depot="actions">
2  <div class="header-controls">
3    <a
4       ng-show="viewsListCtl.showViewCreationButtons() && rbac.cluster.bucket[viewsCtl.currentBucketName].views.write"
5       ng-click="viewsListCtl.showSpatialCreationDialog()">
6      ADD SPATIAL VIEW
7    </a>
8    <a
9       ng-click="viewsListCtl.showMapreduceCreationDialog()"
10       ng-show="viewsListCtl.showViewCreationButtons() && rbac.cluster.bucket[viewsCtl.currentBucketName].views.write">
11      ADD VIEW
12    </a>
13  </div>
14</mn-element-cargo>
15
16<mn-element-cargo depot="alerts">
17  <div
18     ng-if="viewsListCtl.ddocs.status && rbac.bucketNames['.views!read'].length"
19     ng-switch="viewsListCtl.ddocs.status"
20     class="interim alert alert-warning">
21    <p ng-switch-when="_404">Bucket name should be specified.</p>
22    <p ng-switch-when="400">Error 400: Either this bucket is not Couchbase bucket or is hosted on another node.</p>
23    <p ng-switch-when="404">Error 404: This bucket does not exist.</p>
24    <p ng-switch-when="403">Error 403: You do not have the necessary permissions to see views in this bucket.</p>
25    <p ng-switch-default>Unexpected Error</p>
26  </div>
27</mn-element-cargo>
28
29<div>
30  <div class="row">
31    <ui-select
32       ng-model="viewsCtl.currentBucketName"
33       on-select="viewsCtl.onSelectBucket($item)"
34       theme="selectize"
35       ng-disabled="!rbac.bucketNames['.views!read'].length"
36       class="cbui-select">
37      <ui-select-match
38         class="ui-select-match">{{$select.selected}}</ui-select-match>
39      <ui-select-choices
40         class="ui-select-choices"
41         repeat="name in rbac.bucketNames['.views!read'] | filter: $select.search">
42        <span class="select-item ellipsis" ng-bind-html="name | highlight: $select.search" ></span>
43      </ui-select-choices>
44    </ui-select>
45    <span class="pills">
46      <a
47         ui-sref="{ type: 'development' }"
48         ui-sref-active="selected">Development Views</a>
49      <a
50         ui-sref="{ type: 'production' }"
51         ui-sref-active="selected">Production Views</a>
52      <span
53         class="label badge red-3"
54         ng-show="viewsListCtl.ddocs.production.length">{{viewsListCtl.ddocs.production.length}}
55      </span>
56    </span>
57  </div>
58
59  <div mn-spinner="viewsListCtl.showViewsPollerSpinner">
60    <div class="cbui-table">
61      <div
62         class="zero-content"
63         ng-show="viewsListCtl.ddocs.status === '_404' && !rbac.bucketNames['.views!read'].length">
64        There are currently no Couchbase buckets and no views to show.
65        <span ng-show="rbac.cluster.buckets.create">
66          Go to <a ui-sref="app.admin.buckets">Buckets</a> to add one,
67          or load a <a ui-sref="app.admin.settings.sampleBuckets">sample bucket</a> with data & indexes.
68        </span>
69      </div>
70
71      <div
72         class="zero-content"
73         ng-show="!viewsListCtl.ddocs.status && rbac.bucketNames['.views!read'].length && !viewsListCtl.ddocs[viewsListCtl.type].length">
74        <span ng-show="viewsListCtl.isDevelopmentViews">
75          There are currently no design documents in development.
76          <span
77             class="when-roadmin-avoid-me"
78             ng-show="rbac.cluster.bucket[viewsCtl.currentBucketName].views.write">
79            Use ADD VIEW above to create one.
80          </span>
81        </span>
82        <span ng-show="!viewsListCtl.isDevelopmentViews">
83          There are no design documents currently published.
84          <span
85             class="when-roadmin-avoid-me"
86             ng-show="rbac.cluster.bucket[viewsCtl.currentBucketName].views.write">
87            Go to Development Views to create one.
88          </span>
89        </span>
90      </div>
91
92      <div
93         ng-repeat-start="row in viewsListCtl.ddocs[viewsListCtl.type] | orderBy:'hostname' track by row.doc.meta.id"
94         ng-if="viewsListCtl.ddocs.rows.length">
95        <hr class="margin-bottom-half margin-top-1">
96        <div class="cbui-tablerow">
97          <span class="cbui-table-cell flex-grow-2 cbui-tablerow-title">
98            {{row.doc.meta.id}}
99            <span class="label lt-blue" ng-show="viewsListCtl.showSpatialButton(row)">spatial views</span>
100            <span class="label lt-blue" ng-show="viewsListCtl.showCreationButton(row)">views</span>
101          </span>
102          <span class="cbui-table-cell flex-grow-1">
103            <div ng-if="viewsListCtl.tasks[row.doc.meta.id][0].progress && rbac.cluster.tasks.read">
104              <div ng-style="{width: viewsListCtl.tasks[row.doc.meta.id][0].progress + '%'}"></div>
105              <span>{{viewsListCtl.tasks[row.doc.meta.id][0].type == 'indexer' ? "Indexing" : "Compacting"}} {{viewsListCtl.tasks[row.doc.meta.id][0].progress}}%</span>
106            </div>
107          </span>
108          <span class="cbui-table-cell flex-grow-2 wrap text-right">
109            <button
110               class="outline tight"
111               ng-show="rbac.cluster.bucket[viewsCtl.currentBucketName].views.write"
112               ng-click="viewsListCtl.showDdocDeletionDialog(row.doc)">Delete</button>
113            <button
114               class="outline tight"
115               ng-disabled="(('isEmpty' | lodash:row.doc.json.views) && ('isEmpty' | lodash:row.doc.json.spatial)) || !!(viewsListCtl.tasks[row.doc.meta.id][0].type === 'view_compaction') || !!viewsListCtl.getStartedCompactions()[row.controllers.compact]"
116               ng-show="rbac.cluster.bucket[viewsCtl.currentBucketName].views.compact"
117               ng-click="viewsListCtl.registerCompactionAsTriggeredAndPost(row)">Compact</button>
118            <button
119               class="outline tight"
120               ng-click="viewsListCtl.showCreationDialog(row.doc)"
121               ng-show="viewsListCtl.showCreationButton(row) && rbac.cluster.bucket[viewsCtl.currentBucketName].views.write">Add View</button>
122            <button
123               class="outline tight"
124               ng-click="viewsListCtl.showCreationDialog(row.doc, true)"
125               ng-show="viewsListCtl.showSpatialButton(row) && rbac.cluster.bucket[viewsCtl.currentBucketName].views.write">Add Spatial View</button>
126            <button
127               ng-show="!viewsListCtl.isDevelopmentViews && rbac.cluster.bucket[viewsCtl.currentBucketName].views.write"
128               ng-click="viewsListCtl.copyToDev(row.doc)">Copy to Dev</button>
129            <button
130               ng-disabled="('isEmpty' | lodash:row.doc.json.views) && ('isEmpty' | lodash:row.doc.json.spatial)"
131               ng-click="viewsListCtl.publishDdoc(row.doc)"
132               ng-show="viewsListCtl.showPublishButton(row) && rbac.cluster.bucket[viewsCtl.currentBucketName].views.write">Publish</button>
133            <div
134               class="error"
135               ng-show="viewsListCtl.showMatchingWarning(row)">
136              No new views can be added to this document. Delete either mapreduce or spatial views first.
137            </div>
138          </span>
139        </div>
140      </div>
141
142      <div class="zero-content" ng-if="('isEmpty' | lodash:row.doc.json.views) && ('isEmpty' | lodash:row.doc.json.spatial)">
143        No views defined!<span class="when-in-dev"> Click "Create View" above to create one.</span>
144      </div>
145
146      <div
147         class="cbui-tablerow row-min has-hover"
148         ng-if="!('isEmpty' | lodash:row.doc.json.views)"
149         ng-repeat="(key, view) in row.doc.json.views"
150         ui-sref=".editing.result(viewsListCtl.getInitialViewsFilterParams(key, row, false))">
151        <span class="cbui-table-cell">
152          <span class="semi-bold indent-1">{{key}}</span>
153        </span>
154        <span class="cbui-table-cell flex-grow-2 wrap text-right">
155          <button
156             class="outline tight"
157             ng-show="viewsListCtl.isDevModeDoc(row.doc.meta.id) && rbac.cluster.bucket[viewsCtl.currentBucketName].views.write"
158             ng-click="$event.stopPropagation() || viewsListCtl.showViewDeletionDialog(row.doc, key)">
159            Delete
160          </button>
161          <button
162             class="outline tight"
163             ng-click="$event.stopPropagation()"
164             ui-sref=".editing.result(viewsListCtl.getInitialViewsFilterParams(key, row, false))">
165            {{viewsListCtl.isDevModeDoc(row.doc.meta.id) && rbac.cluster.bucket[viewsCtl.currentBucketName].views.write ? 'Edit' : 'Show' }}
166          </button>
167        </span>
168      </div>
169
170      <div class="cbui-tablerow has-hover row-min"
171         ng-repeat-end=""
172         ng-if="!('isEmpty' | lodash:row.doc.json.spatial)"
173         ng-repeat="(key, spatial) in row.doc.json.spatial"
174         ui-sref=".editing.result(viewsListCtl.getInitialViewsFilterParams(key, row, true))">
175        <span class="cbui-table-cell"><span class="semi-bold indent-1">{{key}}</span></span>
176        <span class="cbui-table-cell flex-grow-3 text-right">
177          <button
178             class="outline tight"
179             ng-show="viewsListCtl.isDevModeDoc(row.doc.meta.id) && rbac.cluster.bucket[viewsCtl.currentBucketName].views.write"
180             ng-click="$event.stopPropagation() || viewsListCtl.showViewDeletionDialog(row.doc, key, true)">
181            Delete
182          </button>
183          <button
184             ng-click="$event.stopPropagation()"
185             ui-sref=".editing.result(viewsListCtl.getInitialViewsFilterParams(key, row, true))">
186            {{viewsListCtl.isDevModeDoc(row.doc.meta.id) && rbac.cluster.bucket[viewsCtl.currentBucketName].views.write ? 'Edit' : 'Show' }}
187           </button>
188        </span>
189      </div>
190    </div>
191  </div>
192</div>
193